/* Operator console — tokens and rules in web/DESIGN.md */
:root {
  --bg: #0c0d0f;
  --panel: #131518;
  --raised: #1a1d21;
  --field: #0f1113;
  --line: #24282e;
  --line-strong: #323840;
  --text: #e7e9ec;
  --muted: #8b919a;
  --faint: #5d636c;
  --lime: #b8f34a;
  --lime-soft: rgba(184, 243, 74, 0.12);
  --lime-line: rgba(184, 243, 74, 0.35);
  --lime-ink: #0c0d0f;
  --warn: #f2b84b;
  --warn-soft: rgba(242, 184, 75, 0.12);
  --bad: #ff6b61;
  --bad-soft: rgba(255, 107, 97, 0.12);
  --info: #86b6ff;
  --agent: #161b12;
  --caller: #16181c;
  --radius: 8px;
  --radius-lg: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
/* A scrollbar appearing/disappearing must never shift the layout sideways. */
html { scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--lime); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
::selection { background: var(--lime-soft); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.error-text { color: var(--bad); }
.small { font-size: 12px; }
p { margin: 0 0 10px; }

/* ---- shell ------------------------------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.shell.signed-out { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 12px 10px;
}
.workspace {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--raised);
}
.workspace .mark {
  width: 30px; height: 30px; flex: none; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--lime); color: var(--lime-ink); font: 700 12px/1 var(--mono); letter-spacing: 0.02em;
}
.workspace .names { min-width: 0; line-height: 1.25; }
.workspace .ws-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace .ws-account { color: var(--muted); font-size: 12px; }
/* workspace control: a button opening a compact menu (workspace, Demo, Settings, Sign out) */
.ws-anchor { position: relative; margin-bottom: 14px; }
.ws-anchor .workspace { width: 100%; margin: 0; text-align: left; color: var(--text); cursor: pointer; font: inherit; }
.ws-anchor .workspace:hover, .ws-anchor .workspace[aria-expanded="true"] { border-color: var(--line-strong); }
.ws-anchor .names { flex: 1; }
.ws-chev { color: var(--faint); display: inline-flex; transform: rotate(90deg); flex: none; }
.ws-chev .icon { width: 14px; height: 14px; }
.popover.ws-menu { left: 0; right: 0; width: auto; padding: 6px; }
.ws-menu-head { padding: 6px 8px 8px; line-height: 1.3; }
.ws-menu-head .ws-account { color: var(--muted); font-size: 12px; }
.ws-menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.ws-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px; border-radius: 6px; color: var(--text); font-size: 13px; background: transparent; border: 0; text-align: left; cursor: pointer; }
.ws-menu-item:hover { background: var(--line); text-decoration: none; }
.ws-menu-item .icon { width: 15px; height: 15px; color: var(--muted); }
.ws-menu-item.check { margin: 0; }
button.ghost.ws-menu-item { justify-content: flex-start; font-weight: 400; }
/* persistent DEMO marker (shell only; the toggle lives in the workspace menu) */
.demo-badge { flex: none; font: 700 9.5px/1 var(--mono); letter-spacing: 0.1em; color: var(--lime-ink); background: var(--lime); padding: 3px 5px; border-radius: 4px; }
.mobilebar .demo-badge { margin-left: auto; }
.nav-group { margin-bottom: 14px; }
.nav-label {
  font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint); padding: 0 10px 7px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 6px; color: var(--muted);
}
.nav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 0 var(--lime); }
.nav a[aria-current="page"] .icon { color: var(--lime); }
.nav .soon { margin-left: auto; font: 10px/1 var(--mono); color: var(--faint); letter-spacing: 0.04em; }
.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; }
.sidebar-foot a { color: var(--muted); display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.lang-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px; gap: 1px; flex: none; }
.lang-toggle button { border: 0; background: transparent; color: var(--faint); padding: 2px 6px; font: 600 10.5px/1.4 var(--mono); border-radius: 4px; }
.lang-toggle button[aria-pressed="true"] { background: var(--raised); color: var(--lime); }
.login-top { display: flex; align-items: flex-start; justify-content: space-between; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--lime); box-shadow: 0 0 0 3px var(--lime-soft); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.mobilebar { display: none; }
.content { min-width: 0; }
main { max-width: 1240px; margin: 0 auto; padding: 26px 32px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.eyebrow { font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 16px; }
.panel.flush { padding: 0; overflow-x: auto; }

/* ---- tables ----------------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font: 600 10.5px/1.4 var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--raised); }
td.empty { text-align: center; color: var(--muted); padding: 36px; }
td .sub { color: var(--faint); font-size: 12px; }

/* ---- buttons ---------------------------------------------------------------------------------- */
button, .button {
  font: inherit; font-size: 13.5px; cursor: pointer; border-radius: 7px;
  padding: 7px 13px; border: 1px solid var(--line-strong);
  background: var(--raised); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; line-height: 1.3;
}
button:hover, .button:hover { border-color: var(--faint); text-decoration: none; }
.button { color: var(--text); }
button.primary, .button.primary { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); font-weight: 650; }
button.primary:hover, .button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--raised); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button:disabled, button:disabled:hover { opacity: 0.45; cursor: not-allowed; filter: none; border-color: var(--line-strong); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- forms ------------------------------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.help { color: var(--faint); font-size: 12px; }
.help.error-text { color: var(--bad); }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], textarea {
  font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--lime-line); box-shadow: 0 0 0 3px var(--lime-soft); }
