/* ─────────────────────────────────────────────────────────────
   CADENCE — dark ops console
   Palette: validated against surface #14161a (dataviz six checks)
   ───────────────────────────────────────────────────────────── */

/* ── theme tokens ──────────────────────────────────────────
   Dark is the working default for an ops console; light is a
   designed counterpart, not an inversion. The toggle wins over
   the OS in both directions and is remembered per browser.     */
:root {
  color-scheme: dark;

  --plane:        #0b0c0f;
  --surface-1:    #14161a;
  --surface-2:    #191c21;
  --surface-3:    #21252c;
  --hairline:     rgba(255, 255, 255, 0.08);
  --hairline-2:   rgba(255, 255, 255, 0.14);
  --overlay:      rgba(4, 5, 7, 0.66);

  --text-primary:   #f4f5f7;
  --text-secondary: #a8adb8;
  --text-muted:     #6f7681;

  /* entity → colour (global; a hue means the same thing in every chart) */
  --c-dials:     #3987e5;   /* blue    — volume */
  --c-answered:  #199e70;   /* aqua    — connected */
  --c-talk:      #d95926;   /* orange  — long conversations */
  --c-voicemail: #c98500;   /* yellow  */
  --c-busy:      #d55181;   /* magenta */
  --c-noanswer:  #9085e9;   /* violet  */
  --c-failed:    #e66767;   /* red     */

  --good:     #0ca30c;
  --warning:  #fab219;
  --critical: #d03b3b;

  --grid:     #22262c;
  --axis:     #32373f;
  --chart-surface: #14161a;
  --line-faint: rgba(255,255,255,.045);
  --tooltip-bg: #0a0b0e;
  --ink-answered: #4fd6a4;
  --ink-voicemail: #e0ab45;
  --ink-failed: #f08c8c;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  /* straight from the wordmark */
  --brand-cyan: #00AEEF;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --plane:        #f4f5f7;
    --surface-1:    #ffffff;
    --surface-2:    #f7f8fa;
    --surface-3:    #eceef2;
    --hairline:     rgba(16, 20, 28, 0.09);
    --hairline-2:   rgba(16, 20, 28, 0.16);
    --overlay:      rgba(20, 24, 32, 0.42);
    --text-primary:   #11151b;
    --text-secondary: #4c5563;
    --text-muted:     #79818f;
    --c-dials:     #2a78d6;
    --c-answered:  #1baf7a;
    --c-talk:      #eb6834;
    --c-voicemail: #b57900;
    --c-busy:      #cf5a86;
    --c-noanswer:  #4a3aa7;
    --c-failed:    #d43f3e;
    --good:        #0a8f0a;
    --warning:     #b57900;
    --critical:    #c0332f;
    --grid:        #e6e8ec;
    --axis:        #cdd2d9;
    --chart-surface: #ffffff;
    --line-faint: rgba(16,20,28,.06);
    --tooltip-bg: #ffffff;
    --ink-answered: #0f7a55;
    --ink-voicemail: #8a5c00;
    --ink-failed: #a5302f;
    --shadow: 0 1px 2px rgba(16,22,30,.07), 0 10px 30px rgba(16,22,30,.10);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --plane:        #f4f5f7;
  --surface-1:    #ffffff;
  --surface-2:    #f7f8fa;
  --surface-3:    #eceef2;
  --hairline:     rgba(16, 20, 28, 0.09);
  --hairline-2:   rgba(16, 20, 28, 0.16);
  --overlay:      rgba(20, 24, 32, 0.42);
  --text-primary:   #11151b;
  --text-secondary: #4c5563;
  --text-muted:     #79818f;
  --c-dials:     #2a78d6;
  --c-answered:  #1baf7a;
  --c-talk:      #eb6834;
  --c-voicemail: #b57900;
  --c-busy:      #cf5a86;
  --c-noanswer:  #4a3aa7;
  --c-failed:    #d43f3e;
  --good:        #0a8f0a;
  --warning:     #b57900;
  --critical:    #c0332f;
  --grid:        #e6e8ec;
  --axis:        #cdd2d9;
  --chart-surface: #ffffff;
  --line-faint: rgba(16,20,28,.06);
  --tooltip-bg: #ffffff;
  --ink-answered: #0f7a55;
  --ink-voicemail: #8a5c00;
  --ink-failed: #a5302f;
  --shadow: 0 1px 2px rgba(16,22,30,.07), 0 10px 30px rgba(16,22,30,.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--c-dials); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--hairline-2); border-radius: 8px; border: 2px solid var(--plane); }
