/* styles.css  Artisoft Asistente design system.
   One stylesheet, no build step. Every color is a token so the dark theme is a
   value swap on :root[data-theme="dark"], never a second set of rules.
   Spec: docs/design/README.md */

/* ---------- fonts (self-hosted, no CDN) ---------- */

/* One variable face covers 400-600 for the UI text. */
@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/assets/fonts/ibm-plex-sans-var.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
/* Mono ships as three static weights: case IDs, node IDs, clock times, KPI
   numerals, keycaps and uppercase eyebrows. Never body copy. */
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/assets/fonts/ibm-plex-mono-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/assets/fonts/ibm-plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/assets/fonts/ibm-plex-mono-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */

:root {
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* chrome and canvas */
  --chrome: #1C1A19;
  --chrome-line: rgba(255, 255, 255, 0);
  --chrome-fill: rgba(255, 255, 255, 0.05);
  --chrome-border: rgba(255, 255, 255, 0.14);
  --chrome-text: rgba(255, 255, 255, 0.82);
  --chrome-muted: rgba(255, 255, 255, 0.6);
  --chrome-faint: rgba(255, 255, 255, 0.25);
  --chrome-track: rgba(255, 255, 255, 0.08);
  --chrome-avatar: #3B3734;

  --bg: #FBFAF9;
  --panel: #FFFFFF;
  --panel-2: #F7F6F4;
  --panel-3: #F5F4F2;
  --panel-alt: #FDFCFB;
  --raised: #FFFFFF;

  --line: #DDD8D2;
  --line-soft: #E6E3DF;
  --line-softest: #EFECE8;
  --line-strong: #C9C3BC;
  --line-dashed: #D6D1CB;

  --text: #1C1917;
  --text-body: #292524;
  --muted: #57534E;
  --muted-2: #78716C;
  --muted-3: #A8A29E;

  /* accent: actions only */
  --accent: #EB5D28;
  --accent-hover: #D9521F;
  --accent-ink: #B4530B;
  --accent-wash: #FCF0E6;
  --accent-hl: #FDEEE6;
  --on-accent: #FFFFFF;
  --keycap-on-accent: rgba(255, 255, 255, 0.18);

  /* semantic */
  --ok: #0F7B5F;
  --ok-wash: #E9F5F0;
  --ok-solid: #0F7B5F;
  --on-ok: #FFFFFF;
  --info: #0E6B93;          /* the say-this panel surface */
  --info-ink: #0E6B93;      /* the same blue as text or an edit affordance */
  --info-label: rgba(255, 255, 255, 0.72);
  --live: #34D399;

  /* elevation and rings */
  --shadow-1: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-soft: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-raise: 0 1px 2px rgba(28, 25, 23, 0.04), 0 14px 34px rgba(28, 25, 23, 0.07);
  --shadow-primary: 0 1px 2px rgba(28, 25, 23, 0.12), 0 4px 12px rgba(235, 93, 40, 0.28);
  --ring: 0 0 0 3px rgba(235, 93, 40, 0.10);
  --ring-strong: 0 0 0 3px rgba(235, 93, 40, 0.12);
  --scrim: rgba(28, 25, 23, 0.55);

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
}

:root[data-theme="dark"] {
  --chrome: #0C0B0A;
  --chrome-line: #2A2724;
  --chrome-fill: rgba(255, 255, 255, 0.04);
  --chrome-border: #35312E;
  --chrome-text: #C8C2BC;
  --chrome-muted: #A8A29E;
  --chrome-faint: rgba(255, 255, 255, 0.22);
  --chrome-track: rgba(255, 255, 255, 0.07);
  --chrome-avatar: #3B3734;

  --bg: #131211;
  --panel: #1B1A18;
  --panel-2: #161514;
  --panel-3: #35312E;
  --panel-alt: #1F1E1C;
  --raised: #232120;

  --line: #2A2724;
  --line-soft: #2A2724;
  --line-softest: #232120;
  --line-strong: #4A443F;
  --line-dashed: #524B45;

  --text: #F7F5F3;
  --text-body: #EDE9E5;
  --muted: #C8C2BC;
  --muted-2: #A8A29E;
  --muted-3: #9A938D;

  --accent-ink: #F0A87C;
  --accent-wash: rgba(235, 93, 40, 0.14);
  --accent-hl: rgba(235, 93, 40, 0.22);
  --keycap-on-accent: rgba(255, 255, 255, 0.22);

  --ok: #6EE7B7;
  --ok-wash: rgba(63, 161, 132, 0.16);
  --ok-solid: #1F4D40;
  --on-ok: #EAFBF4;
  --info: #0E4C68;
  --info-ink: #7FC7E8;
  --info-label: #7FC7E8;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-raise: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px rgba(0, 0, 0, 0.45);
  --shadow-primary: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(235, 93, 40, 0.3);
  --scrim: rgba(8, 7, 7, 0.66);
}