/* Sliders: no glow box around the track; keyboard users still get a thin ring. */
input[type="range"]:focus { box-shadow: none; outline: none; }
input[type="range"]:focus-visible { outline: 1px solid var(--lime-line); outline-offset: 4px; border-radius: 4px; }
input[aria-invalid="true"] { border-color: var(--bad); }
textarea { resize: vertical; line-height: 1.55; }
textarea.prompt { min-height: 300px; font: 13px/1.6 var(--mono); }
input[type="range"] { accent-color: var(--lime); width: 100%; }
input[type="checkbox"] { accent-color: var(--lime); width: 15px; height: 15px; margin: 0; }
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 9px; }
.inline-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 10px; align-items: end; }
.inline-form .field { margin: 0; }

.notice { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 16px; background: var(--panel); }
.notice.bad { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.notice.info { border-color: var(--line-strong); color: var(--muted); }
.secret { font-family: var(--mono); font-size: 12.5px; word-break: break-all; background: var(--field); border: 1px dashed var(--lime-line); padding: 10px; border-radius: 7px; color: var(--lime); }

/* select (web/select.js) — the only dropdown in the product */
.select {
  display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; cursor: pointer; user-select: none;
  font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 10px; min-height: 36px;
}
.select:hover { border-color: var(--faint); }
.select:focus-visible, .select.open { outline: none; border-color: var(--lime-line); box-shadow: 0 0 0 3px var(--lime-soft); }
.select.disabled { opacity: 0.5; cursor: not-allowed; }
.select.disabled:hover { border-color: var(--line-strong); }
.select-value { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
.select-value .select-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-placeholder { color: var(--faint); }
.select-meta { color: var(--faint); font: 11.5px/1.3 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: auto; }
.select-value .select-meta { margin-left: 0; }
.select-chev { transform: rotate(90deg); color: var(--muted); transition: transform 0.12s; }
.select.open .select-chev { transform: rotate(-90deg); color: var(--lime); }
.select-menu {
  position: fixed; z-index: 100; overflow-y: auto; overscroll-behavior: contain;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: 9px;
  padding: 4px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.select-option { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 8px; border-radius: 6px; cursor: pointer; line-height: 1.35; }
.select-option.active { background: var(--line); }
.select-option[aria-disabled="true"] { color: var(--faint); cursor: not-allowed; }
.select-option[aria-disabled="true"].active { background: transparent; }
.select-check { width: 3px; align-self: stretch; border-radius: 2px; flex: none; }
.select-option[aria-selected="true"] .select-check { background: var(--lime); }
.select-option[aria-selected="true"] > .select-text > .select-label { color: var(--lime); }
.select-box { width: 14px; height: 14px; flex: none; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--field); display: grid; place-items: center; }
.select-option[aria-selected="true"] .select-box { background: var(--lime); border-color: var(--lime); }
.select-option[aria-selected="true"] .select-box::after { content: ""; width: 7px; height: 4px; border: 2px solid var(--lime-ink); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.select.multi .select-meta { margin-left: auto; }
.select-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.select-text .select-label { overflow-wrap: anywhere; }
.select-desc { color: var(--muted); font-size: 12px; }
.opt-emoji { margin-right: 8px; font-size: 15px; line-height: 1; }
.opt-icon { display: inline-flex; vertical-align: -3px; margin-right: 6px; color: var(--faint); }
.select-option.active .opt-icon { color: var(--muted); }
/* The selected voice's glyph is lime, like its label — in the list and in the closed field. */
.select-option[aria-selected="true"] .opt-icon, .select-value .opt-icon { color: var(--lime); }
.icon.glyph { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* tree select (web/select.js createTreeSelect): a normal menu; submenus float beside the hovered row */
.select-value .tree-head { flex: 0 1 auto; min-width: 2.5em; }
.select-value .tree-tail { flex: none; white-space: nowrap; margin-left: -4px; }
.tree-chev { width: 14px; height: 14px; color: var(--faint); margin-left: auto; }
.select-option.active .tree-chev { color: var(--text); }
.tree-back { display: flex; align-items: center; gap: 6px; padding: 9px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12.5px; cursor: pointer; }
.tree-back:hover { color: var(--text); }
.tree-menu.drill .select-option { min-height: 44px; }
.tree-menu .select-option[role="menuitem"][aria-selected="true"] > .select-text > .select-label { color: var(--text); }

/* voice preview */
.select-with-action { display: flex; gap: 4px; align-items: stretch; min-width: 0; }
.select-with-action .pop-anchor { display: flex; }
.select-with-action .select { flex: 1; }
.preview-button { flex: none; width: 32px; padding: 0; justify-content: center; border-radius: 7px; background: var(--field); color: var(--muted); }
.preview-button:hover { color: var(--lime); border-color: var(--lime-line); }
.preview-button[data-state="playing"] { color: var(--lime-ink); background: var(--lime); border-color: var(--lime); }
.preview-button .icon { width: 14px; height: 14px; }
.preview-button[data-state="idle"] .icon, .preview-button[data-state="playing"] .icon { fill: currentColor; }
.preview-button:disabled { opacity: 1; cursor: progress; }
.icon.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preview-error { font-size: 12px; margin-top: 6px; }
.gear-button .icon { fill: none !important; }
.gear-button { position: relative; }
.gear-button.modified::after { content: ""; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--lime); }
.popover.align-right { left: auto; right: 0; }
.voice-pop { width: 320px; }
.range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.range-head output { font: 600 12px/1.3 var(--mono); color: var(--lime); text-align: right; }
.range-ends { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--faint); }
.preview-error:empty { display: none; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 30px; height: 17px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--text); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--lime); }
.switch input:checked + .track::after { transform: translateX(13px); background: var(--lime-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--lime); outline-offset: 2px; }