::-webkit-scrollbar-track { background: transparent; }

/* ── shell ───────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
/* align-items matters here: a column flexbox stretches its children across the
   cross axis by default, which pulled the wordmark to the full sidebar width
   while its height stayed fixed — the logo rendered twice as wide as it is. */
.brand { display: flex; flex-direction: column; align-items: flex-start;
         gap: 7px; padding: 6px 8px 20px; }
/* the wordmark ships in two inks; the theme decides which one is in the flow */
.logo { display: block; align-self: flex-start; height: 26px; width: auto;
        max-width: 100%; object-fit: contain; }
:root[data-theme="light"] .on-dark, :root[data-theme="dark"] .on-light { display: none; }
.brand-sub { font-size: 10px; color: var(--text-muted); letter-spacing: .12em; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text-secondary); cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--surface-3); color: var(--text-primary); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; opacity: .85; flex: none; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--text-secondary);
  padding: 1px 7px; border-radius: 20px;
}
.nav-group { font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); padding: 16px 11px 6px; }
.me-chip {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 6px; cursor: pointer; color: inherit; transition: background .12s, border-color .12s;
}
.me-chip:hover { background: var(--surface-2); border-color: var(--hairline); }
.me-chip b { display: block; font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip span span, .me-chip > span > span { font-size: 11px; color: var(--text-muted); }
.role-card { border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 12px 14px; margin-bottom: 9px; background: var(--surface-2); }
.role-card h4 { margin: 0 0 3px; font-size: 13.5px; }
.role-card p { margin: 0 0 8px; font-size: 12.5px; color: var(--text-secondary); }
.role-caps { display: flex; flex-wrap: wrap; gap: 5px; }
.role-caps span { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted);
  background: var(--surface-3); border-radius: 4px; padding: 2px 6px; }
.sidebar-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--hairline); }

.main { display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 22px; border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; }
.topbar .spacer { flex: 1; }

.engine-pill {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 20px; padding: 5px 13px 5px 10px; font-size: 12.5px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.dot.live { background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,.7); animation: pulse 1.8s infinite; }
.dot.paused { background: var(--warning); }
.dot.error { background: var(--critical); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(12,163,12,.55); }
  70% { box-shadow: 0 0 0 8px rgba(12,163,12,0); }
  100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); }
}

/* ── controls ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--hairline-2);
  color: var(--text-primary); padding: 7px 13px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); border-color: var(--hairline-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--c-dials); border-color: transparent; color: #fff; }
.btn-primary:hover { background: #4b93ea; }
.btn-good { background: var(--good); border-color: transparent; color: #04170a; font-weight: 650; }
.btn-good:hover { background: #10b810; }
.btn-warn { background: transparent; border-color: rgba(250,178,25,.5); color: var(--warning); }
.btn-danger { background: transparent;
  border-color: color-mix(in srgb, var(--critical) 50%, transparent); color: var(--ink-failed); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: var(--r-sm); }
.btn-icon svg { width: 16px; height: 16px; }

/* one icon system: 24px grid, 1.5px stroke, no fills */
.ico { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none;
       stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 20px; height: 20px; }

/* day / night */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .sun, .theme-toggle .moon {
  transition: transform .3s cubic-bezier(.4,.1,.3,1), opacity .2s;
}
:root[data-theme="light"] .theme-toggle .moon,
:root:not([data-theme="dark"]) .theme-toggle .moon { opacity: 1; transform: none; }
.theme-toggle .sun { position: absolute; inset: 0; margin: auto; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }
.input, select.input, textarea.input {
  background: var(--surface-2); border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm); padding: 7px 10px; outline: none; min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--c-dials); box-shadow: 0 0 0 3px rgba(57,135,229,.18); }
