/* ═══════════════════════════════════════════════════════════
   CRM Admin Panel — Complete Redesign
   Based on Figma: Modern Fintech CRM Admin Panel
   ═══════════════════════════════════════════════════════════ */

/* ── 1. CSS Custom Properties ── */
:root {
  --bg: #060e1a;
  --bg2: #0a1628;
  --panel: #0f1d32;
  --panel2: #132640;
  --line: rgba(148,178,225,.12);
  --muted: #7a8fad;
  --text: #e8f0ff;
  --accent: #22c7e8;
  --accent2: #1bf2a4;
  --danger: #ff5f75;
  --warning: #ffb23d;
  --success: #20d79b;
  --shadow: 0 8px 32px rgba(0,0,0,.25);
  --input-bg: rgba(8,18,34,.85);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --sidebar-w: 260px;
  --topbar-h: 64px;
}
body.theme-light {
  --bg: #f0f4f8;
  --bg2: #f7f9fc;
  --panel: #ffffff;
  --panel2: #f8fbff;
  --line: rgba(100,130,170,.15);
  --muted: #4a5568;
  --text: #0a0a0a;
  --accent: #e67e22;
  --accent2: #d35400;
  --shadow: 0 8px 32px rgba(20,50,90,.08);
  --input-bg: #f5f8fc;
}

/* ── 2. Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; font-family: Inter, -apple-system, system-ui, sans-serif; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(100,140,200,.25) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,140,200,.25); border-radius: 99px; }

/* ── 3. App Layout ── */
.crm-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── 4. Sidebar ── */
.crm-sidebar {
  background: linear-gradient(180deg, rgba(10,22,40,.98), rgba(8,18,32,.95));
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
}
.theme-light .crm-sidebar {
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.crm-side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding: 0 4px;
}
.crm-side-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #22c7e8, #1bf2a4);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  flex-shrink: 0;
}
.crm-side-brand strong { display: block; font-size: 16px; }
.crm-side-brand span { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; }

/* ── 5. Navigation ── */
.crm-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.crm-nav-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .15s ease;
}
.crm-nav-link svg { flex-shrink: 0; opacity: .6; transition: opacity .15s; }
.crm-nav-link:hover svg { opacity: .85; }
.crm-nav-link.active svg { opacity: 1; stroke: var(--accent); }
.crm-nav-link span { flex: 1; }
.crm-nav-link .crm-count-badge { margin-left: auto; }
.crm-nav-link:hover {
  background: rgba(34,199,232,.06);
  color: var(--text);
}
.crm-nav-link.active {
  background: linear-gradient(135deg, rgba(34,199,232,.15), rgba(27,242,164,.08));
  color: var(--accent);
  font-weight: 700;
}
body.theme-light .crm-nav-link.active {
  background: linear-gradient(135deg, rgba(230,126,34,.12), rgba(243,156,18,.06));
}

.crm-count-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #06111d;
  font-size: 11px;
  font-weight: 800;
}

/* ── 6. Main Shell ── */
.crm-main-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* ── 7. Top Bar ── */
.crm-topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 16px;
  background: rgba(10,22,40,.75);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 15;
}
.theme-light .crm-topbar {
  background: rgba(255,255,255,.85);
}
.crm-topbar-search { position: relative; flex: 1; max-width: 520px; }
.crm-topbar-search input {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 16px 0 42px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.crm-topbar-search input::placeholder { color: var(--muted); }
.crm-topbar-search input:focus { border-color: var(--accent); }
.crm-topbar-search::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
}

.crm-global-search-results {
  position: absolute;
  top: 52px;
  left: 0;
  width: min(520px, 60vw);
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 50;
}
.crm-global-search-results button {
  display: grid;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
}
.crm-global-search-results small { color: var(--muted); }