/* Theme switching must not cross-fade while a call is live. */
:root.no-transition *,
:root.no-transition *::before,
:root.no-transition *::after { transition: none !important; }

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

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
#app { display: flex; flex-direction: column; height: 100vh; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: inherit;
}

h1, h2, h3, h4, p { margin: 0; }

/* ---------- type helpers ---------- */

.h1 { font-size: 26px; line-height: 1.18; font-weight: 600; letter-spacing: -0.022em; color: var(--text); }
.h2 { font-size: 16px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.card-title { font-size: 15px; line-height: 1.4; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.body { font-size: 13.5px; line-height: 1.55; }
.body-lg { font-size: 19px; line-height: 1.35; font-weight: 500; letter-spacing: -0.01em; }
.meta { font-size: 12.5px; line-height: 1.5; color: var(--muted-2); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-3);
}
.eyebrow-lg { font-size: 11px; letter-spacing: 0.13em; }
.eyebrow-accent { color: var(--accent-ink); }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.muted-3 { color: var(--muted-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }

/* ---------- top bar ---------- */

.topbar {
  flex: 0 0 auto;
  height: 56px;
  background: var(--chrome);
  border-bottom: 1px solid var(--chrome-line);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px 0 24px;
}
.tb-logo { display: flex; align-items: center; gap: 9px; background: none; border: 0; padding: 0; color: inherit; }
.tb-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
}
.tb-word { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.tb-word span { color: var(--muted-2); font-weight: 400; }
.tb-crumbs { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: rgba(255, 255, 255, 0.55); }
.tb-crumbs .sep { color: var(--chrome-faint); }
.tb-crumbs .current { color: #fff; font-weight: 500; }
.crumb-link {
  background: none; border: 0; padding: 0;
  color: inherit; font-size: 13.5px; font-family: inherit;
  transition: color 120ms var(--ease);
}
.crumb-link:hover { color: #fff; }
.tb-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: rgba(255, 255, 255, 0.62); }
.tb-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--live); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}
.tb-dot.is-off { background: var(--accent); box-shadow: 0 0 0 3px rgba(235, 93, 40, 0.18); }
.tb-div { width: 1px; height: 22px; background: var(--chrome-border); }
.tb-btn {
  height: 32px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 12px; border: 1px solid var(--chrome-border); border-radius: 8px;
  background: transparent; color: var(--chrome-text);
  font-size: 13px; transition: background-color 120ms var(--ease);
}
.tb-btn:hover { background: rgba(255, 255, 255, 0.07); }
.tb-btn .keycap { color: var(--chrome-muted); border-color: var(--chrome-border); }
.tb-btn-light {
  height: 32px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 13px; border: 0; border-radius: 8px;
  background: #fff; color: #1C1A19; font-size: 13px; font-weight: 600;
}
.tb-btn-light:hover { background: #F2EFEC; }
.tb-icon {
  background: transparent; border: 0; color: rgba(255, 255, 255, 0.55);
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.tb-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.tb-icon svg { width: 16px; height: 16px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--chrome-avatar); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  flex: 0 0 auto;
}
.lang-chip {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--chrome-muted); background: transparent;
  border: 1px solid var(--chrome-border); border-radius: 6px; padding: 3px 7px;
  transition: color 120ms var(--ease), background-color 120ms var(--ease);
}
.lang-chip:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.theme-toggle {
  display: flex; gap: 2px; padding: 2px;
  border-radius: 999px; background: var(--chrome-track);
  border: 0;
}
.theme-seg {
  width: 26px; height: 22px; border: 0; border-radius: 999px; padding: 0;
  background: transparent; color: rgba(255, 255, 255, 0.45);
  display: flex; align-items: center; justify-content: center;
}
.theme-seg svg { width: 13px; height: 13px; }
.theme-seg.is-active { background: var(--bg); color: var(--chrome); }
:root[data-theme="dark"] .theme-seg { color: rgba(255, 255, 255, 0.4); }
:root[data-theme="dark"] .theme-seg.is-active { background: #3B3734; color: #fff; }

/* in-call live pill: no timer inside it */
.live-pill {
  display: inline-flex; align-items: center; gap: 11px;
  height: 34px; padding: 0 12px;
  background: rgba(235, 93, 40, 0.12);
  border: 1px solid rgba(235, 93, 40, 0.34);
  border-radius: 8px;
  font-size: 13px; font-weight: 500; color: #fff;
}
.live-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px rgba(235, 93, 40, 0.8);
}
.live-pill .live-sep { width: 1px; height: 14px; background: rgba(255, 255, 255, 0.22); }
.live-pill .live-timer {
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  min-width: 42px; color: #fff;
}

/* ---------- page shell ---------- */

.view { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.view.is-fixed { overflow: hidden; display: flex; flex-direction: column; }
.page { padding: 28px 32px; }
.page-tight { padding: 26px 32px; }
.col { max-width: 1116px; margin: 0 auto; }
.split { display: grid; gap: 26px; align-items: start; }
.split-340 { grid-template-columns: 1fr 340px; }
.split-320 { grid-template-columns: 1fr 320px; gap: 36px; }
.split-316 { grid-template-columns: 1fr 316px; }
.split-372 { grid-template-columns: 1fr 372px; gap: 36px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }

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

.btn {
  height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--panel); color: var(--text-body);
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.btn:disabled { opacity: 0.55; }
.btn-primary {
  background: var(--accent); color: var(--on-accent);
  font-weight: 600; box-shadow: var(--shadow-primary);
  padding-right: 8px; padding-left: 14px;
}
.btn-primary:not(:has(.keycap)) { padding-right: 14px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { border-color: var(--line); background: var(--panel); color: var(--text-body); }
.btn-secondary:hover:not(:disabled) { background: var(--panel-2); }
.btn-emphasis { border-color: var(--line-strong); background: var(--panel); color: var(--text-body); font-weight: 600; }
.btn-emphasis:hover:not(:disabled) { background: var(--panel-2); }
.btn-dark { height: 32px; background: var(--chrome); color: #fff; border-color: var(--chrome); }
:root[data-theme="dark"] .btn-dark { background: var(--panel-3); border-color: var(--line-strong); }
.btn-dark:hover:not(:disabled) { opacity: 0.9; }
.btn-sm { height: 32px; font-size: 13px; padding: 0 12px; }
.btn-34 { height: 34px; font-size: 13px; padding: 0 12px; }
.btn-38 { height: 38px; }
.btn-full { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: 9px;
  border-color: var(--line); background: var(--panel); color: var(--muted);
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover:not(:disabled) { background: var(--panel-2); }
.btn-icon-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-icon-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-icon.is-rec { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-quiet {
  height: auto; padding: 0; border: 0; background: none;
  color: var(--muted-2); font-size: 13px; font-weight: 400;
}
.btn-quiet:hover { color: var(--text); }
.btn-link {
  height: auto; padding: 0; border: 0; background: none;
  color: var(--info-ink); font-size: 12.5px; font-weight: 400; text-align: left;
  display: inline-flex; align-items: flex-start; justify-content: flex-start; gap: 7px;
}
.btn-link svg { margin-top: 2px; }
.btn-link svg { width: 13px; height: 13px; }
.btn-link:hover { text-decoration: underline; }
.btn-under {
  height: auto; padding: 0; border: 0; background: none;
  color: var(--muted-2); font-size: 12px;
  text-decoration: underline; text-decoration-color: var(--line-dashed); text-underline-offset: 2px;
}
.btn-under:hover { color: var(--text); }

.keycap {
  font-family: var(--font-mono); font-size: 11px; font-weight: 400; line-height: 1.35;
  color: var(--muted-3); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: 1px 5px;
}
.keycap-solid {
  border-color: transparent; background: var(--keycap-on-accent);
  color: var(--on-accent); padding: 2px 6px;
}
.keycap-bare { border: 0; padding: 0; }
.keycap-right { margin-left: auto; }

/* ---------- inputs ---------- */

.input {
  width: 100%; height: 40px;
  padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-body);
  font-size: 14px;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.input::placeholder { color: var(--muted-3); }
.input:focus { outline: none; border-color: var(--line-strong); box-shadow: var(--ring); }
.input-36 { height: 36px; border-radius: 8px; font-size: 13.5px; }
.input-44 { height: 44px; border-radius: 10px; font-size: 15px; }
.textarea {
  width: 100%; border: 0; background: transparent; color: var(--text-body);
  font-size: 16px; line-height: 1.55; resize: none;
  padding: 16px 18px 6px; min-height: 112px; display: block;
}
.textarea:focus { outline: none; }
.textarea::placeholder { color: var(--muted-3); }

/* ---------- surfaces ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-1);
}
.card-quiet { background: var(--panel-2); border-color: var(--line-soft); box-shadow: none; }
.card-plain { box-shadow: none; border-color: var(--line-soft); }
.card-pad { padding: 15px 16px; }
.card-pad-lg { padding: 16px 18px; }
.raise { box-shadow: var(--shadow-raise); }

.mono-chip {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 400;
  color: var(--text-body); background: var(--panel-3);
  border-radius: 6px; padding: 3px 7px;
}
.mono-chip-500 { font-weight: 500; }
.mono-chip-outline { background: var(--panel-3); border: 1px solid var(--line-soft); font-size: 11.5px; padding: 3px 8px; }
.mono-chip-dark { background: var(--chrome); color: #fff; font-weight: 500; font-size: 12.5px; padding: 4px 8px; }
:root[data-theme="dark"] .mono-chip-dark { background: var(--text-body); color: var(--bg); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500; border-radius: 999px; padding: 4px 10px;
  white-space: nowrap;
  background: var(--panel-3); color: var(--muted-2); border: 1px solid transparent;
}
.pill svg { width: 12px; height: 12px; }
.pill-ok { color: var(--ok); background: var(--ok-wash); }
.pill-warn { color: var(--accent-ink); background: var(--accent-wash); }
.pill-dashed { color: var(--muted-2); background: transparent; border: 1px dashed var(--line-dashed); font-weight: 400; padding: 3px 10px; }
.pill-dashed:hover { border-color: var(--line-strong); background: var(--panel-2); }
.pill-sm { font-size: 11.5px; padding: 2px 8px; }

/* severity always reads as a word */
.sev-alta { color: var(--accent-ink); background: var(--accent-wash); }
.sev-media { color: var(--muted-2); background: var(--panel-3); }
.sev-baja { color: var(--ok); background: var(--ok-wash); }

/* ---------- KPI strip (hairline grid, no accent rules) ---------- */

.kpi-strip {
  display: grid; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.kpi-cell { background: var(--panel); padding: 15px 18px; }
.kpi-cell-sm { padding: 12px 15px; }
.kpi-label { font-size: 12.5px; color: var(--muted-2); margin-bottom: 6px; }
.kpi-row { display: flex; align-items: baseline; gap: 8px; }
.kpi-num {
  font-family: var(--font-mono); font-size: 27px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--text);
}
.kpi-num-sm { font-size: 15px; font-weight: 500; letter-spacing: 0; }
.kpi-num.is-ok { color: var(--ok); }
.kpi-num.is-warn { color: var(--accent-ink); }
.kpi-delta { font-size: 12px; color: var(--muted-2); }
.kpi-delta.is-ok { color: var(--ok); }

/* ---------- data table ---------- */

.dtable {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-1);
}
.dtable-head {
  display: grid; gap: 14px; padding: 9px 16px;
  background: var(--panel-2); border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-3);
}
.dtable-row {
  display: grid; gap: 14px; padding: 12px 16px; align-items: center;
  border-bottom: 1px solid var(--line-softest);
  background: var(--panel); text-align: left; width: 100%;
  border-left: 0; border-right: 0; border-top: 0;
  color: inherit; font: inherit;
  transition: background-color 120ms var(--ease);
}
.dtable-row:nth-of-type(even) { background: var(--panel-alt); }
.dtable-row:last-child { border-bottom: 0; }
.dtable-row.is-clickable:hover { background: var(--panel-alt); box-shadow: inset 0 0 0 1px var(--line-strong); }
.dtable-time { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted-2); }
.dtable-text { font-size: 13.5px; color: var(--text-body); }
.dtable-num { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted-2); text-align: right; }
.cell-start { justify-self: start; }

/* Home: Hora | Caso | Reporte | Durac. | Resultado */
.cols-calls { grid-template-columns: 62px 104px 1fr 66px 210px; }
/* Base: Caso | Titulo | Familia | Severidad | Nodos */
.cols-base { grid-template-columns: 100px 1fr 128px 92px 74px; gap: 16px; padding-left: 18px; padding-right: 18px; }
/* Usuarios: Usuario | Rol | Estado | Acciones */
.cols-users { grid-template-columns: 1fr 150px 100px 260px; }

/* ---------- filter chips ---------- */

.chip-filter {
  height: 30px; display: inline-flex; align-items: center; gap: 7px;
  padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-body);
  font-size: 12.5px;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.chip-filter:hover { background: var(--panel-2); border-color: var(--line-strong); }
.chip-filter .count { font-family: var(--font-mono); font-size: 11px; color: var(--muted-3); }
.chip-filter.is-active {
  background: var(--chrome); border-color: var(--chrome); color: #fff; font-weight: 500;
}
:root[data-theme="dark"] .chip-filter.is-active { background: var(--text-body); border-color: var(--text-body); color: var(--bg); }
.chip-filter.is-active .count { color: rgba(255, 255, 255, 0.55); }
:root[data-theme="dark"] .chip-filter.is-active .count { color: rgba(0, 0, 0, 0.45); }

/* suggestion chips */
.chip-sug {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--text-body);
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.chip-sug:hover { background: var(--panel-2); border-color: var(--line-strong); }
.chip-sug .n { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-3); }

/* ---------- option cards (Resolver, and in-call branches) ---------- */

.opt-card {
  display: grid; grid-template-columns: 30px 1fr 184px; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px;
  padding: 16px 18px; text-align: left; width: 100%;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.opt-card:hover { background: var(--panel-alt); border-color: var(--line-strong); }
:root[data-theme="dark"] .opt-card:hover { background: var(--raised); }
.opt-card.is-rank1 { border-color: var(--line-strong); box-shadow: var(--ring), var(--shadow-1); }
.opt-index {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  background: var(--panel-3); border: 1px solid var(--line-soft); color: var(--muted);
}
.opt-card.is-rank1 .opt-index { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.opt-head { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.opt-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); margin-bottom: 4px; }
.opt-disc { font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.opt-disc b { font-weight: 600; color: var(--text); }
.opt-cta { display: flex; flex-direction: column; }
.opt-conf { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.opt-conf .label { font-size: 11.5px; color: var(--muted-2); }
.opt-conf .value { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.opt-conf .value.is-high { color: var(--accent-ink); }

/* in-call branch rows: 2-up grid of h52 cards */
.branch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.branch-card {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px; text-align: left;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-1);
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.branch-card:hover:not(:disabled) { background: var(--panel-alt); border-color: var(--accent); }
:root[data-theme="dark"] .branch-card:hover:not(:disabled) { background: var(--panel-3); }
.branch-card:disabled { opacity: 0.55; }
.branch-key {
  width: 24px; height: 24px; flex: 0 0 auto; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  background: var(--panel-3); border: 1px solid var(--line-soft); color: var(--muted);
}
.branch-label { font-size: 15px; font-weight: 500; flex: 1; color: var(--text); }
.branch-target { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-3); }

/* ---------- the blue "read this out loud" panel ---------- */

.say-panel {
  background: var(--info); color: #fff;
  border-radius: 12px; padding: 16px 18px;
}
.say-panel-lg { padding: 18px 20px; }
.say-label {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--info-label); margin-bottom: 8px;
}
.say-label svg { width: 13px; height: 13px; }
.say-line { font-size: 19px; line-height: 1.35; font-weight: 500; letter-spacing: -0.01em; }
.say-opts { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.say-opt {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  width: 100%; cursor: pointer;
  background: rgba(255, 255, 255, 0.12); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 9px;
  padding: 9px 12px; transition: background 0.12s ease, border-color 0.12s ease;
}
.say-opt:hover { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.55); }
.say-opt-label { font-size: 14px; font-weight: 500; line-height: 1.3; }
.say-opt-issue {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.02em;
  opacity: 0.82;
}
.say-none {
  margin-top: 10px; background: none; border: none; cursor: pointer;
  color: rgba(255, 255, 255, 0.85); font-size: 12px; text-decoration: underline;
  text-underline-offset: 2px; padding: 2px 0;
}
.say-none:hover { color: #fff; }

/* admin data-management view */
textarea.mono { font-family: var(--font-mono); }
.inline-ok {
  display: inline-flex; align-items: center; gap: 8px;
  color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0;
  padding: 8px 12px; border-radius: 8px; font-size: 13.5px;
}
.inline-ok svg { width: 15px; height: 15px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
@media (max-width: 640px) { .admin-grid { grid-template-columns: 1fr; } }

/* ---------- in-call workspace ---------- */

.call-body { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 316px; min-height: 0; }
.call-main { display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--panel); }
.call-rail {
  border-left: 1px solid var(--line-soft); background: var(--bg);
  padding: 22px 20px; overflow-y: auto; min-height: 0;
}
.step-strip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  background: var(--panel); border-bottom: 1px solid var(--line-soft);
  padding: 14px 32px; box-shadow: var(--shadow-soft);
  position: sticky; top: 0; z-index: 2;
}
.step-badge {
  flex: 0 0 auto; white-space: nowrap;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--on-accent); background: var(--accent);
  border-radius: 5px; padding: 3px 8px;
}
/* The strip stays one line: the badge and the pills keep their size and the title
   gives way, since the say-this panel repeats it in full right underneath. */
.step-title {
  font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em; color: var(--text);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.step-strip > .eyebrow, .step-strip > .pill, .step-strip > .meta { flex: 0 0 auto; white-space: nowrap; }
.call-scroll { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 24px 32px 28px; }
.call-foot {
  flex: 0 0 auto; border-top: 1px solid var(--line-soft);
  padding: 14px 32px 16px; background: var(--bg);
}
.answer-row { display: flex; gap: 9px; align-items: center; }
.grounding-note {
  display: flex; align-items: center; gap: 7px;
  margin-top: 9px; font-size: 11.5px; color: var(--muted-3);
}
.grounding-note svg { width: 12px; height: 12px; flex: 0 0 auto; }
.step-enter { animation: step-in 140ms var(--ease) both; }
@keyframes step-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* the SOP step body: what to do, then when it applies */
.sop-card { padding: 16px 18px; margin-bottom: 22px; }
.sop-single { font-size: 14.5px; line-height: 1.55; color: var(--text); }
.sop-list {
  margin: 0; padding-left: 0; list-style: none;
  display: flex; flex-direction: column; gap: 9px;
  counter-reset: sop;
}
.sop-list li {
  position: relative; padding-left: 28px;
  font-size: 14.5px; line-height: 1.5; color: var(--text);
}
.sop-list:not(.is-plain) li::before {
  counter-increment: sop;
  content: counter(sop);
  position: absolute; left: 0; top: 1px;
  width: 19px; height: 19px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  background: var(--panel-3); border: 1px solid var(--line-soft); color: var(--muted);
}
/* a body that numbers its own steps keeps them, so we only need the hanging indent */
.sop-list.is-plain li { padding-left: 0; }
.sop-arrow { color: var(--muted-3); }
.sop-ref { font-family: var(--font-mono); font-size: 0.92em; color: var(--muted); }
.sop-when {
  display: flex; gap: 9px; align-items: baseline;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft);
  font-size: 12.5px; line-height: 1.55; color: var(--muted-2);
}
.sop-when-label {
  flex: 0 0 auto;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-3);
}

.note-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 15px; }
.note-head {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 7px;
}
.wisdom-card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 14px 15px; box-shadow: var(--shadow-soft);
}
.wisdom-text { font-size: 13.5px; line-height: 1.55; color: var(--text); margin-bottom: 9px; }
.wisdom-text b { font-weight: 600; }
.wisdom-tag { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted-3); }
.wisdom-tag .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