select.input { cursor: pointer; }
.input-sm { padding: 5px 8px; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 11px; border-radius: 20px; font-size: 12.5px;
  border: 1px solid var(--hairline-2); background: var(--surface-2);
  color: var(--text-secondary); user-select: none; transition: all .12s;
}
.chip:hover { border-color: var(--hairline-2); color: var(--text-primary); }
.chip.on { background: var(--surface-3); color: var(--text-primary); border-color: var(--hairline-2); }
.chip .swatch { width: 8px; height: 8px; border-radius: 2px; }

/* ── page & cards ────────────────────────────────────────── */
.page { padding: 20px 22px 60px; display: none; }
.page.active { display: block; }
.grid { display: grid; gap: 14px; }
.card {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 16px; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.card-sub { font-size: 11.5px; color: var(--text-muted); }
.card-head .spacer { flex: 1; }

/* KPI tiles — value first, movement second, explanation on demand */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1500px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 15px 16px 13px; position: relative;
  display: grid; grid-template-rows: auto auto auto; gap: 3px;
  cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit;
  transition: border-color .14s, background .14s, transform .1s;
}
.kpi:hover { border-color: var(--hairline-2); background: var(--surface-2); }
.kpi:active { transform: translateY(1px); }
.kpi:focus-visible { outline: 2px solid var(--c-dials); outline-offset: 2px; }
.kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-label {
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .08em; font-weight: 600;
}
.kpi-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--kpi-accent, var(--text-muted)); flex: none; }
.kpi-info { margin-left: auto; color: var(--text-muted); opacity: 0; transition: opacity .14s; }
.kpi:hover .kpi-info, .kpi:focus-visible .kpi-info { opacity: 1; }
.kpi-info svg { width: 14px; height: 14px; display: block; }
.kpi-value {
  font-size: 28px; font-weight: 660; line-height: 1.05; letter-spacing: -.02em;
  display: flex; align-items: baseline; gap: 3px;
}
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.kpi-foot { display: flex; align-items: center; gap: 9px; min-height: 20px; }
.kpi-meta { font-size: 11.5px; color: var(--text-secondary); }
.kpi-delta {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.kpi-delta.up { color: var(--good); }
.kpi-delta.down { color: var(--critical); }
.kpi-delta.flat { color: var(--text-muted); }
.kpi-spark { margin-left: auto; width: 68px; height: 22px; flex: none; }
.kpi-spark svg { display: block; width: 100%; height: 100%; }

/* explanation card behind every metric */
.explain h4 { margin: 0 0 6px; font-size: 14px; }
.explain dl { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; margin: 14px 0 0; font-size: 13.5px; }
.explain dt { color: var(--text-muted); }
.explain dd { margin: 0; color: var(--text-secondary); }
.explain .formula {
  font-family: var(--mono); font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 9px 11px; color: var(--text-primary); margin-top: 14px;
}

/* tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 600; padding: 8px 10px;
  border-bottom: 1px solid var(--hairline); white-space: nowrap; position: sticky; top: 0;
  background: var(--surface-1); z-index: 1;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text-secondary); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-faint); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", monospace; font-size: 12.5px; }
.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* status tags — colour never travels alone: every tag carries its label */
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 2px 9px 2px 7px; border-radius: 20px;
  background: var(--surface-3); color: var(--text-secondary); white-space: nowrap;
}
.tag .swatch { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.tag.answered  .swatch { background: var(--c-answered); }
.tag.voicemail .swatch { background: var(--c-voicemail); }
.tag.busy      .swatch { background: var(--c-busy); }
.tag.no_answer .swatch { background: var(--c-noanswer); }
.tag.failed    .swatch { background: var(--c-failed); }
.tag.in_progress .swatch { background: var(--c-dials); animation: pulse 1.6s infinite; }
.tag.interested { background: color-mix(in srgb, var(--c-answered) 18%, transparent); color: var(--ink-answered); }
.tag.callback { background: color-mix(in srgb, var(--c-voicemail) 18%, transparent); color: var(--ink-voicemail); }
.tag.not_interested, .tag.dnc { background: color-mix(in srgb, var(--c-failed) 16%, transparent); color: var(--ink-failed); }

/* quick review controls */
.mark-btn {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  border: 1px solid var(--hairline-2); background: var(--surface-2);
  color: var(--text-secondary); border-radius: 20px; padding: 3px 10px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; transition: all .12s;
}
.mark-btn:hover { border-color: var(--c-answered); color: var(--ink-answered); }
.mark-btn.on {
  background: color-mix(in srgb, var(--c-answered) 18%, transparent);
  border-color: color-mix(in srgb, var(--c-answered) 55%, transparent); color: var(--ink-answered);
}
.mark-btn svg { width: 12px; height: 12px; }

.outcome-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.outcome-picker .chip.on { border-color: var(--c-answered); }
.note-box {
  width: 100%; min-height: 82px; resize: vertical; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm); padding: 9px 11px; outline: none;
}
.note-box:focus { border-color: var(--c-dials); box-shadow: 0 0 0 3px rgba(57,135,229,.18); }
.review-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  color: var(--ink-answered); background: color-mix(in srgb, var(--c-answered) 15%, transparent);
  padding: 2px 9px; border-radius: 20px;
}

