/* Design tokens and shared components. Mobile first.
   Area styles live in site.css, app.css (portal + ops) and built.css. Use these tokens there. */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-700.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-condensed-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-condensed-700.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 800; font-style: normal; font-display: swap; src: url("/public/fonts/barlow-condensed-800.woff2") format("woff2"); }

:root {
  /* ink (asphalt) */
  --ink-950: #0c0d0f;
  --ink-900: #131518;
  --ink-800: #1c1f23;
  --ink-700: #2a2e34;
  --ink-600: #3d424a;
  --ink-500: #5a606a;
  --ink-400: #838993;
  --ink-300: #b3b7be;
  --ink-200: #d7d9dd;
  /* paper (job ticket) */
  --paper: #faf8f4;
  --paper-2: #f3efe7;
  --paper-3: #ebe5d9;
  --card: #ffffff;
  --line: #e6e0d4;
  --line-strong: #cfc7b7;
  /* signal amber: the light that is on */
  --accent: #ffb000;
  --accent-hi: #ffc53d;
  --accent-600: #e89b00;
  --accent-700: #9a6400; /* amber text on paper: 4.7:1 */
  --accent-ink: #1a1300;
  --accent-soft: #fff4d6;
  /* status */
  --ok: #1c8a4b;
  --ok-soft: #e2f4e9;
  --warn: #b25c05;
  --warn-soft: #fdecd4;
  --danger: #c5301d;
  --danger-soft: #fbe5e0;
  --info: #4a4f57;
  --info-soft: #eceae3;

  /* semantic */
  --bg: var(--paper);
  --surface: var(--card);
  --text: var(--ink-900);
  --text-2: var(--ink-600);
  --muted: var(--ink-500);
  --border: var(--line);

  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", Impact, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --shadow-sm: 0 1px 2px rgba(19, 21, 24, 0.06), 0 1px 1px rgba(19, 21, 24, 0.04);
  --shadow: 0 2px 6px rgba(19, 21, 24, 0.06), 0 10px 24px -12px rgba(19, 21, 24, 0.18);
  --shadow-lg: 0 24px 60px -24px rgba(19, 21, 24, 0.35), 0 4px 12px rgba(19, 21, 24, 0.08);

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --container: 1120px;
}

/* dark surfaces (site hero, ops console header, night sections) */
.dark {
  --bg: var(--ink-900);
  --surface: var(--ink-800);
  --text: #f5f2ea;
  --text-2: #c9c5ba;
  --muted: #9b9a94;
  --border: #33373d;
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; height: auto; }
svg.icon { flex: none; vertical-align: -0.18em; }
a { color: inherit; text-decoration-color: var(--accent-600); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3, h4 { margin: 0 0 0.4em; line-height: 1.08; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.005em; }
h1 { font-size: clamp(2.3rem, 8.5vw, 4.4rem); font-weight: 800; text-wrap: balance; }
h2 { font-size: clamp(1.8rem, 5.5vw, 2.9rem); text-wrap: balance; }
h3 { font-size: 1.45rem; }
h4 { font-size: 1.15rem; font-family: var(--font); font-weight: 600; line-height: 1.3; }
p { margin: 0 0 1em; }
small, .small { font-size: 0.86rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s-4); }
.container-narrow { max-width: 760px; }
.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.stack-lg > * + * { margin-top: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.between { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; justify-content: space-between; }
.grid { display: grid; gap: var(--s-4); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--s-4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.section { padding: var(--s-7) 0; }
@media (min-width: 800px) { .section { padding: var(--s-8) 0; } }
.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.95rem; color: var(--accent-700); }
.dark .eyebrow { color: var(--accent); }
.lead { font-size: 1.2rem; color: var(--text-2); }
.hide-mobile { display: none; }
@media (min-width: 800px) { .hide-mobile { display: revert; } .show-mobile { display: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons: a body you can press ---------- */
.btn {
  --btn-bg: var(--ink-800);
  --btn-bg-2: var(--ink-900);
  --btn-fg: #fff;
  --btn-edge: #000;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  font: 700 1.02rem/1.1 var(--font); letter-spacing: 0.01em;
  color: var(--btn-fg); text-decoration: none; text-align: center;
  background: linear-gradient(180deg, var(--btn-bg), var(--btn-bg-2));
  border: 1px solid var(--btn-edge); border-radius: var(--r);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 3px 0 var(--btn-edge), 0 6px 14px -6px rgba(0, 0, 0, 0.45);
  cursor: pointer; user-select: none; transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 1px 0 var(--btn-edge), 0 2px 6px -4px rgba(0, 0, 0, 0.4); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent-hi); --btn-bg-2: var(--accent); --btn-fg: var(--accent-ink); --btn-edge: var(--accent-700); }
.btn-danger { --btn-bg: #d9412d; --btn-bg-2: var(--danger); --btn-fg: #fff; --btn-edge: #7e1d10; }
.btn-ok { --btn-bg: #25a25b; --btn-bg-2: var(--ok); --btn-fg: #fff; --btn-edge: #0f5a2f; }
.btn-ghost { --btn-fg: var(--text); background: var(--surface); border-color: var(--line-strong); box-shadow: 0 2px 0 var(--line-strong); }
.btn-ghost:active { box-shadow: 0 0 0 var(--line-strong); }
.dark .btn-ghost { background: transparent; border-color: #4a4f57; box-shadow: 0 2px 0 #000; }
.btn-lg { min-height: 58px; padding: 14px 28px; font-size: 1.18rem; border-radius: 14px; }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: 0.92rem; border-radius: 10px; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 2px 0 var(--btn-edge); }
.btn-block { display: flex; width: 100%; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent-600); text-underline-offset: 3px; cursor: pointer; box-shadow: none; }

/* ---------- forms ---------- */
label, .label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="number"], input[type="url"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px;
  font: 500 16px/1.4 var(--font); color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235a606a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-800); box-shadow: 0 0 0 3px var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--ink-900); vertical-align: -4px; margin-right: 8px; }
