/* ═══════════════════════════════════════════════════════════════════════════
   crm_components.css — building blocks of the new CRM design.
   Same values as tradingplatform/assets/css/app.css + polish.css + admin.css
   (cards 18px / radius 10px, inputs 11px 13px, tables 13px with 11.5px uppercase heads,
   badges, segmented switches, KPI tiles, toasts). Colours only ever come from the tokens.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout helpers ───────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.grid.split { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid.split { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 16px; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 1280px) { .grid.cols6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .grid.cols4, .grid.cols6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols2, .grid.cols3 { grid-template-columns: 1fr; }
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3, .card h3 { margin: 0; font-size: 16px; font-weight: 700; }
.card .sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 14px 18px; margin: 0; border-bottom: 1px solid var(--border); }
.more { font-size: 12.5px; font-weight: 700; color: var(--primary-2); white-space: nowrap; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 16px;
  font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer; white-space: nowrap;
  background: var(--surface-3); color: var(--text);
  transition: background var(--t), border-color var(--t), filter var(--t);
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { filter: brightness(.95); }
.btn:disabled, .btn.is-busy { opacity: .55; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--btn-glow); }
.btn-buy, .btn-success { background: var(--buy); color: #fff; }
.btn-sell { background: var(--sell); color: #fff; }
.btn-danger { background: var(--sell-bg); color: var(--sell); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none; position: relative;
  border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.icon-btn:hover { border-color: var(--primary); background: var(--surface-3); }
.icon-btn .dot-count { position: absolute; top: -5px; inset-inline-end: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--sell); color: #fff; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; }
.btn .spin { width: 14px; height: 14px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; margin-bottom: 14px; align-content: start; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint, .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--sell); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none; color: var(--text);
  transition: border-color var(--t), box-shadow var(--t);
}
.input-sm { padding: 7px 10px; font-size: 13px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.input::placeholder { color: var(--muted); opacity: .7; }
.input.is-invalid { border-color: var(--sell); box-shadow: 0 0 0 3px var(--sell-bg); }
.input.is-active { color: var(--primary-2); font-weight: 600; border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.input:disabled, .input[readonly] { opacity: .75; }

/* ── Selects: one look on every page (form selects, quick filters, DataTables "Show", top-bar search type) ──
   Native arrow replaced by a token-coloured chevron (two gradients, so it follows every theme / mode),
   pill-like height matching inputs, hover + active states, and readable option lists in dark mode. */
select.input, .dataTables_length select, .gsearch-box select, :where(body.crm select:not([multiple]):not([size])) {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-color: var(--surface-2);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 32px;
  cursor: pointer;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  transition: border-color var(--t), box-shadow var(--t), background-color var(--t);
}
[dir="rtl"] select.input, [dir="rtl"] .dataTables_length select, :where([dir="rtl"] body.crm select:not([multiple]):not([size])) {
  background-position: 10px 50%, 15px 50%;
}
select.input:hover:not(:disabled), .dataTables_length select:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background-color: var(--surface-3); }
select.input:focus, .dataTables_length select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%);
}
select.input.is-active {
  background-color: color-mix(in srgb, var(--primary) 10%, var(--surface-2));
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary-2) 50%),
    linear-gradient(135deg, var(--primary-2) 50%, transparent 50%);
}
select.input:disabled { cursor: not-allowed; }
select.input-sm { padding-inline-end: 30px; height: 34px; padding-top: 0; padding-bottom: 0; }
select.input:not(.input-sm) { height: 44px; padding-top: 0; padding-bottom: 0; }
body.crm select option, body.crm select optgroup { background: var(--surface); color: var(--text); font-weight: 500; }
body.crm select option:disabled { color: var(--muted); }
select[multiple].input { background-image: none; padding-inline-end: 13px; height: auto; }