.empty { padding: 46px 20px; text-align: center; color: var(--text-muted); }
.empty svg { width: 34px; height: 34px; opacity: .35; margin-bottom: 10px; }

/* ── top bar identity ────────────────────────────────────── */
.top-profile {
  display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px;
  border-radius: 20px; border: 1px solid var(--hairline); background: var(--surface-2);
  cursor: pointer; color: inherit; transition: border-color .14s, background .14s;
}
.top-profile:hover { border-color: var(--hairline-2); background: var(--surface-3); }
.top-profile .who { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.top-profile .who b { font-size: 12.5px; font-weight: 600; }
.top-profile .who span { font-size: 10.5px; color: var(--text-muted); }
@media (max-width: 1200px) { .top-profile .who { display: none; } }

.bell { position: relative; }
.bell-dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c-talk); border: 1.5px solid var(--surface-1);
}
.notif-panel {
  position: fixed; top: 62px; right: 18px; width: min(380px, calc(100vw - 24px)); z-index: 55;
  background: var(--surface-1); border: 1px solid var(--hairline-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(-6px); transition: opacity .16s, transform .16s;
}
.notif-panel.open { opacity: 1; pointer-events: auto; transform: none; }
.notif-head { display: flex; align-items: center; gap: 10px; padding: 13px 15px;
              border-bottom: 1px solid var(--hairline); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif { display: flex; gap: 11px; padding: 11px 15px; border-bottom: 1px solid var(--line-faint); }
.notif:last-child { border-bottom: 0; }
.notif .dot { margin-top: 6px; }
.notif b { display: block; font-size: 13px; font-weight: 600; }
.notif span { font-size: 12px; color: var(--text-secondary); }
.notif time { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); margin-left: auto; }

/* ── explainer ───────────────────────────────────────────────────────────── */
.explainer .steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 900px) { .explainer .steps { grid-template-columns: 1fr; } }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step-n {
  flex: none; width: 25px; height: 25px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-secondary);
}
.step b { font-size: 13px; }
.step p { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.explainer-note:not(:empty) {
  margin-top: 16px; padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--hairline-2); background: var(--surface-2);
  font-size: 12.5px; color: var(--text-secondary);
}

/* ── segmented switch ────────────────────────────────────────────────────── */
.seg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.segmented {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 11px;
}
.segmented .seg {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px;
  border: 0; background: transparent; color: var(--text-secondary); cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 500; border-radius: 8px;
  transition: background .15s, color .15s;
}
.segmented .seg:hover { color: var(--text-primary); }
.segmented .seg.on { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.18); }