/* Userbar */
.crm-userbar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.crm-icon-btn, .crm-chip-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: border-color .15s;
}
.crm-icon-btn:hover, .crm-chip-btn:hover { border-color: var(--accent); }
/* User dropdown menu */
.crm-user-menu { position: relative; }
.crm-user-menu-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 14px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md); cursor: pointer; color: var(--text);
  transition: border-color .15s, background .15s;
}
.crm-user-menu-trigger:hover { border-color: var(--accent); }
.crm-user-menu.is-open .crm-user-menu-trigger { border-color: var(--accent); }
.crm-ump-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
#crmAdminName { font-weight: 700; font-size: 13px; color: var(--text); }
#crmAdminRole { font-size: 11px; color: var(--muted); }
.crm-ump-chevron { color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.crm-user-menu.is-open .crm-ump-chevron { transform: rotate(180deg); }
.crm-user-menu-drop {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  display: none; flex-direction: column; gap: 2px;
  z-index: 9999;
}
.crm-user-menu.is-open .crm-user-menu-drop { display: flex; }
.crm-umi {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 13px; font-weight: 500;
  text-align: left; width: 100%;
  transition: background .12s;
}
.crm-umi:hover { background: rgba(255,255,255,.06); }
.crm-umi-ico { font-size: 13px; width: 18px; flex-shrink: 0; text-align: center; opacity: .7; }
.crm-umi-sep { height: 1px; background: var(--line); margin: 3px 0; }
.crm-umi--exit { color: #ef4444; }
.crm-umi--exit:hover { background: rgba(239,68,68,.1) !important; }
.theme-light .crm-user-menu-drop { box-shadow: 0 8px 28px rgba(0,0,0,.12); }
.theme-light .crm-umi:hover { background: rgba(0,0,0,.05); }

/* ── 8. Content Area ── */
.crm-content { padding: 28px; }
.crm-login-wrap { display: grid; place-items: center; min-height: calc(100vh - 140px); }
.crm-panel { display: grid; gap: 24px; }
.crm-page { display: none; gap: 24px; }
.crm-page.active { display: grid; }

/* Page Header */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-kicker {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(34,199,232,.1);
  color: var(--accent);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ── 9. Cards ── */
.crm-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.crm-login-card { width: min(480px, 100%); }
.crm-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.crm-card h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }
.crm-card * { user-select: text; }
.crm-muted, .crm-feedback, .crm-override-meta, .crm-user-id, .ticket-meta { color: var(--muted); }
.crm-spaced-top { margin-top: 18px; }
.crm-card.crm-inner-card { padding: 16px; }

/* ── 10. Forms ── */
.crm-form { display: grid; gap: 14px; }
.crm-form label { display: grid; gap: 6px; position: relative; }
.crm-form label > span { font-weight: 700; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.crm-form input,
.crm-form textarea,
.crm-form select,
.crm-filters input,
.crm-fiat-input,
.crm-card input,
.crm-card select,
.crm-card textarea {
  width: 100%;
  min-height: 44px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.crm-form textarea { min-height: 92px; padding-top: 12px; resize: vertical; }
.crm-form input:focus,
.crm-form textarea:focus,
.crm-form select:focus,
.crm-card input:focus,
.crm-card select:focus,
.crm-card textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,199,232,.12);
}
.theme-light .crm-form input,
.theme-light .crm-form textarea,
.theme-light .crm-form select,
.theme-light .crm-card input,
.theme-light .crm-card select,
.theme-light .crm-card textarea {
  background: #f8fbff;
  color-scheme: light;
}
body.theme-dark .crm-form input,
body.theme-dark .crm-card input,
body.theme-dark .crm-form select,
body.theme-dark .crm-card select,
body.theme-dark .crm-form textarea,
body.theme-dark .crm-card textarea {
  color-scheme: dark;
}

/* Grid layouts */
.crm-row2, .crm-row3, .split-grid { display: grid; gap: 14px; }
.crm-row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.crm-row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.crm-row1 { display: grid; gap: 14px; }
.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.trade-layout-grid { grid-template-columns: 480px minmax(0, 1fr); }

/* Buttons */
.crm-btn {
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all .15s;
  white-space: nowrap;
}
.crm-btn:hover { border-color: rgba(148,178,225,.3); }
.crm-btn.primary {
  background: linear-gradient(135deg, #22c7e8, #1bf2a4);
  color: #06111d;
  border: 0;
  font-weight: 800;
}
.crm-btn.primary:hover { filter: brightness(1.05); }
.crm-btn.ghost {
  background: transparent;
  border-color: var(--line);
}
.crm-btn.danger {
  background: rgba(255,95,117,.08);
  color: var(--danger);
  border-color: rgba(255,95,117,.2);
}
.crm-btn.warning { background: #f59e0b; color: #07111f; border: 0; }
.crm-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Toggle */
.crm-toggle {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.crm-toggle input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.crm-toggle span { font-weight: 700; font-size: 14px; text-align: left; flex: 1; }
.crm-toggle-line { border: 0; padding: 8px 0; }

/* ── 11. Dashboard ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.metric-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  gap: 6px;
}
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 600; }
.metric-card strong { font-size: 1.75rem; font-weight: 800; }
.metric-card em { font-style: normal; color: var(--accent2); font-size: 13px; font-weight: 600; }
.crm-accent-card { border-color: rgba(34,199,232,.2); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.dashboard-grid > .dashboard-card:first-child { grid-row: span 2; }
.dashboard-list { display: grid; gap: 8px; }
.dashboard-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.dashboard-row:last-child { border-bottom: 0; }
.dashboard-row strong { display: block; font-size: 14px; }
.dashboard-row small { color: var(--muted); font-size: 12px; }

/* Funnel stats */
.crm-funnel-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.crm-funnel-stat { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; background: var(--panel); }
.crm-funnel-stat strong { display: block; font-size: 18px; margin-bottom: 8px; }
.crm-funnel-stat .crm-funnel-metrics { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }

/* ── 12. Filters ── */
.crm-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto auto;
  gap: 10px;
  margin-bottom: 16px;
}
.crm-filter-select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  padding: 0 12px;
  font-weight: 600;
  outline: none;
}
.theme-light .crm-filter-select { background: #f8fbff; border-color: #cfe0f2; }

/* Segmented control */
.crm-segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin: 0 0 16px;
  background: rgba(255,255,255,.03);
}
.crm-segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all .15s;
}
.crm-segmented button.active {
  background: rgba(34,199,232,.12);
  color: var(--accent);
  font-weight: 700;
}

/* ── 13. User List / Cards ── */
.crm-user-list, .crm-list { display: grid; gap: 10px; }
.crm-user-card, .crm-override-card {
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  transition: border-color .15s;
}
.crm-user-card:hover { border-color: rgba(34,199,232,.2); }
.theme-light .crm-user-card, .theme-light .crm-override-card { background: #fff; }
.crm-user-meta, .crm-balance-row, .crm-inline-actions, .crm-ticket-top, .crm-ticket-badges {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.crm-user-meta .crm-badge {
  padding: 8px 14px;
  border-radius: 99px;
  background: rgba(34,199,232,.1);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}
.crm-table { display: grid; gap: 10px; }

/* Lead cards */
.crm-user-card.compact { display: grid; gap: 12px; padding: 16px 18px; }
.crm-lead-card-top { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 14px; align-items: start; }
.crm-lead-main { min-width: 0; display: grid; gap: 3px; }
.crm-lead-balance {
  display: grid;
  justify-items: end;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: rgba(34,199,232,.06);
  min-width: 110px;
}
.crm-lead-balance span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.crm-lead-balance strong { color: var(--accent); font-size: 15px; }
.crm-lead-balance small { font-size: 10px; color: var(--muted); font-weight: 700; text-align: right; line-height: 1.35; max-width: 260px; }
.crm-lead-details-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.crm-lead-details-grid > div { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px; background: rgba(255,255,255,.02); min-width: 0; }
.crm-lead-details-grid span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; margin-bottom: 4px; }
.crm-lead-details-grid strong { display: block; color: var(--text); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-lead-name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-mini-deals { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-mini-deal { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 5px 10px; background: rgba(255,255,255,.03); color: var(--text); font-size: 12px; font-weight: 700; }
.crm-mini-deal.muted { color: var(--muted); font-weight: 600; }
.crm-lead-check { display: flex !important; align-items: center !important; margin-right: 10px; }
.crm-lead-check input { width: 18px !important; height: 18px !important; padding: 0 !important; }
.theme-light .crm-lead-balance { background: #eaf9ff; border-color: #c9e8f5; }
.theme-light .crm-lead-balance strong { color: #05a9cf; }
.theme-light .crm-lead-details-grid > div, .theme-light .crm-mini-deal { background: #f8fbff; }
.crm-real-balance, .crm-bonus-balance, .crm-credit-balance { display: inline-block; margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.crm-bonus-balance { color: var(--accent2); }
.crm-credit-balance { color: #7c8cff; }
.crm-wallet-title { line-height: 1.7; }

/* ── 14. Status Pills ── */
.status-pill {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
}
.is-success { background: rgba(32,215,155,.1); color: var(--success); }
.is-danger { background: rgba(255,95,117,.1); color: var(--danger); }
.is-warning { background: rgba(255,178,61,.1); color: var(--warning); }

.crm-lead-status-pill { padding: 4px 9px; font-size: 10px; line-height: 1; border: 1px solid transparent; vertical-align: middle; }
.crm-lead-status-pill.is-danger { background: rgba(255,93,122,.1); color: #ff4f6d; border-color: rgba(255,93,122,.2); }
.crm-lead-status-pill.is-warning { background: rgba(255,190,78,.1); color: #ffbd4a; border-color: rgba(255,190,78,.2); }
.crm-lead-status-pill.is-success { background: rgba(25,212,123,.1); color: #19d47b; border-color: rgba(25,212,123,.2); }
.crm-lead-status-pill.is-muted { background: rgba(148,163,184,.1); color: #94a3b8; border-color: rgba(148,163,184,.2); }
.crm-lead-status-pill.is-info { background: rgba(99,102,241,.1); color: #818cf8; border-color: rgba(99,102,241,.25); }
.theme-light .crm-lead-status-pill.is-info { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.theme-light .crm-lead-status-pill.is-danger { background: #fff0f3; color: #c9183a; border-color: #ffc2cc; }
.theme-light .crm-lead-status-pill.is-warning { background: #fff7df; color: #a66a00; border-color: #ffe1a3; }
.theme-light .crm-lead-status-pill.is-success { background: #eafff5; color: #058a58; border-color: #b9efd7; }
.theme-light .crm-lead-status-pill.is-muted { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.crm-ret-status-pill { padding: 4px 9px; font-size: 10px; line-height: 1; border: 1px solid rgba(96,165,250,.3); background: rgba(96,165,250,.1); color: #8ec5ff; vertical-align: middle; }
.theme-light .crm-ret-status-pill { background: #eaf4ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ── 15. Market Widget ── */
.crm-market-widget {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-xl);
  border: none;
  background: transparent;
}
body.theme-light .crm-market-widget { background: transparent; }
.crm-market-widget--compact { min-height: 0; padding-bottom: 0 !important; }
.crm-market-widget--compact .crm-market-chart-wrap { height: 320px; min-height: 0; flex-shrink: 0; }
.crm-market-widget--compact .crm-market-main { padding-bottom: 0 !important; gap: 8px; }
/* scenario-preview-card: tight bottom, no gap below chart */
.scenario-preview-card .crm-card-head { margin-bottom: 10px !important; }
.scenario-preview-card > .crm-market-widget--compact { margin-bottom: 0 !important; }
.crm-market-widget--compact .crm-market-chart-wrap svg { display: block; width: 100%; height: 100%; }
.crm-market-widget--compact .crm-market-asset { padding: 10px 12px; }

.crm-market-sidebar { display: grid; grid-template-rows: auto 1fr; gap: 12px; min-width: 0; }
.crm-market-controls { display: grid; gap: 10px; margin-bottom: 8px; }
.crm-market-search {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font: inherit;
  outline: none;
}
.crm-market-categories { display: flex; gap: 6px; overflow: auto; padding-bottom: 2px; }
.crm-market-categories button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 99px;
  padding: 7px 12px;
  font: 600 12px/1 inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.crm-market-categories button.active { background: rgba(34,199,232,.12); border-color: rgba(34,199,232,.3); color: var(--accent); }

.crm-market-list { display: grid; gap: 6px; max-height: 100%; overflow: auto; padding-right: 4px; }
.crm-market-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 3px 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: .82rem;
  transition: all .12s;
}
.crm-market-item.active, .crm-market-item:hover { border-color: rgba(34,199,232,.3); background: rgba(34,199,232,.08); }
.crm-market-item small { display: block; color: var(--muted); font-size: 11px; }
/* Price column in market items */
.cmi-info { min-width: 0; }
.cmi-info strong { display: block; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmi-info small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmi-price { text-align: right; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; flex-shrink: 0; }
.cmi-val { font-size: .8rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.cmi-chg { font-size: .7rem; font-weight: 700; white-space: nowrap; }
.cmi-chg.pos { color: #29f18f; }
.cmi-chg.neg { color: #ff5b8e; }
.theme-light .cmi-val { color: #0d2140; }

.crm-market-asset {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  color: var(--text);
  transition: all .15s;
}
.crm-market-asset.active { border-color: rgba(34,199,232,.4); background: rgba(34,199,232,.1); }
.theme-light .crm-market-asset { background: #f8fbff; border-color: #d8e2ef; }
.theme-light .crm-market-asset.active { background: #eaf7ff; border-color: #7dd3fc; }

.crm-market-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.crm-market-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 4px; }
.crm-market-head h3 { margin: 0; font-size: 1.4rem; }
.crm-market-head p { margin: 4px 0 0; color: var(--muted); }
.crm-market-pricebox { text-align: right; }
.crm-market-pricebox strong { display: block; font-size: 1.4rem; }
.crm-market-pricebox span { font-weight: 800; font-size: 14px; }
.crm-market-pricebox span.up { color: var(--success); }
.crm-market-pricebox span.down { color: var(--danger); }
.crm-market-change.positive { color: var(--success); }
.crm-market-change.negative { color: var(--danger); }

.crm-market-ranges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.03);
}
.crm-market-ranges button {
  height: 34px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.crm-market-ranges button:hover { background: rgba(255,255,255,.06); color: var(--text); }
.crm-market-ranges button.active { background: linear-gradient(135deg, var(--accent), #1bf2a4); color: #06111e; }
body.theme-light .crm-market-ranges { background: #eef5ff; }

.crm-market-chart-wrap {
  position: relative;
  height: 320px;
  min-height: 0;
  border: none;
  border-radius: var(--radius-xl);
  background: transparent;
  padding: 0;
  overflow: hidden;
}
body.theme-light .crm-market-chart-wrap { background: transparent; border: none; padding: 0; }
#crmMarketChart, #crmTradeMarketChart { width: 100%; height: 100%; display: block; }

/* Chart SVG elements */
:root { --crm-chart-line: #12d8ff; --crm-chart-overlay: #9a63ff; --crm-chart-fill-top: rgba(18,216,255,.25); --crm-chart-fill-bottom: rgba(18,216,255,.02); }
body.theme-light { --crm-chart-line: #0ea5e9; --crm-chart-overlay: #8b5cf6; --crm-chart-fill-top: rgba(14,165,233,.15); --crm-chart-fill-bottom: rgba(14,165,233,.03); }
.crm-candle-up { fill: #0ecb81; stroke: #0ecb81; }
.crm-candle-down { fill: #f6465d; stroke: #f6465d; }
.crm-candle-override { fill: #f5c542; stroke: #f5c542; filter: drop-shadow(0 0 4px rgba(245,197,66,.6)); }
.crm-chart-grid { stroke: rgba(139,162,196,.12); stroke-width: 1; vector-effect: non-scaling-stroke; }
.crm-chart-grid-v { stroke: rgba(139,162,196,.08); }
.crm-price-line { stroke: rgba(210,220,235,.35); stroke-width: 1; stroke-dasharray: 6 6; vector-effect: non-scaling-stroke; }
.crm-price-flag { fill: #f6465d; stroke: rgba(255,255,255,.15); stroke-width: 1; }
.crm-price-flag-text { fill: #fff; font-size: 10px; font-weight: 800; }
.crm-chart-asset-title { fill: #fff; font-size: 12px; font-weight: 800; }
.crm-chart-asset-stats { fill: #b8c6d8; font-size: 10px; font-weight: 700; }
.theme-light .crm-chart-grid { stroke: rgba(72,98,135,.15); }
.theme-light .crm-chart-asset-title { fill: #0d2140; }
.theme-light .crm-chart-asset-stats { fill: #4f6689; }

.crm-chart-viewer-controls { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.crm-chart-view-toggle { display: flex; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.crm-chart-view-btn {
  padding: 7px 14px; font-size: .82rem; font-weight: 700; cursor: pointer; border: none;
  background: transparent; color: var(--muted); transition: background .15s, color .15s;
}
.crm-chart-view-btn.active { background: var(--accent); color: #04111a; }
.crm-chart-view-btn:not(.active):hover { background: rgba(255,255,255,.06); color: var(--text); }
.theme-light .crm-chart-view-toggle { border-color: #cfe0f2; }
.theme-light .crm-chart-view-btn { color: #5a7090; }
.theme-light .crm-chart-view-btn.active { background: var(--accent); color: #fff; }
.theme-light .crm-chart-view-btn:not(.active):hover { background: rgba(0,0,0,.05); color: #1a3556; }

/* Chart viewer */
.market-embed-wrap, .trade-iframe-card { border-radius: var(--radius-xl); overflow: hidden; border: 1px solid var(--line); background: #050a12; min-height: 560px; }
.market-embed-wrap iframe, .trade-iframe-card iframe { display: block; width: 100%; height: 100%; min-height: 560px; border: 0; }
.theme-light .market-embed-wrap, .theme-light .trade-iframe-card, .theme-light .market-embed-wrap iframe, .theme-light .trade-iframe-card iframe { background: #fff; }
.origin-tag { display: inline-flex; padding: 5px 10px; border-radius: 99px; background: rgba(255,255,255,.05); color: var(--muted); font-size: .75rem; }
.custom-tag, .marked-insert { box-shadow: 0 0 0 1px rgba(34,199,232,.2) inset; }
.marked-insert { position: relative; }
.marked-insert::after { content: "CRM insert"; position: absolute; top: 4px; right: 4px; padding: 4px 8px; border-radius: 99px; background: rgba(34,199,232,.12); color: var(--accent); font-size: .7rem; font-weight: 800; z-index: 2; }

/* ── 16. Modals ── */
.crm-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.crm-modal-backdrop { position: absolute; inset: 0; background: rgba(3,8,16,.7); backdrop-filter: blur(10px); }
.crm-modal-dialog {
  position: relative;
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin: 16px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow);
}
.crm-modal-sm { max-width: 640px; }
.crm-modal-md { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 56px); overflow: auto; }

.crm-modal-card {
  position: relative;
  z-index: 1;
  max-width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin: 16px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.crm-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.crm-modal-head h2 { margin: 4px 0 0; }
.card-label { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: inherit;
  cursor: pointer;
  transition: border-color .15s;
}
.icon-button:hover { border-color: var(--accent); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}
.ghost-button, .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.ghost-button { background: rgba(255,255,255,.03); color: inherit; }
.ghost-button:hover { background: rgba(255,255,255,.06); }
.ghost-button.small { padding: 8px 12px; font-size: 12px; min-height: 34px; }
.primary-button { background: linear-gradient(135deg, #22c7e8, #1bf2a4); border-color: transparent; color: #08111d; font-weight: 800; }
.primary-button:hover { filter: brightness(1.05); }

.theme-light .crm-modal-card { background: #fff; border-color: #d9e3ef; box-shadow: 0 24px 60px rgba(16,24,40,.12); }

/* Client card modal — Redesigned */
.crm-client-card-body { display: grid; gap: 24px; }

/* Overview: info on the left, actions on the right, side by side */
.crm-client-overview { display: grid; grid-template-columns: 1fr 340px; align-items: start; gap: 24px; }

/* Info grid: compact 4-column layout */
.crm-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--panel);
}
.crm-info-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  word-break: break-word;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.crm-info-grid > div:nth-child(4n) { border-right: 0; }
.crm-info-grid > div:nth-last-child(-n+4) { border-bottom: 0; }
.crm-info-grid .crm-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  line-height: 1.2;
}
.crm-info-grid strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
.crm-info-wide { grid-column: span 2; }

/* Sections: single column for better readability */
.crm-client-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.crm-client-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
.crm-client-summary > div { min-width: 0; }
.crm-client-summary strong, .crm-wallet-line code, .crm-user-id, .crm-muted { overflow-wrap: anywhere; word-break: break-word; }

/* Actions panel: compact card on the right side */
.crm-client-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.crm-client-actions .crm-btn {
  min-height: 38px;
  height: 38px;
  font-size: 13px;
  padding: 0 14px;
}
.crm-client-actions .crm-btn.primary {
  min-height: 44px;
  height: 44px;
  font-size: 14px;
}
.crm-client-actions .crm-inline-select { display: grid; gap: 4px; width: 100%; }
.crm-client-actions .crm-inline-select span,
.crm-client-actions .crm-inline-select input,
.crm-client-actions .crm-inline-select select,
.crm-client-actions input,
.crm-client-actions select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}
.crm-client-actions .crm-inline-select span { font-weight: 700; color: var(--muted); font-size: 11px; min-height: auto; border: 0; background: transparent; padding: 0; text-transform: uppercase; letter-spacing: .04em; }
.crm-client-actions .crm-toggle { min-height: 38px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; background: rgba(255,255,255,.02); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.crm-client-actions .crm-comment-field textarea { min-height: 60px !important; font-size: 13px; padding: 10px 12px; }
.theme-light .crm-client-actions { background: #fff; border-color: #d9e3ef; }
.theme-light .crm-client-actions input, .theme-light .crm-client-actions select { background: #f8fbff; }
.theme-light .crm-client-actions .crm-toggle { background: #f8fbff; }

/* Section inner cards: cleaner look */
.crm-client-sections .crm-inner-card {
  padding: 18px;
  border-radius: var(--radius-lg);
}
.crm-client-sections .crm-inner-card .crm-card-head {
  margin-bottom: 12px;
}
.crm-client-sections .crm-inner-card h3 {
  font-size: 1rem;
  font-weight: 800;
}
.crm-client-sections .crm-badge {
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(34,199,232,.1);
  color: var(--accent);
  font-weight: 900;
  letter-spacing: .08em;
  display: inline-flex;
  margin-bottom: 4px;
}

.crm-wallet-card, .crm-position-card, .crm-ticket-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.02);
  border: 1px solid var(--line);
}
.crm-wallet-card { overflow: hidden; }
.crm-wallet-line { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; align-items: start; }
.crm-wallet-line code { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }

.crm-ticket-card-clean { display: grid; gap: 12px; }
.crm-ticket-card-clean .crm-ticket-top { align-items: center; }
.crm-ticket-card-clean .crm-ticket-body { display: grid; gap: 12px; }
.crm-ticket-card-clean .crm-ticket-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.crm-ticket-card-clean.crm-ticket-fiat { box-shadow: 0 0 0 1px rgba(34,199,232,.18) inset; }
.crm-ticket-card-clean.crm-ticket-withdrawal { box-shadow: 0 0 0 1px rgba(255,178,61,.18) inset; }
.crm-ticket-images { display: flex; flex-wrap: wrap; gap: 12px; }
.crm-ticket-image { max-width: 180px; border-radius: var(--radius-md); cursor: zoom-in; user-select: text; }

.crm-table-wrap { overflow: auto; max-width: 100%; }
.crm-mini-table { min-width: 640px; border-collapse: separate; border-spacing: 0 6px; table-layout: auto; }
.crm-mini-table td, .crm-mini-table th { padding: 8px 10px; vertical-align: middle; white-space: nowrap; overflow-wrap: anywhere; text-align: left; }
.crm-mini-table input, .crm-mini-table select { width: 100%; background: var(--input-bg); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); padding: 8px 10px; }
.crm-mini-table .crm-readonly { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.crm-client-sections .crm-mini-table button.crm-edit-trade { white-space: nowrap; }

.crm-position-grid { display: grid; gap: 12px; }
.crm-position-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.crm-position-meta { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; margin: 10px 0; color: var(--muted); font-size: 13px; }
.crm-requisites-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); background: rgba(255,255,255,.03); border: 1px solid var(--line); }

/* old overrides removed — see section 38 */
#tradeEditModal .crm-inline-actions { justify-content: space-between; }

/* ── 17. Permissions ── */
.crm-permissions-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.02);
}
.crm-permissions-box--modal { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crm-permissions-title { grid-column: 1/-1; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.crm-permissions-box .crm-toggle { min-height: 48px; }
.crm-hidden-by-permission { display: none !important; }

/* Check rows */
.crm-check-row, .crm-perm-grid label {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  min-height: 44px !important;
}
.crm-check-row span, .crm-perm-grid span { font-size: 14px !important; font-weight: 700 !important; text-align: left !important; order: 1 !important; }
.crm-check-row input[type="checkbox"], .crm-perm-grid input[type="checkbox"] {
  appearance: none !important;
  -webkit-appearance: none !important;
  order: 2 !important;
  width: 18px !important; height: 18px !important;
  min-width: 18px !important; max-width: 18px !important;
  border-radius: 5px !important;
  border: 1px solid rgba(125,211,252,.4) !important;
  background: rgba(255,255,255,.05) !important;
  display: grid !important; place-items: center !important;
  margin: 0 !important; cursor: pointer;
}
.crm-check-row input[type="checkbox"]:checked, .crm-perm-grid input[type="checkbox"]:checked { background: var(--accent) !important; border-color: var(--accent) !important; }
.crm-check-row input[type="checkbox"]:checked::after, .crm-perm-grid input[type="checkbox"]:checked::after { content: '✓'; font-size: 13px; line-height: 1; color: #06131f; font-weight: 900; }

/* Admin cards */
.crm-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.crm-admin-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; background: var(--panel); }
.crm-admin-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.crm-admin-perm-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.crm-admin-perm-summary .crm-mini-badge { background: rgba(30,200,255,.08); border: 1px solid rgba(30,200,255,.2); }
.crm-rights-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ── 18. Period Control ── */
.crm-period-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-md);
  width: auto;
  max-width: max-content;
  flex: 0 0 auto;
  position: relative;
  z-index: 5;
}
.crm-period-control > span { font-size: 11px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.crm-period-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}
.crm-period-tabs button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all .15s;
  min-width: 36px;
  height: 30px;
  white-space: nowrap;
  pointer-events: auto;
}
.crm-period-tabs button:hover { color: var(--text); background: rgba(255,255,255,.06); }
.crm-period-tabs button.active { color: #03111e; background: linear-gradient(135deg, #22c7e8, #1bf2a4); box-shadow: 0 6px 18px rgba(34,199,232,.2); }
.crm-period-control select { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; }
.crm-period-custom { display: inline-flex; gap: 6px; align-items: center; }
.crm-period-custom input { height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); padding: 0 8px; }

.theme-light .crm-period-control { background: #f8fbff; border-color: #cfe0ef; box-shadow: none; }
.theme-light .crm-period-control > span { color: #355172; }
.theme-light .crm-period-tabs { background: #edf5fd; border-color: #d4e3f2; }
.theme-light .crm-period-tabs button { color: #57708f; }
.theme-light .crm-period-tabs button.active { color: #053047; background: linear-gradient(135deg, #9fe9ff, #8cf2c7); box-shadow: none; }
.theme-light .crm-period-custom input { background: #fff; color: #0d2140; border-color: #cfe0ef; }

/* ── 19. Inline Actions ── */
.crm-inline-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; position: relative; z-index: 3; }
.crm-page .page-head .crm-inline-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* Analytics switch */
.crm-analytics-switch { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); }
.crm-analytics-switch.hidden { display: none !important; }
.crm-analytics-switch select, #hyperAnalyticsMode {
  appearance: none;
  -webkit-appearance: none;
  min-width: 200px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font-weight: 700;
  padding: 0 14px;
  cursor: pointer;
}
.crm-analytics-switch select:focus, #hyperAnalyticsMode:focus { border-color: var(--accent); }
.theme-light .crm-analytics-switch select, .theme-light #hyperAnalyticsMode { background: #fff; color: #0d2140; border-color: #cfe0ef; }

/* ── 20. Scenario Sliders ── */
.crm-scenario-sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin: 12px 0; }
.crm-slider-field { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.03); }
.crm-slider-field span { font-weight: 800; color: var(--text); }
.crm-slider-field small { color: var(--muted); font-size: 11px; }
.crm-slider-field input[type=range] { width: 100%; accent-color: var(--accent); }
.crm-slider-field select { height: 38px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); font-weight: 700; padding: 0 10px; }
.theme-light .crm-slider-field { background: #f3f8ff; }
.theme-light .crm-slider-field select { background: #fff; color: #0d2140; }

.crm-snap-slider-field {
  padding: 16px 18px !important;
  border: 0 !important;
  border-radius: var(--radius-xl) !important;
  background: linear-gradient(180deg, rgba(16,33,57,.96), rgba(9,21,38,.92)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 14px 30px rgba(0,0,0,.2) !important;
}
.theme-light .crm-snap-slider-field {
  background: linear-gradient(180deg, rgba(232,247,255,.95), rgba(211,237,250,.82)) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 14px 30px rgba(25,122,190,.08) !important;
}
.crm-snap-slider-field > span { display: flex !important; align-items: center !important; justify-content: space-between !important; margin-bottom: 14px !important; font-size: 13px !important; font-weight: 900 !important; }
.crm-snap-slider {
  appearance: none !important; -webkit-appearance: none !important;
  width: 100% !important; height: 22px !important; padding: 0 !important;
  margin: 2px 0 10px !important; border: 0 !important; background: transparent !important; cursor: pointer !important;
}
.crm-snap-slider::-webkit-slider-runnable-track { height: 8px !important; border-radius: 99px !important; border: 0 !important; background: linear-gradient(90deg, #1fd2ef var(--crm-slider-fill, 33%), rgba(101,131,169,.25) var(--crm-slider-fill, 33%)) !important; }
.crm-snap-slider::-moz-range-track { height: 8px !important; border-radius: 99px !important; border: 0 !important; background: rgba(101,131,169,.25) !important; }
.crm-snap-slider::-moz-range-progress { height: 8px !important; border-radius: 99px !important; background: #1fd2ef !important; }
.crm-snap-slider::-webkit-slider-thumb { -webkit-appearance: none !important; width: 24px !important; height: 24px !important; border-radius: 50% !important; border: 4px solid #eafaff !important; background: linear-gradient(135deg, #00c8ef, #1ee788) !important; box-shadow: 0 6px 16px rgba(0,200,239,.3) !important; margin-top: -8px !important; }
.crm-snap-slider::-moz-range-thumb { width: 18px !important; height: 18px !important; border-radius: 50% !important; border: 4px solid #eafaff !important; background: linear-gradient(135deg, #00c8ef, #1ee788) !important; }
.crm-slider-marks { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; margin: 2px 2px 8px !important; position: relative !important; }
.crm-slider-marks::before { content: ""; position: absolute; left: 0; right: 0; top: -16px; height: 8px; background: repeating-linear-gradient(90deg, transparent 0 calc(33.333% - 1px), rgba(209,239,255,.3) calc(33.333% - 1px) calc(33.333% + 1px)); pointer-events: none; }
.crm-slider-marks span { font-size: 11px !important; font-weight: 800 !important; color: var(--muted) !important; text-align: center !important; white-space: nowrap !important; }
.crm-slider-marks span:first-child { text-align: left !important; }
.crm-slider-marks span:last-child { text-align: right !important; }
.crm-snap-slider-field small { display: block !important; color: var(--muted) !important; font-size: 12px !important; font-weight: 700 !important; margin-top: 4px !important; }

.crm-scenario-targets { display: flex; flex-direction: column; gap: 8px; }

/* ── 21. User Picker ── */
.crm-user-picker { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.crm-user-picker.hidden { display: none; }
.crm-user-picker input { background: var(--input-bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.crm-user-picker-list {
  max-height: 200px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}
.crm-user-picker-row {
  display: flex !important; align-items: center; gap: 8px; padding: 7px 9px;
  border-radius: var(--radius-sm); cursor: pointer;
  background: rgba(255,255,255,.03); border: 1px solid var(--line);
  color: var(--text); min-width: 0; text-align: left;
  transition: all .12s;
}
.crm-user-picker-row:hover { background: rgba(34,199,232,.06); border-color: rgba(34,199,232,.3); }
.crm-user-picker-row.active { background: rgba(34,199,232,.1); border-color: var(--accent); }
.crm-user-picker-row input { width: auto !important; flex-shrink: 0; accent-color: var(--accent); }
.crm-user-picker-row span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.crm-user-picker-row strong { color: #fff; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-user-picker-row small { opacity: .6; font-size: 11px; line-height: 1.3; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-user-picker-button { width: 100%; font: inherit; }
.theme-light .crm-user-picker-list { background: #f8fbff; border-color: #cfe0ef; }
.theme-light .crm-user-picker-row { background: #fff; border-color: #d8e2ef; color: #0d2140; }
.theme-light .crm-user-picker-row:hover { background: #eef7ff; border-color: #7dd3fc; }
.theme-light .crm-user-picker-row.active { background: #e5f7ff; border-color: #38bdf8; }
.theme-light .crm-user-picker-row strong { color: #0d2140; }
.theme-light .crm-user-picker-row small { color: #53698c; opacity: 1; }

/* ── 22. Symbol Menu ── */
.crm-symbol-menu {
  display: grid; gap: 6px; max-height: 280px; overflow: auto; padding: 10px;
  border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--panel);
}
.crm-symbol-group-title { font-size: .7rem; color: var(--accent); font-weight: 800; text-transform: uppercase; }
.crm-symbol-option {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: rgba(255,255,255,.03); cursor: pointer; transition: background .12s;
}
.crm-symbol-option:hover, .crm-symbol-option.active { background: rgba(34,199,232,.1); }

.crm-inline-symbol-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 80; box-shadow: 0 18px 45px rgba(0,0,0,.35); }

/* ── 23. Notifications / Feedback ── */
.crm-notice {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  padding: 14px 18px; border-radius: var(--radius-md);
  border: 1px solid var(--line); background: var(--panel);
  box-shadow: var(--shadow); max-width: 380px;
}

/* ── 24. Confirmation Dialog ── */
.crm-confirm-overlay { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 30px; background: rgba(15,23,42,.42); backdrop-filter: blur(10px); opacity: 0; transition: opacity .16s ease; }
.crm-confirm-overlay.is-visible { opacity: 1; }
.crm-confirm-card { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--panel); color: var(--text); box-shadow: 0 28px 80px rgba(0,0,0,.35); padding: 28px; transform: translateY(8px) scale(.98); transition: transform .16s ease; }
.crm-confirm-overlay.is-visible .crm-confirm-card { transform: translateY(0) scale(1); }
.crm-confirm-badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 99px; background: rgba(34,199,232,.12); color: var(--accent); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 12px; }
.crm-confirm-card h3 { margin: 0 0 10px; font-size: 20px; line-height: 1.2; }
.crm-confirm-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.crm-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.crm-confirm-actions .crm-btn { width: 100%; min-height: 44px; border-radius: var(--radius-md); }
body.theme-light .crm-confirm-card { background: #fff; border-color: #d7e5f4; box-shadow: 0 28px 80px rgba(15,23,42,.18); }
body.theme-light .crm-confirm-card h3 { color: #071525; }
body.theme-light .crm-confirm-card p { color: #49617f; }
body.theme-light .crm-confirm-badge { background: #dff8ff; color: #06a6c8; }
body.theme-light .crm-confirm-actions .crm-btn.secondary { background: #f8fbff; color: #0d2140; border-color: #cfe0ef; }
body.theme-dark .crm-confirm-actions .crm-btn.secondary,
body:not(.theme-light) .crm-confirm-actions .crm-btn.secondary { background: rgba(255,255,255,.04); color: #e8f1ff; border-color: rgba(148,163,184,.25); }

/* ── 25. Media Preview ── */
.crm-media-preview { position: fixed; inset: 0; z-index: 9999; background: rgba(4,9,18,.8); display: flex; align-items: center; justify-content: center; padding: 32px; }
.crm-media-preview-card { position: relative; max-width: min(92vw, 1000px); max-height: 90vh; }
.crm-media-preview-card img { display: block; max-width: 100%; max-height: 82vh; border-radius: var(--radius-lg); border: 1px solid rgba(34,199,232,.2); box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.crm-media-preview-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.crm-media-preview-actions a, .crm-media-preview-actions button { border: 1px solid rgba(34,199,232,.2); background: var(--panel); color: var(--text); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 700; text-decoration: none; }

/* ── 26. Support Tickets ── */
.crm-ticket-thread { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; max-height: 360px; overflow: auto; padding-right: 4px; }
.crm-ticket-message { position: relative; padding: 12px 48px 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.crm-ticket-message.is-admin { margin-right: 34px; background: rgba(34,199,232,.05); border-color: rgba(34,199,232,.18); }
.crm-ticket-message.is-user { margin-left: 34px; background: rgba(34,197,94,.05); border-color: rgba(34,197,94,.15); }
.crm-ticket-message-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.crm-ticket-message-head strong { color: var(--text); font-size: 13px; }
.crm-ticket-message-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.crm-ticket-message-actions { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; }
.crm-icon-mini { width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); cursor: pointer; font-weight: 900; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.crm-icon-mini:hover { border-color: rgba(34,199,232,.4); color: var(--accent); }
.crm-icon-mini.danger { color: #ff7b91; }
.crm-icon-mini.danger:hover { border-color: rgba(255,91,122,.4); color: #ff4f72; }
.crm-message-editor-card textarea { width: 100%; min-height: 130px; border-radius: var(--radius-md); border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); padding: 14px; font: inherit; resize: vertical; outline: none; }
body.theme-light .crm-ticket-message { background: #f8fbff; border-color: #d7e5f4; color: #0d2140; }
body.theme-light .crm-ticket-message.is-admin { background: #eaf8ff; border-color: #bcecff; }
body.theme-light .crm-ticket-message.is-user { background: #eefdf5; border-color: #b7f0ce; }
body.theme-light .crm-icon-mini { background: #fff; color: #0d2140; border-color: #cfe0ef; }

/* ── 27. Traffic / Funnels ── */
#trafficApisList { display: grid; gap: 14px; }
.traffic-api-card { border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--panel); padding: 18px; box-shadow: var(--shadow); }
.traffic-api-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.traffic-api-kicker { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 9px; background: rgba(34,199,232,.1); color: var(--accent); font-weight: 900; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }
.traffic-api-top h3 { margin: 0 0 6px; font-size: 17px; line-height: 1.2; }
.traffic-api-top p { margin: 0; color: var(--muted); font-size: 13px; }
.traffic-api-top p b { color: var(--text); font-weight: 700; }
.traffic-api-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 2px; }
.traffic-api-metrics span { border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.02); padding: 12px; display: grid; gap: 3px; }
.traffic-api-metrics b { font-size: 18px; color: var(--text); }
.traffic-api-metrics small { color: var(--muted); font-size: 12px; }
.traffic-api-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 14px; }
.traffic-api-editor { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.traffic-api-copybox { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid rgba(34,199,232,.15); background: rgba(34,199,232,.04); border-radius: var(--radius-lg); padding: 14px; }
.traffic-api-copybox p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.traffic-api-mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.traffic-api-mini-grid div { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.02); padding: 12px; }
.traffic-api-mini-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.traffic-api-mini-grid code { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-size: 12px; }
.traffic-api-actions { justify-content: flex-end; }
body.theme-light .traffic-api-card { background: #fff; border-color: #d7e5f4; }
body.theme-light .traffic-api-metrics span, body.theme-light .traffic-api-mini-grid div { background: #f8fbff; border-color: #d7e5f4; }
body.theme-light .traffic-api-copybox { background: #eaf8ff; border-color: #bcecff; }

/* KPI grid */
.crm-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.crm-kpi { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.03); }
.crm-kpi span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.crm-kpi strong { font-size: 22px; }
.crm-code-preview { white-space: pre-wrap; max-height: 180px; overflow: auto; border-radius: var(--radius-md); padding: 12px; background: rgba(0,0,0,.18); font-size: 12px; }
.crm-access-box { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.03); }
.crm-access-users { max-height: 220px; overflow: auto; display: grid; gap: 8px; margin: 10px 0; }

/* ── 28. Telephony ── */
.crm-phone-link { border: 0; background: transparent; color: #38bdf8; font: inherit; font-weight: 800; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.crm-phone-link:hover { color: #67e8f9; }
.crm-telephony-panel {
  grid-column: 1/-1;
  border: 1px solid rgba(56,189,248,.18);
  background: var(--panel);
  border-radius: var(--radius-xl);
  padding: 18px;
  margin: 8px 0 12px;
  box-shadow: var(--shadow);
  color: var(--text);
}
.crm-telephony-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.crm-telephony-head > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crm-telephony-head strong { font-size: 16px; line-height: 1.15; }
.crm-call-close { width: 38px; height: 38px; border-radius: var(--radius-md); border: 1px solid rgba(248,113,113,.4); background: linear-gradient(180deg, #ef4444, #b91c1c); color: #fff; font-size: 20px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.crm-call-close:hover { filter: brightness(1.07); }
.crm-call-status { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 5px 10px; font-size: 11px; font-weight: 800; background: rgba(148,163,184,.15); color: #cbd5e1; white-space: nowrap; }
.crm-call-status.connected { background: rgba(16,185,129,.15); color: #34d399; }
.crm-call-status.dialing, .crm-call-status.ringing, .crm-call-status.external_dialer { background: rgba(250,204,21,.12); color: #fde047; }
.crm-call-status.route_blocked, .crm-call-status.error, .crm-call-status.failed { background: rgba(244,63,94,.15); color: #fb7185; }
.crm-call-status.ended { background: rgba(148,163,184,.15); color: #e2e8f0; }
.crm-telephony-body { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; margin-bottom: 14px; }
.crm-telephony-meta { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; min-width: 0; }
.crm-telephony-meta span { color: var(--muted); font-size: 12px; font-weight: 700; }
.crm-telephony-meta strong { color: var(--text); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crm-call-open-card { border: 0; border-radius: var(--radius-lg); padding: 11px 18px; background: linear-gradient(135deg, #22c7e8, #1bf2a4); color: #05111d; font-size: 13px; font-weight: 900; cursor: pointer; }
.crm-call-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.crm-call-actions .crm-btn { min-height: 42px; padding: 9px 10px; border-radius: var(--radius-md); font-size: 12px; line-height: 1.15; white-space: normal; }
.crm-recording-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px; background: rgba(255,255,255,.02); }
.crm-recording-row span, .crm-recording-row small { color: var(--muted); }
.crm-recording-row a { color: #38bdf8; font-weight: 800; }
.crm-telephony-settings input, .crm-telephony-settings select { width: 100%; }
.theme-light .crm-telephony-panel { background: #fff; border-color: #cfe0ef; box-shadow: 0 24px 60px rgba(15,23,42,.12); color: #0d2140; }
.theme-light .crm-telephony-head strong { color: #0d2140; }
.theme-light .crm-telephony-meta strong { color: #0d2140; }
.theme-light .crm-telephony-meta span { color: #64779a; }
.theme-light .crm-call-actions { border-top-color: #d7e5f4; }
.theme-light .crm-recording-row { background: rgba(255,255,255,.75); }

/* Floating telephony widget */
.crm-telephony-floating {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  width: min(380px, calc(100vw - 32px));
  margin: 0;
  backdrop-filter: blur(14px);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.crm-telephony-floating.hidden { display: none !important; }
.crm-storage-card { border-style: dashed; }

/* ── 29. SMM Lead Form ── */
.crm-smm-form textarea { min-height: 86px; resize: vertical; }
.crm-smm-assignee { display: grid; gap: 10px; }
.crm-assignee-picker { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); padding: 10px; max-height: 280px; overflow: auto; }
.crm-assignee-group + .crm-assignee-group { margin-top: 10px; }
.crm-assignee-group-title { color: var(--muted); font-weight: 800; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; margin: 4px 6px 8px; }
.crm-assignee-option { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; margin: 6px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; background: rgba(255,255,255,.03); color: var(--text); cursor: pointer; text-align: left; transition: all .15s; }
.crm-assignee-option small { color: var(--muted); }
.crm-assignee-option:hover, .crm-assignee-option.active { border-color: rgba(34,199,232,.5); background: rgba(34,199,232,.08); }
.crm-smm-info-card { margin: 14px 0; }
.crm-checkbox-list { max-height: 170px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 8px; background: rgba(255,255,255,.03); }
.crm-checkbox-list .crm-toggle { padding: 7px 6px; margin: 0; border-radius: var(--radius-sm); }
.crm-checkbox-list .crm-toggle:hover { background: rgba(255,255,255,.05); }
.theme-light .crm-checkbox-list { background: #fff; border-color: #cfe0ef; }

/* ── 30. Tooltip / Help ── */
.crm-tooltip-row { align-items: center; gap: 10px; flex-direction: row !important; }
.crm-help-dot { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 99px; border: 1px solid rgba(34,199,232,.4); color: var(--accent); font-weight: 800; font-size: 12px; cursor: help; position: relative; background: rgba(34,199,232,.06); }
.crm-help-dot:hover::after, .crm-help-dot:focus::after { content: attr(aria-label); position: absolute; left: 50%; bottom: 135%; transform: translateX(-50%); width: 320px; max-width: 70vw; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: 0 14px 35px rgba(0,0,0,.35); font-size: 12px; line-height: 1.45; z-index: 50; text-align: left; font-weight: 600; }

/* Comment field */
.crm-comment-field { min-width: min(560px, 100%); flex: 1 1 560px; }
.crm-comment-field textarea { width: 100%; border: 0; outline: 0; border-radius: var(--radius-md); background: var(--input-bg); color: var(--text); padding: 12px 14px; resize: vertical; min-height: 86px; font: inherit; }

/* Notify form */
.crm-notify-form { display: grid; gap: 10px; }
.crm-notify-form input, .crm-notify-form textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--input-bg); color: var(--text); padding: 12px 14px; font: 600 14px Inter, sans-serif; outline: none; }
.crm-notify-form textarea { resize: vertical; }
.crm-notify-form input:focus, .crm-notify-form textarea:focus { border-color: rgba(34,199,232,.5); }

/* ── 31. Crypto Wallet Status ── */
.crypto-status-panel { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; background: rgba(255,255,255,.02); margin-top: 12px; }
.crypto-status-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.crypto-status-head h3 { margin: 2px 0 0; font-size: 16px; }
.crypto-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.crypto-status-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px; background: rgba(255,255,255,.02); color: var(--text); font-size: 13px; line-height: 1.7; }
.crypto-status-card span { color: var(--muted); word-break: break-all; }
.crypto-status-title { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.crypto-history-box, .crypto-log-box { max-height: 230px; overflow: auto; padding-right: 4px; }
.crypto-table { min-width: 860px; }
.crypto-table-row { display: grid; grid-template-columns: 1.35fr .95fr .65fr .85fr 1fr 1fr .8fr; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.crypto-table-head { color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.crypto-log-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; background: rgba(255,255,255,.02); font-size: 12px; line-height: 1.55; }
.crypto-log-row.is-success { border-color: rgba(46,213,115,.25); }
.crypto-log-row.is-warning { border-color: rgba(255,196,87,.25); }
.crypto-log-row.is-error { border-color: rgba(255,82,82,.25); }
.scan-link { color: var(--accent); text-decoration: none; font-weight: 700; }
.scan-link:hover { text-decoration: underline; }
.crm-error-text { color: #ff7b7b; font-size: 12px; word-break: break-word; }

/* Crypto history controls */
.crypto-history-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 12px; }
.crypto-history-controls .crm-toggle.compact { min-height: 38px; padding: 8px 12px; border-radius: var(--radius-sm); }
.crypto-uid-filter { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: min(260px, 100%); }
.crypto-uid-filter span { font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.crypto-uid-filter input { height: 38px; min-height: 38px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--input-bg); border: 1px solid var(--line); color: var(--text); }

/* Master Wallet Modal */
#masterWalletModal .crm-modal-card { width: min(1560px, calc(100vw - 16px)) !important; max-width: 1560px !important; height: min(94vh, 900px) !important; max-height: 94vh !important; display: flex !important; flex-direction: column !important; overflow: hidden !important; padding: 20px !important; }
#masterWalletModal .crm-modal-head { flex: 0 0 auto !important; margin-bottom: 10px !important; }
/* form = flex column; scroll wrapper takes remaining space; actions fixed at bottom */
#masterWalletModal .crm-form { flex: 1 1 auto !important; min-height: 0 !important; display: flex !important; flex-direction: column !important; gap: 0 !important; overflow: hidden !important; padding: 0 !important; }
#masterWalletModal .mw-scroll-body { flex: 1 1 auto !important; min-height: 0 !important; overflow-y: auto !important; overflow-x: hidden !important; display: block !important; padding: 0 8px 12px 0 !important; }
#masterWalletModal .mw-scroll-body > * { margin-bottom: 12px !important; }
#masterWalletModal .mw-scroll-body > *:last-child { margin-bottom: 0 !important; }
#masterWalletModal .mw-form-actions { flex: 0 0 auto !important; display: flex !important; justify-content: flex-end !important; gap: 12px !important; border-top: 1px solid var(--line) !important; padding-top: 16px !important; margin-top: 14px !important; }
#masterWalletModal .crypto-status-panel { display: block !important; min-height: 0 !important; margin: 4px 0 0 !important; }
#masterWalletModal .crypto-status-grid { display: grid !important; grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 10px !important; margin: 0 !important; }
#masterWalletModal .crypto-status-card { min-height: 54px !important; padding: 11px 12px !important; }
#masterWalletModal .crypto-history-box, #masterWalletModal .crypto-log-box { max-height: 230px !important; overflow: auto !important; margin-top: 8px !important; background: rgba(255,255,255,.02) !important; border-radius: var(--radius-md) !important; border: 1px solid var(--line) !important; padding: 10px !important; }
#masterWalletModal .crypto-table { min-width: 1120px !important; }
#masterWalletModal .crypto-table-row { grid-template-columns: 1.28fr .9fr .58fr .72fr .95fr .95fr .68fr .9fr !important; }
#masterWalletModal .crypto-table-row.is-sweep-failed { background: rgba(255,82,82,.04) !important; }
#masterWalletModal .crm-btn.tiny { min-height: 28px !important; height: 28px !important; padding: 0 10px !important; border-radius: 8px !important; font-size: 11px !important; white-space: nowrap !important; }

/* ── 32. Import / Export ── */
.crm-import-export { display: grid; gap: 12px; margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.03); }
.crm-import-export--modal { margin: 0; background: rgba(255,255,255,.03); }
.theme-light .crm-import-export { background: #f8fbff; }
.crm-file-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.crm-file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── 33. Misc Status ── */
.transaction-amount-status { display: flex !important; align-items: center !important; gap: 12px !important; justify-content: flex-end !important; flex-wrap: wrap !important; }
.trade-result.deducted-success strong { color: var(--text) !important; }
.wallet-withdraw-blocked { color: #ff4d6d !important; font-weight: 900 !important; margin-left: 8px !important; }
.cap-verified-badge { display: inline-flex !important; align-items: center !important; justify-content: center; min-width: 18px !important; width: 18px !important; height: 18px !important; border-radius: 99px; background: #1677ff; color: #fff; font-size: 12px; font-weight: 900; margin-left: 6px !important; flex: 0 0 auto; }
.trade-edit-now-box { display: flex; align-items: flex-end; }

/* Client card compact */
.client-card, .crm-client-card { min-height: auto !important; padding: 12px 14px !important; }
.client-card .crm-grid, .crm-client-card .crm-grid { grid-template-columns: repeat(4, minmax(0,1fr)) !important; gap: 8px !important; }
.client-card .crm-card-head, .crm-client-card .crm-card-head { margin-bottom: 8px !important; }

/* Title UID row */
.crm-title-uid-row { display: inline-flex; align-items: center; gap: 14px; margin-left: 10px; vertical-align: middle; flex-wrap: wrap; }
.crm-title-uid { color: var(--text); font-size: 15px; font-weight: 800; }
.crm-title-last-login { color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ── 34. Light Theme Overrides ── */
.theme-light .crm-sidebar { border-color: #d9e3ef; }
.theme-light .crm-topbar { border-color: #d9e3ef; }
.theme-light .crm-card { border-color: #d9e3ef; background: #fff; }
.theme-light .crm-nav-link:hover { background: rgba(230,126,34,.06); color: #1a1a1a; }
.theme-light .crm-nav-link.active { background: rgba(230,126,34,.1); color: #e67e22; }

/* ── 35. Responsive ── */
@media (max-width: 1280px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid > .dashboard-card:first-child { grid-row: auto; }
  .trade-layout-grid, .two-up { grid-template-columns: 1fr; }
  .crm-market-widget { grid-template-columns: 1fr; }
  .crm-permissions-box { grid-template-columns: 1fr; }
  .crm-client-summary, .crm-funnel-stats, .crm-admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .crm-app { grid-template-columns: 1fr; }
  .crm-topbar { padding: 12px 16px; height: auto; flex-wrap: wrap; }
  .crm-topbar-search { max-width: 100%; }
  .crm-topbar-search input { width: 100%; }
  .crm-filters { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .crm-row2, .crm-row3 { grid-template-columns: 1fr; }
  .traffic-api-top, .traffic-api-copybox { flex-direction: column; align-items: stretch; }
  .traffic-api-metrics, .traffic-api-editor, .traffic-api-mini-grid { grid-template-columns: 1fr; }
  .traffic-api-actions { justify-content: stretch; }
  .traffic-api-actions .crm-btn { width: 100%; }
}

@media (max-width: 680px) {
  .crm-content { padding: 12px; }
  .metric-grid, .crm-filters { grid-template-columns: 1fr; }
  .crm-userbar { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .market-embed-wrap, .trade-iframe-card { min-height: 360px; }
  .market-embed-wrap iframe, .trade-iframe-card iframe { min-height: 360px; }
  .crm-confirm-actions { grid-template-columns: 1fr; }
  .crm-lead-details-grid { grid-template-columns: 1fr; }
  .crm-lead-card-top { grid-template-columns: auto 1fr; }
  .crm-lead-balance { grid-column: 1 / -1; }
  .crm-telephony-body { grid-template-columns: 1fr; }
  .crm-call-actions { grid-template-columns: 1fr; }
  .crm-telephony-head > div { align-items: flex-start; flex-direction: column; }
  .crm-recording-row { grid-template-columns: 1fr; }
  .crm-scenario-sliders { grid-template-columns: 1fr; }
  .crm-title-uid-row { display: flex; margin-left: 0; margin-top: 6px; gap: 8px; }
  .crm-title-last-login { white-space: normal; }
  .crypto-status-grid { grid-template-columns: 1fr; }
  .crypto-history-controls { align-items: stretch; }
  .crypto-uid-filter { width: 100%; margin-left: 0; }
  .crypto-uid-filter input { flex: 1; }

  /* Small phone specific */
  .crm-card { padding: 16px; border-radius: var(--radius-lg); }
  .metric-card { padding: 14px; }
  .metric-card strong { font-size: 1.25rem; }
  .crm-card h2 { font-size: 1.1rem; }
  .page-head h1 { font-size: 1.3rem; }
  .crm-market-widget { grid-template-columns: 1fr; padding: 12px; }
  .crm-market-sidebar { max-height: 180px; overflow-y: auto; }
  .crm-market-chart-wrap { min-height: 240px; height: 260px; }
  .crm-permissions-box, .crm-permissions-box--modal { grid-template-columns: 1fr; }
  .crm-admin-grid { grid-template-columns: 1fr; }
  .crm-client-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }

  /* Mobile bottom nav smaller */
  .crm-mobile-nav .crm-nav-link { padding: 6px 8px; min-width: 48px; }
  .crm-mobile-nav .crm-nav-link svg { width: 20px; height: 20px; }
  .crm-mobile-nav .crm-nav-link span { font-size: 9px; }

  /* Login card */
  .crm-login-card { padding: 20px !important; }
  .crm-login-wrap h1 { font-size: 1.5rem; }
}

@media (max-width: 900px) {
  .crm-lead-details-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .crm-lead-card-top { grid-template-columns: auto 1fr; }
  .crm-lead-balance { grid-column: 2; justify-items: start; width: max-content; }
  #masterWalletModal .crm-modal-card { width: calc(100vw - 10px) !important; height: calc(100vh - 10px) !important; max-height: calc(100vh - 10px) !important; padding: 14px !important; }
  #masterWalletModal .crypto-status-grid { grid-template-columns: 1fr !important; }
  #masterWalletModal .mw-form-actions { flex-wrap: wrap !important; }
}

@media (max-width: 700px) {
  .crm-period-control { width: auto; max-width: 100%; }
  .crm-global-search-results { width: calc(100vw - 32px); }
  .crm-period-custom { width: 100%; }
  .crm-period-custom input { flex: 1; min-width: 0; }
  .crm-market-ranges { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .crm-market-ranges::-webkit-scrollbar { display: none; }
  .crm-market-ranges button { flex: 0 0 auto; }
}

@media (max-width: 1100px) {
  #masterWalletModal .crypto-status-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
}

/* ── 36. Mobile Bottom Nav ── */
.crm-mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  background: rgba(10,22,40,.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: 0 4px env(safe-area-inset-bottom, 0px) 4px;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -4px 24px rgba(0,0,0,.25);
}
.theme-light .crm-mobile-nav {
  background: rgba(255,255,255,.96);
  box-shadow: 0 -4px 24px rgba(20,50,90,.08);
}

/* Override .crm-nav-link defaults when inside mobile nav */
.crm-mobile-nav .crm-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color .15s;
  text-align: center;
  min-width: 56px;
  -webkit-tap-highlight-color: transparent;
}
.crm-mobile-nav .crm-nav-link svg { flex-shrink: 0; opacity: .55; transition: opacity .15s; width: 22px; height: 22px; }
.crm-mobile-nav .crm-nav-link.active { color: var(--accent); background: rgba(34,199,232,.08); }
.crm-mobile-nav .crm-nav-link.active svg { opacity: 1; stroke: var(--accent); }
.crm-mobile-nav .crm-nav-link span { font-size: 10px; line-height: 1.2; }

@media (max-width: 980px) {
  .crm-mobile-nav { display: flex; }
  .crm-sidebar { display: none; }
  .crm-content { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

  /* Touch-friendly spacing */
  .crm-btn { min-height: 48px; padding: 0 18px; font-size: 15px; }
  .crm-form input,
  .crm-form textarea,
  .crm-form select,
  .crm-filters input,
  .crm-card input,
  .crm-card select,
  .crm-card textarea { min-height: 48px; font-size: 16px; /* prevent iOS zoom */ }
  .crm-toggle { padding: 14px; min-height: 52px; }
  .crm-toggle input[type="checkbox"] { width: 22px !important; height: 22px !important; flex: 0 0 22px; }

  /* Topbar mobile adjustments */
  .crm-topbar { gap: 10px; }
  .crm-topbar-search input { height: 48px; font-size: 16px; }

  /* Modal full-screen on mobile */
  .crm-modal-dialog { width: calc(100vw - 16px) !important; max-height: calc(100vh - 16px); border-radius: var(--radius-lg); padding: 18px; }
  .crm-modal-card { max-width: calc(100vw - 16px) !important; max-height: calc(100vh - 16px); border-radius: var(--radius-lg); padding: 18px; }
  .crm-modal-sm, .crm-modal-md { width: calc(100vw - 16px); }

  /* Client card — handled in section 38 */

  /* Dashboard adjustments */
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .metric-card { padding: 16px; }
  .metric-card strong { font-size: 1.4rem; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }
  .dashboard-grid > .dashboard-card:first-child { grid-row: auto; }

  /* Period control horizontal scroll */
  .crm-period-control { overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .crm-period-control::-webkit-scrollbar { display: none; }

  /* Page header stacked */
  .page-head { flex-direction: column; gap: 12px; }
  .page-head h1 { font-size: 1.5rem; }
  .crm-inline-actions { width: 100%; justify-content: stretch; }
  .crm-inline-actions .crm-btn { flex: 1; }

  /* Telephony floating widget wider */
  .crm-telephony-floating { width: calc(100vw - 16px); right: 8px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}

/* ── 37. Light Theme — Darker Fonts & Orange Accent ── */
body.theme-light h1, body.theme-light h2, body.theme-light h3,
body.theme-light strong, body.theme-light b,
body.theme-light .page-head h1, body.theme-light .crm-card h2,
body.theme-light .metric-card strong, body.theme-light .dashboard-row strong,
body.theme-light #crmAdminName { color: #000 !important; }
body.theme-light .crm-nav-link.active { color: #e67e22; }
body.theme-light .crm-nav-link.active svg { stroke: #e67e22; }
body.theme-light .crm-count-badge { background: #e67e22; color: #fff; }
body.theme-light .crm-period-tabs button.active {
  background: linear-gradient(135deg, #e67e22, #f39c12);
  color: #fff;
  box-shadow: 0 6px 18px rgba(230,126,34,.25);
}
body.theme-light .crm-btn.primary {
  background: linear-gradient(135deg, #e67e22, #f39c12);
  color: #fff;
}
body.theme-light .primary-button {
  background: linear-gradient(135deg, #e67e22, #f39c12);
  color: #fff;
}
body.theme-light .page-kicker {
  background: rgba(230,126,34,.1);
  color: #e67e22;
}
body.theme-light .crm-accent-card { border-color: rgba(230,126,34,.25); }
body.theme-light .metric-card em { color: #d35400; }
body.theme-light .crm-side-logo {
  background: linear-gradient(135deg, #e67e22, #f39c12);
}
body.theme-light .crm-market-ranges button.active {
  background: linear-gradient(135deg, #e67e22, #f39c12);
  color: #fff;
}
body.theme-light .crm-confirm-badge { background: rgba(230,126,34,.12); color: #e67e22; }
body.theme-light .crm-segmented button.active { background: rgba(230,126,34,.12); color: #e67e22; }
body.theme-light .crm-topbar-search input:focus { border-color: #e67e22; }
body.theme-light .crm-form input:focus,
body.theme-light .crm-form select:focus,
body.theme-light .crm-form textarea:focus,
body.theme-light .crm-card input:focus,
body.theme-light .crm-card select:focus { border-color: #e67e22; box-shadow: 0 0 0 3px rgba(230,126,34,.12); }

/* ── 38. Client Card — Fullscreen Page Mode ── */
#clientCardModal .crm-modal-backdrop {
  background: rgba(3,8,16,.6);
  backdrop-filter: blur(8px);
}
#clientCardModal .crm-modal-dialog {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: var(--sidebar-w) !important;
  width: auto !important;
  max-width: none !important;
  max-height: none !important;
  height: 100vh !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  border-left: 1px solid var(--line) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 0 !important;
  background: var(--bg) !important;
  animation: clientCardSlideIn .35s cubic-bezier(.22,.61,.36,1) both;
  scrollbar-width: thin;
}
@keyframes clientCardSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─ Sticky header bar ─ */
#clientCardModal > .crm-modal-dialog > .crm-card-head {
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  background: var(--panel) !important;
  border-bottom: 1px solid var(--line) !important;
  padding: 10px 24px !important;
  margin: 0 !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  min-height: 48px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
/* Hide CLIENT CARD kicker — not needed */
#clientCardModal > .crm-modal-dialog > .crm-card-head .page-kicker {
  display: none !important;
}
#clientCardModal > .crm-modal-dialog > .crm-card-head h2 {
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  margin: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#clientCardModal > .crm-modal-dialog > .crm-card-head > div {
  display: flex !important;
  align-items: center !important;
  gap: 0 !important;
  min-width: 0 !important;
  flex: 1 !important;
}
#clientCardModal > .crm-modal-dialog > .crm-card-head .crm-btn {
  flex-shrink: 0;
  min-height: 32px;
  height: 32px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  letter-spacing: .02em;
  text-transform: uppercase;
}
.theme-light #clientCardModal > .crm-modal-dialog > .crm-card-head {
  background: rgba(255,255,255,.97) !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

/* ─ Title UID row ─ */
#clientCardModal .crm-title-uid-row {
  display: inline-flex;
  margin-left: 10px;
  gap: 12px;
  font-size: 12px;
  align-items: center;
}
#clientCardModal .crm-title-uid {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(34,199,232,.1);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: .02em;
}
.theme-light #clientCardModal .crm-title-uid {
  color: #d35400;
  background: rgba(230,126,34,.1);
}
#clientCardModal .crm-title-last-login {
  font-size: 11px;
  color: var(--muted);
  opacity: .6;
}

/* ─ Body: 2-column master grid via display:contents ─ */
#clientCardModal .crm-client-card-body {
  max-height: none !important;
  overflow: visible !important;
  padding: 14px 20px 40px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 10px 14px;
  align-items: start;
}
/* Flatten overview + sections so children become body-grid items */
#clientCardModal .crm-client-overview {
  display: contents !important;
}
#clientCardModal .crm-client-sections {
  display: contents !important;
}

/* ─ Info grid: left column, compact 4-col ─ */
#clientCardModal .crm-info-grid {
  grid-column: 1;
  order: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
#clientCardModal .crm-info-grid > div {
  padding: 8px 10px;
  gap: 2px;
}
#clientCardModal .crm-info-grid .crm-label {
  font-size: 9px;
  letter-spacing: .07em;
  opacity: .65;
}
#clientCardModal .crm-info-grid strong {
  font-size: 12px;
}

/* ─ Actions: right column, spans all rows ─ */
#clientCardModal .crm-client-actions {
  grid-column: 2;
  grid-row: 1 / 30;
  order: 1;
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 12px;
  gap: 5px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  scrollbar-width: thin;
}
#clientCardModal .crm-client-actions .crm-btn {
  font-size: 11.5px;
  padding: 7px 10px;
  min-height: 32px;
}
#clientCardModal .crm-client-actions .crm-btn.primary {
  font-size: 12.5px;
  padding: 9px 12px;
  min-height: 36px;
}
#clientCardModal .crm-client-actions .crm-inline-select > span,
#clientCardModal .crm-client-actions .crm-inline-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-top: 2px;
}
#clientCardModal .crm-client-actions input,
#clientCardModal .crm-client-actions select,
#clientCardModal .crm-client-actions textarea {
  font-size: 12px;
  padding: 6px 9px;
  min-height: 30px;
}
#clientCardModal .crm-client-actions .crm-comment-field textarea {
  min-height: 44px;
  resize: vertical;
}
#clientCardModal .crm-client-actions .crm-toggle {
  font-size: 12px;
  padding: 4px 0;
}

/* ─ Positions & Trades: fill empty space next to actions, order 2-3 ─ */
#clientCardModal .crm-client-sections .crm-inner-card:has(#clientPositionsBox) {
  grid-column: 1;
  order: 2;
}
#clientCardModal .crm-client-sections .crm-inner-card:nth-child(4) {
  grid-column: 1;
  order: 3;
}

/* ─ All other sections: left column, order 10+ ─ */
#clientCardModal .crm-client-sections .crm-inner-card {
  grid-column: 1;
  order: 10;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* ─ Hide call recordings ─ */
#clientCardModal .crm-client-sections .crm-inner-card:has(#clientRecordingsBox) {
  display: none !important;
}

/* ─ Notification section: order last, keep compact ─ */
#clientCardModal .crm-client-sections .crm-inner-card:has(.crm-notify-form) {
  order: 20;
}
#clientCardModal .crm-notify-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 10px 14px;
}
#clientCardModal .crm-notify-form input,
#clientCardModal .crm-notify-form textarea { font-size: 12px; }
#clientCardModal .crm-notify-form textarea { min-height: 48px; }
#clientCardModal .crm-notification-history {
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Support section: order last */
#clientCardModal .crm-client-sections .crm-inner-card:last-child {
  order: 21;
}

/* ─ Section card headers (not the modal sticky header) ─ */
#clientCardModal .crm-client-sections .crm-inner-card > .crm-card-head {
  position: static !important;
  z-index: auto !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  padding: 8px 14px !important;
  min-height: auto !important;
  border-bottom: 1px solid var(--line) !important;
  background: var(--panel) !important;
}
#clientCardModal .crm-client-sections .crm-inner-card h3 {
  font-size: .8rem;
  font-weight: 800;
}
#clientCardModal .crm-client-sections .crm-inner-card .crm-badge {
  font-size: 8px;
  padding: 2px 6px;
}

/* ─ Section body content ─ */
#clientCardModal .crm-client-sections .crm-inner-card > div:not(.crm-card-head),
#clientCardModal .crm-client-sections .crm-inner-card > .crm-table-wrap,
#clientCardModal .crm-client-sections .crm-inner-card > .crm-transaction-list,
#clientCardModal .crm-client-sections .crm-inner-card > .crm-list {
  padding: 8px 14px;
}

/* ─ Scrollable areas with height limits ─ */
#clientCardModal .crm-client-sections .crm-table-wrap {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 0 14px 8px !important;
}
#clientCardModal .crm-client-sections .crm-table-wrap h4 {
  padding: 6px 0 8px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0;
}
#clientCardModal .crm-client-sections .crm-transaction-list {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 0 14px 8px !important;
}
#clientCardModal .crm-client-sections .crm-list {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}
/* Compact tables */
#clientCardModal .crm-mini-table { width: 100%; }
#clientCardModal .crm-mini-table td,
#clientCardModal .crm-mini-table th {
  padding: 5px 8px;
  font-size: 11.5px;
  white-space: nowrap;
}
/* Transaction items */
#clientCardModal .crm-transaction-list > div {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
#clientCardModal .crm-transaction-list > div:last-child { border-bottom: 0; }

/* ─ Section hover ─ */
#clientCardModal .crm-client-sections .crm-inner-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  border-color: var(--accent);
}
.theme-light #clientCardModal .crm-client-sections .crm-inner-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  border-color: rgba(230,126,34,.3);
}

/* ─ Responsive: tablet (≤1280px) ─ */
@media (max-width: 1280px) {
  #clientCardModal .crm-client-card-body {
    grid-template-columns: 1fr !important;
  }
  #clientCardModal .crm-client-actions {
    grid-column: 1;
    grid-row: auto;
    position: static;
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    order: 5;
  }
  #clientCardModal .crm-client-actions .crm-btn.primary,
  #clientCardModal .crm-client-actions .crm-comment-field,
  #clientCardModal .crm-client-actions .crm-inline-select:has(textarea) {
    grid-column: 1 / -1;
  }
  #clientCardModal .crm-info-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #clientCardModal .crm-info-grid > div:nth-child(4n) { border-right: 1px solid var(--line); }
  #clientCardModal .crm-info-grid > div:nth-child(3n) { border-right: 0; }
}

/* ─ Responsive: mobile (≤980px) ─ */
@media (max-width: 980px) {
  #clientCardModal .crm-modal-dialog {
    left: 0 !important;
  }
  #clientCardModal > .crm-modal-dialog > .crm-card-head {
    padding: 8px 12px !important;
    min-height: 44px !important;
  }
  #clientCardModal > .crm-modal-dialog > .crm-card-head h2 {
    font-size: .85rem !important;
  }
  /* Show UID on mobile — just hide last-login */
  #clientCardModal .crm-title-uid-row {
    margin-left: 6px;
    gap: 6px;
  }
  #clientCardModal .crm-title-uid {
    font-size: 10px;
    padding: 1px 6px;
  }
  #clientCardModal .crm-title-last-login {
    display: none !important;
  }
  #clientCardModal .crm-client-card-body {
    padding: 10px 10px 80px !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  #clientCardModal .crm-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #clientCardModal .crm-info-grid > div:nth-child(4n),
  #clientCardModal .crm-info-grid > div:nth-child(3n) { border-right: 1px solid var(--line); }
  #clientCardModal .crm-info-grid > div:nth-child(2n) { border-right: 0; }
  #clientCardModal .crm-info-wide { grid-column: 1 / -1; }
  #clientCardModal .crm-client-actions {
    grid-column: 1;
    grid-row: auto;
    position: static;
    max-height: none;
    grid-template-columns: 1fr;
    padding: 10px;
    order: 5;
  }
  #clientCardModal .crm-client-sections .crm-inner-card {
    grid-column: 1;
  }
  #clientCardModal .crm-client-sections .crm-table-wrap { max-height: 220px; }
  #clientCardModal .crm-client-sections .crm-transaction-list { max-height: 240px; }
}

/* ── 38b. Lead / Mini Client Cards — Compact Row Style ── */
.crm-user-card.compact {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  padding: 12px 16px !important;
}
.crm-user-card.compact .crm-lead-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  grid-template-columns: none;
}
.crm-user-card.compact .crm-lead-check {
  flex-shrink: 0;
  margin-right: 0;
}
.crm-user-card.compact .crm-lead-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.crm-user-card.compact .crm-lead-main > div {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
/* Test line: inline */
.crm-user-card.compact .crm-lead-name-line {
  font-weight: 800;
  font-size: 13px;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
/* UID/email line: muted, inline */
.crm-user-card.compact .crm-user-id {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Status pills inline */
.crm-user-card.compact .crm-lead-status-pill {
  font-size: 10px;
  padding: 2px 8px;
}
/* Balance: compact pill on the right */
.crm-user-card.compact .crm-lead-balance {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  min-width: auto;
  border-radius: 8px;
}
.crm-user-card.compact .crm-lead-balance span {
  font-size: 9px;
}
.crm-user-card.compact .crm-lead-balance strong {
  font-size: 14px;
}
.crm-user-card.compact .crm-lead-balance small {
  font-size: 9px;
  max-width: 180px;
}
/* Hide details grid — info already visible in the row */
.crm-user-card.compact .crm-lead-details-grid {
  display: none;
}
/* Mini deals: compact inline */
.crm-user-card.compact .crm-mini-deals {
  display: none;
}
/* Bottom row: inline with card */
.crm-user-card.compact .crm-balance-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.crm-user-card.compact .crm-balance-row .crm-muted {
  font-size: 11px;
  white-space: nowrap;
  display: none;
}
.crm-user-card.compact .crm-balance-row .crm-btn {
  font-size: 12px;
  padding: 7px 16px;
  min-height: 32px;
  white-space: nowrap;
}
/* Light theme */
.theme-light .crm-user-card.compact:hover {
  border-color: rgba(230,126,34,.3);
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}

/* Mobile: stack card vertically */
@media (max-width: 980px) {
  .crm-user-card.compact {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 12px !important;
  }
  .crm-user-card.compact .crm-lead-card-top {
    flex-wrap: wrap;
  }
  .crm-user-card.compact .crm-lead-main {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .crm-user-card.compact .crm-lead-balance {
    align-self: flex-start;
  }
  .crm-user-card.compact .crm-balance-row .crm-muted {
    display: block;
  }
}

/* ── 39. Mobile Horizontal Overflow Fix ── */
.crm-main-shell { overflow-x: hidden; max-width: 100vw; }
.crm-content { overflow-x: hidden; }
.crm-page { overflow-x: hidden; max-width: 100%; }
.crm-card { overflow: hidden; }
.crm-form { overflow: hidden; }
.crm-modal-dialog { overflow-x: hidden; }
.crm-modal-card { overflow-x: hidden; }
.page-head { overflow: hidden; }
.crm-filters { overflow-x: auto; }
.crm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.crm-mini-table { min-width: 0; }
@media (max-width: 980px) {
  html, body { overflow-x: hidden; }
  .crm-app { overflow-x: hidden; max-width: 100vw; }
  .crm-main-shell { overflow-x: hidden; }
  .crm-content { overflow-x: hidden; max-width: 100vw; }
  .crm-page { overflow-x: hidden; }
  .crm-card { overflow: hidden; max-width: 100%; }
  .crm-client-overview, .crm-client-sections { overflow-x: hidden; }
  .crm-info-grid { overflow-x: hidden; }
  .crm-requisites-summary { grid-template-columns: repeat(2, minmax(0,1fr)); overflow: hidden; }
  .crm-position-meta { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .crm-lead-details-grid { overflow: hidden; }
  .crm-scenario-sliders { overflow-x: hidden; }
  .crm-market-widget { overflow: hidden; }
  .traffic-api-card { overflow: hidden; }
  .crm-permissions-box, .crm-permissions-box--modal { overflow: hidden; }
  .crm-telephony-panel { overflow: hidden; }
  .crm-admin-grid { overflow: hidden; }
}

/* ── 40. Trade Scenarios — Mobile Collapsible ── */
/* Opened scenarios: collapsible on mobile */
@media (max-width: 980px) {
  .crm-card[data-scenario-card] {
    position: relative;
  }
  .crm-card[data-scenario-card] .crm-scenario-sliders,
  .crm-card[data-scenario-card] .crm-scenario-targets,
  .crm-card[data-scenario-card] .crm-user-picker,
  .crm-card[data-scenario-card] .modal-actions {
    display: none;
  }
  .crm-card[data-scenario-card].expanded .crm-scenario-sliders,
  .crm-card[data-scenario-card].expanded .crm-scenario-targets,
  .crm-card[data-scenario-card].expanded .crm-user-picker,
  .crm-card[data-scenario-card].expanded .modal-actions {
    display: grid;
  }

  /* Compact sliders on mobile */
  .crm-slider-field { padding: 10px !important; gap: 6px !important; }
  .crm-snap-slider-field { padding: 10px 12px !important; }
  .crm-snap-slider-field > span { margin-bottom: 8px !important; font-size: 12px !important; }
  .crm-snap-slider { height: 18px !important; margin: 0 0 6px !important; }
  .crm-snap-slider-field small { display: none !important; }
  .crm-slider-marks { margin: 0 2px 4px !important; }
  .crm-slider-marks span { font-size: 10px !important; }
  .crm-scenario-sliders { gap: 8px !important; margin: 8px 0 !important; }
}

/* ── 41. Trade Scenarios — Hide "All Users" Target ── */
.crm-scenario-targets label[data-target="all"],
.crm-scenario-targets .crm-toggle[data-target="all"],
.crm-scenario-targets [data-apply-all],
.crm-scenario-targets > label:first-child {
  display: none !important;
}

/* ── 42. Trade Scenarios — Desktop List Height Limits ── */
@media (min-width: 981px) {
  [data-page="trade"] .crm-list,
  [data-page="trade"] .crm-table {
    max-height: 520px;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .crm-market-list {
    max-height: 400px;
    overflow-y: auto;
  }
}

/* ── 43. Premium Animations ── */
/* SVG checkmark draw animation on nav hover */
.crm-nav-link {
  position: relative;
  overflow: visible;
}
.crm-nav-link::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 10px;
  border-left: 2.5px solid var(--accent);
  border-bottom: 2.5px solid var(--accent);
  transform: translateY(-60%) rotate(-45deg) scale(0);
  opacity: 0;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  pointer-events: none;
}
.crm-nav-link:hover::after {
  transform: translateY(-60%) rotate(-45deg) scale(1);
  opacity: 1;
}
.crm-nav-link.active::after {
  transform: translateY(-60%) rotate(-45deg) scale(1);
  opacity: 1;
}
body.theme-light .crm-nav-link::after {
  border-color: #e67e22;
}

/* Button press animation */
.crm-btn, .primary-button, .ghost-button, .crm-icon-btn, .crm-chip-btn, .icon-button {
  transition: all .2s cubic-bezier(.25,.46,.45,.94), transform .1s;
}
.crm-btn:active, .primary-button:active, .ghost-button:active {
  transform: scale(.96);
}
.crm-btn.primary:hover, .primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(34,199,232,.25);
}
body.theme-light .crm-btn.primary:hover,
body.theme-light .primary-button:hover {
  box-shadow: 0 8px 24px rgba(230,126,34,.25);
}

/* Ripple effect on buttons */
.crm-btn::before, .primary-button::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,.25) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
}
.crm-btn { position: relative; overflow: hidden; }
.primary-button { position: relative; overflow: hidden; }

/* Card hover micro-animation */
.crm-user-card, .metric-card, .dashboard-card, .crm-admin-card, .traffic-api-card {
  transition: transform .25s cubic-bezier(.25,.46,.45,.94), border-color .2s, box-shadow .25s;
}
.crm-user-card:hover, .crm-admin-card:hover, .traffic-api-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0,0,0,.2);
}
.metric-card {
  transition: transform .25s cubic-bezier(.25,.46,.45,.94), border-color .2s, box-shadow .25s;
}
.metric-card:hover {
  transform: translateY(-3px);
  border-color: rgba(34,199,232,.25);
  box-shadow: 0 14px 40px rgba(0,0,0,.2);
}
body.theme-light .metric-card:hover {
  border-color: rgba(230,126,34,.25);
  box-shadow: 0 14px 40px rgba(20,50,90,.1);
}

/* Modal open/close transitions */
.crm-modal-backdrop {
  transition: opacity .3s ease;
}
.crm-modal-dialog, .crm-modal-card {
  animation: modalSlideUp .35s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Status pill pulse on appear */
.status-pill {
  animation: pillFadeIn .4s ease both;
}
@keyframes pillFadeIn {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: scale(1); }
}

/* Sidebar brand logo shimmer */
.crm-side-logo {
  position: relative;
  overflow: hidden;
}
.crm-side-logo::after {
  content: '';
  position: absolute;
  inset: -50%;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.2) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: logoShimmer 3s ease-in-out infinite;
}
@keyframes logoShimmer {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

/* Badge count bounce */
.crm-count-badge {
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.crm-nav-link:hover .crm-count-badge {
  transform: scale(1.15);
}

/* Toggle switch animation */
.crm-toggle input[type="checkbox"] {
  transition: background .2s, border-color .2s, transform .15s;
}
.crm-toggle input[type="checkbox"]:active {
  transform: scale(.9);
}

/* Input focus glow animation */
@keyframes inputFocusGlow {
  0% { box-shadow: 0 0 0 0 rgba(34,199,232,.3); }
  100% { box-shadow: 0 0 0 4px rgba(34,199,232,.08); }
}
body.theme-light .crm-form input:focus,
body.theme-light .crm-card input:focus {
  animation: inputFocusGlowOrange .3s ease forwards;
}
@keyframes inputFocusGlowOrange {
  0% { box-shadow: 0 0 0 0 rgba(230,126,34,.3); }
  100% { box-shadow: 0 0 0 4px rgba(230,126,34,.08); }
}

/* Page transition */
.crm-page.active {
  animation: pageReveal .35s ease both;
}
@keyframes pageReveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Topbar search expand */
.crm-topbar-search input {
  transition: border-color .15s, box-shadow .3s, width .3s;
}

/* Mobile bottom nav active indicator */
.crm-mobile-nav .crm-nav-link.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--accent);
  animation: navDotAppear .3s cubic-bezier(.34,1.56,.64,1) both;
}
.crm-mobile-nav .crm-nav-link { position: relative; }
@keyframes navDotAppear {
  from { width: 0; opacity: 0; }
  to { width: 28px; opacity: 1; }
}

/* Confirmation dialog animation */
.crm-confirm-overlay {
  transition: opacity .25s ease;
}
.crm-confirm-card {
  transition: transform .3s cubic-bezier(.22,.61,.36,1);
}

/* Skeleton loading shimmer (for dynamically loaded content) */
@keyframes skeletonShimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

/* profile verification styles kept from v36 */
.profile-wrapper.is-verified .profile-trigger { min-width: 92px; max-width: none; padding-right: 12px; }
#verificationModal .modal-header { display: flex !important; align-items: center !important; justify-content: space-between !important; gap: 16px !important; }
#verificationModal .modal-header h2 { margin: 0 !important; }
#verificationModal .modal-header .icon-button { position: static !important; margin-left: auto !important; flex: 0 0 auto !important; }
#withdrawStatusBox.placeholder-card { display: block !important; margin-top: 8px !important; }
@media (max-width: 700px) {
  .profile-wrapper.is-verified .profile-trigger { min-width: 76px; width: 76px; max-width: 76px; }
}

/* Status config textareas */
.crm-status-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
  outline: none;
}
.crm-status-textarea:focus {
  border-color: rgba(34,199,232,.4);
}
.three-up {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 900px) { .three-up { grid-template-columns: 1fr; } }

/* Admin list scroll limit */
#adminsList {
  max-height: calc(7 * 54px + 16px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Master wallet modal — scroll handled by .mw-scroll-body; actions fixed at bottom via .mw-form-actions */

/* Suppress ::after checkmark on Transactions/Support nav when unread badge is visible */
.crm-nav-link[data-route="withdrawals"]:has(.crm-count-badge:not(.hidden)):hover::after,
.crm-nav-link[data-route="withdrawals"]:has(.crm-count-badge:not(.hidden)).active::after,
.crm-nav-link[data-route="support"]:has(.crm-count-badge:not(.hidden)):hover::after,
.crm-nav-link[data-route="support"]:has(.crm-count-badge:not(.hidden)).active::after {
  opacity: 0 !important;
  transform: translateY(-60%) rotate(-45deg) scale(0) !important;
}

/* Pagination controls */
.crm-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 4px;
  flex-wrap: wrap;
}
.crm-page-info {
  font-size: 13px;
  color: var(--muted-2);
  flex: 1;
  text-align: center;
}

/* Admin mini card */
.crm-admin-mini-card {
  transition: background .15s;
  border-radius: 12px;
}
.crm-admin-mini-card:hover {
  background: rgba(255,255,255,.04) !important;
}
/* Lead-limit buttons: full text on desktop, icon-only on mobile */
.emp-limit-btn { font-size: 12px; padding: 3px 10px; white-space: nowrap; }
.emp-limit-btn .lbl { display: inline; }
.emp-limit-icon { font-size: 15px; line-height: 1; vertical-align: middle; }
.emp-limit-paused-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: #94a3b8;
  background: rgba(148,163,184,.12); border-radius: 5px;
  padding: 1px 7px; white-space: nowrap;
}
@media (max-width: 640px) {
  .emp-limit-btn { font-size: 10px; padding: 2px 6px; }
  .emp-limit-btn .lbl { display: none; }
  .emp-limit-icon { font-size: 14px; }
}

/* ── Traffic Analytics Dashboard ── */
.ta-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.ta-controls .crm-search-input { flex: 1 1 220px; min-width: 180px; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); font-size: 13px; }
.ta-sort-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ta-sort-label select { height: 38px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); font-size: 13px; min-width: 160px; }
.ta-table-wrap { overflow-x: auto; }
.ta-table-head, .ta-row { display: grid; grid-template-columns: minmax(160px,2fr) 56px 56px 62px 52px 60px 48px 48px 48px; gap: 0 4px; align-items: center; min-width: 640px; }
.ta-table-head { padding: 6px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); }
.ta-table-head > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-row { padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 13px; transition: background .12s; }
.ta-row:hover { background: rgba(255,255,255,.03); }
.ta-row:last-child { border-bottom: 0; }
.ta-col-funnel { min-width: 0; }
.ta-col-funnel strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-col-funnel small { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-col-num, .ta-col-pct { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.ta-col-pct { color: var(--accent); font-weight: 700; }
.ta-row .ta-col-num:nth-child(4) { color: #ff7e7e; } /* Novalid */

/* ═══════════════════════════════════════════════════════════
   UI OVERHAUL — toggles, inputs, selects, filters, lead cards
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Toggle: replace bordered-box with sliding pill switch ── */
.crm-toggle {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 4px 0 !important;
  border: 0 !important;
  background: none !important;
  border-radius: 0 !important;
  cursor: pointer !important;
  user-select: none !important;
  justify-content: flex-start !important;
  min-height: 0 !important;
}
.crm-toggle input[type="checkbox"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 32px !important; height: 18px !important;
  flex: 0 0 32px !important;
  border-radius: 9px !important;
  background: rgba(148,178,225,.22) !important;
  border: none !important;
  position: relative !important;
  cursor: pointer !important;
  transition: background .2s !important;
  margin: 0 !important;
  box-shadow: none !important;
}
.crm-toggle input[type="checkbox"]::after {
  content: '' !important;
  position: absolute !important;
  top: 2px !important; left: 2px !important;
  width: 14px !important; height: 14px !important;
  border-radius: 50% !important;
  background: rgba(255,255,255,.55) !important;
  transition: transform .2s cubic-bezier(.4,0,.2,1), background .2s !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.25) !important;
}
.crm-toggle input[type="checkbox"]:checked {
  background: var(--accent) !important;
}
.crm-toggle input[type="checkbox"]:checked::after {
  transform: translateX(14px) !important;
  background: #fff !important;
  box-shadow: 0 1px 4px rgba(0,0,0,.2) !important;
}
body.theme-light .crm-toggle input[type="checkbox"] {
  background: rgba(0,0,0,.14) !important;
}
body.theme-light .crm-toggle input[type="checkbox"]::after {
  background: rgba(0,0,0,.35) !important;
}
body.theme-light .crm-toggle input[type="checkbox"]:checked {
  background: var(--accent) !important;
}
body.theme-light .crm-toggle input[type="checkbox"]:checked::after {
  background: #fff !important;
}
.crm-toggle span {
  font-weight: 500 !important;
  font-size: 13px !important;
  flex: 1 !important;
  color: var(--text) !important;
  text-align: left !important;
}
.crm-toggle-line { padding: 2px 0 !important; }
/* Permissions box compact toggles */
.crm-permissions-box .crm-toggle { padding: 6px 0 !important; min-height: 0 !important; }
.crm-client-actions .crm-toggle { background: rgba(255,255,255,.02) !important; padding: 0 12px !important; min-height: 38px !important; border: 1px solid var(--line) !important; border-radius: var(--radius-sm) !important; }
.theme-light .crm-client-actions .crm-toggle { background: #f8fbff !important; }
.crm-checkbox-list .crm-toggle { padding: 5px 6px !important; min-height: 0 !important; }
/* Mobile */
@media (max-width: 980px) {
  .crm-toggle { min-height: 0 !important; padding: 6px 0 !important; }
  .crm-toggle input[type="checkbox"] { width: 36px !important; height: 20px !important; flex: 0 0 36px !important; }
  .crm-toggle input[type="checkbox"]::after { width: 16px !important; height: 16px !important; }
  .crm-toggle input[type="checkbox"]:checked::after { transform: translateX(16px) !important; }
}

/* ── 2. Inputs & selects: lighter, thinner, consistent ── */
.crm-form input,
.crm-form textarea,
.crm-form select,
.crm-filters input,
.crm-fiat-input,
.crm-card input,
.crm-card select,
.crm-card textarea {
  min-height: 38px !important;
  background: rgba(255,255,255,.05) !important;
  border: 1px solid rgba(148,178,225,.18) !important;
  border-radius: var(--radius-sm) !important;
  padding: 7px 12px !important;
  font-size: 13px !important;
  color: var(--text) !important;
}
body.theme-light .crm-form input,
body.theme-light .crm-form textarea,
body.theme-light .crm-form select,
body.theme-light .crm-card input,
body.theme-light .crm-card select,
body.theme-light .crm-card textarea,
body.theme-light .crm-filters input {
  background: rgba(0,0,0,.04) !important;
  border-color: rgba(0,0,0,.1) !important;
  color: var(--text) !important;
}
.crm-form textarea { min-height: 80px !important; padding-top: 10px !important; }
/* Dropdowns: custom arrow */
.crm-form select,
.crm-filters select,
.crm-card select,
.crm-filter-select,
.ta-sort-label select {
  -webkit-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 11px center !important;
  background-size: 11px !important;
  padding-right: 30px !important;
}
body.theme-light .crm-form select,
body.theme-light .crm-filters select,
body.theme-light .crm-card select,
body.theme-light .crm-filter-select {
  background-color: rgba(0,0,0,.04) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 11px !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  padding-right: 28px !important;
}
/* Light theme: force visible inputs everywhere */
body.theme-light input, body.theme-light select, body.theme-light textarea {
  color-scheme: light !important;
  background-color: rgba(0,0,0,.04);
  border-color: rgba(0,0,0,.1);
  color: var(--text);
}
/* Mobile — keep font-size 16px to prevent iOS zoom */
@media (max-width: 980px) {
  .crm-form input,
  .crm-form textarea,
  .crm-form select,
  .crm-filters input,
  .crm-card input,
  .crm-card select,
  .crm-card textarea { font-size: 16px !important; min-height: 44px !important; }
}

/* ── 3. Filters: flex pill bar, compact & responsive ── */
.crm-filters {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
  overflow-x: visible !important;
  margin-bottom: 14px !important;
}
.crm-filters input {
  flex: 1 1 120px !important;
  min-width: 90px !important;
  max-width: 180px !important;
  min-height: 34px !important;
  font-size: 12px !important;
  padding: 5px 10px !important;
}
.crm-filters select,
.crm-filter-select {
  flex: 1 1 140px !important;
  min-width: 110px !important;
  max-width: 200px !important;
  min-height: 34px !important;
  font-size: 12px !important;
  padding: 5px 28px 5px 10px !important;
}
.crm-filters .crm-btn {
  flex-shrink: 0 !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 14px !important;
  font-size: 12px !important;
}
@media (max-width: 640px) {
  .crm-filters input { max-width: none !important; flex-basis: calc(50% - 4px) !important; }
  .crm-filters select, .crm-filter-select { max-width: none !important; flex-basis: 100% !important; }
  .crm-filters .crm-btn { flex: 1 !important; }
}

/* ── 4. Lead cards: narrow screen optimization ── */
@media (max-width: 600px) {
  .crm-user-card { padding: 12px !important; }
  .crm-lead-card-top { gap: 8px !important; }
  .crm-lead-name-line strong,
  .crm-lead-name-line span { font-size: 12px !important; }
  .crm-lead-details-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 6px !important; }
  .crm-lead-details-grid > div { padding: 7px !important; }
  .crm-lead-details-grid strong { font-size: 11px !important; }
  .crm-lead-balance { min-width: 90px !important; padding: 7px 10px !important; }
  .crm-lead-balance strong { font-size: 13px !important; }
  .crm-lead-balance small { font-size: 9px !important; }
  .crm-mini-deals { gap: 4px !important; }
  .crm-mini-deal { font-size: 11px !important; padding: 3px 8px !important; }
  .crm-user-card.compact .crm-lead-name-line { font-size: 12px !important; }
  .crm-user-card.compact .crm-lead-balance strong { font-size: 12px !important; }
}
@media (max-width: 420px) {
  .crm-lead-details-grid { grid-template-columns: 1fr 1fr !important; }
  .crm-lead-name-line strong { font-size: 11px !important; }
  .crm-user-id { font-size: 10px !important; }
  .crm-lead-balance { display: none !important; }
  .crm-lead-card-top { grid-template-columns: auto 1fr !important; }
}

/* ── 5. Scan links in crypto history ── */
.chr-scan-btn {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 5px; cursor: pointer; white-space: nowrap;
  background: rgba(99,102,241,.1); color: #818cf8;
  border: 1px solid rgba(99,102,241,.2);
  transition: background .14s, color .14s;
  user-select: none;
}
.chr-scan-btn:hover { background: rgba(99,102,241,.22); }
body.theme-light .chr-scan-btn { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
body.theme-light .chr-scan-btn:hover { background: #e0e7ff; }
.chr-scan-sweep { background: rgba(255,255,255,.05); color: var(--muted); border-color: rgba(255,255,255,.1); }
.chr-scan-sweep:hover { background: rgba(255,255,255,.1); }
body.theme-light .chr-scan-sweep { background: rgba(0,0,0,.05); color: #64748b; border-color: rgba(0,0,0,.1); }

/* Remove copy hint space */
.chr-copy-hint { display: none !important; }

/* ── 6. Section headers: reduce dark backgrounds ── */
body.theme-light .adm-inline-section-head,
body.theme-light .buying-header,
body.theme-light .tkt-head,
body.theme-light .buying-funnel-head,
body.theme-light .dashboard-row,
body.theme-light .crm-region-header {
  background: #f8f9fc !important;
}
body.theme-light .mw-info-head { background: #f8f9fc !important; }
body.theme-light .adm-panel { background: transparent; }
/* Dark theme: slightly lighter section headers */
body.theme-dark .adm-inline-section-head { background: rgba(255,255,255,.02) !important; }
body.theme-dark .mw-info-head { background: rgba(255,255,255,.02) !important; }

/* ── 7. Form label font: less uppercase weight ── */
.crm-form label > span {
  font-weight: 600 !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
  color: var(--muted) !important;
}

/* ── 8. Selects in dashboard/regions: styled ── */
#hyperProjectFilter,
#hyperAnalyticsMode,
#dashboardPeriodSelect,
select.crm-analytics-select {
  background: rgba(255,255,255,.05) !important;
  border: 1px solid rgba(148,178,225,.18) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text) !important;
  padding: 6px 28px 6px 10px !important;
  font-size: 12px !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
  background-size: 11px !important;
}
body.theme-light #hyperProjectFilter,
body.theme-light #hyperAnalyticsMode,
body.theme-light #dashboardPeriodSelect {
  background-color: rgba(0,0,0,.04) !important;
  border-color: rgba(0,0,0,.1) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
}

/* ═══════════════════════════════════════════════════════════
   CRITICAL FIXES: toggle, lead cards, positions, selects
   ═══════════════════════════════════════════════════════════ */

/* ── Toggle: fix .crm-form label overrides (uppercase, display:grid) ── */
.crm-form .crm-toggle,
.crm-card .crm-toggle,
label.crm-toggle {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 4px 0 !important;
  border: 0 !important;
  background: none !important;
  min-height: 0 !important;
  border-radius: 0 !important;
}
/* Override .crm-form label > span styles that make toggle text ugly */
.crm-toggle > span,
.crm-form .crm-toggle > span,
.crm-card .crm-toggle > span,
label.crm-toggle > span {
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  color: var(--text) !important;
  flex: 1 !important;
  order: unset !important;
}
/* Force pill switch size explicitly */
.crm-form .crm-toggle input[type="checkbox"],
.crm-card .crm-toggle input[type="checkbox"],
label.crm-toggle input[type="checkbox"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 32px !important;
  height: 18px !important;
  flex: 0 0 32px !important;
  min-width: 32px !important;
  min-height: 18px !important;
  max-height: 18px !important;
  border-radius: 9px !important;
  background: rgba(148,178,225,.22) !important;
  border: none !important;
  position: relative !important;
  cursor: pointer !important;
  transition: background .2s !important;
  margin: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  display: block !important;
}
/* Client actions toggles: keep bordered style for those specifically */
.crm-client-actions label.crm-toggle {
  padding: 0 12px !important;
  min-height: 38px !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-sm) !important;
  background: rgba(255,255,255,.02) !important;
}
.theme-light .crm-client-actions label.crm-toggle { background: #f8fbff !important; }

/* ── Lead cards: compact on narrow screens ── */
@media (max-width: 700px) {
  .crm-user-card.compact {
    padding: 10px 12px !important;
    gap: 8px !important;
  }
  /* Top row: checkbox + name/uid/status, balance to the right */
  .crm-user-card.compact .crm-lead-card-top {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    grid-template-columns: none !important;
  }
  .crm-user-card.compact .crm-lead-main {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
  }
  /* Name line: one line, truncated */
  .crm-user-card.compact .crm-lead-name-line {
    font-size: 12px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
  }
  /* Copy chips row: smaller */
  .crm-user-card.compact .crm-copy-row { flex-wrap: nowrap !important; }
  .crm-user-card.compact .crm-copy-chip { font-size: 10px !important; padding: 1px 5px !important; }
  .crm-user-card.compact .crm-phone-popup-btn { font-size: 10px !important; }
  /* Status pills: compact */
  .crm-user-card.compact .crm-lead-status-pill { font-size: 9px !important; padding: 2px 6px !important; }
  /* Balance: compact right-side pill */
  .crm-user-card.compact .crm-lead-balance {
    flex-shrink: 0 !important;
    min-width: 70px !important;
    padding: 5px 8px !important;
    gap: 2px !important;
    display: grid !important;
    justify-items: end !important;
  }
  .crm-user-card.compact .crm-lead-balance span { font-size: 8px !important; }
  .crm-user-card.compact .crm-lead-balance strong { font-size: 12px !important; }
  .crm-user-card.compact .crm-lead-balance small { display: none !important; }
  /* Hide details grid and mini-deals on narrow screens */
  .crm-user-card.compact .crm-lead-details-grid { display: none !important; }
  .crm-user-card.compact .crm-mini-deals { display: none !important; }
  /* Action row: compact */
  .crm-user-card.compact .crm-balance-row { gap: 6px !important; }
  .crm-user-card.compact .crm-balance-row .crm-muted { font-size: 10px !important; }
  .crm-user-card.compact .crm-open-card-btn { font-size: 11px !important; height: 30px !important; min-height: 30px !important; padding: 0 12px !important; }
}
@media (max-width: 420px) {
  .crm-user-card.compact .crm-lead-balance { display: none !important; }
  .crm-user-card.compact .crm-lead-card-top { grid-template-columns: auto 1fr !important; }
}

/* ── "No positions" empty state ── */
.crm-position-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Position cards: TP/SL tags ── */
.crm-position-tp-sl {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.crm-pos-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
}
.crm-pos-tag.tp { background: rgba(16,185,129,.1); color: #10b981; border: 1px solid rgba(16,185,129,.2); }
.crm-pos-tag.sl { background: rgba(239,68,68,.1); color: #ef4444; border: 1px solid rgba(239,68,68,.2); }
.crm-pos-tag.sched { background: rgba(99,102,241,.1); color: #818cf8; border: 1px solid rgba(99,102,241,.2); }

/* ── Custom status dropdown ── */
.crm-custom-select { position: relative; display: inline-block; min-width: 140px; }
.crm-custom-select-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 34px; padding: 5px 10px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(148,178,225,.18);
  border-radius: var(--radius-sm); color: var(--text); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: border-color .15s, background .15s; white-space: nowrap;
}
.crm-custom-select-btn:hover { border-color: var(--accent); background: rgba(255,255,255,.08); }
.crm-custom-select-btn svg { flex-shrink: 0; color: var(--muted); transition: transform .2s; }
.crm-custom-select.is-open .crm-custom-select-btn svg { transform: rotate(180deg); }
body.theme-light .crm-custom-select-btn { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.1); }
body.theme-light .crm-custom-select-btn:hover { background: rgba(0,0,0,.07); }
.crm-custom-select-drop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 500;
  min-width: 220px; max-height: 280px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md); box-shadow: 0 8px 32px rgba(0,0,0,.3);
  display: none; scrollbar-width: thin;
}
.crm-custom-select.is-open .crm-custom-select-drop { display: block; animation: dropIn .15s ease; }
@keyframes dropIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.crm-custom-select-opt {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  font-size: 13px; cursor: pointer; transition: background .12s;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.crm-custom-select-opt:last-child { border-bottom: 0; }
.crm-custom-select-opt:hover { background: rgba(255,255,255,.06); }
.crm-custom-select-opt.is-selected { color: var(--accent); font-weight: 700; }
body.theme-light .crm-custom-select-drop { background: #fff; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
body.theme-light .crm-custom-select-opt:hover { background: rgba(0,0,0,.04); }
body.theme-light .crm-custom-select-opt { border-color: rgba(0,0,0,.05); }

/* ── Add wallet form in client card ── */
.crm-add-wallet-form {
  display: none; padding: 12px 14px; margin-top: 8px;
  background: rgba(99,102,241,.04); border: 1px solid rgba(99,102,241,.15);
  border-radius: var(--radius-md); gap: 10px; grid-template-columns: 1fr auto;
  align-items: end;
}
.crm-add-wallet-form.is-open { display: grid; }

/* ═══════════════════════════════════════════════════════════
   WALLET, ADMIN PANEL, LEAD CARDS — final fixes
   ═══════════════════════════════════════════════════════════ */

/* ── Admin panel: remove dark section heads, use themed backgrounds ── */
.adm-inline-section-head {
  background: rgba(255,255,255,.03) !important;
  border-bottom: 1px solid var(--line) !important;
}
body.theme-light .adm-inline-section-head {
  background: rgba(0,0,0,.025) !important;
}
.adm-inline-section { border: 1px solid var(--line) !important; }
body.theme-light .adm-inline-section { border-color: rgba(0,0,0,.08) !important; }
/* Boss gate / mw-info heads */
.mw-info-head {
  background: rgba(255,255,255,.02) !important;
}
body.theme-light .mw-info-head { background: rgba(0,0,0,.02) !important; }
/* Buying/funnel section heads */
.theme-dark .buying-header { background: rgba(255,255,255,.025) !important; }
.theme-dark .buying-header:hover { background: rgba(255,255,255,.04) !important; }
.theme-dark .tkt-head { background: rgba(255,255,255,.025) !important; }
.theme-dark .tkt-head:hover { background: rgba(255,255,255,.04) !important; }
/* Region section heads */
.theme-dark .crm-region-header { background: rgba(255,255,255,.025) !important; }
/* Admin section search input */
#adminsSearchInput { width: 100% !important; }

/* ── Wallet section: copyable lines ── */
.crm-wallet-line--copy {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin: 0 -6px;
  transition: background .12s;
  position: relative;
}
.crm-wallet-line--copy:hover { background: rgba(99,102,241,.08); }
body.theme-light .crm-wallet-line--copy:hover { background: rgba(99,102,241,.06); }
.crm-wallet-copy-icon { margin-left: auto; font-size: 13px; color: var(--muted); opacity: 0; transition: opacity .15s; }
.crm-wallet-line--copy:hover .crm-wallet-copy-icon { opacity: 1; }
.crm-wallet-line {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  padding: 3px 0;
}
.crm-wallet-line span:first-child { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.crm-wallet-line code { font-size: 12px; word-break: break-all; overflow-wrap: anywhere; }
/* Wallet card header */
.crm-wallet-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* Add wallet form */
.crm-add-wallet-form {
  display: none;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(99,102,241,.04);
  border: 1px solid rgba(99,102,241,.15);
  border-radius: var(--radius-md);
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}
.crm-add-wallet-form.is-open { display: grid; }
body.theme-light .crm-add-wallet-form { background: rgba(99,102,241,.03); }

/* ── Lead card balance: compact at medium screen ── */
@media (max-width: 1100px) {
  .crm-user-card.compact .crm-lead-balance small { display: none !important; }
  .crm-user-card.compact .crm-lead-balance { min-width: 90px !important; padding: 8px 10px !important; }
}
@media (max-width: 900px) {
  .crm-user-card.compact .crm-lead-balance { min-width: 80px !important; }
  .crm-user-card.compact .crm-lead-balance strong { font-size: 13px !important; }
}

/* ── Client card & CRM selects: standard arrow ── */
#leadStatusSelect,
#retentionStatusSelect,
#portraitTagSelect,
.crm-client-actions select,
.crm-inline-select select,
#balanceAdjustForm select,
#transactionEditForm select,
#openPositionForm select,
#tradeEditForm select,
#adminEditForm select,
#createAdminForm select {
  -webkit-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 11px !important;
  padding-right: 28px !important;
}
body.theme-light #leadStatusSelect,
body.theme-light #retentionStatusSelect,
body.theme-light .crm-client-actions select,
body.theme-light #balanceAdjustForm select,
body.theme-light #transactionEditForm select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
}

/* ── Dashboard region/analytics selects ── */
.crm-analytics-switch select,
#hyperAnalyticsMode,
#hyperProjectFilter {
  min-height: 32px !important;
  height: 32px !important;
  padding: 0 28px 0 10px !important;
  font-size: 12px !important;
}

/* ═══════════════════════════════════════════════════════════
   LEAD CARD: proportional responsive — FINAL (overrides all above)
   ═══════════════════════════════════════════════════════════ */

/* ── Base compact card: full info at wide viewports ── */
.crm-user-card.compact {
  display: grid !important;
  gap: 0 !important;
  padding: 14px 16px !important;
}
.crm-user-card.compact .crm-lead-card-top {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
  grid-template-columns: none !important;
}
.crm-user-card.compact .crm-lead-main {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 1 !important;
  min-width: 0 !important;
  flex-wrap: wrap !important;
}
/* Each row inside lead-main: inline pill */
.crm-user-card.compact .crm-lead-main > div,
.crm-user-card.compact .crm-lead-main > button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  flex-shrink: 0 !important;
}
.crm-user-card.compact .crm-lead-name-line {
  font-size: 13px !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 260px !important;
}
.crm-user-card.compact .crm-copy-chip {
  font-size: 11px !important;
  padding: 1px 6px !important;
}
.crm-user-card.compact .crm-phone-popup-btn {
  font-size: 11px !important;
}
.crm-user-card.compact .crm-lead-status-pill {
  font-size: 10px !important;
  padding: 2px 7px !important;
}
/* Balance: right-side compact card */
.crm-user-card.compact .crm-lead-balance {
  flex-shrink: 0 !important;
  display: grid !important;
  justify-items: end !important;
  padding: 6px 10px !important;
  min-width: 110px !important;
  max-width: 200px !important;
  border-radius: 8px !important;
}
.crm-user-card.compact .crm-lead-balance span {
  font-size: 9px !important;
  text-transform: uppercase !important;
  letter-spacing: .05em !important;
}
.crm-user-card.compact .crm-lead-balance strong {
  font-size: 14px !important;
  font-weight: 800 !important;
}
.crm-user-card.compact .crm-lead-balance small {
  font-size: 10px !important;
  white-space: nowrap !important;
  color: var(--muted) !important;
}
/* Details, mini-deals: always hidden in compact view */
.crm-user-card.compact .crm-lead-details-grid { display: none !important; }
.crm-user-card.compact .crm-mini-deals { display: none !important; }
/* Action row */
.crm-user-card.compact .crm-balance-row {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-top: 8px !important;
}
.crm-user-card.compact .crm-lead-status-text {
  font-size: 11px !important;
  color: var(--muted) !important;
}
.crm-user-card.compact .crm-open-card-btn {
  margin-left: auto !important;
  font-size: 12px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 16px !important;
}

/* ── 1200px → hide balance breakdown ── */
@media (max-width: 1200px) {
  .crm-user-card.compact .crm-lead-balance small { display: none !important; }
  .crm-user-card.compact .crm-lead-balance { min-width: 90px !important; }
  .crm-user-card.compact .crm-lead-name-line { font-size: 12.5px !important; max-width: 220px !important; }
}

/* ── 1050px → hide funnel chip ── */
@media (max-width: 1050px) {
  .crm-user-card.compact .crm-lead-funnel { display: none !important; }
  .crm-user-card.compact .crm-lead-name-line { font-size: 12px !important; max-width: 180px !important; }
  .crm-user-card.compact .crm-copy-chip { font-size: 10.5px !important; }
  .crm-user-card.compact .crm-lead-balance strong { font-size: 13px !important; }
}

/* ── 900px → hide country, hide email ── */
@media (max-width: 900px) {
  .crm-user-card.compact .crm-lead-country { display: none !important; }
  .crm-user-card.compact .crm-lead-email { display: none !important; }
  .crm-user-card.compact .crm-lead-messenger { display: none !important; }
  .crm-user-card.compact .crm-lead-name-line { font-size: 12px !important; max-width: 160px !important; }
  .crm-user-card.compact .crm-copy-chip { font-size: 10px !important; padding: 1px 5px !important; }
  .crm-user-card.compact .crm-lead-balance { min-width: 80px !important; }
  .crm-user-card.compact .crm-lead-balance strong { font-size: 12px !important; }
}

/* ── 750px (mobile: no sidebar, full width) → wrap to 2 rows, hide balance ── */
@media (max-width: 750px) {
  .crm-user-card.compact { padding: 10px 12px !important; }
  .crm-user-card.compact .crm-lead-card-top {
    flex-wrap: wrap !important;
    align-items: flex-start !important;
  }
  .crm-user-card.compact .crm-lead-balance { display: none !important; }
  .crm-user-card.compact .crm-lead-main { gap: 5px !important; }
  .crm-user-card.compact .crm-lead-name-line { font-size: 13px !important; max-width: none !important; }
  .crm-user-card.compact .crm-lead-row-contact { display: none !important; }
  .crm-user-card.compact .crm-balance-row { margin-top: 6px !important; }
  .crm-user-card.compact .crm-lead-status-text { display: none !important; }
}

/* ── 480px → minimum essential ── */
@media (max-width: 480px) {
  .crm-user-card.compact { padding: 8px 10px !important; }
  .crm-user-card.compact .crm-lead-row-uid { display: none !important; }
  .crm-user-card.compact .crm-lead-name-line { font-size: 12px !important; }
  .crm-user-card.compact .crm-lead-row-status .crm-lead-status-pill { font-size: 9px !important; padding: 1px 5px !important; }
  .crm-user-card.compact .crm-open-card-btn { font-size: 11px !important; padding: 0 10px !important; }
}

/* ═══════════════════════════════════════════════════════════
   LC (Lead Card) — clean single-row layout, v3 FINAL
   ═══════════════════════════════════════════════════════════ */

/* Base card reset */
.crm-user-card.compact {
  padding: 10px 14px !important;
  display: block !important;
  gap: 0 !important;
}
/* Hide old multi-row remnants */
.crm-user-card.compact .crm-lead-details-grid,
.crm-user-card.compact .crm-mini-deals,
.crm-user-card.compact .crm-balance-row,
.crm-user-card.compact .crm-lead-card-top { display: none !important; }

/* ── Single row ── */
.lc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

/* Name: bold, truncated, flex-shrink but not disappear */
.lc-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 80px;
  flex-shrink: 2;
  color: var(--text);
}

/* Thin separator between name and UID */
.lc-sep {
  width: 1px;
  height: 14px;
  background: var(--line);
  flex-shrink: 0;
}

/* Chips */
.lc-uid, .lc-email, .lc-country, .lc-funnel {
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px !important;
  padding: 1px 6px !important;
}
.lc-uid { flex-shrink: 3; max-width: 120px; }
.lc-email { flex-shrink: 5; max-width: 200px; }
.lc-country { flex-shrink: 4; max-width: 60px; }
.lc-funnel { flex-shrink: 4; max-width: 90px; }

/* Phone */
.lc-phone { font-size: 11px !important; flex-shrink: 3; white-space: nowrap; }

/* Status pills: no wrap */
.lc-status { display: flex; align-items: center; gap: 4px; flex-shrink: 0; flex-wrap: nowrap; }
.lc-status .crm-lead-status-pill,
.lc-status .crm-ret-status-pill { font-size: 10px !important; padding: 2px 7px !important; white-space: nowrap; }

/* Spacer: pushes balance+button to the right */
.lc-spacer { flex: 1 1 0; min-width: 4px; }

/* Balance: compact number block */
.lc-balance {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-shrink: 0;
  white-space: nowrap;
}
.lc-balance strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
}
body.theme-light .lc-balance strong { color: var(--accent2); }
.lc-balance small { font-size: 10px; color: var(--muted); }

/* Open button */
.lc-btn {
  flex-shrink: 0 !important;
  font-size: 12px !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 14px !important;
  white-space: nowrap !important;
}

/* ── Progressive hiding by viewport ──
   lc-hide-lg  → hidden at ≤1100px  (country, funnel)
   lc-hide-md  → hidden at ≤900px   (email, balance breakdown)
   lc-hide-sm  → hidden at ≤700px   (phone, separator)
   lc-hide-xs  → hidden at ≤520px   (uid, whole balance)
*/
@media (max-width: 1100px) {
  .lc-hide-lg { display: none !important; }
}
@media (max-width: 900px) {
  .lc-hide-md { display: none !important; }
  .lc-name { font-size: 12px !important; }
  .lc-balance strong { font-size: 13px !important; }
}
@media (max-width: 700px) {
  .lc-hide-sm { display: none !important; }
  .lc-name { font-size: 12px !important; min-width: 60px !important; }
}
@media (max-width: 520px) {
  .lc-hide-xs { display: none !important; }
  .lc-name { max-width: 140px !important; }
  .lc-btn { font-size: 11px !important; padding: 0 10px !important; }
}

/* ── lc-info / lc-actions split (v4) ── */
.lc-row {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
  overflow: visible !important;
  flex-wrap: nowrap !important;
  min-width: 0 !important;
}
/* Left: shrinks, clips its own overflow */
.lc-info {
  display: flex !important;
  align-items: center !important;
  gap: 7px !important;
  flex: 1 1 0 !important;
  min-width: 0 !important;
  overflow: hidden !important;
  flex-wrap: nowrap !important;
}
/* Right: fixed, never shrinks */
.lc-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  margin-left: 4px !important;
}

/* ════════════════════════════════════════════════
   LEAD CARD v5 — FINAL FINAL. Простые правила.
   ════════════════════════════════════════════════ */
.crm-user-card.compact { padding: 8px 14px !important; display: block !important; }
.crm-user-card.compact .crm-lead-card-top,
.crm-user-card.compact .crm-lead-details-grid,
.crm-user-card.compact .crm-mini-deals,
.crm-user-card.compact .crm-balance-row { display: none !important; }

.lc-row {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
  min-width: 0 !important;
}
/* Левая часть: сжимается, скрывает overflow */
.lc-info {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex: 1 1 0% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  flex-wrap: nowrap !important;
}
/* Правая часть: никогда не сжимается */
.lc-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
}

.lc-name {
  font-size: 13px !important; font-weight: 700 !important;
  white-space: nowrap !important; overflow: hidden !important;
  text-overflow: ellipsis !important; flex-shrink: 1 !important;
  min-width: 60px !important; color: var(--text) !important;
}
.lc-sep { width: 1px !important; height: 13px !important; background: var(--line) !important; flex-shrink: 0 !important; }
.lc-uid,.lc-email,.lc-country,.lc-funnel {
  font-size: 11px !important; padding: 1px 6px !important;
  flex-shrink: 1 !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
}
.lc-uid { max-width: 115px !important; }
.lc-email { max-width: 180px !important; flex-shrink: 3 !important; }
.lc-country { max-width: 55px !important; flex-shrink: 2 !important; }
.lc-funnel { max-width: 80px !important; flex-shrink: 2 !important; }
.lc-phone { font-size: 11px !important; flex-shrink: 2 !important; white-space: nowrap !important; }
.lc-status { display: flex !important; align-items: center !important; gap: 4px !important; flex-shrink: 0 !important; }
.lc-status .crm-lead-status-pill, .lc-status .crm-ret-status-pill { font-size: 10px !important; padding: 2px 6px !important; }
.lc-balance strong { font-size: 13px !important; font-weight: 800 !important; color: var(--accent) !important; white-space: nowrap !important; }
body.theme-light .lc-balance strong { color: var(--accent2) !important; }
.lc-btn {
  font-size: 12px !important; height: 30px !important;
  min-height: 30px !important; padding: 0 14px !important;
  white-space: nowrap !important; flex-shrink: 0 !important;
}

/* Скрытие по ширине */
@media (max-width: 1100px) { .lc-hide-lg { display: none !important; } }
@media (max-width: 900px)  { .lc-hide-md { display: none !important; } }
@media (max-width: 700px)  { .lc-hide-sm { display: none !important; } }
@media (max-width: 500px)  { .lc-hide-xs { display: none !important; } }

/* На маленьком десктопе (с учётом сайдбара ~260px) */
@media (max-width: 1050px) {
  .lc-name { font-size: 12px !important; }
}

/* ── Lead card: просто меньше на 1200-1500px ── */
@media (max-width: 1500px) and (min-width: 1200px) {
  .crm-user-card.compact { padding: 6px 12px !important; }
  .lc-name { font-size: 11.5px !important; }
  .lc-uid, .lc-email, .lc-country, .lc-funnel { font-size: 10px !important; padding: 1px 5px !important; }
  .lc-phone { font-size: 10px !important; }
  .lc-status .crm-lead-status-pill, .lc-status .crm-ret-status-pill { font-size: 9px !important; padding: 1px 5px !important; }
  .lc-balance strong { font-size: 11.5px !important; }
  .lc-btn { font-size: 11px !important; height: 26px !important; min-height: 26px !important; padding: 0 11px !important; }
  .lc-row { gap: 6px !important; }
  .lc-info { gap: 5px !important; }
  .lc-actions { gap: 6px !important; }
}

/* ── Lead card: 1200-1500px — скрываем лишнее + ещё меньше ── */
@media (max-width: 1500px) and (min-width: 981px) {
  .lc-email { display: none !important; }
}
@media (max-width: 1300px) and (min-width: 981px) {
  .lc-phone { display: none !important; }
  .lc-sep { display: none !important; }
  .lc-uid { max-width: 90px !important; }
  .crm-user-card.compact { padding: 5px 12px !important; }
  .lc-name { font-size: 11px !important; }
  .lc-uid { font-size: 10px !important; padding: 1px 4px !important; }
  .lc-status .crm-lead-status-pill { font-size: 9px !important; padding: 1px 5px !important; }
  .lc-balance strong { font-size: 11px !important; }
  .lc-btn { height: 24px !important; min-height: 24px !important; font-size: 11px !important; padding: 0 10px !important; }
}

/* ── Verified badge ── */
.lc-verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  background: #10b981;
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 900;
  flex-shrink: 0;
  vertical-align: middle;
  line-height: 1;
}
body.theme-light .lc-verified { background: #059669; }

/* ── Anti-flicker: smooth list transitions ── */
#usersTable, #crmWithdrawalsList, #crmSupportTickets, #adminsList, #regionsList, #buyingsList {
  transition: opacity .15s ease;
}
#usersTable.is-refreshing,
#crmWithdrawalsList.is-refreshing,
#crmSupportTickets.is-refreshing {
  opacity: 0.5;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════
   MISC FIXES: search icon, admin input, dropdowns
   ═══════════════════════════════════════════════════════ */

/* ── 1. Remove lead card separator ── */
.lc-sep { display: none !important; }

/* ── 2. Remove is-refreshing opacity (was making whole list grey) ── */
#usersTable.is-refreshing { opacity: 1 !important; pointer-events: auto !important; }

/* ── 3. Search icon: fix vertical alignment ── */
.crm-topbar-search::before {
  content: "" !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a8fad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-size: 16px !important;
  width: 16px !important;
  height: 16px !important;
  display: block !important;
  position: absolute !important;
  left: 14px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  font-size: 0 !important;
}

/* ── 4. Admin search input: proper dark/light theme ── */
.crm-form-input-standalone {
  background: rgba(255,255,255,.05) !important;
  border: 1px solid rgba(148,178,225,.18) !important;
  color: var(--text) !important;
  transition: border-color .15s !important;
}
.crm-form-input-standalone:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(34,199,232,.1) !important;
}
body.theme-light .crm-form-input-standalone {
  background: rgba(0,0,0,.04) !important;
  border-color: rgba(0,0,0,.1) !important;
  color: #0a0a0a !important;
}

/* ── 5. Dashboard dropdowns: dark theme + custom arrow ── */
.crm-analytics-switch {
  background: rgba(255,255,255,.04) !important;
  border-color: rgba(148,178,225,.18) !important;
}
body.theme-light .crm-analytics-switch {
  background: rgba(0,0,0,.03) !important;
  border-color: rgba(0,0,0,.1) !important;
}
.crm-analytics-switch select,
#hyperAnalyticsMode,
#hyperProjectFilter {
  -webkit-appearance: none !important;
  appearance: none !important;
  background-color: rgba(255,255,255,.06) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%238892a4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
  background-size: 11px !important;
  border: 1px solid rgba(148,178,225,.2) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  padding: 0 30px 0 10px !important;
  height: 34px !important;
  min-width: 0 !important;
  font-size: 12px !important;
  cursor: pointer !important;
}
body.theme-light .crm-analytics-switch select,
body.theme-light #hyperAnalyticsMode,
body.theme-light #hyperProjectFilter {
  background-color: #fff !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  border-color: rgba(0,0,0,.12) !important;
  color: #0a0a0a !important;
}
.crm-analytics-switch select option,
#hyperAnalyticsMode option,
#hyperProjectFilter option {
  background: var(--panel) !important;
  color: var(--text) !important;
}
body.theme-light .crm-analytics-switch select option,
body.theme-light #hyperAnalyticsMode option,
body.theme-light #hyperProjectFilter option {
  background: #fff !important;
  color: #0a0a0a !important;
}

/* ── Sidebar/topbar hidden before login ── */
.crm-sidebar--hidden { display: none !important; }
.crm-topbar--hidden { visibility: hidden !important; pointer-events: none !important; }

/* ── Login screen: centered, full-width when sidebar hidden ── */
.crm-sidebar--hidden + .crm-main-shell {
  grid-column: 1 / -1 !important;
  width: 100% !important;
}
.crm-topbar--hidden {
  display: none !important;
}
.crm-login-wrap:not(.hidden) {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 100vh !important;
  padding: 24px 16px !important;
}
.crm-login-card {
  width: min(440px, 100%) !important;
  padding: 40px 36px !important;
  border-radius: 20px !important;
}
@media (max-width: 520px) {
  .crm-login-card { padding: 28px 20px !important; }
}

/* ═══════════════════════════════════════════════
   Scenario Tab Redesign
   ═══════════════════════════════════════════════ */
.scenario-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
/* Medium screens: narrow the form card */
@media (max-width: 1700px) {
  .scenario-layout { grid-template-columns: 360px minmax(0, 1fr); }
}
/* Stack vertically at 1500px */
@media (max-width: 1500px) {
  .scenario-layout {
    grid-template-columns: 1fr;
    max-width: 900px;
  }
  .crm-market-widget--compact {
    min-height: auto;
  }
  .crm-market-widget--compact .crm-market-chart-wrap {
    height: clamp(260px, 38vw, 420px);
  }
}
/* Narrow widget: stack asset list above chart */
@media (max-width: 800px) {
  .crm-market-widget {
    grid-template-columns: 1fr !important;
  }
  .crm-market-widget .crm-market-sidebar {
    max-height: 180px;
    overflow-y: auto;
  }
}

.scenario-form-card { overflow: visible !important; }

.crm-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--input-bg, rgba(255,255,255,.04));
  color: var(--text);
  padding: 0 14px;
  font-size: .9rem;
  font-weight: 600;
  outline: none;
  transition: border-color .15s;
}
.crm-input:focus { border-color: var(--accent); }
.crm-field-label { font-size: .75rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.theme-light .crm-input { background: #f8fbff; border-color: #cfe0f2; color: #0d2140; }

.scenario-asset-row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; margin-bottom: 14px; }
.scenario-price-col { display: flex; flex-direction: column; }
.scenario-live-price {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: rgba(17,216,255,.07); border: 1px solid rgba(17,216,255,.22);
  border-radius: var(--radius-sm); font-weight: 900; font-size: .95rem;
  color: var(--accent); min-height: 44px; padding: 0 10px;
}
.theme-light .scenario-live-price { background: rgba(17,216,255,.08); color: #0077a8; }

.scenario-target-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.scenario-dir-hint {
  height: 44px; min-width: 80px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: .8rem; font-weight: 800; padding: 0 10px;
  background: rgba(255,255,255,.04); color: var(--muted);
}
.scenario-dir-hint.up { background: rgba(26,183,96,.14); color: #29f18f; }
.scenario-dir-hint.down { background: rgba(255,60,120,.12); color: #ff5090; }

.scenario-timing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.scenario-timing-block { background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; }
.theme-light .scenario-timing-block { background: #f3f8ff; border-color: #cfe0f2; }
.scenario-block-label { font-size: .73rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }

.scenario-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.sc-pill {
  padding: 5px 12px; border-radius: 99px; font-size: .78rem; font-weight: 800; cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.10); background: transparent; color: var(--muted);
  transition: all .15s;
}
.sc-pill:hover { border-color: var(--accent); color: var(--accent); }
.sc-pill.active { background: var(--accent); border-color: var(--accent); color: #04111a; }
.theme-light .sc-pill { border-color: #cfe0f2; color: #5a7090; }
.theme-light .sc-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.scenario-vol-row { background: rgba(255,255,255,.025); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 16px; }
.theme-light .scenario-vol-row { background: #f3f8ff; border-color: #cfe0f2; }
.scenario-vol-hint { font-size: .72rem; color: var(--muted); margin-top: 8px; }

.scenario-users-block { margin-bottom: 18px; }
.scenario-launch-btn { width: 100%; height: 48px; font-size: 1rem; font-weight: 900; letter-spacing: .02em; }

/* Active scenarios list */
.scenario-active-list { display: grid; gap: 10px; margin-bottom: 18px; }
.scenario-active-card {
  background: rgba(17,216,255,.04);
  border: 1.5px solid rgba(17,216,255,.22);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: center;
}
.theme-light .scenario-active-card { background: rgba(17,216,255,.06); border-color: rgba(17,216,255,.3); }
.scenario-card-info { min-width: 0; }
.scenario-card-title { font-weight: 900; font-size: .95rem; margin-bottom: 3px; display: flex; align-items: center; gap: 8px; }
.scenario-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #29f18f; box-shadow: 0 0 0 3px rgba(41,241,143,.2); flex-shrink: 0; }
.scenario-status-dot.returning { background: #ff9f3f; box-shadow: 0 0 0 3px rgba(255,159,63,.2); }
.scenario-status-dot.done { background: var(--muted); box-shadow: none; }
.scenario-card-meta { font-size: .78rem; color: var(--muted); margin-bottom: 8px; }
.scenario-progress-wrap { background: rgba(255,255,255,.08); border-radius: 99px; height: 5px; overflow: hidden; }
.scenario-progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #11d8ff, #1ee788); transition: width .5s ease; }
.scenario-progress-bar.returning { background: linear-gradient(90deg, #ff9f3f, #ff5090); }
.scenario-card-time { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.scenario-stop-btn { padding: 5px 12px; border-radius: var(--radius-sm); background: rgba(246,70,93,.12); color: #ff5b8e; border: 1px solid rgba(246,70,93,.28); font-weight: 800; font-size: .78rem; cursor: pointer; white-space: nowrap; flex-shrink: 0; align-self: center; transition: background .15s; }
.scenario-stop-btn:hover { background: rgba(246,70,93,.22); }

/* ── Scenarios drawer ──────────────────────────────────────────────── */
@keyframes sc-badge-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .55; }
}
@keyframes sc-badge-pulse-orange {
  0%,100% { opacity: 1; background: rgba(230,126,34,1); }
  50%      { opacity: .6; background: rgba(230,126,34,.7); }
}
@keyframes sc-card-in {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
/* The tab is a horizontal button rotated 90deg to sit on the right wall.
   Natural state: horizontal row (badge + label).
   Rotated: reads bottom-to-top, protruding from the right side of the screen.
   border-bottom = against wall (bottom becomes right after CW 90deg rotation).
   border-radius bottom corners = become left-side corners (facing content). */
/* Right-side vertical tab. writing-mode: vertical-lr = text reads top→bottom naturally.
   Border on left/top/bottom faces the content; border-right: none merges with the wall.
   Border-radius on left corners (top-left, bottom-left) creates the tab "ear" shape. */
.scenarios-drawer-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1200;
  writing-mode: vertical-lr;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  cursor: pointer;
  /* Menu-style: dark panel, gray text */
  background: var(--panel, #131c2e);
  color: var(--nav-muted, #8994ae);
  border: 1px solid var(--line, rgba(255,255,255,.1));
  border-right: none;             /* right edge is against the wall — no border */
  border-radius: 10px 0 0 10px;  /* rounded left corners face the content      */
  font: 700 .78rem/1 inherit;
  letter-spacing: .04em;
  box-shadow: -3px 0 16px rgba(0,0,0,.25);
  transition: background .15s, color .15s;
}
.scenarios-drawer-tab:hover {
  background: rgba(255,255,255,.06);
  color: var(--text, #c8d0e4);
}
/* Badge and label are inline elements in the vertical flow — they appear
   as a single continuous "line" reading top-to-bottom. */
.sdt-badge {
  writing-mode: horizontal-tb;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; border-radius: 50%; padding: 0;
  background: var(--accent, #11d8ff); color: #000;
  font-size: .7rem; font-weight: 900; line-height: 1;
  border: none;
  animation: sc-badge-pulse 2s ease-in-out infinite;
  transform: rotate(-90deg);
}
.theme-light .sdt-badge {
  background: #e67e22;
  color: #000;
  animation: sc-badge-pulse-orange 2s ease-in-out infinite;
}
.sdt-label { /* inherits vertical-lr */ }
/* Light theme */
.theme-light .scenarios-drawer-tab {
  background: #ffffff;
  color: #4a5470;
  border-color: #dde4f0;
  box-shadow: -3px 0 12px rgba(0,0,0,.08);
}
.theme-light .scenarios-drawer-tab:hover { background: #f0f5ff; color: #1a2a5e; }

.scenarios-drawer-backdrop {
  display: none; position: fixed; inset: 0; z-index: 1199;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .25s;
}
.scenarios-drawer-backdrop.open { display: block; }
.scenarios-drawer-backdrop.visible { opacity: 1; }

.scenarios-drawer {
  position: fixed; right: 0; top: 0; height: 100%; width: min(420px, 95vw);
  z-index: 1200; background: var(--panel);
  border-left: 1px solid rgba(17,216,255,.2);
  box-shadow: -8px 0 40px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.scenarios-drawer.open { transform: translateX(0); }
.theme-light .scenarios-drawer { background: #f0f5fb; border-color: rgba(17,216,255,.3); }

.scenarios-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.scenarios-drawer-header h3 { margin: 0; font-size: 1rem; }
.scenarios-drawer-close {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.scenarios-drawer-close:hover { background: rgba(255,255,255,.08); color: var(--text); }
.scenarios-drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.scenarios-drawer-search {
  width: 100%; padding: 9px 13px; flex-shrink: 0;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: .85rem;
  outline: none; transition: border-color .15s;
}
.scenarios-drawer-search:focus { border-color: rgba(34,199,232,.4); }
.theme-light .scenarios-drawer-search { background: #f3f7ff; border-color: #cce0f5; }
.scenarios-drawer-empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 32px 0; flex-shrink: 0; }
/* Equal-height animated grid inside drawer */
#overridesList { display: flex; flex-direction: column; gap: 8px; }
.scenario-active-card {
  animation: sc-card-in .22s ease both;
}
.scenario-active-card { background: rgba(17,216,255,.04); border: 1.5px solid rgba(17,216,255,.18); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; transition: border-color .15s; }
.scenario-active-card:hover { border-color: rgba(17,216,255,.32); }
/* Live price chip on scenario card */
.scenario-live-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .75rem; font-weight: 700;
  background: rgba(17,216,255,.08); border: 1px solid rgba(17,216,255,.2);
  border-radius: 99px; padding: 2px 9px; color: var(--accent);
  transition: color .3s;
}
.scenario-live-chip::before { content: '●'; font-size: .5rem; animation: sc-badge-pulse 2s ease-in-out infinite; }
.scenario-date { font-size: .7rem; color: var(--muted); opacity: .75; }

/* ── Chart user-picker overlay ─────────────────────────────────────── */
.crm-market-chart-wrap { position: relative; overflow: hidden; }
.crm-chart-user-overlay {
  position: absolute; inset: 0; z-index: 10;
  background: var(--panel);
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  transform: translateY(100%); opacity: 0;
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .2s;
  pointer-events: none;
}
.crm-chart-user-overlay.visible {
  transform: translateY(0); opacity: 1; pointer-events: auto;
}
.crm-chart-user-overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.crm-chart-user-overlay-head span { font-weight: 700; font-size: .9rem; }
.crm-chart-user-overlay-back {
  padding: 5px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: transparent;
  color: var(--muted); font: 600 .78rem inherit; cursor: pointer;
  transition: all .12s;
}
.crm-chart-user-overlay-back:hover { border-color: rgba(34,199,232,.4); color: var(--accent); }
.crm-chart-user-overlay .crm-market-search { width: 100%; flex-shrink: 0; }
.crm-chart-user-overlay .crm-user-picker-list {
  flex: 1; max-height: none; overflow-y: auto;
  grid-template-columns: 1fr;
}

/* ── Chart viewer controls (tighter) ──────────────────────────────── */
.crm-chart-viewer-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crm-chart-view-toggle { display: flex; gap: 4px; }
.crm-chart-view-btn {
  padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: 600 .78rem inherit;
  cursor: pointer; transition: all .12s;
}
.crm-chart-view-btn.active { background: rgba(34,199,232,.12); border-color: rgba(34,199,232,.3); color: var(--accent); }
.crm-chart-view-btn:hover:not(.active) { border-color: rgba(34,199,232,.2); color: var(--text); }

/* === Scenario blocks: gray border + orange hover (like other CRM cards) === */
.scenario-form-card,
.scenario-preview-card {
  border: 1px solid var(--line) !important;
  transition: border-color .2s, box-shadow .2s !important;
}
.scenario-form-card:hover,
.scenario-preview-card:hover {
  border-color: var(--accent) !important;
  box-shadow: 0 6px 28px rgba(0,0,0,.15) !important;
}
body.theme-light .scenario-form-card:hover,
body.theme-light .scenario-preview-card:hover {
  border-color: rgba(230,126,34,.5) !important;
  box-shadow: 0 6px 28px rgba(20,50,90,.1) !important;
}

/* === Dashboard/main tab cards hover === */
.dashboard-card {
  transition: border-color .2s, box-shadow .2s, transform .2s !important;
}
.dashboard-card:hover {
  border-color: var(--accent) !important;
  box-shadow: 0 8px 28px rgba(0,0,0,.15) !important;
  transform: translateY(-2px) !important;
}
body.theme-light .dashboard-card:hover {
  border-color: rgba(230,126,34,.45) !important;
  box-shadow: 0 8px 28px rgba(20,50,90,.1) !important;
}
/* metric-card already has hover, just add orange for dark theme too */
body.theme-dark .metric-card:hover,
body:not(.theme-light) .metric-card:hover {
  border-color: rgba(34,199,232,.35) !important;
}

/* === CRM password reveal row in client card === */
.crm-password-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crm-password-value {
  font-weight: 700;
  letter-spacing: .08em;
  cursor: default;
  user-select: all;
}
.crm-pw-toggle {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  font-size: 14px !important;
  cursor: pointer;
  opacity: .65;
  transition: opacity .15s;
}
.crm-pw-toggle:hover {
  opacity: 1;
  border-color: var(--accent) !important;
}

/* === Scenario form collapsible === */
.scenario-collapse-icon {
  font-size: .8rem;
  color: var(--muted);
  transition: transform .25s ease;
  flex-shrink: 0;
}
.scenario-form-card.is-collapsed .scenario-collapse-icon {
  transform: rotate(180deg);
}
#scenarioFormBody {
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.4,0,.2,1), opacity .25s ease;
  max-height: 1200px;
  opacity: 1;
}
.scenario-form-card.is-collapsed #scenarioFormBody {
  max-height: 0;
  opacity: 0;
}

/* === Scenario price col animation on asset select === */
.scenario-price-col {
  transition: opacity .3s ease, transform .3s ease;
}
.scenario-price-col.is-selecting {
  opacity: 0;
  transform: translateY(-6px);
}
.scenario-price-col.has-price .scenario-price-label {
  display: none;
}
#overrideCurrentPrice {
  transition: all .3s ease;
}

/* === Asset sidebar in preview — compact dropdown overlay === */
@media (max-width: 1500px) {
  .crm-market-widget--compact {
    position: relative;
    grid-template-columns: 1fr !important;
    overflow: visible !important;
  }
  #crmTradeAssetSidebar {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 30;
    width: 270px;
    max-height: min(480px, 75vh);
    background: var(--panel, #111827);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
    transform: translateY(-8px) scale(.97);
    opacity: 0;
    transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .18s ease;
    pointer-events: none;
  }
  #crmTradeAssetSidebar.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  /* Compact categories inside the dropdown */
  #crmTradeAssetSidebar .crm-market-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
  #crmTradeAssetSidebar .crm-market-categories button {
    padding: 4px 10px;
    font-size: .72rem;
    height: auto;
    border-radius: 99px;
  }
  #crmTradeAssetSidebar .crm-market-controls {
    padding: 10px 10px 6px;
    flex-shrink: 0;
  }
  #crmTradeAssetSidebar .crm-market-search {
    height: 34px;
    font-size: .82rem;
    margin-bottom: 6px;
  }
  #crmTradeAssetSidebar .crm-market-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 8px 8px;
    gap: 3px;
    max-height: none;
  }
  /* Compact list items in dropdown */
  #crmTradeAssetSidebar .crm-market-item {
    padding: 5px 8px;
    border-radius: 8px;
  }
  #crmTradeAssetSidebar .cmi-info strong { font-size: .8rem; }
  #crmTradeAssetSidebar .cmi-info small { font-size: .68rem; }
  #crmTradeAssetSidebar .cmi-val { font-size: .75rem; }
  #crmTradeAssetSidebar .cmi-chg { font-size: .65rem; }
}

/* === Asset toggle button in scenario preview === */
.crm-asset-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.crm-asset-toggle-btn:hover,
.crm-asset-toggle-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(17,216,255,.06);
}
body.theme-light .crm-asset-toggle-btn:hover,
body.theme-light .crm-asset-toggle-btn.is-active {
  border-color: rgba(230,126,34,.6);
  color: #e67e22;
  background: rgba(230,126,34,.06);
}
/* Smaller variant used below symbol heading */
.crm-asset-toggle-btn--small {
  height: 24px !important;
  padding: 0 9px !important;
  font-size: .68rem !important;
  gap: 4px !important;
}
.crm-asset-toggle-btn--small svg {
  width: 11px !important;
  height: 11px !important;
}
/* Show asset name on wide screens, hide where toggle button is visible */
#crmTradeMarketName {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  margin: 0 0 4px !important;
}
/* On narrow screens where sidebar is a dropdown, hide the name */
@media (max-width: 1500px) {
  #crmTradeMarketName {
    display: none !important;
  }
}

/* Gap between symbol heading and toggle button */
.crm-market-head > div:first-child {
  gap: 6px !important;
}
/* Hide on wide screens where sidebar is always visible */
@media (min-width: 1501px) {
  .crm-asset-toggle-btn { display: none !important; }
}

/* === Dark theme: transparent chart bg, no border/bg on wrap === */
body:not(.theme-light) .crm-market-chart-wrap {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
/* No empty space under the chart — wrap must not exceed chart height */
.crm-market-chart-wrap {
  flex-shrink: 0 !important;
}
.crm-market-main {
  overflow: hidden !important;
}
/* Remove bottom padding from scenario-preview-card so chart is flush */
.scenario-preview-card {
  padding-bottom: 0 !important;
}
.scenario-preview-card .crm-market-widget {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

/* ── Lead Mail ──────────────────────────────────────────────────── */
@keyframes mailPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
.crm-mail-pulse {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 10px; margin-left: 6px;
  animation: mailPulse 1.6s ease-in-out infinite;
  cursor: default;
}
.crm-mail-section-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; margin-left: 8px; vertical-align: middle;
  animation: mailPulse 1.6s ease-in-out infinite;
}
.crm-mail-section-badge.hidden { display: none; }
.crm-mail-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; display: inline-block; animation: mailPulse 1.6s infinite; flex-shrink: 0; }

.crm-mail-thread {
  max-height: 360px; overflow-y: auto; padding: 8px 12px;
  display: flex; flex-direction: column; gap: 10px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.crm-mail-msg { border-radius: 8px; padding: 10px 12px; font-size: 13px; max-width: 90%; }
.crm-mail-out {
  background: rgba(96,89,232,.12); align-self: flex-end;
  border: 1px solid rgba(96,89,232,.25);
}
.crm-mail-in {
  background: var(--bg2); align-self: flex-start;
  border: 1px solid rgba(0,0,0,.1);
}
body.theme-light .crm-mail-in  { background: #f0f4f8; border-color: #d1dce8; }
body.theme-light .crm-mail-out { background: rgba(96,89,232,.08); border-color: rgba(96,89,232,.2); }
body.theme-light .crm-mail-thread { border-bottom-color: #e2eaf3; }

.crm-mail-msg-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; font-size: 11px; color: var(--muted); }
.crm-mail-msg-time { margin-left: auto; }
.crm-mail-msg-subj { font-weight: 600; margin-bottom: 4px; color: var(--text); font-size: 13px; }
.crm-mail-msg-body { color: var(--text); line-height: 1.5; font-size: 13px; opacity: .85; }
.crm-mail-msg-body p { margin: 0; }

.crm-mail-compose { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.crm-mail-subject-inp, .crm-mail-body-inp {
  background: var(--bg2); border: 1px solid rgba(0,0,0,.12);
  color: var(--text); border-radius: 6px; padding: 8px 10px;
  font-size: 13px; width: 100%; box-sizing: border-box;
}
body.theme-light .crm-mail-subject-inp,
body.theme-light .crm-mail-body-inp { background: #fff; border-color: #c8d8e8; }
.crm-mail-subject-inp::placeholder, .crm-mail-body-inp::placeholder { color: var(--muted); opacity: .7; }
.crm-mail-body-inp { resize: vertical; min-height: 80px; font-family: inherit; }
.crm-mail-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.crm-mail-from-label { font-size: 11px; color: var(--muted); }

/* === Lead card row (lc3) === */
.crm-user-card.lc2-card { border-radius: 0 !important; padding: 9px 14px !important; margin-bottom: 4px; background: var(--bg2); display: block !important; }
.crm-user-card.lc2-card:hover { box-shadow: 0 1px 6px rgba(0,0,0,.1); border-color: var(--line); }
body.theme-light .crm-user-card.lc2-card { background: #fff; }
.lc3 { display: flex; align-items: center; gap: 8px; width: 100%; }
.lc3-name { font-weight: 700; font-size: 13px; color: var(--text); white-space: nowrap; flex: 0 0 140px; overflow: hidden; text-overflow: ellipsis; }
.lc3-val { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; text-align: left; }
.lc3-uid { flex: 0 0 130px; }
.lc3-email { flex: 0 0 185px; }
.lc3-phone { flex: 0 0 115px; }
.lc3-country { flex: 0 0 60px; }
.lc3-funnel { flex: 0 0 90px; }
.lc3-affiliate { flex: 0 0 90px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc3-spacer { flex: 1; }
.lc3-source { flex: 0 0 auto; font-size: 10px; font-weight: 700; padding: 2px 6px; white-space: nowrap; border-radius: 0; }
.lc3-source.is-smm { background: rgba(99,102,241,.15); color: #818cf8; }
.lc3-source.is-conv { background: rgba(16,185,129,.1); color: #10b981; }
.lc3-balance { font-size: 14px; color: var(--text); white-space: nowrap; flex: 0 0 80px; text-align: right; }
.lc3-open { flex-shrink: 0; }
.lc3-ret { font-size: 10px; font-weight: 700; padding: 2px 5px; background: rgba(99,102,241,.15); color: #6366f1; white-space: nowrap; flex-shrink: 0; }
.lc3-presence { display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-right: 10px; }
.lc3-pres-online, .lc3-pres-push { font-size: 11px; font-weight: 700; padding: 3px 9px; white-space: nowrap; border-radius: 0; transition: background .3s, color .3s; cursor: default; }
.lc3-pres-online.is-online { background: rgba(16,185,129,.15); color: #10b981; }
.lc3-pres-online.is-offline { background: rgba(75,85,99,.12); color: #6b7280; }
.lc3-pres-push.push-on { background: rgba(99,102,241,.15); color: #818cf8; }
.lc3-pres-push.push-off { background: rgba(75,85,99,.12); color: #6b7280; opacity: .6; }
/* Custom status dropdown */
.csdd { position: relative; flex-shrink: 0; }
.lc3 > .csdd, .lc3 > .csdd-ret { flex: 0 0 148px; }
.lc3 > .csdd .csdd-btn, .lc3 > .csdd-ret .csdd-btn { width: 100%; box-sizing: border-box; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.csdd-btn { font-size: 11px; font-weight: 600; color: #fff; border: none; border-radius: 0; padding: 3px 8px; cursor: pointer; white-space: nowrap; line-height: 1.4; }
.csdd-list { display: none; position: absolute; top: calc(100% + 2px); left: 0; z-index: 9999; background: var(--bg2); border: 1px solid rgba(0,0,0,.2); min-width: 160px; max-height: 260px; overflow-y: auto; box-shadow: 0 6px 20px rgba(0,0,0,.22); }
.csdd.is-open .csdd-list { display: block; }
.csdd-item { padding: 6px 10px; font-size: 12px; cursor: pointer; color: var(--text); border-bottom: 1px solid rgba(0,0,0,.05); white-space: nowrap; }
.csdd-item:last-child { border-bottom: none; }
.csdd-item:hover { background: rgba(0,0,0,.07); }
body.theme-light .csdd-list { background: #fff; border-color: #d1d5db; }
body.theme-light .csdd-item:hover { background: #f3f4f6; }
.crm-phone-popup-btn { font-size: 12px !important; background: none !important; border: none !important; padding: 0 !important; cursor: pointer; color: var(--accent) !important; text-align: left; white-space: nowrap; }