/* history disclosure above the step */
.hist-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 32px; border-bottom: 1px solid var(--line-softest);
  background: var(--bg); color: var(--muted-2); font-size: 13px;
  width: 100%; text-align: left; border-top: 0; border-left: 0; border-right: 0;
}
.hist-bar svg { width: 14px; height: 14px; color: var(--muted-3); transition: transform 120ms var(--ease); }
.hist-bar.is-open svg { transform: rotate(180deg); }
.hist-list { padding: 14px 32px; border-bottom: 1px solid var(--line-softest); background: var(--bg); }

/* ---------- route map (in-call rail + detail) ---------- */

.route-step { display: grid; grid-template-columns: 20px 1fr; gap: 11px; }
.route-marker { display: flex; flex-direction: column; align-items: center; }
.route-dot {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--ok-solid); color: var(--on-ok);
}
.route-dot svg { width: 11px; height: 11px; }
.route-dot.is-now { background: var(--accent); box-shadow: 0 0 0 4px rgba(235, 93, 40, 0.16); }
.route-dot.is-todo { background: transparent; border: 1.5px dashed var(--line-strong); }
.route-line { width: 1.5px; flex: 1; background: var(--line); margin: 4px 0; }
.route-node { padding-bottom: 16px; }
.route-id { font-family: var(--font-mono); font-size: 11px; color: var(--muted-3); margin-bottom: 3px; }
.route-id.is-now { color: var(--accent); font-weight: 500; }
.route-text { font-size: 13px; line-height: 1.4; color: var(--muted); margin-bottom: 4px; }
.route-text.is-now { font-size: 13.5px; font-weight: 600; color: var(--text); }
.route-answer { font-size: 12px; font-weight: 500; color: var(--ok); }
.route-answer .hint { font-size: 10.5px; color: var(--muted-3); font-weight: 400; }
.route-step.is-todo { opacity: 0.5; }