/* ── Themed dropdown (crm_select.js): the native select is hidden, this button + popover replace it ── */
.cs-native { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; }
.cs-btn {
  display: inline-flex; align-items: center; gap: 8px; position: relative; max-width: 100%;
  height: 34px; padding: 0 12px; padding-inline-end: 32px; text-align: start; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color var(--t), box-shadow var(--t), background-color var(--t);
}
.cs-btn.input { width: 100%; padding: 0 13px; padding-inline-end: 34px; }
.cs-btn.input:not(.input-sm) { height: 44px; font-size: 14px; }
.cs-btn.input-sm { height: 34px; font-size: 13px; }
.cs-btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background-color: var(--surface-3); }
.cs-btn:focus-visible, .cs-btn.is-open { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.cs-btn:disabled { opacity: .6; cursor: not-allowed; }
.cs-btn.is-active { color: var(--primary-2); font-weight: 600; background-color: color-mix(in srgb, var(--primary) 10%, var(--surface-2)); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.cs-btn.is-placeholder .cs-label { color: var(--muted); }
.cs-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-caret { position: absolute; inset-inline-end: 12px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-inline-end: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform var(--t), margin var(--t); }
.cs-btn.is-open .cs-caret { transform: rotate(-135deg); margin-top: -1px; border-color: var(--primary); }
.cs-btn:hover:not(:disabled) .cs-caret, .cs-btn.is-active .cs-caret { border-color: var(--primary-2); }
/* Inside the top-bar client search: compact, borderless chip */
.gsearch-box .cs-btn { height: 28px; border: 0; border-radius: 7px; background: var(--surface-3); color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 0 10px; padding-inline-end: 26px; }
.gsearch-box .cs-btn .cs-caret { inset-inline-end: 10px; width: 6px; height: 6px; }

.cs-pop {
  position: fixed; z-index: 6000; display: flex; flex-direction: column; gap: 6px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: crm-pop .14s ease-out; overflow: hidden;
}
.cs-pop.is-up { animation-name: cs-pop-up; }
@keyframes cs-pop-up { from { opacity: 0; transform: translateY(4px); } }
.cs-search { flex: none; }
.cs-list { overflow-y: auto; display: grid; gap: 2px; min-height: 0; overscroll-behavior: contain; }
.cs-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cs-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text); user-select: none; }
.cs-opt[hidden] { display: none; }
.cs-opt.is-active { background: var(--surface-2); }
.cs-opt[aria-selected="true"] { color: var(--primary-2); font-weight: 600; background: color-mix(in srgb, var(--primary) 12%, transparent); }
.cs-opt[aria-selected="true"].is-active { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.cs-opt[aria-disabled="true"] { color: var(--muted); opacity: .6; cursor: not-allowed; }
.cs-check { width: 16px; flex: none; display: grid; place-items: center; }
.cs-opt[aria-selected="true"] .cs-check::before { content: ''; width: 9px; height: 5px; border-inline-start: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translate(1px, -1px); }
.cs-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13px; }
.switch input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: color-mix(in srgb, var(--text) 22%, transparent); cursor: pointer; transition: background .18s; }
.switch input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); transition: transform .18s; }
.switch input[type="checkbox"]:checked { background: var(--primary); }
.switch input[type="checkbox"]:checked::after { transform: translateX(16px); }
[dir="rtl"] .switch input[type="checkbox"]:checked::after { transform: translateX(-16px); }

/* ── Segmented switch & tabs (the trading platform's .seg / settings tabs) ── */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; max-width: 100%; }
.seg-btn { padding: 6px 11px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 12.5px; cursor: pointer; border: 0; background: none; white-space: nowrap; transition: background var(--t), color var(--t); }
.seg-btn:hover { color: var(--text); }
.seg-btn.on, .seg-btn[aria-selected="true"] { background: var(--grad); color: #fff; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin-bottom: 16px; max-width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.tabs .tab { appearance: none; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px; padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab[aria-selected="true"] { background: var(--grad); color: #fff; }
.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs-line .tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.tabs-line .tab:hover { color: var(--text); }
.tabs-line .tab[aria-selected="true"] { color: var(--primary-2); border-bottom-color: var(--primary); }
.tab .count { margin-inline-start: 6px; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: var(--surface-3); color: var(--muted); }
.tab-panel[hidden] { display: none; }

/* ── Badges & pills ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok, .badge.buy { background: var(--buy-bg); color: var(--buy); }
.badge.bad, .badge.sell { background: var(--sell-bg); color: var(--sell); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.info { background: color-mix(in srgb, var(--primary-2) 14%, transparent); color: var(--primary-2); }
.badge.primary { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.rs { display: inline-block; padding: 2px 9px; border-radius: 8px; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.rs.ok { background: var(--buy-bg); color: var(--buy); } .rs.bad { background: var(--sell-bg); color: var(--sell); } .rs.warn { background: var(--amber-bg); color: var(--amber); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); }
.dot.ok { background: var(--buy); } .dot.warn { background: var(--amber); } .dot.bad { background: var(--sell); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.err { background: var(--sell-bg); color: var(--sell); border-color: color-mix(in srgb, var(--sell) 30%, transparent); }
.alert.ok { background: var(--buy-bg); color: var(--buy); border-color: color-mix(in srgb, var(--buy) 30%, transparent); }
.alert.warn { background: var(--amber-bg); color: var(--amber); }
.alert.info { background: color-mix(in srgb, var(--primary-2) 10%, transparent); color: var(--primary-2); }

/* ── KPI tiles ────────────────────────────────────────────────────────────── */
.kpi { display: grid; gap: 4px; position: relative; overflow: hidden; --c: var(--primary); }
.kpi::after { content: ''; position: absolute; inset-inline-end: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%; background: var(--c); opacity: .16; pointer-events: none; }
.kpi .n { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi .l { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.kpi.buy { --c: var(--buy); } .kpi.sell { --c: var(--sell); } .kpi.warn { --c: var(--amber); } .kpi.accent { --c: var(--cyan); }

/* ── Key / value lists (profile-style data) ───────────────────────────────── */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); margin: 0; }
.kv > dt, .kv > dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--border); }
.kv > dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.kv > dd { font-size: 13.5px; overflow-wrap: anywhere; }
.kv > dt:last-of-type, .kv > dd:last-of-type { border-bottom: 0; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--surface); text-align: start; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; transition: background var(--t); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }

/* ── States: loading / empty / error (every async block renders one of these) ── */
.state { display: grid; place-items: center; gap: 10px; padding: 34px 16px; text-align: center; color: var(--muted); }
.state-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.state.is-error .state-ico { background: var(--sell-bg); color: var(--sell); }
.state b { color: var(--text); font-size: 14px; }
.state p { margin: 0; max-width: 460px; font-size: 13px; }
.sk { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 300% 100%; animation: crm-sk 1.4s linear infinite; }
.sk-line { height: 12px; margin: 8px 0; }
.sk-block { min-height: 120px; }
@keyframes crm-sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; animation: crm-sp .7s linear infinite; display: inline-block; flex: none; }
@keyframes crm-sp { to { transform: rotate(360deg); } }

/* ── Dropdown menus ───────────────────────────────────────────────────────── */
.dd { position: relative; }
.dd-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 90; min-width: 200px; max-height: 70vh; overflow: auto; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); animation: crm-pop .14s ease-out; }
.dd-pop[hidden] { display: none; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font-weight: 600; font-size: 13.5px; text-align: start; cursor: pointer; }
body.crm a.dd-item { color: var(--text); }
.dd-item:hover { background: var(--surface-2); }
.dd-item.on { color: var(--primary-2); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.dd-item.danger { color: var(--sell); }
.dd-head { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dd-sep { height: 1px; margin: 5px 0; background: var(--border); }
.chip-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); max-width: 240px; transition: border-color var(--t), background var(--t); }
.chip-btn:hover, .dd.is-open > .chip-btn { border-color: var(--primary); background: var(--surface-3); }
.chip-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; }
@keyframes crm-pop { from { opacity: 0; transform: translateY(-4px); } }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; z-index: 5000; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: rgba(6, 9, 14, .6); overflow-y: auto; overscroll-behavior: contain; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: crm-pop .16s ease-out; }
.modal.lg { width: min(900px, 100%); }
.modal.xl { width: min(1280px, 100%); }
/* the backdrop column is minmax(0,1fr): a wide table scrolls inside the modal instead of stretching it past the screen */
.modal { min-width: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 18px; overflow: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
/* The dialog always fits the window (any height, zoom or display scaling): head and foot keep their size, only the body scrolls */
.modal { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.modal-head, .modal-foot { flex: none; }
.modal-foot { background: var(--surface); border-radius: 0 0 12px 12px; }
@media (max-height: 520px) { .modal-back { padding: 8px; } .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); } .modal-head { padding: 10px 14px; } .modal-body { padding: 12px 14px; } .modal-foot { padding: 10px 14px; } }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ── Toasts (top-right, under the top bar) ───────────────────────────────── */
.toasts { position: fixed; inset: 74px 18px auto auto; z-index: 9999; display: grid; gap: 10px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
[dir="rtl"] .toasts { inset: 74px auto auto 18px; }
.toast {
  --c: var(--primary-2); pointer-events: auto; position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 16px; border-radius: 14px;
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
  border: 1px solid var(--border); border-inline-start: 5px solid var(--c);
  box-shadow: 0 16px 40px rgba(2, 5, 20, .25), 0 0 0 4px color-mix(in srgb, var(--c) 14%, transparent);
  animation: crm-tpop .28s cubic-bezier(.2, 1.3, .4, 1);
}
.toast.ok { --c: var(--buy); } .toast.err { --c: var(--sell); } .toast.warn { --c: var(--amber); }
.toast-ic { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); font-weight: 800; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-x { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.toast-x:hover { background: var(--surface-3); color: var(--text); }
.toast.out { opacity: 0; transform: translateY(-10px) scale(.97); transition: all .22s; }
@keyframes crm-tpop { from { opacity: 0; transform: translateY(-18px) scale(.94); } }
@media (max-width: 560px) { .toasts { inset: 62px 10px auto 10px; width: auto; } }

/* ── Multi-select (crm_multiselect.js) ────────────────────────────────────── */
.ms { position: relative; min-width: 0; }
.ms-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: start; cursor: pointer; }
.ms-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms.is-empty .ms-label { color: var(--muted); }
.pf-value .ms, .pf-value .ms-trigger { width: 100%; } .pf-value .ms { justify-self: stretch; }
.ms-caret { width: 7px; height: 7px; border-inline-end: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); flex: none; }
.ms-pop { position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 95; min-width: 240px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); animation: crm-pop .14s ease-out; }
.ms-pop[hidden] { display: none; }
.ms-tools { display: flex; gap: 6px; margin-bottom: 6px; }
.ms-tools .input { flex: 1; min-width: 0; }
.ms-list { max-height: 260px; overflow: auto; display: grid; gap: 1px; }
.ms-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.ms-item:hover { background: var(--surface-2); }