/* ── funnel ──────────────────────────────────────────────────────────────── */
.funnel-row { display: flex; align-items: center; gap: 11px; padding: 6px 0; }
.funnel-label { width: 118px; font-size: 12.5px; color: var(--text-secondary); }
.funnel-bar { flex: 1; height: 9px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: var(--c-answered); border-radius: 5px; }
.funnel-n { width: 34px; text-align: right; font-size: 12px; }
.funnel-foot { display: flex; gap: 16px; margin-top: 12px; padding-top: 11px;
               border-top: 1px solid var(--hairline); font-size: 12px; color: var(--text-secondary); }

.cap-editor { max-height: 46vh; overflow-y: auto; margin-top: 6px; padding-right: 4px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl tr.dim td { opacity: .5; }

.profile-head { display: flex; align-items: center; gap: 16px; }
.cap-group { border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 12px 14px;
             margin-bottom: 9px; background: var(--surface-2); }
.cap-group h4 { margin: 0 0 2px; font-size: 13px; }
.cap-group p { margin: 0 0 9px; font-size: 12px; color: var(--text-muted); }
.cap-row { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 12.5px; }
.cap-row input { width: 15px; height: 15px; accent-color: var(--c-dials); cursor: pointer; }
.cap-row.has { color: var(--text-primary); }
.cap-row.hasnt { color: var(--text-muted); }
.cap-row .mark { width: 14px; text-align: center; font-size: 12px; }

/* ── loading ─────────────────────────────────────────────────
   A drop of fuel filling, in the brand cyan. It only appears once a
   fetch has been slow enough to notice, so quick pages never flash.  */
.page-loader {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.page-loader.on { opacity: 1; pointer-events: auto; }

/* Everything is centred on one column. The mark used to sit inside a block as
   wide as the caption, which pushed it off to the left of its own text. */
.loader-inner {
  display: flex; flex-direction: column; align-items: center;
  transform: translateY(6px) scale(.96); opacity: .5;
  transition: transform .26s cubic-bezier(.2,.7,.3,1), opacity .26s;
}
.page-loader.on .loader-inner { transform: none; opacity: 1; }

.loader-mark { width: 104px; height: 104px; overflow: visible; display: block; }

.loader-orbit {
  fill: none; stroke: var(--brand-cyan); stroke-width: 1.5; opacity: .35;
  stroke-dasharray: 3 12; stroke-linecap: round;
  transform-origin: 60px 60px;
  animation: orbit 7s linear infinite;
}
@keyframes orbit { to { transform: rotate(360deg); } }

/* the drop is a steady outline — never a dash that can be caught mid-draw
   looking like a broken shape */
.loader-drop {
  fill: color-mix(in srgb, var(--brand-cyan) 8%, transparent);
  stroke: var(--brand-cyan); stroke-width: 2.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--brand-cyan) 35%, transparent));
}

/* the liquid: a wave that travels sideways, on a body that rises and falls */
.loader-liquid { fill: var(--brand-cyan); opacity: .85; }
.loader-lift { animation: lift 2.6s cubic-bezier(.45,0,.55,1) infinite alternate; }
@keyframes lift {
  from { transform: translateY(74px); }
  to   { transform: translateY(-6px); }
}

.loader-brand {
  margin-top: 20px; font-size: 19px; font-weight: 700; letter-spacing: -.01em;
  color: var(--text-primary); line-height: 1;
}
.loader-brand b { color: var(--brand-cyan); font-weight: 700; }

.loader-note {
  margin-top: 7px; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--text-muted);
}

/* an indeterminate rail: it says "working", never a false percentage */
.loader-track {
  margin-top: 16px; width: 132px; height: 2px; border-radius: 2px;
  background: var(--surface-3); overflow: hidden;
}
.loader-track i {
  display: block; width: 40%; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--brand-cyan) 20%, transparent), var(--brand-cyan));
  animation: rail 1.15s cubic-bezier(.65,0,.35,1) infinite;
}
@keyframes rail {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

@media (prefers-reduced-motion: reduce) {
  .loader-orbit, .loader-lift, .loader-track i { animation: none; }
  .loader-lift { transform: translateY(30px); }
}

/* the thin line across the top, for the fast ones */
.top-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--brand-cyan), color-mix(in srgb, var(--brand-cyan) 40%, transparent));
  z-index: 60; opacity: 0; transition: width .2s ease-out, opacity .25s;
  box-shadow: 0 0 10px color-mix(in srgb, var(--brand-cyan) 60%, transparent);
}
.top-progress.on { opacity: 1; }