/* path chips (call detail) */
.path-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; font-size: 13px; color: var(--text-body);
}
.path-chip .id { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted-2); }
.path-chip.is-end { background: var(--ok-wash); border-color: var(--ok); color: var(--ok); font-weight: 500; }
.path-chip.is-end .id { color: inherit; }
.path-arrow { color: var(--line-strong); display: inline-flex; }
.path-arrow svg { width: 14px; height: 14px; }

/* ---------- transcript (call detail) ---------- */

.turn { display: grid; grid-template-columns: 82px 1fr; gap: 16px; }
.turn-gutter {
  text-align: right; padding-top: 2px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-3);
}
.turn-gutter.is-guide { color: var(--info-ink); }
/* Transcript gutter rule, not a card accent: neutral, and the spec allows it. */
.turn-body { font-size: 14px; line-height: 1.6; border-left: 2px solid var(--line-soft); padding-left: 15px; }

/* ---------- segmented control ---------- */

.seg { display: flex; gap: 3px; padding: 3px; background: var(--panel-3); border: 1px solid var(--line-soft); border-radius: 9px; }
.seg-item {
  flex: 1; height: 30px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 12.5px;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 120ms var(--ease);
}
.seg-item:hover { background: var(--panel-alt); }
.seg-item.is-active { background: var(--chrome); color: #fff; font-weight: 600; }
.seg-item.is-active.is-ok { background: var(--ok-solid); color: var(--on-ok); }
.seg-item.is-active.is-warn { background: var(--accent-ink); color: #fff; }
:root[data-theme="dark"] .seg-item.is-active { background: var(--line-strong); color: var(--text); }
:root[data-theme="dark"] .seg-item.is-active.is-warn { background: var(--accent-ink); color: var(--bg); }

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

.modal-back {
  position: fixed; inset: 0; background: var(--scrim);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.modal-back.is-open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-raise);
}
.modal-wide { max-width: 1000px; height: 100%; }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--panel-2);
}