/* ── Tri-state filter chips: include / exclude / ignore ───────────────────── */
.tri-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.tri { display: inline-flex; align-items: center; gap: 9px; padding: 5px 6px; border: 0; background: none; border-radius: 8px; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; text-align: start; }
.tri:hover { background: var(--surface-2); }
.tri-box { width: 18px; height: 18px; flex: none; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 800; border: 1.5px solid var(--border); background: var(--surface); color: #fff; }
.tri[data-state="1"] .tri-box { background: var(--buy); border-color: var(--buy); }
.tri[data-state="0"] .tri-box { background: var(--sell); border-color: var(--sell); }
.tri-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.tri-legend span { display: inline-flex; align-items: center; gap: 6px; }
.filter-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.filter-section > h4 { margin: 0 0 10px; font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.filter-section > h4 .join { font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--amber); }
.filter-sub { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 6px; }
.filter-row { display: grid; grid-template-columns: 150px 120px minmax(0, 1fr); gap: 8px; align-items: center; padding: 4px 0; }
.filter-row > span { font-weight: 600; font-size: 13px; }
.filter-row .join { font-size: 11px; font-weight: 800; color: var(--amber); margin-inline-end: 6px; }
@media (max-width: 760px) { .filter-row { grid-template-columns: 1fr; } }

/* ── Branding page: presets, colour pickers, preview (admin.css) ─────────── */
.presets { display: flex; flex-wrap: wrap; gap: 10px; }
.preset { display: grid; gap: 6px; padding: 8px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface-2); cursor: pointer; width: 118px; text-align: center; color: var(--text); }
.preset small { font-size: 11px; margin-top: -4px; }
/* mini preview of a preset: top bar, main button, buy / sell chips */
.preset-pv { display: grid; gap: 6px; padding: 7px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); }
.preset-pv .pv-h { display: block; height: 9px; border-radius: 5px; }
.preset-pv .pv-l { display: flex; gap: 4px; }
.preset-pv .pv-btn { flex: 1; height: 12px; border-radius: 4px; }
.preset-pv .pv-chip { width: 14px; height: 12px; border-radius: 4px; }
.preset:hover, .preset.on { border-color: var(--primary); }
.preset i { height: 30px; border-radius: 9px; display: block; }
.preset span { font-size: 12px; font-weight: 700; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.pick { display: grid; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.pick-row { display: flex; gap: 8px; }
.pick input[type=color] { width: 46px; height: 42px; padding: 3px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; flex: none; }
.pick .input { flex: 1; min-width: 0; }
.pal-preview { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface-2); display: grid; gap: 12px; }
.pv-top { display: flex; align-items: center; gap: 10px; }
.pv-top .logo-mark { width: 30px; height: 30px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: var(--btn-glow); }
.pv-bar { height: 8px; border-radius: 8px; background: var(--grad); }
.pv-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Period picker (core/crm_daterange.js) and page filter bars ───────────── */
.crm-range { flex-wrap: nowrap; }
.crm-range .input[type="date"] { min-width: 136px; height: 34px; padding-block: 0; }
@media (max-width: 640px) { .crm-range { flex-wrap: wrap; } }
.tt-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; }
.tt-filters h3 { margin: 0; }