/* skeletons, so a table does not jump when it fills */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ── experiments ─────────────────────────────────────────── */
.verdict { display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px;
           border-radius: var(--r-md); border: 1px solid var(--hairline); background: var(--surface-2); }
.verdict .badge { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.verdict.clear .badge { background: color-mix(in srgb, var(--c-answered) 18%, transparent); color: var(--ink-answered); }
.verdict.leaning .badge { background: color-mix(in srgb, var(--c-voicemail) 18%, transparent); color: var(--ink-voicemail); }
.verdict.tie .badge, .verdict.early .badge { background: var(--surface-3); color: var(--text-secondary); }
.verdict p { margin: 0; font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.verdict b { color: var(--text-primary); }
.bar-compare { display: flex; align-items: center; gap: 8px; }
.bar-compare .track { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-compare .track i { display: block; height: 100%; background: var(--c-dials); }

/* ── coach ───────────────────────────────────────────────── */
.finding { border: 1px solid var(--hairline); border-radius: var(--r-md);
           background: var(--surface-2); margin-bottom: 10px; overflow: hidden; }
.finding-head { display: flex; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer; }
.finding-head:hover { background: var(--surface-3); }
.finding-bar { height: 5px; background: var(--surface-3); }
.finding-bar i { display: block; height: 100%; background: var(--c-failed); }
.finding-count { font-family: var(--mono); font-size: 18px; font-weight: 650; min-width: 46px; }
.finding-share { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); min-width: 48px; }
.finding-label { flex: 1; font-size: 13.5px; font-weight: 550; }
.finding-body { display: none; padding: 0 15px 15px; }
.finding.open .finding-body { display: block; }
.finding-why { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin: 4px 0 12px; }
.finding pre {
  font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap;
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 12px; margin: 0; color: var(--text-primary); overflow-x: auto;
}
.example { display: flex; gap: 9px; align-items: baseline; padding: 5px 0; font-size: 12.5px; cursor: pointer; }
.example:hover .said { color: var(--text-primary); }
.example .said { color: var(--text-secondary); }
.opener { display: flex; align-items: baseline; gap: 9px; padding: 5px 0; font-size: 12.5px; }
.opener .n { font-family: var(--mono); font-size: 11px; color: var(--text-muted); min-width: 22px; }

/* ── deal board ──────────────────────────────────────────── */
.board { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px;
         align-items: start; overflow-x: auto; padding-bottom: 8px; }
@media (max-width: 1280px) { .board { grid-template-columns: repeat(3, minmax(230px, 1fr)); } }
@media (max-width: 820px)  { .board { grid-template-columns: 1fr; } }
.column { background: var(--surface-2); border: 1px solid var(--hairline);
          border-radius: var(--r-lg); padding: 11px; min-height: 150px;
          transition: border-color .14s, background .14s; }
.column.drop { border-color: var(--c-dials);
               background: color-mix(in srgb, var(--c-dials) 8%, var(--surface-2)); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.column-head b { font-size: 12.5px; font-weight: 640; }
.column-head .n { font-family: var(--mono); font-size: 11px; color: var(--text-muted); margin-left: auto; }
.stage-dot { width: 7px; height: 7px; border-radius: 50%; }
.deal {
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 11px 12px; margin-bottom: 9px; cursor: grab;
  transition: border-color .14s, transform .08s;
}
.deal:hover { border-color: var(--hairline-2); }
.deal:active { cursor: grabbing; transform: scale(.995); }
.deal.dragging { opacity: .45; }
.deal b { display: block; font-size: 13px; font-weight: 620; }
.deal .co { font-size: 11.5px; color: var(--text-muted); margin-top: 1px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal .meta { display: flex; align-items: center; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.deal .due { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); }
.deal .due.late { color: var(--critical); font-weight: 600; }
.deal .who { font-size: 10.5px; color: var(--text-secondary); margin-left: auto; }
.column .empty { padding: 16px 8px; font-size: 12px; }

/* ── live calls: who is on the line and what is being said ─ */
.live-list { display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.live-row {
  display: flex; flex-direction: column; gap: 8px; padding: 11px 12px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: var(--r-md); animation: slide-in .25s ease-out; cursor: pointer;
  transition: border-color .14s;
}
.live-row:hover { border-color: var(--hairline-2); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.live-top { display: flex; align-items: center; gap: 11px; }
.live-row .who { min-width: 0; flex: 1; }
.live-row .who b { display: block; font-weight: 600; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-row .who span { font-size: 11.5px; color: var(--text-muted); }

/* the conversation, as it happens */
.live-feed {
  display: flex; flex-direction: column; gap: 5px; max-height: 132px; overflow: hidden;
  border-top: 1px solid var(--hairline); padding-top: 8px;
  mask-image: linear-gradient(transparent, #000 22px);
}
.live-turn { font-size: 12.5px; line-height: 1.45; display: flex; gap: 7px;
             animation: turn-in .22s ease-out; }
.live-turn i {
  font-style: normal; font-family: var(--mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); flex: none; width: 34px; padding-top: 2px;
}
.live-turn.agent i { color: var(--c-dials); }
.live-turn.customer i { color: var(--c-answered); }
.live-turn p { margin: 0; color: var(--text-secondary); }
.live-turn.customer p { color: var(--text-primary); }
@keyframes turn-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.live-waiting { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.live-waiting b { width: 4px; height: 4px; border-radius: 50%; background: var(--text-muted);
                  animation: blink-dot 1.2s infinite; }
.live-waiting b:nth-child(2) { animation-delay: .2s; }
.live-waiting b:nth-child(3) { animation-delay: .4s; }
@keyframes blink-dot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.wave { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.wave i { width: 2.5px; background: var(--c-answered); border-radius: 2px; animation: wv .9s ease-in-out infinite; }
.wave i:nth-child(1) { height: 40%; animation-delay: 0s; }
.wave i:nth-child(2) { height: 85%; animation-delay: .12s; }
.wave i:nth-child(3) { height: 60%; animation-delay: .24s; }
.wave i:nth-child(4) { height: 100%; animation-delay: .36s; }
@keyframes wv { 0%,100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }

/* ── charts ──────────────────────────────────────────────── */
.chart-host { position: relative; width: 100%; }
.chart-host svg { display: block; width: 100%; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 9px; height: 9px; border-radius: 2px; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 40; opacity: 0;
  background: var(--tooltip-bg); border: 1px solid var(--hairline-2); border-radius: var(--r-sm);
  padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); transition: opacity .1s;
  min-width: 120px;
}
.tooltip .t-title { font-weight: 600; margin-bottom: 5px; font-size: 11.5px; color: var(--text-secondary); }
.tooltip .t-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; }

/* ── sheet: the one way detail opens, centred and large ──── */
.sheet {
  position: fixed; z-index: 51; inset: 0; margin: auto;
  width: min(1080px, calc(100vw - 48px));
  height: min(860px, calc(100vh - 56px));
  background: var(--surface-1); border: 1px solid var(--hairline-2);
  border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(10px) scale(.99);
  transition: opacity .18s ease, transform .18s cubic-bezier(.2,.75,.3,1);
}
.sheet.open { opacity: 1; pointer-events: auto; transform: none; }
@media (max-width: 720px) {
  .sheet { width: 100vw; height: 100vh; border-radius: 0; border: 0; }
}

.sheet-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 22px 15px; border-bottom: 1px solid var(--hairline);
  background: var(--surface-1);
}
.sheet-avatar {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 650; font-size: 16px;
  background: var(--surface-3); color: var(--text-secondary);
  object-fit: cover; overflow: hidden;
}
.sheet-title { font-size: 18px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.sheet-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.sheet-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.sheet-head .spacer { flex: 1; }

.sheet-tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--hairline);
              background: var(--surface-1); }
.sheet-tab {
  border: 0; background: none; color: var(--text-muted); cursor: pointer;
  padding: 10px 13px; font-size: 13px; font-weight: 550; position: relative;
}
.sheet-tab:hover { color: var(--text-primary); }
.sheet-tab.on { color: var(--text-primary); }
.sheet-tab.on::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--c-dials); border-radius: 2px;
}
.sheet-body { flex: 1; overflow-y: auto; padding: 20px 22px 26px; }
.sheet-pane { display: none; }
.sheet-pane.on { display: block; }
.sheet-cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 900px) { .sheet-cols { grid-template-columns: 1fr; } }
.sheet-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 22px; border-top: 1px solid var(--hairline); background: var(--surface-2);
}

.block { border: 1px solid var(--hairline); border-radius: var(--r-md);
         background: var(--surface-2); padding: 14px 16px; margin-bottom: 14px; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-fields label { display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.row-fields .input { text-transform: none; letter-spacing: normal; font-size: 13.5px;
  color: var(--text-primary); }
.block-title { font-size: 12px; font-weight: 640; letter-spacing: .04em; text-transform: uppercase;
               color: var(--text-muted); margin-bottom: 10px; }

/* expandable charts */
.chart-expand { position: fixed; z-index: 51; inset: 0; margin: auto;
  width: min(1240px, calc(100vw - 48px)); height: min(760px, calc(100vh - 56px));
  background: var(--surface-1); border: 1px solid var(--hairline-2); border-radius: 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none; transform: scale(.99); transition: opacity .18s, transform .18s; }
.chart-expand.open { opacity: 1; pointer-events: auto; transform: none; }
.chart-expand .body { flex: 1; padding: 20px 24px 26px; overflow: auto; }
.btn-expand { opacity: .5; transition: opacity .14s; }
.card:hover .btn-expand { opacity: 1; }

/* ── drawer & modal ──────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .18s;
  backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface-1); border-left: 1px solid var(--hairline);
  z-index: 51; transform: translateX(100%); transition: transform .22s cubic-bezier(.3,.8,.4,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: 10px; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal {
  position: fixed; z-index: 52; left: 50%; top: 50%; transform: translate(-50%, -46%) scale(.98);
  width: min(560px, calc(100% - 32px)); max-height: 86vh; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s;
}
.modal.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.kv { display: grid; grid-template-columns: 118px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.transcript { display: flex; flex-direction: column; gap: 9px; }
.bubble { padding: 9px 12px; border-radius: 12px; max-width: 88%; font-size: 13px; line-height: 1.5; }
.bubble.ai { background: var(--surface-3); border-bottom-left-radius: 3px; }
.bubble.human { background: color-mix(in srgb, var(--c-dials) 16%, transparent); align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble .role { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 3px; }

.dropzone {
  border: 1.5px dashed var(--hairline-2); border-radius: var(--r-md);
  padding: 26px; text-align: center; color: var(--text-secondary); cursor: pointer;
  transition: border-color .14s, background .14s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--c-dials); background: rgba(57,135,229,.07); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface-3); border: 1px solid var(--hairline-2); border-left: 3px solid var(--c-dials);
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow);
  animation: slide-in .2s ease-out; max-width: 340px;
}
.toast.err { border-left-color: var(--critical); }
.toast.ok { border-left-color: var(--good); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font-size: 12.5px; color: var(--text-secondary); }
.bar-track { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--c-dials); transition: width .3s; }

.progress-lines { display: flex; flex-direction: column; gap: 11px; }
.progress-line .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 520px at 50% -8%, rgba(57,135,229,.13), transparent 62%), var(--plane); }
.login-card { width: min(380px, 100%); background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 16px; padding: 30px; box-shadow: var(--shadow); }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 10px; }
  .sidebar .nav-group, .sidebar-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
}