/* ---------- states ---------- */

.inline-error {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; line-height: 1.5; color: var(--accent-ink);
}
.inline-error svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }
.inline-error .btn { margin-left: auto; flex: 0 0 auto; }
.error-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.empty-state { font-size: 13px; line-height: 1.6; color: var(--muted-2); }
.empty-state .btn { margin-top: 12px; }

.skel { background: var(--panel-3); border-radius: 8px; animation: skel 1.4s ease-in-out infinite; }
.skel-row { height: 44px; margin-bottom: 1px; }
.skel-card { height: 78px; border-radius: 12px; margin-bottom: 9px; }
.skel-line { height: 13px; }
@keyframes skel { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--muted-2); font-size: 13px; }
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: 0.35;
  animation: thinking-bounce 1.25s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes thinking-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .thinking-dots span, .skel, .step-enter { animation: none; }
  .thinking-dots span { opacity: 0.6; }
}

/* ---------- highlight of the customer's literal words ---------- */

.hl { background: var(--accent-hl); border-radius: 3px; padding: 0 3px; color: var(--text); }

/* ---------- rendered assistant answers (markdown-lite) ---------- */

.md-answer { font-size: 14px; line-height: 1.6; color: var(--text-body); }
.md-answer p { margin: 0 0 10px; }
.md-answer p:last-child { margin-bottom: 0; }
.md-answer .md-list { margin: 4px 0 10px; padding-left: 20px; }
.md-answer .md-list li { margin: 3px 0; }
.md-answer .md-list:last-child { margin-bottom: 0; }
.md-answer code {
  background: var(--panel-3); border: 1px solid var(--line-soft);
  border-radius: 5px; padding: 1px 5px;
  font-size: 12.5px; font-family: var(--font-mono);
}
.md-answer strong { font-weight: 600; }