/* ═══ Moved from client_center.css: shared by every page that shows label/value rows or a timeline ═══ */
/* ── Inline profile fields ────────────────────────────────────────────────── */
.pf-row { display: grid; grid-template-columns: minmax(120px, 36%) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); min-height: 42px; }
.pf-row:last-child { border-bottom: 0; }
.pf-label { color: var(--muted); font-weight: 600; font-size: 13px; }
.pf-value { font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; display: grid; gap: 4px; justify-items: start; }
.pf-hint { color: var(--muted); font-size: 12px; font-weight: 500; }
.pf-tools { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.pf-tools .icon-btn.pf-edit { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; background: transparent; color: var(--muted); }
.pf-tools .icon-btn.pf-edit:hover { color: var(--primary-2); }
.pf-row.is-editing { background: color-mix(in srgb, var(--primary) 5%, transparent); margin: 0 -10px; padding-inline: 10px; border-radius: 8px; }
.pf-edit-box { width: 100%; display: flex; gap: 6px; }
.pf-edit-box .input { flex: 1; min-width: 0; }
.pf-edit-box.is-phone .pf-code { flex: 0 0 120px; }
.pf-error { color: var(--sell); font-size: 12px; font-weight: 600; }
@media (max-width: 560px) { .pf-row { grid-template-columns: 1fr auto; } .pf-label { grid-column: 1 / -1; } }

/* ── Timeline ─────────────────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; display: grid; gap: 10px; max-height: 560px; overflow: auto; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 3px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -18px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.tl-comment::before { border-color: var(--primary); }
.tl-reminder::before { border-color: var(--amber); }
.tl-status::before { border-color: var(--buy); }
.tl-when { font-size: 12.5px; }
.tl-by { font-size: 12px; color: var(--muted); }
.tl-text { font-size: 13px; overflow-wrap: anywhere; }

/* ── Skeleton loading states (CRM.ui.skeleton / CRM.ui.state 'loading' / CRM.table.skeleton) ── */
.sk-wrap { display: grid; gap: 10px; padding: 6px 0; }
.sk-wrap .sk-line { margin: 0; }
.sk-row { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk-row .sk-line { margin: 0; }
.sk-card { display: grid; gap: 8px; padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sk-card-top { display: flex; justify-content: space-between; }
.sk-pill { display: inline-block; width: 46px; height: 18px; border-radius: 999px; }
.sk-avatar { width: 52px; height: 52px; border-radius: 14px; flex: none; }
.sk-hero { display: flex; gap: 14px; align-items: center; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; align-items: start; }
.sk-grid .card { display: grid; gap: 4px; }
.sk-table { display: grid; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.sk-tr { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; padding: 13px 14px; border-bottom: 1px solid var(--border); }
.sk-tr:last-child { border-bottom: 0; }
.sk-tr.is-head { background: var(--surface-2); }
.sk-tr.is-head .sk-line { height: 9px; opacity: .7; }
tr.sk-tr-row td { padding-top: 13px !important; padding-bottom: 13px !important; }
tr.sk-tr-row:hover td { background: transparent !important; }
.dataTables_wrapper .dataTables_processing { display: none !important; }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.sk-line, .sk-pill, .sk-avatar { display: block; }
.sk-pill { display: inline-block; }
tr.sk-tr-row .sk-line, thead .sk-line { min-width: 48px; height: 11px; }
table.crm-table { width: 100%; border-collapse: collapse; }
table.crm-table:not(.dataTable) { border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.crm-table:not(.dataTable) th, table.crm-table:not(.dataTable) td { padding: 12px; border-bottom: 1px solid var(--border); text-align: start; }

/* ── Charts (core/crm_chart.js). Colours validated (dataviz validate_palette) for CVD + both modes ── */
:root { --chart-a: #7c6cff; --chart-b: #e5304f; }
.chart { display: grid; gap: 10px; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chart-key { display: inline-flex; align-items: center; gap: 7px; }
.chart-key i, .chart-tip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.chart-plot { position: relative; min-width: 0; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-hit { cursor: default; outline: none; }
.chart-hit.is-on, .chart-hit:focus-visible { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.chart-tip { position: absolute; z-index: 3; pointer-events: none; display: grid; gap: 4px; min-width: 150px; padding: 9px 11px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 12.5px; color: var(--text); }
.chart-tip span { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.chart-tip span b { margin-inline-start: auto; color: var(--text); }

/* ── Detail header (hero), state pill, line tabs in a card — shared by Client Center, Tasks Center, Employees … ── */
.cc-state { --state: var(--muted); display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; color: var(--state); background: color-mix(in srgb, var(--state) 15%, transparent); }
.cc-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.cc-hero-id { display: flex; gap: 14px; align-items: center; min-width: 0; flex: 1 1 420px; }
.cc-avatar { width: 52px; height: 52px; border-radius: 14px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; box-shadow: var(--btn-glow); }
.cc-hero-text { display: grid; gap: 6px; min-width: 0; }
.cc-hero-text h2 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.cc-hero-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 13px; }
.cc-hero-meta span { display: inline-flex; align-items: center; gap: 5px; overflow-wrap: anywhere; }
.cc-hero-actions { justify-content: flex-end; }
.cc [data-banners] { display: grid; gap: 8px; }
.cc [data-banners] .alert { margin: 0; }
.cc-tabs { margin-bottom: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 8px; flex-wrap: wrap; overflow: visible; row-gap: 0; column-gap: 2px; }
@media (max-width: 760px) { .cc-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; } .cc-tabs .tab { white-space: nowrap; } }
.cc-classic-ico { font-size: 11px; margin-inline-start: 4px; opacity: .55; }

/* ── Departments: permission matrix ───────────────────────────────────────── */
.perm-group-title { margin: 6px 0 0; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; align-items: start; }
.perm-card { padding: 0; overflow: hidden; border-top: 3px solid var(--border); }
.perm-card.lv1 { border-top-color: var(--cyan); } .perm-card.lv2 { border-top-color: var(--primary); } .perm-card.lv0 { border-top-color: var(--border); }
.perm-card.is-busy { opacity: .7; pointer-events: none; }
.perm-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 12px 14px; background: var(--surface-2); }
.perm-title { display: grid; gap: 2px; min-width: 0; }
.perm-title small { color: var(--muted); font-size: 12px; }
.perm-pages { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 14px 0; }
.perm-list { padding: 4px 14px 10px; }
.perm-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.perm-row:last-child { border-bottom: 0; }
.perm-row[hidden] { display: none; }
.perm-name { font-size: 13px; min-width: 0; }
.perm-seg { flex: none; padding: 2px; }
.perm-seg .seg-btn { padding: 4px 9px; font-size: 11.5px; }
.perm-seg .seg-btn.on.lv0 { background: var(--surface-3); color: var(--text); }
.perm-seg .seg-btn.on.lv1 { background: color-mix(in srgb, var(--cyan) 85%, #000); color: #fff; }
.perm-seg .seg-btn:disabled { opacity: .35; cursor: not-allowed; }
.perm-seg.is-busy { opacity: .6; }
.access-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.access-opt:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.access-opt span { display: grid; gap: 2px; }
.access-opt small { color: var(--muted); font-size: 12px; }
.tag-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }
.tag-color { width: 44px; height: 32px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }

/* ── Operations dashboard panels ──────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-grid > .wide { grid-column: 1 / -1; }
.dash-grid > [hidden] { display: none; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

/* ── New Client ───────────────────────────────────────────────────────────── */
.nc-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1200px) { .nc-layout { grid-template-columns: 1fr; } }
.nc-phone { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 6px; }
.field .err:empty { display: none; }

/* ── Custom Reports (native read-only table widgets) ──────────────────────── */
.rep-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.rep-grid > .rep-widget { min-width: 0; }
@media (max-width: 1100px) { .rep-grid > .rep-widget { grid-column: 1 / -1 !important; } }
.rep-body { padding: 12px 16px 14px; }
.rep-scroll { overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rep-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.rep-table th, .rep-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: start; white-space: nowrap; }
.rep-table thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rep-table thead tr.rep-filters th { top: 38px; padding: 6px 8px; text-transform: none; }
.rep-table thead tr.rep-filters .input { min-width: 90px; width: 100%; }
.rep-table th.n, .rep-table td.n { text-align: end; font-variant-numeric: tabular-nums; }
.rep-table tbody tr:hover td { background: var(--surface-2); }
.rep-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; }
.rep-sort:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; border-radius: 4px; }
.rep-sort i { opacity: .55; font-size: 13px; }
th[aria-sort="ascending"] .rep-sort, th[aria-sort="descending"] .rep-sort { color: var(--primary-2); }
th[aria-sort="ascending"] .rep-sort i, th[aria-sort="descending"] .rep-sort i { opacity: 1; }
.rep-pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 12px; }
.rep-table .pos { color: var(--buy); } .rep-table .neg { color: var(--sell); }

/* ── Company Config ───────────────────────────────────────────────────────── */
.cfg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cfg-grid[hidden] { display: none; }
@media (max-width: 1100px) { .cfg-grid { grid-template-columns: minmax(0, 1fr); } }
/* KYC rule view: classic sections (Rule info / Action bar / Filters / Config) as cards with titled groups */
/* Payment method and rule panels (company_config_payments.js) */
.pm-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; align-items: start; }
.pm-panel { min-width: 0; padding: 14px 16px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.pm-panel h4 { margin: 0 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 13.5px; font-weight: 700; color: var(--text); }
.pm-panel > .hint { margin: 0 0 4px; }
.pm-heading { margin: 20px 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.pm-rule { background: var(--surface); border-color: color-mix(in srgb, var(--primary) 30%, var(--border)); }
.pm-preview { display: block; width: 100%; min-height: 150px; border: 1px solid var(--border); border-radius: 10px; }
.pm-status { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 1.4fr); gap: 14px 20px; align-items: center; margin-bottom: 16px; padding: 14px 16px; border: 1px solid; border-radius: 12px; }
.pm-status.is-off { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.pm-status.is-live { background: var(--buy-bg); border-color: color-mix(in srgb, var(--buy) 35%, transparent); }
.pm-status__head { display: grid; gap: 2px; font-size: 13px; color: var(--muted); }
.pm-status__head strong { font-size: 15px; color: var(--text); }
.pm-status ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pm-status li { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13.5px; font-weight: 600; }
.pm-status li > span { flex: 1; min-width: 0; }
.pm-status li > i { font-size: 18px; }
.pm-status li.is-done > i { color: var(--buy); }
.pm-status li.is-todo > i { color: var(--amber); }
.pm-status li.is-note > i { color: var(--primary-2); }
@media (max-width: 720px) { .pm-status { grid-template-columns: 1fr; } }
.kyc-sub { margin: 0; background: var(--surface-2); box-shadow: none; }
.kyc-sub > .card-head { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.kyc-group + .kyc-group { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.kyc-group > h4 { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kyc-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kyc-sub .switch input:disabled + span, .kyc-sub .radio-row input:disabled ~ span { opacity: .75; }
.cfg-row .pf-value .input { width: 100%; }
.cfg-row input[type="color"].input { padding: 2px; height: 34px; }
.cfg-val { white-space: pre-wrap; }
.cfg-color { display: inline-flex; align-items: center; gap: 8px; }
.cfg-swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border); }
.cfg-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.cfg-image { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cfg-image .hint { margin-top: 2px; }
.cfg-preview { display: grid; place-items: center; padding: 16px; border-radius: var(--radius-sm); background: repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.cfg-preview img { max-width: 100%; max-height: 260px; }
.cfg-checks { display: grid; gap: 12px; }
.cfg-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.cfg-link { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: inherit; text-decoration: none; }
.cfg-link:hover { border-color: var(--primary-2); }
.cfg-link > span { display: grid; gap: 2px; }

/* ── Account dialogs (core/crm_account.js) ────────────────────────────────── */
.acc-grid { display: grid; }
.acc-setup { margin-top: 16px; }
.acc-steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 14px; }
.acc-qr { display: block; width: 180px; height: 180px; margin: 6px 0; background: #fff; padding: 8px; border-radius: 8px; }
.acc-key { font-size: 15px; letter-spacing: .08em; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); overflow-wrap: anywhere; }
button.dd-item { width: 100%; background: none; border: 0; text-align: start; font: inherit; color: inherit; cursor: pointer; }

/* ── Combobox (core/crm_combobox.js) + New Transaction ────────────────────── */
.cb { position: relative; }
.cb .input { width: 100%; padding-inline-end: 32px; }
.cb-clear { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.cb-clear:hover { color: var(--text); background: var(--surface-2); }
.cb-list { position: absolute; z-index: 30; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow, 0 10px 30px rgba(0,0,0,.25)); }
.cb-opt { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.cb-opt:hover, .cb-opt.is-active { background: color-mix(in srgb, var(--primary-2) 14%, transparent); }
.cb-msg { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.nt-section { margin: 0; }
.hint.err { color: var(--sell); }
.chart-zero { stroke: var(--muted); stroke-width: 1.5; }
.chart-hit.is-clickable { cursor: pointer; }
.chart-hit:focus-visible { outline: 2px solid var(--primary-2); }
.pos { color: var(--buy); } .neg { color: var(--sell); }

/* PAMM dashboard period groups */
.pamm-period { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 8px; }
.pamm-period > summary { cursor: pointer; font-size: 13px; }
.pamm-period[open] > summary { margin-bottom: 8px; }

/* ── Leads Center ─────────────────────────────────────────────────────────── */
.lc-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .lc-layout { grid-template-columns: 1fr; } }
.lc-picker { position: sticky; top: 86px; }
.lc-cards { display: grid; align-content: start; gap: 8px; max-height: calc(100vh - 360px); min-height: 160px; overflow: auto; padding-inline-end: 2px; }
.lc-card { display: grid; gap: 3px; justify-items: start; text-align: start; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: inherit; font: inherit; cursor: pointer; }
.lc-card:hover { border-color: var(--primary-2); }
.lc-card.is-on { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.lc-name { font-weight: 700; font-size: 13.5px; }
.lc-meta { font-size: 12px; color: var(--muted); }

/* ── Task processor (shared/task_processor.js) ───────────────────────────── */
.tp-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.tp-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }
.tp-psp { display: grid; gap: 4px; max-width: 280px; }
.tp-psp small { font-size: 12px; }
.tp-warn { color: var(--amber); font-size: 13px; }
.tp-soft { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; }
.tp-edit .pf-value { justify-items: stretch; }
.tp-edit .input { width: 100%; min-width: 0; }
.tp-edit .input:disabled { background: transparent; border-color: transparent; padding-left: 0; opacity: 1; cursor: default; appearance: none; -webkit-appearance: none; resize: none; color: inherit; }

/* ── IB campaigns rule editor (pages/ibs_campaigns_page.js) ──────────────── */
.ib-sys { margin: 0; padding: 0 18px 16px; display: grid; gap: 4px; font-size: 13px; }
.ib-sys dt { font-weight: 700; margin-top: 8px; }
.ib-sys dd { margin: 0; color: var(--muted); }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h3::after { content: " ▾"; color: var(--muted); font-size: 12px; }
details.card[open] > summary h3::after { content: " ▴"; }
.chip-x { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 0 0 2px; font-size: 11px; line-height: 1; }
.chip-x:hover { color: var(--sell); }
.table-scroll { overflow-x: auto; }
.crm-table.compact td, .crm-table.compact th { padding: 6px 8px; }

/* Read-only multi value shown like a select (chips wrap; caret as select.input). Used in edit rows. */
.chip-field { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; width: 100%; min-height: 36px; padding: 5px 30px 5px 8px; background-color: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); position: relative; text-align: start; color: var(--text); font: inherit; }
.chip-field::after { content: ""; position: absolute; inset-inline-end: 12px; top: 50%; width: 7px; height: 7px; border-inline-end: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); }
button.chip-field { cursor: pointer; transition: border-color var(--t), background-color var(--t); }
button.chip-field:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background-color: var(--surface-3); }
button.chip-field:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.chip-field .badge { white-space: normal; overflow-wrap: anywhere; max-width: 100%; text-align: start; line-height: 1.35; border-radius: 8px; }
.chip-field .muted { padding-inline-start: 4px; }
.pf-value > .chip-field { justify-self: stretch; }
[dir="rtl"] .chip-field { padding: 5px 8px 5px 30px; }
/* Edit row with the label above the value (long labels in narrow cards) */
.pf-row.pf-stack { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
.pf-row.pf-stack .pf-label { grid-column: 1 / -1; }

/* ── Rich text (CKEditor 4, moono-lisa) themed with the CRM tokens. The writing area stays white:
   it is the email itself, so what you see is what the client gets. ── */
.cke_chrome.cke_chrome { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: none; background: var(--surface); }
.cke_chrome .cke_inner { background: var(--surface); }
.cke_chrome .cke_top { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 6px 8px 2px; }
.cke_chrome .cke_bottom { background: var(--surface-2); border-top: 1px solid var(--border); }
.cke_chrome .cke_toolgroup, .cke_chrome .cke_combo_button { background: transparent; border: 0; }
.cke_chrome a.cke_button, .cke_chrome .cke_combo_button { border-radius: 6px; }
.cke_chrome a.cke_button_off:hover, .cke_chrome a.cke_button_off:focus, .cke_chrome a.cke_button_on, .cke_chrome .cke_combo_off a.cke_combo_button:hover,
.cke_chrome .cke_combo_on a.cke_combo_button { background: var(--surface-3); border: 0; }
.cke_chrome a.cke_button_on { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent); }
.cke_chrome .cke_combo_text, .cke_chrome .cke_button_label { color: var(--text); font-family: var(--font); }
.cke_chrome .cke_toolbar_separator, .cke_chrome .cke_combo:after { background: var(--border); }
.cke_chrome .cke_combo_arrow, .cke_chrome .cke_button_arrow { border-top-color: var(--muted); }
/* the skin's icons are dark sprites: lighten them on the dark theme */
:root:is(.dark, [data-theme="dark"], [data-bs-theme="dark"]) .cke_chrome .cke_button_icon { filter: invert(.9); }
.cke_chrome .cke_button_disabled .cke_button_icon { opacity: .35; }
.cke_maximized.cke_chrome { border-radius: 0; }

/* Email body / footer editor in the rule panel */
.mail-part { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 12px; }
.mail-part + .mail-part { margin-top: 14px; }
.mail-part-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.mail-part-head h5 { margin: 0; font-size: 13px; font-weight: 700; }
.mail-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 8px; }
.mail-vars > span { font-size: 11px; color: var(--muted); margin-inline-end: 4px; }
.mail-vars button { font: inherit; font-size: 11.5px; padding: 3px 8px; border-radius: 999px; border: 1px dashed var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.mail-vars button:hover { border-color: var(--primary); color: var(--primary); }
.mail-part iframe.mail-view { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; display: block; }
