/* ==========================================================================
   Lead Manager — design system
   Light tokens on :root, dark tokens on [data-theme="dark"].
   ========================================================================== */

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eff2f7;
  --border: #e3e7ee;
  --border-strong: #d0d6e1;
  --text: #0f172a;
  --text-2: #4a5568;
  --text-3: #818da1;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-text: #4338ca;
  --on-primary: #ffffff;
  --ring: 0 0 0 3px rgba(79, 70, 229, .22);

  --success: #15803d;  --success-soft: #e6f6ec;
  --warning: #b45309;  --warning-soft: #fdf2e1;
  --danger: #dc2626;   --danger-soft: #fdeaea;
  --info: #0369a1;     --info-soft: #e4f2fb;
  --wa: #128c4a;       --wa-soft: #e5f6ec;

  --sidebar-bg: #0e1526;
  --sidebar-line: rgba(255, 255, 255, .07);
  --sidebar-text: #a9b3c7;
  --sidebar-hover: rgba(255, 255, 255, .05);
  --sidebar-active: rgba(129, 140, 248, .18);

  --chart-1: #2a78d6;
  --chart-1-hover: #1c5cab;
  --chart-track: #cde2fb;
  --chart-grid: #e8ebf1;
  --chart-axis: #c6cdd8;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 6px 18px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 24px 56px rgba(16, 24, 40, .18), 0 6px 16px rgba(16, 24, 40, .06);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --sidebar-w: 252px;
  --topbar-h: 60px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a0f1d;
  --surface: #111a2c;
  --surface-2: #0e1627;
  --surface-3: #18233a;
  --border: #1f2a40;
  --border-strong: #2c3a54;
  --text: #e7ebf3;
  --text-2: #a7b2c6;
  --text-3: #74819a;

  --primary: #6366f1;
  --primary-hover: #7a7df4;
  --primary-soft: rgba(99, 102, 241, .16);
  --primary-text: #a5b4fc;
  --ring: 0 0 0 3px rgba(129, 140, 248, .32);

  --success: #4ade80;  --success-soft: rgba(34, 197, 94, .14);
  --warning: #fbbf24;  --warning-soft: rgba(245, 158, 11, .14);
  --danger: #f87171;   --danger-soft: rgba(239, 68, 68, .15);
  --info: #38bdf8;     --info-soft: rgba(14, 165, 233, .14);
  --wa: #4ade80;       --wa-soft: rgba(34, 197, 94, .14);

  --sidebar-bg: #070c18;

  --chart-1: #3987e5;
  --chart-1-hover: #6da7ec;
  --chart-track: #173a66;
  --chart-grid: #1e2839;
  --chart-axis: #2e3a50;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow: 0 8px 22px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* --------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