/* segmented */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; padding: 2px; background: var(--field); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 6px; }
.seg.seg-fill { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
.seg.seg-fill button { justify-content: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 5px 8px; }
.compact-field { margin-bottom: 10px; }
.greeting-check { align-items: center; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.greeting-field { margin-bottom: 0; }
/* Call Screening: on/off row and direction checkboxes as chips */
.screen-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.check-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.check-chip { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--field); color: var(--muted); font-size: 13px; cursor: pointer; }
.check-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-chip.on { color: var(--text); border-color: var(--lime-line); }
.check-chip:has(input:disabled) { cursor: default; }
.check-chip:has(input:focus-visible) { outline: 2px solid var(--lime); outline-offset: 2px; }
.seg button[aria-checked="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--lime-line); }

/* ---- badges & capability states -------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid currentColor; white-space: nowrap; line-height: 1.6; }
.badge.ok { color: var(--lime); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.neutral { color: var(--muted); }
.state { display: inline-flex; align-items: center; gap: 5px; font: 600 10px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 7px; border-radius: 5px; white-space: nowrap; }
.state::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.state.live { color: var(--lime); background: var(--lime-soft); }
.state.config { color: var(--warn); background: var(--warn-soft); }
.state.soon { color: var(--muted); background: var(--raised); }

/* ---- key-value, stats ------------------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat .label { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.stat .value { font: 600 20px/1.3 var(--mono); margin-top: 6px; }

/* ---- placeholders ----------------------------------------------------------------------------- */
.placeholder { border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 36px 28px; text-align: center; background: var(--panel); }
.placeholder .icon { width: 28px; height: 28px; color: var(--faint); margin-bottom: 10px; }
.placeholder h2 { font-size: 16px; margin-bottom: 6px; }
.placeholder p { color: var(--muted); max-width: 520px; margin: 0 auto 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card p { color: var(--muted); margin: 0; font-size: 13px; }

/* ---- transcript ------------------------------------------------------------------------------- */
.turns { display: flex; flex-direction: column; gap: 6px; }
.turn { display: grid; grid-template-columns: 70px 1fr; gap: 12px; padding: 9px 12px; border-radius: 7px; border-left: 2px solid transparent; }
.turn.agent { background: var(--agent); border-left-color: var(--lime); }
.turn.caller { background: var(--caller); border-left-color: var(--faint); }
.turn .who { font: 600 10.5px/1.6 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.turn.agent .who { color: var(--lime); }
.turn .when { color: var(--faint); font-size: 12px; font-family: var(--mono); }
.turn .text { white-space: pre-wrap; }
.turn .badge { margin-left: 8px; }

/* ---- agent editor ----------------------------------------------------------------------------- */
.editor-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: -26px -32px 20px; padding: 14px 32px;
  background: rgba(12, 13, 15, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.editor-head .crumb { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.editor-head .name-input {
  font: 650 18px/1.3 var(--sans); background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 4px 8px; width: auto; min-width: 180px; max-width: 360px; flex: 0 1 360px; color: var(--text);
}
.editor-head .name-input:hover { border-color: var(--line-strong); }
.editor-head .status { display: flex; align-items: center; gap: 10px; }
.editor-head .actions { margin-left: auto; }
.draft-state { font: 600 11px/1 var(--mono); letter-spacing: 0.04em; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.draft-state.dirty { color: var(--warn); }
.draft-state.dirty .dot { background: var(--warn); }

.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 10px; }
.section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-lg); user-select: none;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary:hover { background: var(--raised); }
.section > summary .title { font-weight: 600; white-space: nowrap; }
.section > summary .readout {
  margin-left: auto; font: 12px/1.3 var(--mono); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; min-width: 0;
}
.section > summary .readout.accent { color: var(--lime); }
.section > summary .chev { transition: transform 0.15s; color: var(--faint); }
.section[open] > summary .chev { transform: rotate(90deg); }
.section[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.section .body { padding: 14px; }

.prompt-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 8px; font: 12px/1.4 var(--mono); color: var(--faint); }
.token-count { color: var(--lime); cursor: help; border-bottom: 1px dotted var(--lime-line); }
.token-count.stale { color: var(--muted); }
/* estimated cost chip + details (the rate card is secondary, inside the popover) */
.cost-area { margin-top: 10px; }
.cost-metric {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 0;
  background: transparent; border: 0; border-radius: 4px; font-size: 12px; color: var(--muted);
}
.cost-metric:hover, .cost-metric[aria-expanded="true"] { color: var(--text); }
.cost-metric:hover .cost-more, .cost-metric[aria-expanded="true"] .cost-more { color: var(--text); }
.cost-metric .cost-value { font: 600 12.5px/1 var(--mono); color: var(--lime); }
.cost-metric .cost-none { color: var(--faint); }
.cost-metric .cost-more { color: var(--faint); font-size: 11px; }
.popover.cost-pop { width: 360px; max-width: calc(100vw - 56px); font-size: 12.5px; }
.cost-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cost-head.stack { flex-direction: column; align-items: flex-start; gap: 4px; }
.cost-big { font: 600 18px/1.2 var(--mono); color: var(--lime); }
.cost-big.none { font: 500 13px/1.3 var(--sans); color: var(--muted); }
.cost-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.cost-row .cost-num { font-family: var(--mono); white-space: nowrap; text-align: right; }
.cost-row.secondary, .cost-row.muted { color: var(--muted); }
.cost-row.muted .cost-num { color: var(--faint); }
.cost-sub { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.cost-note { color: var(--faint); font-size: 11.5px; line-height: 1.45; margin: 8px 0 0; }
.rate-head { margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid var(--line-strong); }
.rate-card dd { margin: 0; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; margin-top: 10px; }
.note .state { margin-top: 1px; }

.events { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.event { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; }
.event .ev-name { font-weight: 550; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.event .ev-wire { font: 11px/1.4 var(--mono); color: var(--faint); }
.event.disabled .ev-name { color: var(--faint); }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { font: 600 13px/1 var(--mono); color: var(--lime); min-width: 44px; text-align: right; }
.test-result { font: 12.5px/1.4 var(--mono); padding: 8px 10px; border-radius: 7px; background: var(--field); border: 1px solid var(--line); }
.test-result.ok { color: var(--lime); border-color: var(--lime-line); }
.test-result.bad { color: var(--bad); border-color: rgba(255, 107, 97, 0.4); }

/* ---- agent editor workspace: main | settings | test audio ------------------------------------- */
main.wide { max-width: none; }
.editor-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px 300px; gap: 16px; align-items: start; }
.editor-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.editor-settings { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.editor-settings .section { margin: 0; }
.editor-settings .events { grid-template-columns: 1fr; gap: 0; }
.editor-settings .section > summary .readout { max-width: 50%; }
.col-label { font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); padding: 2px 2px 4px; }
.col-label ~ .col-label { margin-top: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
/* Voice gets more room: it carries the ▶ preview and ⚙ settings buttons. */
/* One row: model · voice (carries ▶ ⚙) · language; stacked only when the card is phone-narrow. */
.model-card { container-type: inline-size; }
.model-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.15fr) minmax(0, 0.75fr); gap: 10px; align-items: end; }
@container (max-width: 520px) { .model-row { grid-template-columns: minmax(0, 1fr); } }
/* hint glyph beside a field label (e.g. language on models that ignore it) */
.info-tip { margin-left: 6px; color: var(--faint); cursor: help; font-weight: 400; }
.info-tip:hover, .info-tip:focus-visible { color: var(--text); }
.model-row .field { margin: 0; }
.prompt-card textarea.prompt { min-height: max(300px, calc(100vh - 560px)); }
.settings-foot { border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.agent-meta { margin-top: 10px; font-size: 12px; color: var(--faint); }
.agent-meta button { margin-top: 8px; }
.small-button { padding: 4px 10px; font-size: 12.5px; }

.test-panel {
  position: sticky; top: 76px; height: calc(100vh - 100px); min-height: 420px;
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.ta-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ta-head h2 { margin: 0; font-size: 13.5px; }
.ta-head .ta-close { margin-left: auto; }
.ta-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ta-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.ta-button { width: 100%; justify-content: center; }
.ta-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 2px; }
.ta-stage .live-row { margin: 0; justify-content: center; }
.ta-stage .meter { width: 100%; }
.ta-intro { margin: 0; }
.mic-orb {
  --level: 0;
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line-strong); background: var(--field); color: var(--muted);
  box-shadow: 0 0 0 calc(var(--level) * 16px) var(--lime-soft); transition: box-shadow 80ms linear, border-color 0.2s, color 0.2s;
}
.mic-orb .icon { width: 28px; height: 28px; }
.test-panel.running .mic-orb { border-color: var(--lime-line); color: var(--lime); }
.test-panel.agent-speaking .mic-orb { border-color: var(--lime); background: var(--lime-soft); }
.test-panel .live-transcript { min-height: 120px; max-height: none; flex: 1; }
.ta-toggle, .ta-close { display: none; }
.ta-scrim { display: none; }

/* knowledge base */
.kb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.kb-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.kb-side { position: sticky; top: 76px; min-width: 0; }
.kb-summary { font-size: 12px; color: var(--muted); text-align: right; }
.row-actions { white-space: nowrap; text-align: right; }
.source-text { min-height: 320px; }
.inline-create { max-width: 520px; }
.kb-chips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.kb-chip { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--field); min-width: 0; }
.kb-chip .kb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-chip .kb-meta { font: 11px/1.3 var(--mono); color: var(--faint); white-space: nowrap; }
.kb-chip button { padding: 2px 4px; border: 0; background: transparent; color: var(--muted); }
.kb-chip button:hover { color: var(--bad); }
.context-bar { margin-top: 10px; }
.context-row { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 12px/1.4 var(--mono); color: var(--muted); }
.context-row b { color: var(--text); font-weight: 600; }
.meter-line { position: relative; height: 5px; border-radius: 3px; background: var(--line); margin-top: 7px; overflow: hidden; display: flex; }
.meter-line i { display: block; height: 100%; }
.meter-line .seg-prompt { background: var(--muted); }
.meter-line .seg-knowledge { background: var(--lime); }
.context-warn { margin-top: 6px; font-size: 12px; color: var(--warn); }
.context-warn.bad { color: var(--bad); }

/* usage & billing */
.ta-cost { color: var(--faint); font: 11.5px/1.4 var(--mono); margin-top: 6px; }
.stat-sub { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.currency-pick { width: 96px; }
.ledger { width: 100%; }
.ledger td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.ledger td.num { text-align: right; white-space: nowrap; }
.ledger tr.total td { border-bottom: 0; border-top: 1px solid var(--line-strong); font-weight: 600; color: var(--lime); padding-top: 10px; }
.ledger tr.muted td { color: var(--faint); }
.ledger tr.group td { color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 12px; }
.ledger tr.indent td:first-child { padding-left: 14px; font-family: var(--mono); font-size: 12.5px; }
.ledger-sub { font: 11.5px/1.4 var(--sans); color: var(--faint); margin-top: 2px; }
/* Test Audio: what is being tested (model · voice · language) + an optional small credential status */
.ta-env { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 10px 14px 0; font-size: 12px; min-width: 0; }
.ta-agent { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta-model { color: var(--text); font-weight: 600; }
.ta-profile { flex: none; font: 11.5px/1.3 var(--mono); color: var(--lime); }
.ta-profile.paid { color: var(--muted); }
.ta-profile.missing { color: var(--warn); }
.ta-summary { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 8px 0 0; font-size: 12px; }
.ta-summary dt { color: var(--faint); }
.ta-summary dd { margin: 0; font-family: var(--mono); text-align: right; }
.billing-notes { color: var(--faint); font-size: 12px; margin-top: 6px; }
.billing-notes p { margin: 0 0 4px; }
.usage-block { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.usage-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.usage-head .mono { color: var(--lime); }
.kv.small { font-size: 12.5px; gap: 4px 14px; }

/* popover (silence) */
.pop-anchor { position: relative; display: inline-block; }
.popover.up { top: auto; bottom: calc(100% + 6px); }
.popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: 320px; max-width: calc(100vw - 32px);
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  padding: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.value-chip { font-family: var(--mono); }

.live-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.live-status { font: 600 12px/1 var(--mono); letter-spacing: 0.04em; display: inline-flex; align-items: center; gap: 7px; }
.timer { font: 600 13px/1 var(--mono); color: var(--muted); }
.meter { display: flex; align-items: flex-end; gap: 3px; height: 22px; flex: 1; min-width: 120px; }
.meter i { flex: 1; background: var(--line-strong); border-radius: 2px; height: 20%; transition: height 60ms linear, background 60ms linear; }
.meter i.on { background: var(--lime); }
.live-transcript { min-height: 140px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--field); }

/* toast */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; background: var(--raised); border: 1px solid var(--lime-line); color: var(--text); padding: 10px 14px; border-radius: 8px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); display: flex; align-items: center; gap: 8px; }
.toast .dot { background: var(--lime); }

/* login */
.login { max-width: 380px; margin: 14vh auto 0; }
.login .mark { width: 36px; height: 36px; border-radius: 8px; background: var(--lime); color: var(--lime-ink); display: grid; place-items: center; font: 700 13px/1 var(--mono); margin-bottom: 14px; }
.login-shell { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---- narrow screens --------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .kb-layout { grid-template-columns: minmax(0, 1fr); }
  .kb-side { position: static; }
}
/* Desktop: the editor is a fixed-height workspace; each column scrolls on its own, so opening a section
   or growing the transcript never moves or resizes the other columns. */
@media (min-width: 1024px) {
  main.wide { height: 100vh; display: flex; flex-direction: column; padding-bottom: 16px; overflow: hidden; }
  main.wide > .editor-head { position: static; flex: none; margin-bottom: 16px; }
  main.wide > .editor-workspace { flex: 1; min-height: 0; align-items: stretch; }
  /* Columns scroll with wheel/trackpad/keyboard, without a visible scrollbar track between them. */
  .editor-workspace > .editor-main, .editor-workspace > .editor-settings {
    height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  }
  .editor-workspace > .editor-main::-webkit-scrollbar, .editor-workspace > .editor-settings::-webkit-scrollbar { display: none; }
  .editor-workspace > .editor-settings { position: static; }
}
@media (min-width: 1360px) {
  .editor-workspace > .test-panel { position: static; height: 100%; min-height: 0; }
}
/* Test Audio becomes a drawer, settings stay beside the prompt */
@media (max-width: 1359px) {
  .editor-workspace { grid-template-columns: minmax(0, 1fr) 320px; }
  .test-panel {
    position: fixed; top: 0; right: 0; bottom: 0; height: auto; width: min(380px, 100vw); z-index: 45;
    border-radius: 0; border-width: 0 0 0 1px; transform: translateX(100%); transition: transform 0.18s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6); visibility: hidden;
  }
  .ta-open .test-panel { transform: none; visibility: visible; }
  .ta-open .ta-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 44; }
  .ta-toggle, .ta-close { display: inline-flex; }
  .ta-close { margin-left: 4px; }
}
/* settings move below the main editor */
@media (max-width: 1023px) {
  .editor-workspace { grid-template-columns: minmax(0, 1fr); }
  .editor-settings { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 40;
    transform: translateX(-100%); transition: transform 0.18s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }
  .shell.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 30; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .mobilebar .title { font-weight: 600; }
  main { padding: 18px 16px 48px; }
  .editor-head { margin: -18px -16px 16px; padding: 10px 16px; top: 53px; gap: 8px 10px; }
  .editor-head .name-input { flex: 1 1 100%; max-width: none; order: 1; }
  .editor-head .crumb { display: none; }
  .editor-head .status { order: 2; }
  .editor-head .actions { order: 3; margin-left: auto; }
  .cols-2, .cols-3, .grid-2, .inline-form, .events { grid-template-columns: 1fr; }
  .turn { grid-template-columns: 1fr; gap: 2px; }
  .section > summary .readout { max-width: 45%; }
  th, td { padding: 9px 10px; }
}

/* Conversation Start: one compact row — direction · "Who speaks first?" — then the greeting */
.start-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; margin-bottom: 12px; }
.start-row .seg button { padding: 5px 14px; font-size: 13px; }
.start-who { display: flex; align-items: center; gap: 10px; }
.dir-note { margin: -4px 0 10px; }
.greeting-field textarea { max-width: 720px; }

/* Phone Numbers: one compact vertical mini-section per direction (switch = title, then its settings) */
.dir-cell { min-width: 190px; vertical-align: top; }
.outbound-cell { min-width: 0; width: 180px; }
.num-actions { width: 1%; }
.numbers-table td.num-e164, .numbers-table td.num-label, .numbers-table td.num-actions { vertical-align: top; }
.dir-switch { color: var(--text); font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.dir-field-label { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.dir-cell .select { width: 0; min-width: 100%; } /* no intrinsic width: the table fits its panel */
.dir-cell .sub { margin-top: 6px; font-size: 12px; }
.caller-id { align-items: center; font-size: 13px; cursor: pointer; }
.caller-id.off { color: var(--faint); cursor: default; }
.dir-status { margin-top: 8px; font-size: 11.5px; color: var(--faint); }
.warn-text, .dir-cell .sub.warn-text { color: var(--warn); }
/* narrow screens: each number is a stacked card (no sideways scrolling inside the table) */
@media (max-width: 640px) {
  .numbers-table thead { display: none; }
  .numbers-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .numbers-table td { display: block; padding: 0; border: 0; }
  .numbers-table .num-e164 { grid-column: 1; grid-row: 1; }
  .numbers-table .num-label { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 12.5px; }
  .numbers-table .num-actions { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
  .numbers-table .inbound-cell { grid-column: 1 / -1; grid-row: 3; min-width: 0; margin-top: 8px; }
  .numbers-table .outbound-cell { grid-column: 1 / -1; grid-row: 4; min-width: 0; width: auto; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
  .numbers-table td.empty { grid-column: 1 / -1; }
}

/* ---- settings: grouped label | value rows (one panel per group, no cards inside cards) ------------ */
.set-group { padding: 4px 18px; }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.set-head h2 { margin: 0; }
.set-row { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.set-row:last-child { border-bottom: 0; }
.set-label { color: var(--muted); }
.set-value { min-width: 0; overflow-wrap: anywhere; }
.set-value .help { margin-top: 3px; }
.set-control { max-width: 240px; }
.set-inline { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.set-state { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 640px) { .set-row { grid-template-columns: minmax(0, 1fr); } }

/* ---- billing: controls row + one summary strip (equal cells, same label height) ------------------ */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 16px; }
.toolbar .currency-pick { margin-left: auto; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 16px; }
.metric { padding: 14px 18px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric .label { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .value { font: 600 20px/1.3 var(--mono); margin-top: 6px; white-space: nowrap; }
.metric-sub { color: var(--faint); font-size: 11.5px; margin-top: 2px; min-height: 1.4em; }
.grid-2.top { align-items: start; }
.grid-2.top .panel { margin-bottom: 0; }
.grid-2.top + .billing-notes { margin-top: 14px; }
.fold > summary { cursor: pointer; color: var(--muted); width: max-content; margin: 2px 0 6px; }
.fold > summary:hover { color: var(--text); }
@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .toolbar .currency-pick { margin-left: 0; }
}

/* ---- M7–M10: integrations, lead bases, campaigns ---------------------------------------------- */
.integration-section { margin-top: 28px; }
.integration-section > h2 { font-size: 16px; margin: 0 0 6px; }
.form-title { font-size: 14px; margin: 0 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 12px; }
.notice.ok { border-color: var(--lime-line); color: var(--text); background: var(--lime-soft); }
.notice.warn { border-color: var(--warn); color: var(--text); background: var(--warn-soft); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.progress { height: 6px; border-radius: 3px; background: var(--raised); overflow: hidden; min-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--lime); transition: width 0.4s ease; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.preview-table th { vertical-align: top; min-width: 150px; }
.preview-table th > div:first-child { font-weight: 600; margin-bottom: 6px; }
.preview-table .key-input { margin-top: 6px; width: 100%; }
.preview-table td { color: var(--muted); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 320px; }
.outcome-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(110px, 0.8fr) minmax(110px, 0.7fr) minmax(160px, 2fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.outcome-row:not(:has(.select)) { grid-template-columns: minmax(120px, 1fr) minmax(110px, 0.8fr) minmax(160px, 2.7fr) auto; }
.map-row { display: grid; grid-template-columns: minmax(160px, 1fr) 18px minmax(160px, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.map-row > span:first-child { color: var(--text); }
.map-arrow { color: var(--faint); text-align: center; }
.icon-button { background: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px; color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--bad); border-color: var(--bad); }
.panel h3 { font-size: 13px; margin: 16px 0 6px; }
.panel h2 { font-size: 15px; margin: 0 0 10px; }
@media (max-width: 720px) {
  .outcome-row, .outcome-row:not(:has(.select)), .map-row { grid-template-columns: 1fr; }
  .map-arrow { display: none; }
}
.var-name { display: flex; align-items: center; gap: 4px; }
.var-name input { min-width: 0; flex: 1; }
.webhook-url { padding: 6px 8px; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); word-break: break-all; font-size: 12px; }
.context-list { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.context-list li { margin-bottom: 4px; }
table.compact td, table.compact th { padding: 6px 8px; }

/* ---- analytics (web/analytics.js) --------------------------------------------------------------- */
.period-control { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-dates { display: inline-flex; align-items: center; gap: 6px; }
.period-dates input { width: 150px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 14px; }
.filter { display: flex; flex-direction: column; gap: 4px; min-width: 170px; flex: 0 1 210px; }
.filter-label { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.stats.kpis { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.chart-panel .card-head { flex-wrap: wrap; }
.chart { position: relative; height: 220px; margin: 8px 0 30px 44px; }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-gridline { border-top: 1px solid var(--line); position: relative; height: 0; }
.chart-gridline span { position: absolute; right: calc(100% + 6px); top: -8px; font: 11px/1 var(--mono); color: var(--faint); white-space: nowrap; }
.chart-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.chart-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; cursor: default; border-radius: 4px 4px 0 0; }
.chart-col:hover, .chart-col.hover, .chart-col:focus-visible { background: rgba(255, 255, 255, 0.03); }
.chart-bar { background: var(--lime); border-radius: 4px 4px 0 0; width: min(100%, 28px); margin: 0 auto; }
.chart-x { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); font: 10.5px/1 var(--mono); color: var(--faint); white-space: nowrap; }
.chart-tip { position: absolute; top: 0; width: 160px; padding: 8px 10px; background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius); font-size: 12px; pointer-events: none; z-index: 2; }
.chart-tip-title { font: 600 11px/1.4 var(--mono); color: var(--muted); margin-bottom: 2px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.chart-table .panel { margin: 8px 0 0; }
.breakdowns { margin-bottom: 16px; }
.breakdowns .panel { margin-bottom: 0; }
.breakdown td:first-child { min-width: 140px; }
.breakdown th { white-space: nowrap; }
.breakdown-title { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding: 12px 14px 4px; }
th.num, td.num { text-align: right; }

/* ---- versions (web/versions.js) ----------------------------------------------------------------- */
.version-chip { color: var(--muted); font-size: 11.5px; margin-right: 4px; white-space: nowrap; }
.publish-anchor { position: relative; display: inline-flex; }
.popover.publish-pop { width: 300px; top: calc(100% + 6px); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.publish-pop label { display: flex; flex-direction: column; gap: 4px; }
.publish-pop-title { font-weight: 600; }
.publish-pop-actions { display: flex; justify-content: flex-end; gap: 8px; }
.version-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -8px 0 12px; }
.rename-row { display: flex; gap: 8px; margin-bottom: 14px; max-width: 520px; }
.rename-row input { flex: 1; min-width: 0; }
.prompt-view { white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 var(--mono); background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0; max-height: 520px; overflow: auto; }
.prompt-view.patch { border-color: var(--lime-line); }
.prompt-view.removed { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.findings { margin: 0; padding-left: 18px; }
.findings li { margin-bottom: 6px; }
.compare-controls { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin-bottom: 14px; }
.compare-result .panel { margin-bottom: 12px; }

/* ---- Agent Analysis (web/agent-analysis.js) ----------------------------------------------------- */
.analysis-form textarea { width: 100%; }
.req { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
button.chip { background: var(--field); color: var(--muted); font-size: 12px; padding: 3px 10px; border-radius: 999px; text-align: left; white-space: normal; }
button.chip:hover { color: var(--text); }
.analysis-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.analysis-preview { flex: 1 1 260px; }
.goal-cell { max-width: 420px; }
.section-label { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.analysis-goal .goal { font-size: 15px; margin: 0; }
.analysis-scope { margin: -6px 0 12px; }
p.lead { font-size: 15px; margin: 0; }
.section-head { font-size: 15px; margin: 22px 0 10px; }
.section-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-head-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.problem-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.problem-head h3 { margin: 0; font-size: 14px; }
.freq { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.freq-bar { flex: 0 0 160px; height: 6px; background: var(--field); border-radius: 3px; overflow: hidden; }
.freq-bar > div { height: 100%; background: var(--lime); border-radius: 3px; }
.affected { margin-bottom: 8px; line-height: 1.9; }
.call-ref { padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 6px; font-size: 11.5px; }
.evidence { margin: 8px 0 10px; }
.quote { margin: 0 0 8px; padding: 8px 12px; background: var(--caller); border-left: 2px solid var(--line-strong); border-radius: 0 var(--radius) var(--radius) 0; }
.quote.agent { background: var(--agent); border-left-color: var(--lime); }
.quote-meta { color: var(--faint); margin-bottom: 2px; }
.prompt-change .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.prompt-change .prompt-view { margin-bottom: 8px; }
.isolated summary { cursor: pointer; color: var(--muted); }
.isolated ul { margin: 8px 0 0; padding-left: 18px; }

@media (max-width: 720px) {
  .stats.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stats.kpis .stat { padding: 10px 12px; }
  .stats.kpis .value { font-size: 17px; }
  .filter { flex: 1 1 100%; min-width: 0; }
  .period-dates input { width: 132px; }
  .chart { margin-left: 34px; height: 180px; }
  .freq-bar { flex-basis: 90px; }
  .editor-head .actions { flex-wrap: wrap; }
  .version-chip { display: none; }
  .problem dl.kv { display: block; }
  .problem dl.kv dt { margin-top: 6px; }
  .problem dl.kv dd { margin: 0; }
  .popover.publish-pop { position: fixed; left: 16px; right: 16px; top: 72px; width: auto; }
}