.field { margin-bottom: var(--s-4); }
.field-row { display: grid; gap: var(--s-3); grid-template-columns: 1fr; }
@media (min-width: 640px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field-error { color: var(--danger); font-size: 0.9rem; font-weight: 600; margin-top: 4px; }
.check { display: flex; align-items: flex-start; gap: 4px; font-weight: 500; padding: 8px 0; }
fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: var(--s-4); margin: 0 0 var(--s-4); }
legend { font-weight: 700; padding: 0 8px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-sm); }
.card-tight { padding: var(--s-4); }
.card-flush { padding: 0; overflow: hidden; }
.card-title { font-family: var(--font); font-weight: 700; font-size: 1.05rem; margin: 0 0 var(--s-3); display: flex; align-items: center; gap: 8px; }
.card-accent { border-top: 4px solid var(--accent); }
a.card { display: block; text-decoration: none; transition: transform 0.12s ease, box-shadow 0.12s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; line-height: 1.4; white-space: nowrap; background: var(--paper-3); color: var(--ink-700); }
.badge-ok { background: var(--ok-soft); color: #0e5c30; }
.badge-warn { background: var(--warn-soft); color: #7a3e00; }
.badge-danger { background: var(--danger-soft); color: #8f1f10; }
.badge-info { background: var(--info-soft); color: #34383f; }
.badge-accent { background: var(--accent-soft); color: #6b4500; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-300); }
.dot-ok { background: #2ebd69; box-shadow: 0 0 0 4px rgba(46, 189, 105, 0.18); }
.dot-warn { background: var(--accent); }
.dot-danger { background: var(--danger); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(46, 189, 105, 0.45); } 60% { box-shadow: 0 0 0 9px rgba(46, 189, 105, 0); } }
.dot-live { background: #2ebd69; animation: pulse 2s infinite; }
@media (prefers-reduced-motion: reduce) { .dot-live { animation: none; } html { scroll-behavior: auto; } }

/* ---------- stats ---------- */
.stats { display: grid; gap: var(--s-3); grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s-4); }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.9rem, 6vw, 2.5rem); line-height: 1.05; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.86rem; color: var(--muted); margin-top: 2px; }
.stat-accent { background: var(--ink-900); color: #fff; border-color: var(--ink-900); }
.stat-accent .stat-label, .stat-accent .stat-sub { color: #c9c5ba; }
.stat-accent .stat-value { color: var(--accent); }
.stat-danger .stat-value { color: var(--danger); }
.stat-ok .stat-value { color: var(--ok); }

/* ---------- tables: rows become cards on a phone ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--paper-2); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fffdf7; }
.table a.row-link { text-decoration: none; font-weight: 600; }
@media (max-width: 720px) {
  table.table-cards thead { display: none; }
  table.table-cards, table.table-cards tbody, table.table-cards tr, table.table-cards td { display: block; width: 100%; }
  table.table-cards tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.table-cards tr:last-child { border-bottom: 0; }
  table.table-cards td { padding: 2px 0; border: 0; }
  table.table-cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
  table.table-cards td.cell-main { font-weight: 700; font-size: 1.04rem; }
  table.table-cards td.cell-main::before { content: none; }
}

/* ---------- messages ---------- */
.flash { padding: 12px 16px; border-radius: var(--r); font-weight: 600; margin-bottom: var(--s-4); border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: #0e5c30; border-color: #bfe5cd; }
.flash-warn { background: var(--warn-soft); color: #7a3e00; border-color: #f3d3a2; }
.flash-error { background: var(--danger-soft); color: #8f1f10; border-color: #f2c2b9; }
.note { background: var(--accent-soft); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--muted); }
.empty h3 { color: var(--text); font-family: var(--font); font-size: 1.15rem; }
.empty-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--paper-2); display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--s-3); color: var(--ink-500); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4) 0; }

/* ---------- tiny charts ---------- */
.spark-line { stroke: var(--accent-600); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--accent-soft); stroke: none; }
.bars { display: flex; align-items: flex-end; gap: 4px; width: 100%; }
.bar-col { flex: 1; min-width: 0; text-align: center; }
.bar-stack { display: flex; flex-direction: column; justify-content: flex-end; border-radius: 6px 6px 0 0; overflow: hidden; }
.bar-fill { background: linear-gradient(180deg, var(--accent-hi), var(--accent-600)); min-height: 0; }
.bar-fill.bar-2 { background: linear-gradient(180deg, var(--ink-600), var(--ink-900)); }
.bar-label { font-size: 0.7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; }
.hbars { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: 10px; align-items: center; font-size: 0.95rem; }
.hbar-track { height: 14px; background: var(--paper-3); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-600), var(--accent-hi)); border-radius: 999px; }
.hbar-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- call player and transcript ---------- */
.player { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--ink-900); color: #fff; }
.player-none { background: var(--paper-2); color: var(--muted); font-size: 0.92rem; }
.player-btn { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--accent-ink); background: linear-gradient(180deg, var(--accent-hi), var(--accent)); box-shadow: 0 3px 0 var(--accent-700); }
.player-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-700); }
.player-track { flex: 1; height: 10px; background: #3a3f46; border-radius: 999px; cursor: pointer; position: relative; overflow: hidden; }
.player-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 999px; }
.player-time { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: #d7d3c8; min-width: 44px; text-align: right; }
.player audio { display: none; }
.transcript { list-style: none; margin: 0; padding: 14px; display: grid; gap: 10px; max-height: 520px; overflow-y: auto; }
.player-compact .transcript { max-height: 300px; }
.turn { display: grid; gap: 2px; max-width: 88%; padding: 10px 14px; border-radius: 16px; background: var(--paper-2); transition: background 0.2s ease, box-shadow 0.2s ease; }
.turn-agent { justify-self: start; border-bottom-left-radius: 4px; }
.turn-caller { justify-self: end; background: var(--ink-800); color: #fff; border-bottom-right-radius: 4px; }
.turn-who { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.65; }
.turn.is-active { box-shadow: 0 0 0 3px var(--accent); }
.turn.is-past { opacity: 0.6; }

/* ---------- small pieces ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--ink-800); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.95rem; flex: none; }
.kbd { font-family: var(--font-mono); background: var(--ink-900); color: var(--accent); padding: 4px 10px; border-radius: 8px; font-size: 1.05em; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: var(--s-4); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 0.95rem; text-decoration: none; background: var(--paper-2); color: var(--ink-700); border: 1px solid transparent; }
.tab.is-active { background: var(--ink-900); color: #fff; }
.tab .count { opacity: 0.7; font-weight: 500; margin-left: 4px; }
details.disclosure { border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
details.disclosure > summary { cursor: pointer; padding: 14px 16px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--muted); }
details.disclosure[open] > summary::after { content: "\2212"; }
details.disclosure > .disclosure-body { padding: 0 16px 16px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
.steps > li { counter-increment: step; position: relative; padding: 14px 16px 14px 62px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); min-height: 60px; }
.steps > li::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 34px; height: 34px; border-radius: 50%; background: var(--ink-900); color: var(--accent); font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; justify-content: center; }
.steps > li.is-done::before { content: "\2713"; background: var(--ok); color: #fff; }
.progress { height: 10px; background: var(--paper-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-600), var(--accent-hi)); border-radius: 999px; }