body.no-scroll { overflow: hidden; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 650; letter-spacing: -.012em; line-height: 1.25; }
h1 { font-size: 23px; }
h2 { font-size: 16px; }
h3 { font-size: 14.5px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg { vertical-align: middle; }
[hidden] { display: none !important; }
::selection { background: rgba(79, 70, 229, .22); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 300; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------- layout */

.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; width: var(--sidebar-w);
  display: flex; flex-direction: column; background: var(--sidebar-bg); color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-line);
}
.brand {
  display: flex; align-items: center; gap: 11px; height: var(--topbar-h); padding: 0 20px; flex: none;
  color: #fff; text-decoration: none !important; border-bottom: 1px solid var(--sidebar-line);
}
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, #818cf8, #4f46e5 55%, #4338ca);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .45), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.brand-mark .icon { width: 17px; height: 17px; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin: 18px 12px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #5f6b84; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 9px;
  color: var(--sidebar-text); font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s;
}
.nav-item .icon { opacity: .85; }
.nav-item:hover { background: var(--sidebar-hover); color: #e8ecf5; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active .icon { opacity: 1; color: #a5b4fc; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: #ef4444;
  color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
}
.sidebar-foot { display: flex; align-items: center; gap: 6px; padding: 12px; border-top: 1px solid var(--sidebar-line); }
.sidebar-foot form { margin: 0; }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; color: #e8ecf5; text-decoration: none !important; }
.me:hover { background: var(--sidebar-hover); }
.me-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.me-text strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { font-size: 11.5px; color: #7f8aa3; }
.sidebar .icon-btn { color: #8b96ad; }
.sidebar .icon-btn:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(8, 12, 24, .5); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: rgba(244, 246, 250, .84); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
}
[data-theme="dark"] .topbar { background: rgba(10, 15, 29, .82); }
.global-search { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; margin: 0; }
.global-search > .icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.global-search input {
  width: 100%; height: 38px; padding: 0 40px 0 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.global-search input::placeholder { color: var(--text-3); }
.global-search input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.global-search kbd {
  position: absolute; right: 10px; font: 600 11px/1 var(--font); color: var(--text-3);
  border: 1px solid var(--border-strong); border-radius: 5px; padding: 3px 6px; background: var(--surface-2);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.bell { position: relative; }
.bell-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px var(--bg); }
.theme-light { display: none; }
[data-theme="dark"] .theme-light { display: inline; }
[data-theme="dark"] .theme-dark { display: none; }
.content { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 26px 28px 56px; }
.only-mobile { display: none !important; }

/* ------------------------------------------------------ page structure */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin-top: 5px; color: var(--text-2); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); min-height: 58px; }
.card-head h2 { font-size: 15px; }
.card-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-link { font-size: 13px; font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }
.card-link .icon { width: 15px; height: 15px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: .92em; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid transparent; font-weight: 550; font-size: 13.5px; line-height: 1;
  cursor: pointer; white-space: nowrap; user-select: none; text-decoration: none !important;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(79, 70, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { filter: brightness(.97); }
.btn-wa { background: var(--wa-soft); color: var(--wa); }
.btn-wa:hover { filter: brightness(.97); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { height: 46px; padding: 0 18px; font-size: 15px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer; text-decoration: none !important; flex: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.sm .icon { width: 15px; height: 15px; }
.icon-btn.call { color: var(--primary-text); background: var(--primary-soft); }
.icon-btn.call:hover { background: var(--primary); color: #fff; }
.icon-btn.wa { color: var(--wa); background: var(--wa-soft); }
.icon-btn.wa:hover { background: #16a34a; color: #fff; }
.link-btn {
  display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; padding: 0; color: var(--primary-text);
  font-weight: 550; font-size: 13px; cursor: pointer;
}
.link-btn .icon { width: 14px; height: 14px; }
.link-btn:hover { text-decoration: underline; }
.spinner {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- forms */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12px; color: var(--danger); font-weight: 500; }
.req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23818da1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.select-sm, .input-sm { height: 34px; font-size: 13px; border-radius: 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; cursor: pointer; flex: none; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text); user-select: none; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 76px; }
.input-wrap .input-actions { position: absolute; right: 4px; top: 4px; display: flex; gap: 2px; }
.input-wrap .input-actions .icon-btn { width: 30px; height: 30px; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
fieldset.section { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
fieldset.section legend { padding: 0; margin-bottom: 12px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; flex: none; }
.segmented button {
  height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: none; color: var(--text-2);
  font-size: 12.5px; font-weight: 550; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.segmented button .icon { width: 14px; height: 14px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------------------------------------------------- chips & badges */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 0 12px; scrollbar-width: thin; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; flex: none;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-weight: 550; font-size: 13px; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, color .15s;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-3)); }
.chip .count {
  font-variant-numeric: tabular-nums; color: var(--text-3); font-weight: 600; font-size: 11.5px;
  background: var(--surface-3); padding: 1px 7px; border-radius: 999px; min-width: 24px; text-align: center;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.active .count { background: rgba(255, 255, 255, .18); color: inherit; }
[data-theme="dark"] .chip.active .count { background: rgba(0, 0, 0, .2); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--c-bg, var(--surface-3)); color: var(--text); vertical-align: middle;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--text-3)); flex: none; }
.badge.soft { background: var(--surface-3); color: var(--text-2); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary-text); }
.badge .icon { width: 13px; height: 13px; }
.mini-badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px;
  font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.mini-badge.ok { background: var(--success-soft); color: var(--success); }
.mini-badge.warn { background: var(--warning-soft); color: var(--warning); }
.mini-badge.danger { background: var(--danger-soft); color: var(--danger); }
.mini-badge.info { background: var(--info-soft); color: var(--info); }
.mini-badge.muted { background: var(--surface-3); color: var(--text-3); }
.tag-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.priority { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 650; }
.priority .icon { width: 12px; height: 12px; }
.priority.p3 { background: var(--danger-soft); color: var(--danger); }
.priority.p2 { background: var(--warning-soft); color: var(--warning); }
.priority.p1 { background: var(--info-soft); color: var(--info); }
.platform-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.platform-tag::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--text-3)); flex: none; }
.role-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.role-badge.super_admin { background: var(--primary-soft); color: var(--primary-text); }
.role-badge.admin { background: var(--info-soft); color: var(--info); }
.role-badge.staff { background: var(--surface-3); color: var(--text-2); }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 7px 0 10px; border-radius: 8px;
  border: 1px solid transparent; background: var(--c-bg, var(--surface-3)); color: var(--text); font-size: 12.5px;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: border-color .15s, box-shadow .15s;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.status-pill .icon { width: 14px; height: 14px; opacity: .55; }