/* ---------- login ---------- */

.login-screen {
  flex: 1; min-height: 100vh;
  display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--panel);
}
.login-brand {
  position: relative; overflow: hidden;
  background: var(--chrome); color: #fff;
  border-right: 1px solid var(--chrome-line);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px;
}
.login-brand::before {
  content: ""; position: absolute; top: -20%; left: -10%; width: 70%; height: 70%;
  background: radial-gradient(closest-side, rgba(235, 93, 40, 0.28), rgba(235, 93, 40, 0));
  filter: blur(8px); pointer-events: none;
}
.login-brand::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(135deg, #000 0%, transparent 70%);
  -webkit-mask-image: linear-gradient(135deg, #000 0%, transparent 70%);
  pointer-events: none;
}
.login-brand-inner { position: relative; margin-top: auto; margin-bottom: 32px; max-width: 420px; }
.login-logo { display: block; height: 48px; width: auto; margin-bottom: 40px; }
.login-headline { font-size: 34px; line-height: 1.14; font-weight: 600; letter-spacing: -0.024em; margin: 0 0 16px; }
.login-tagline { font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, 0.62); margin: 0; max-width: 380px; }
.login-brand-foot {
  position: relative; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 255, 255, 0.4);
}
.login-form-panel { display: flex; align-items: center; justify-content: center; padding: 48px 40px; }
.login-form-wrap { width: 100%; max-width: 360px; }
.login-eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 10px;
}
.login-title { font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -0.022em; margin: 0 0 8px; }
.login-lede { font-size: 14px; line-height: 1.55; color: var(--muted); margin: 0 0 28px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.login-field input {
  width: 100%; height: 44px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text-body); font-size: 15px;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.login-field input::placeholder { color: var(--muted-3); }
.login-field input:focus { outline: none; border-color: var(--line-strong); box-shadow: var(--ring-strong); }
.login-submit { width: 100%; height: 44px; margin-top: 8px; font-size: 15px; }
.login-error { color: var(--accent-ink); font-size: 13px; margin-top: 14px; min-height: 18px; }

@media (max-width: 820px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 28px 28px; min-height: auto; }
  .login-brand-inner { margin-top: 0; }
  .login-logo { height: 38px; margin-bottom: 22px; }
  .login-headline { font-size: 24px; }
  .login-tagline, .login-brand-foot { display: none; }
  .login-form-panel { padding: 32px 28px 48px; }
}

/* ---------- decision-tree overlay (Mermaid, unchanged behavior) ---------- */

.tree-modal-back {
  position: fixed; inset: 0; background: var(--scrim);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
.tree-modal-back.open { display: flex; }
.tree-modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  max-width: 1000px; width: 100%; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-raise);
}
.tree-modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.tree-modal-title { font-weight: 600; font-size: 15px; color: var(--text); }
.tree-modal-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.tree-modal-actions button {
  background: var(--panel); border: 1px solid var(--line); color: var(--text-body);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; min-width: 34px;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease);
}
.tree-modal-actions button:hover { background: var(--panel-2); border-color: var(--line-strong); }
.tree-modal-body { overflow: auto; padding: 14px 18px; cursor: grab; }
.tree-modal-body.grabbing { cursor: grabbing; user-select: none; }
.tree-zoom-wrap svg { max-width: none; height: auto; }
.tree-node { border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; margin: 8px 0; background: var(--panel-2); }
.tree-node-focus { border-color: var(--line-strong); background: var(--accent-wash); }
.tree-node-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 13.5px; }