.status-pill:hover { border-color: var(--c); }
.status-pill[aria-expanded="true"] { border-color: var(--c); box-shadow: 0 0 0 3px var(--c-bg); }

.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none;
  font-size: 13px; font-weight: 650; color: #fff; letter-spacing: .02em; background: hsl(var(--h, 230) 52% 52%);
}
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.lg { width: 50px; height: 50px; font-size: 17px; }
[data-theme="dark"] .avatar { background: hsl(var(--h, 230) 42% 42%); }
.assignee { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; white-space: nowrap; }

/* ------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .04em; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.selected td { background: var(--primary-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-check { width: 44px; padding-right: 0; }
.table .col-actions { width: 48px; text-align: right; }
.table tbody.is-loading { opacity: .5; transition: opacity .15s; pointer-events: none; }
.table.compact td { padding: 9px 14px; }
.clickable-rows tbody tr { cursor: pointer; }

.lead-cell { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.lead-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lead-name { font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.lead-name:hover { color: var(--primary-text); text-decoration: none; }
.lead-sub { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 3px 6px; flex-wrap: wrap; }
.lead-sub .sep { opacity: .5; }
.lead-sub .tag-list { flex-wrap: nowrap; margin-left: 2px; }
.leads-table th, .leads-table td { padding-left: 12px; padding-right: 12px; }
.leads-table.no-check .col-assigned { display: none; }
.leads-table .col-date { white-space: nowrap; }
.calls-sub { font-size: 12px; color: var(--text-3); margin-top: 5px; white-space: nowrap; }
.lead-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.phone-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.phone-cell .num-text { font-variant-numeric: tabular-nums; margin-right: 4px; color: var(--text); }
.email-sub { font-size: 12px; color: var(--text-3); max-width: 240px; margin-top: 4px; }
.due { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.due .icon { width: 14px; height: 14px; }
.due.overdue { color: var(--danger); }
.due.today { color: var(--warning); }
.due.soon { color: var(--info); }
.due.later { color: var(--text-2); font-weight: 500; }
.due-sub { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-meta { display: none; }

/* ------------------------------------------------------------ toolbar */

.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1 1 220px; min-width: 180px; }
.toolbar .search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.toolbar .search .input { padding-left: 36px; }
.toolbar .select { width: auto; min-width: 130px; max-width: 200px; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.filters-more { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-text); font-size: 12.5px; font-weight: 550;
}
.filter-pill button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.filter-pill button:hover { background: rgba(79, 70, 229, .15); }
.filter-pill .icon { width: 12px; height: 12px; }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap;
  background: var(--primary-soft); border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.bulk-bar .select { width: auto; min-width: 160px; height: 34px; font-size: 13px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { color: var(--text-2); font-size: 13px; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager button {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--text-2); font-weight: 550; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.pager button .icon { width: 16px; height: 16px; }
.pager button:hover { background: var(--surface-3); color: var(--text); }
.pager button.active { background: var(--primary); color: #fff; }
.pager button[disabled] { opacity: .35; cursor: default; background: none; }
.pager-gap { color: var(--text-3); padding: 0 4px; }
.per-page { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.per-page .select { width: auto; height: 32px; font-size: 13px; }

/* -------------------------------------------------- empty / skeleton */

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--primary-soft); color: var(--primary-text); }
.empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { max-width: 400px; margin: 0 auto; font-size: 13.5px; }
.empty .btn { margin-top: 16px; }
.empty.sm { padding: 28px 16px; }
.empty.sm .empty-icon { width: 44px; height: 44px; border-radius: 12px; }
.skeleton {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 40%, var(--surface-3) 60%);
  background-size: 300% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; }
.notice .icon { margin-top: 1px; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warning-soft); color: var(--warning); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.success { background: var(--success-soft); color: var(--success); }
.notice strong { color: inherit; }
.notice p + p { margin-top: 4px; }

/* ------------------------------------------------ menus & popovers */

.dropdown { position: relative; }
.dropdown .menu { position: absolute; top: calc(100% + 6px); right: 0; display: none; }
.dropdown.open .menu { display: block; }
.menu, .popover {
  min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 90;
}
.popover { position: fixed; max-height: min(420px, 80vh); overflow-y: auto; animation: pop .14s ease-out; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0;
  background: none; color: var(--text); font-size: 13.5px; text-align: left; cursor: pointer; text-decoration: none !important; white-space: nowrap;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item.selected { font-weight: 600; }
.menu-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.menu-item .menu-hint { margin-left: auto; color: var(--text-3); display: inline-flex; }
.menu-item .menu-check { margin-left: auto; color: var(--primary-text); }
.menu-item .menu-hint + .menu-check { margin-left: 4px; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; background: none; border: 0;
  color: var(--text-2); font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab .count { font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums; }
.tab.danger .count { background: var(--danger-soft); color: var(--danger); }
.tab.active { color: var(--text); }
.tab.active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--primary); }

/* -------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 110; display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 24px; overflow-y: auto; background: rgba(8, 12, 24, .55); animation: fade .15s ease;
}
.modal-backdrop.closing { animation: fade-out .15s ease forwards; }
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: rise .2s cubic-bezier(.2, .8, .2, 1);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 16px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16.5px; }
.modal-body { padding: 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 22px;
  border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.modal-foot .left { margin-right: auto; }
.modal.is-busy .modal-body { opacity: .7; pointer-events: none; }
.confirm-msg { color: var(--text-2); font-size: 14px; line-height: 1.6; }
.confirm-msg strong { color: var(--text); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- drawer */

.drawer-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(8, 12, 24, .42); opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 101; width: min(580px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(104%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 18px 16px 22px; border-bottom: 1px solid var(--border); }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title h2 { font-size: 19px; word-break: break-word; }
.drawer-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.drawer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.drawer-loading { padding: 28px 22px; display: flex; flex-direction: column; gap: 14px; }
.contact-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.contact-bar .call-btn { flex: 1 1 220px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; background: var(--surface); }
.panel.accent { border-color: rgba(79, 70, 229, .28); box-shadow: 0 0 0 4px var(--primary-soft); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h3 { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.panel-head h3 .icon { width: 16px; height: 16px; color: var(--text-3); }
.outcomes { display: flex; flex-wrap: wrap; gap: 8px; }
.outcome {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 550;
  cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s;
}
.outcome .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.outcome:hover { border-color: var(--c); }
.outcome.selected { border-color: var(--c); background: var(--c-bg); box-shadow: inset 0 0 0 1px var(--c); }
.log-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset {
  height: 28px; padding: 0 10px; border-radius: 7px; border: 1px dashed var(--border-strong); background: var(--surface-2);
  color: var(--text-2); font-size: 12px; font-weight: 550; cursor: pointer;
}
.preset:hover { border-style: solid; border-color: var(--primary); color: var(--primary-text); }
.log-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 3px; }
.kv dd { margin: 0; color: var(--text); font-size: 13.5px; word-break: break-word; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kv .span-2 { grid-column: 1 / -1; }
.kv.compact { gap: 10px 18px; }
.edited-tag { font-size: 10.5px; font-weight: 600; color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
details.raw { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
details.raw summary { cursor: pointer; font-size: 13px; font-weight: 550; color: var(--text-2); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.raw summary::-webkit-details-marker { display: none; }
details.raw summary::before { content: '▸'; font-size: 11px; transition: transform .15s; }
details.raw[open] summary::before { transform: rotate(90deg); }
.raw-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; }
.raw-table th, .raw-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.raw-table th { width: 40%; font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: var(--text-2); word-break: break-all; }
.raw-table td { color: var(--text); word-break: break-word; }
.inline-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }

.timeline { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl-item { position: relative; display: flex; gap: 12px; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-icon {
  position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2); box-shadow: 0 0 0 3px var(--surface);
}
.tl-icon .icon { width: 15px; height: 15px; }
.tl-call .tl-icon { background: var(--primary-soft); color: var(--primary-text); }
.tl-note .tl-icon { background: var(--warning-soft); color: var(--warning); }
.tl-assign .tl-icon { background: var(--info-soft); color: var(--info); }
.tl-status .tl-icon, .tl-create .tl-icon { background: var(--success-soft); color: var(--success); }
.tl-followup .tl-icon { background: rgba(139, 92, 246, .13); color: #8b5cf6; }
.tl-body { flex: 1; min-width: 0; padding-top: 5px; }
.tl-head { font-size: 13.5px; color: var(--text-2); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.tl-head strong { color: var(--text); font-weight: 600; }
.tl-head .arrow { width: 13px; height: 13px; color: var(--text-3); }
.tl-note {
  margin-top: 7px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; white-space: pre-wrap; word-break: break-word; color: var(--text);
}
.tl-meta { margin-top: 5px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-meta .icon { width: 13px; height: 13px; }

/* ------------------------------------------------------------- toasts */

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 440px; padding: 12px 12px 12px 14px;
  border-radius: 12px; background: #111827; color: #f3f4f6; box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.45; animation: toast-in .25s ease;
}
[data-theme="dark"] .toast { background: #1f2a40; border: 1px solid #2c3a54; }
.toast-icon { margin-top: 1px; }
.toast-success .toast-icon { color: #4ade80; }
.toast-error .toast-icon { color: #f87171; }
.toast-info .toast-icon { color: #93c5fd; }
.toast-warning .toast-icon { color: #fbbf24; }
.toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.toast-action { background: none; border: 0; color: #a5b4fc; font-weight: 650; cursor: pointer; padding: 0 4px; }
.toast-close { background: none; border: 0; color: #9ca3af; cursor: pointer; padding: 0; display: grid; place-items: center; }
.toast-close .icon { width: 16px; height: 16px; }
.toast.hide { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------- dashboard */

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  color: inherit; text-decoration: none !important; transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); font-weight: 550; }
.kpi-label .icon { width: 16px; height: 16px; color: var(--text-3); }
.kpi-value { font-size: 30px; font-weight: 650; letter-spacing: -.025em; line-height: 1.1; color: var(--text); }
.kpi-foot { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-3); min-height: 18px; }
.kpi-foot .icon { width: 14px; height: 14px; }
.kpi.alert { border-color: rgba(220, 38, 38, .28); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.dashboard.is-refreshing .card, .dashboard.is-refreshing .kpis { opacity: .6; transition: opacity .2s; }

.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-when { width: 74px; flex: none; display: flex; flex-direction: column; line-height: 1.25; }
.task-when strong { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.task-when span { font-size: 11.5px; color: var(--text-3); }
.task-when.overdue strong, .task-when.overdue span { color: var(--danger); }
.task-main { flex: 1; min-width: 0; }
.task-name { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-name:hover { color: var(--primary-text); text-decoration: none; }
.task-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.task-sub .truncate { min-width: 0; }
.task-actions { display: flex; gap: 6px; flex: none; }

.dist { display: flex; flex-direction: column; gap: 4px; }
.dist-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 7px 8px; margin: 0 -8px;
  border-radius: 8px; color: inherit; text-decoration: none !important;
}
.dist-row:hover { background: var(--surface-2); }
.dist-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 550; color: var(--text); min-width: 0; }
.dist-name .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dist-val { font-size: 13px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.dist-val small { color: var(--text-3); font-weight: 500; margin-left: 6px; }
.dist-bar { grid-column: 1 / -1; height: 6px; border-radius: 0 3px 3px 0; background: var(--surface-3); overflow: hidden; }
.dist-bar span { display: block; height: 100%; min-width: 2px; background: var(--chart-1); border-radius: 0 3px 3px 0; }

.board { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.board th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 0 20px 8px; }
.board td { padding: 10px 20px; border-top: 1px solid var(--border); }
.board .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 700; }
.rank.r1 { background: #fef3c7; color: #92400e; }
.rank.r2 { background: #e5e7eb; color: #374151; }
.rank.r3 { background: #fde7d9; color: #9a3412; }
[data-theme="dark"] .rank.r1 { background: rgba(251, 191, 36, .2); color: #fcd34d; }
[data-theme="dark"] .rank.r2 { background: rgba(229, 231, 235, .14); color: #e5e7eb; }
[data-theme="dark"] .rank.r3 { background: rgba(251, 146, 60, .18); color: #fdba74; }
.inline-bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.inline-bar .track { width: 70px; height: 6px; border-radius: 0 3px 3px 0; background: var(--surface-3); overflow: hidden; }
.inline-bar .track span { display: block; height: 100%; background: var(--chart-1); border-radius: 0 3px 3px 0; }

.feed { list-style: none; margin: 0; padding: 4px 0; }
.feed li { display: flex; gap: 12px; padding: 10px 20px; align-items: flex-start; }
.feed .f-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.feed .f-icon .icon { width: 14px; height: 14px; }
.feed .f-call { background: var(--primary-soft); color: var(--primary-text); }
.feed .f-note { background: var(--warning-soft); color: var(--warning); }
.feed .f-assign { background: var(--info-soft); color: var(--info); }
.feed .f-status, .feed .f-create { background: var(--success-soft); color: var(--success); }
.feed .f-text { font-size: 13.5px; color: var(--text-2); line-height: 1.45; min-width: 0; }
.feed .f-text strong, .feed .f-text a { color: var(--text); font-weight: 600; }
.feed .f-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.health { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; }
.health-top { display: flex; align-items: center; gap: 10px; }
.health-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health-msg { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-3); }
.state-dot.success { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.state-dot.failed { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.state-dot.running { background: #2563eb; animation: pulse 1.2s ease infinite; }
.state-dot.cancelled, .state-dot.aborted { background: #d97706; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(37, 99, 235, .15); } }

/* -------------------------------------------------------------- charts */

.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-base { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--chart-1); transition: fill .12s; }
.chart .bar.hover { fill: var(--chart-1-hover); }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .val { fill: var(--text-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart-1); opacity: .1; }
.chart .crosshair { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .end-dot, .chart .hover-dot { fill: var(--chart-1); stroke: var(--surface); stroke-width: 2; }
.chart .overlay { fill: transparent; outline: none; }
.chart-tip {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5; padding: 8px 10px; border-radius: 10px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12px; transform: translate(-50%, calc(-100% - 10px));
}
.chart-tip strong { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); font-weight: 650; }
.chart-tip .key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; background: var(--chart-1); }
.chart-tip span { color: var(--text-3); }
.chart-box { min-height: 250px; }
.chart-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chart-table th, .chart-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.chart-table th { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.chart-table td.num, .chart-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-table-wrap { max-height: 260px; overflow-y: auto; }

.meter { display: flex; align-items: center; gap: 10px; }
.meter .track { flex: 1; min-width: 60px; height: 8px; border-radius: 0 4px 4px 0; background: var(--chart-track); overflow: hidden; }
.meter .track span { display: block; height: 100%; background: var(--chart-1); border-radius: 0 4px 4px 0; }
.meter .val { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

/* ------------------------------------------------------- follow-ups */

.fu-group { padding: 0; }
.fu-day {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 12px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.fu-day .count { font-weight: 600; color: var(--text-3); letter-spacing: 0; text-transform: none; }
.fu-day.overdue { color: var(--danger); }
.fu-item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.fu-item:hover { background: var(--surface-2); }
.fu-time { display: flex; flex-direction: column; line-height: 1.3; }
.fu-time strong { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.fu-time span { font-size: 12px; color: var(--text-3); }
.fu-item.overdue .fu-time strong, .fu-item.overdue .fu-time span { color: var(--danger); }
.fu-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fu-title a { font-weight: 600; color: var(--text); font-size: 14.5px; }
.fu-title a:hover { color: var(--primary-text); text-decoration: none; }
.fu-sub { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.fu-note { color: var(--text-2); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px; }
.fu-owner { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); }
.fu-actions { display: flex; gap: 6px; align-items: center; }

/* --------------------------------------------------------- platforms */

.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; }
.pcard { position: relative; overflow: hidden; display: flex; flex-direction: column; }
.pcard::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c, var(--primary)); }
.pcard.inactive { opacity: .78; }
.pc-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 12px; }
.pc-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; color: #fff; background: var(--c, var(--primary)); font-weight: 700; font-size: 16px; }
.pc-title { flex: 1; min-width: 0; }
.pc-title h3 { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-url { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.pc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 18px; border: 1px solid var(--border); border-radius: 12px; }
.pc-stat { padding: 10px 12px; min-width: 0; }
.pc-stat + .pc-stat { border-left: 1px solid var(--border); }
.pc-stat span { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 550; }
.pc-stat strong { display: block; font-size: 18px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pc-sync { display: flex; gap: 10px; align-items: flex-start; margin: 14px 18px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 12.5px; color: var(--text-2); }
.pc-sync .state-dot { margin-top: 5px; }
.pc-sync p { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 0; }
.pc-actions { display: flex; align-items: center; gap: 6px; padding: 14px 18px 16px; margin-top: auto; flex-wrap: wrap; }
.pc-actions .spacer { flex: 1; }
.type-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.type-card:hover { border-color: var(--primary); }
.type-card.selected { border-color: var(--primary); box-shadow: var(--ring); }
.type-card input { margin-top: 3px; }
.type-card strong { display: block; }
.type-card small { display: block; color: var(--text-3); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.test-result { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.test-result .tr-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 600; }
.test-result.ok .tr-head { background: var(--success-soft); color: var(--success); }
.test-result.bad .tr-head { background: var(--danger-soft); color: var(--danger); }
.test-result .tr-body { padding: 12px 14px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 10px; }
.fields-cloud { display: flex; flex-wrap: wrap; gap: 4px; }
.fields-cloud code { font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); }
.sync-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.sync-stats div { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.sync-stats span { display: block; font-size: 11.5px; color: var(--text-3); }
.sync-stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .35s ease; }
.progress.indeterminate span { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }

/* ---------------------------------------------------------- settings */

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.side-tabs { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.side-tab {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; border: 0; background: none;
  color: var(--text-2); font-weight: 550; text-align: left; cursor: pointer;
}
.side-tab:hover { background: var(--surface-3); color: var(--text); }
.side-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.status-item:last-child { border-bottom: 0; }
.status-item.archived { opacity: .6; }
.status-item .order { display: flex; flex-direction: column; }
.status-item .order button { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 0; height: 14px; display: grid; place-items: center; }
.status-item .order button:hover { color: var(--text); }
.status-item .order .icon { width: 14px; height: 14px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.status-flags { display: flex; gap: 4px; flex-wrap: wrap; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.color-dot.selected { box-shadow: 0 0 0 2px var(--text); }
.code-box {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); font-family: var(--mono); font-size: 12.5px; word-break: break-all;
}
.code-box code { flex: 1; min-width: 0; }
.sys-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sys-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.sys-item span { display: block; font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.sys-item strong { font-size: 14px; }

/* ------------------------------------------------------------- auth */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside {
  position: relative; overflow: hidden; padding: 44px 52px; display: flex; flex-direction: column; justify-content: space-between; color: #dbe2f0;
  background: radial-gradient(900px 500px at 10% -10%, rgba(99, 102, 241, .45), transparent 60%),
              radial-gradient(700px 480px at 110% 110%, rgba(14, 165, 233, .28), transparent 60%), #0b1224;
}
.auth-aside .brand { border: 0; padding: 0; height: auto; }
.auth-hero h1 { color: #fff; font-size: 34px; line-height: 1.15; letter-spacing: -.025em; max-width: 460px; }
.auth-hero p { margin-top: 14px; color: #aab5cc; font-size: 15px; max-width: 440px; line-height: 1.6; }
.auth-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth-points li { display: flex; align-items: center; gap: 10px; color: #cdd6e8; font-size: 14px; }
.auth-points .icon { color: #a5b4fc; width: 18px; height: 18px; }
.auth-card-demo {
  width: min(360px, 100%); padding: 16px; border-radius: 16px; background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1); backdrop-filter: blur(6px); box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
}
.auth-card-demo .row { gap: 12px; }
.auth-card-demo .demo-lines span { display: block; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .16); margin-top: 7px; }
.auth-card-demo .demo-pills { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.auth-card-demo .demo-pills span { font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: #e2e8f0; }
.auth-card-demo .demo-pills span.on { background: rgba(74, 222, 128, .18); color: #86efac; }
.auth-foot { font-size: 12.5px; color: #7f8bb0; }
.auth-main { display: grid; place-items: center; padding: 40px 22px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 24px; letter-spacing: -.02em; }
.auth-card .lead-text { color: var(--text-2); margin: 6px 0 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-mobile-brand { display: none; margin-bottom: 26px; }

.install-wrap { max-width: 820px; margin: 0 auto; padding: 40px 20px 60px; }
.install-steps { display: flex; gap: 8px; margin: 18px 0 22px; flex-wrap: wrap; }
.install-steps span { font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.install-steps span.on { background: var(--primary); color: #fff; }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.req-list li { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 13.5px; }
.req-list .ok { color: var(--success); }
.req-list .bad { color: var(--danger); }

/* ------------------------------------------------------- responsive */

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .leads-table .col-date { display: none; }
}
@media (max-width: 1100px) {
  .grid-3-1 { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .side-tabs { position: static; flex-direction: row; overflow-x: auto; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-overlay.show { display: block; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-mobile-brand .brand { color: var(--text); padding: 0; height: auto; border: 0; }
}
@media (max-width: 760px) {
  .content { padding: 18px 14px 40px; }
  h1 { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 24px; }
  .global-search kbd { display: none; }
  .form-grid, .kv, .check-list, .type-grid, .sys-grid, .req-list { grid-template-columns: minmax(0, 1fr); }
  .toolbar .select { flex: 1 1 140px; max-width: none; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .toolbar-right .select { flex: 1; }
  .modal-backdrop { padding: 12px 8px; align-items: flex-end; }
  .modal { border-radius: 16px; }
  .sync-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .platform-grid { grid-template-columns: minmax(0, 1fr); }
  .fu-item { grid-template-columns: 70px minmax(0, 1fr); }
  .fu-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }

  /* Leads table becomes a stack of cards. */
  .leads-table thead { display: none; }
  .leads-table, .leads-table tbody { display: block; }
  .leads-table tbody tr {
    display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px 10px; padding: 14px 14px 14px 12px; border-bottom: 1px solid var(--border);
  }
  .leads-table.no-check tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  .leads-table tbody td { display: block; padding: 0; border: 0; background: none !important; }
  .leads-table .col-check { grid-column: 1; grid-row: 1 / span 3; width: auto; padding-top: 10px; }
  .leads-table .col-lead { grid-column: 2; grid-row: 1; }
  .leads-table .col-actions { grid-column: 3; grid-row: 1; width: auto; }
  .leads-table .col-phone { grid-column: 2 / 4; grid-row: 2; }
  .leads-table .col-status { grid-column: 2 / 4; grid-row: 3; }
  .leads-table.no-check .col-lead { grid-column: 1; }
  .leads-table.no-check .col-actions { grid-column: 2; }
  .leads-table.no-check .col-phone, .leads-table.no-check .col-status { grid-column: 1 / 3; }
  .leads-table .col-assigned, .leads-table .col-followup, .leads-table .col-date { display: none; }
  .leads-table .lead-cell { min-width: 0; }
  .leads-table .lead-sub { flex-wrap: wrap; white-space: normal; }
  .leads-table .email-sub { max-width: none; }
  .m-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
  .m-meta .due { font-size: 12.5px; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
