/* ─── Agentic Platform dashboard styles ────────────────────────────────────
   Dependency-free design system shared with FormBridge: flat, border-driven,
   neutral dark theme. Colors are CSS variables; dark mode follows the OS
   preference with an explicit [data-theme] override. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=DM+Serif+Display&display=swap');

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-fg: #ffffff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0891b2;
  --info-bg: #cffafe;
  --shadow: none;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 230px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme='dark'] {
  --bg: #151515;
  --surface: #1c1c1c;
  --surface-2: #232323;
  --border: #2e2e2e;
  --text: #e6e6e6;
  --text-muted: #9a9a9a;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --success: #4ade80;
  --success-bg: #16301f;
  --danger: #f87171;
  --danger-bg: #3a1d1d;
  --warning: #fbbf24;
  --warning-bg: #332a14;
  --info: #38bdf8;
  --info-bg: #16282f;
  --shadow: none;
}

[data-theme='cwik'] {
  --bg: #faf6ef;
  --surface: #fffdf8;
  --surface-2: #f7f2e6;
  --border: #e6dec9;
  --text: #26221b;
  --text-muted: #5a5244;
  --primary: #9a621c;
  --primary-hover: #7c4e13;
  --primary-fg: #ffffff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0891b2;
  --info-bg: #cffafe;
  --shadow: 0 4px 12px rgba(148, 108, 30, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']):not([data-theme='cwik']) {
    --bg: #151515;
    --surface: #1c1c1c;
    --surface-2: #232323;
    --border: #2e2e2e;
    --text: #e6e6e6;
    --text-muted: #9a9a9a;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --success: #4ade80;
    --success-bg: #16301f;
    --danger: #f87171;
    --danger-bg: #3a1d1d;
    --warning: #fbbf24;
    --warning-bg: #332a14;
    --info: #38bdf8;
    --info-bg: #16282f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { color: var(--text); margin: 0 0 0.5rem; line-height: 1.25; }
[data-theme='cwik'] h1, [data-theme='cwik'] h2, [data-theme='cwik'] h3 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; }
[data-theme='cwik'] body { font-family: 'DM Sans', 'Segoe UI', Roboto, Helvetica, sans-serif; }

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 12px; }

code, .mono { font-family: var(--mono); font-size: 0.85em; }

/* ─── Layout shell ─────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 18px 20px;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.sidebar-context { padding: 12px 20px; border-bottom: 1px solid var(--border); }
.sidebar-context .ctx-back { display: block; font-size: 0.8rem; margin-bottom: 4px; }
.sidebar-context .ctx-name { font-weight: 700; overflow-wrap: anywhere; }
.sidebar-nav { padding: 12px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--primary); color: var(--primary-fg); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .spacer { flex: 1; }
.topbar .user-email { color: var(--text-muted); font-size: 0.85rem; }
.topbar .user-email:hover { color: var(--text); }
.content { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.inline-form { margin: 0; display: inline-flex; }

.subnav {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); margin-bottom: 24px;
}
.subnav a {
  padding: 10px 14px; color: var(--text-muted); font-weight: 600; font-size: 0.9rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.active { color: var(--primary); border-bottom-color: var(--primary); }

.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-toggle { display: none; }

/* ─── Cards & grids ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-sidebar { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }
.align-start { align-items: start; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 1.9rem; font-weight: 700; margin-top: 6px; line-height: 1.2; }
.stat .sub { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

/* ─── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th {
  text-align: left; padding: 11px 16px; color: var(--text-muted);
  font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.right { text-align: right; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data.compact th, table.data.compact td { padding: 6px 10px; }
table.data input { min-width: 90px; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty .btn { margin-top: 4px; }

/* ─── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
a.badge:hover { text-decoration: none; filter: brightness(0.97); }
.badge.ok, .badge.enabled { background: var(--success-bg); color: var(--success); }
.badge.err { background: var(--danger-bg); color: var(--danger); }
.badge.pending { background: var(--warning-bg); color: var(--warning); }
.badge.muted, .badge.disabled { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 0.88rem; font-family: inherit;
  cursor: pointer; text-decoration: none; line-height: 1; transition: background 0.12s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(0.95); }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn.sm { padding: 5px 11px; font-size: 0.8rem; }
.btn.ghost { background: none; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.is-busy { opacity: 0.8; cursor: progress; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-row .spacer { flex: 1; }
.justify-end { justify-content: flex-end; }

.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ─── Forms ────────────────────────────────────────────────────────────── */
.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-weight: 600; font-size: 0.85rem; }
.hint { color: var(--text-muted); font-size: 0.78rem; }
.hint.block, .block { display: block; }
input[type='text'], input[type='email'], input[type='password'], input[type='number'],
input[type='url'], input[type='search'], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 0.9rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input:disabled, select:disabled { opacity: 0.7; }
textarea { resize: vertical; min-height: 70px; }
.code-editor { font-family: var(--mono); font-size: 0.84rem; line-height: 1.55; tab-size: 2; }
.num-input { text-align: right; font-variant-numeric: tabular-nums; }
.checkbox { display: flex; align-items: center; gap: 9px; font-weight: 400; cursor: pointer; }
.checkbox input { width: auto; margin: 0; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; padding-top: 6px; }
.option-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 400;
}
.option-card input { margin-top: 3px; }
.option-card:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.switch-list { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 14px; }
.switch-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row:last-child { border-bottom: none; }
.switch-row input { width: auto; margin-top: 3px; }
.section-title {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  margin: 26px 0 12px; font-weight: 600;
}
.char-count { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-count.over { color: var(--danger); font-weight: 700; }
.color-field { display: flex; align-items: center; gap: 10px; }
input[type='color'] {
  width: 46px; height: 38px; padding: 3px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}

/* ─── Flash ────────────────────────────────────────────────────────────── */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-weight: 500; border: 1px solid transparent; }
.flash.success { background: var(--success-bg); color: var(--success); }
.flash.error { background: var(--danger-bg); color: var(--danger); }
.flash.info { background: var(--info-bg); color: var(--info); }
.flash a { color: inherit; text-decoration: underline; }
.flash code { color: inherit; }
.flash .flash-link { margin-top: 10px; color: var(--text); background: var(--surface); }

/* ─── Token / snippet box ──────────────────────────────────────────────── */
.token-box {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 0.82rem; word-break: break-all;
}
.token-box .val { flex: 1; white-space: pre-wrap; }

/* ─── Toolbar / filter row ─────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { min-width: 160px; gap: 4px; }
.toolbar .field > label { font-size: 0.75rem; color: var(--text-muted); }
.toolbar .grow { flex: 1; }

/* ─── Definition list ──────────────────────────────────────────────────── */
.dl { display: grid; grid-template-columns: 200px 1fr; gap: 0; margin: 0; }
.dl dt { color: var(--text-muted); padding: 9px 0; border-bottom: 1px solid var(--border); font-weight: 600; }
.dl dd { padding: 9px 0; border-bottom: 1px solid var(--border); margin: 0; word-break: break-word; }
.dl.stacked { grid-template-columns: 1fr; }
.dl.stacked dt { border-bottom: none; padding-bottom: 0; font-size: 0.78rem; }
.dl.stacked dd { padding-top: 2px; }

.plain-list { list-style: none; padding: 0; margin: 0 0 12px; }
.plain-list li { padding: 3px 0; }
.plain-list.bullets li { padding-left: 16px; position: relative; }
.plain-list.bullets li::before { content: '–'; position: absolute; left: 0; color: var(--text-muted); }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; }
.pagination .info { color: var(--text-muted); font-size: 0.85rem; }

/* ─── Setup checklist ──────────────────────────────────────────────────── */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.check-icon {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; border: 1px solid var(--border); color: var(--text-muted);
}
.checklist li.done .check-icon { background: var(--success-bg); color: var(--success); border-color: transparent; }
.checklist li.done .check-label { color: var(--text-muted); }

/* ─── Meter (budget) ───────────────────────────────────────────────────────
   Fill carries severity (accent → warning → danger); the track is a lighter
   step of the same hue so the state reads across the whole bar. */
.meter {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
}
.meter-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.meter.level-warn { background: color-mix(in srgb, var(--warning) 22%, var(--surface)); }
.meter.level-warn .meter-fill { background: var(--warning); }
.meter.level-over { background: color-mix(in srgb, var(--danger) 20%, var(--surface)); }
.meter.level-over .meter-fill { background: var(--danger); }
.meter.sm { height: 6px; width: 84px; flex-shrink: 0; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.meter-head .spacer { flex: 1; }
.meter-label { color: var(--text-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.meter-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }

/* ─── Column chart ─────────────────────────────────────────────────────────
   Thin columns (≤16px) with a 4px rounded data end and square baseline, 2px
   surface gap, hairline recessive grid. Each column slot is the hover/focus
   target; the tooltip is added by app.js; a table view sits underneath. */
figure.chart { margin: 0 0 20px; }
.bar-chart {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: 180px auto;
  padding: 22px 20px 10px 8px;
}
.bc-axis { grid-row: 1; grid-column: 1; position: relative; }
.bc-axis span {
  position: absolute; right: 10px; transform: translateY(50%);
  font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bc-plot {
  grid-row: 1; grid-column: 2; position: relative;
  display: flex; align-items: flex-end; gap: 2px;
  border-bottom: 1px solid var(--border);
}
.bc-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); pointer-events: none; }
.bc-col {
  flex: 1 1 0; min-width: 0; height: 100%; position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  border-radius: 4px 4px 0 0; outline: none;
}
.bc-col:hover, .bc-col:focus-visible { background: color-mix(in srgb, var(--text) 5%, transparent); }
.bc-col:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.bc-bar { width: 100%; max-width: 16px; background: var(--primary); border-radius: 4px 4px 0 0; }
.bc-col:hover .bc-bar, .bc-col:focus-visible .bc-bar { background: var(--primary-hover); }
.bc-xlabels { grid-row: 2; grid-column: 2; display: flex; gap: 2px; padding-top: 6px; }
.bc-xlabels span {
  flex: 1 1 0; min-width: 0; font-size: 0.72rem; color: var(--text-muted);
  white-space: nowrap; overflow: visible; text-align: left;
}
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 10px; font-size: 0.78rem; transform: translate(-50%, -100%);
}
.chart-tip strong { display: block; font-size: 0.92rem; color: var(--text); }
.chart-tip span { color: var(--text-muted); }
.chart-table { padding: 0 20px 14px; }
.chart-table summary { cursor: pointer; color: var(--text-muted); font-size: 0.82rem; width: max-content; }
.chart-table table { margin-top: 10px; max-width: 420px; }

/* ─── Agent: appearance preview ────────────────────────────────────────── */
.widget-preview {
  --wp-primary: #2563eb; --wp-fg: #ffffff;
  display: flex; flex-direction: column; align-items: flex-end; gap: 14px;
  padding: 22px; min-height: 440px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px dashed var(--border);
}
.widget-preview.pos-left { align-items: flex-start; }
.wp-panel {
  width: 300px; max-width: 100%; overflow: hidden; border-radius: 16px;
  background: #ffffff; color: #111827; border: 1px solid #e5e7eb;
}
.wp-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--wp-primary); color: var(--wp-fg); }
.wp-avatar { width: 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--wp-fg) 22%, transparent); flex-shrink: 0; }
.wp-title { font-weight: 700; font-size: 0.92rem; }
.wp-subtitle { font-size: 0.75rem; opacity: 0.85; }
.wp-body { display: flex; flex-direction: column; gap: 8px; padding: 14px; min-height: 170px; background: #f8fafc; }
.wp-bubble {
  max-width: 85%; padding: 8px 11px; font-size: 0.82rem;
  background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px 12px 12px 4px;
}
.wp-bubble.wp-user { align-self: flex-end; background: var(--wp-primary); color: var(--wp-fg); border-color: transparent; border-radius: 12px 12px 4px 12px; }
.wp-input { padding: 11px 14px; font-size: 0.8rem; color: #9ca3af; border-top: 1px solid #e5e7eb; }
.wp-launcher-row { display: flex; align-items: center; gap: 10px; }
.pos-left .wp-launcher-row { flex-direction: row-reverse; }
.wp-launcher {
  width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--wp-primary); color: var(--wp-fg);
}
.wp-launcher-text { padding: 7px 12px; font-size: 0.8rem; border-radius: 12px; background: #ffffff; color: #111827; border: 1px solid #e5e7eb; }

/* ─── Agent: test ──────────────────────────────────────────────────────── */
.test-layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
.phone-frame { height: 640px; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: var(--surface); }
.phone-frame iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ─── Transcript ───────────────────────────────────────────────────────── */
.transcript { display: flex; flex-direction: column; gap: 14px; }
.t-msg { max-width: 82%; }
.t-user { align-self: flex-end; }
.t-meta { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; font-size: 0.75rem; color: var(--text-muted); }
.t-user .t-meta { justify-content: flex-end; }
.t-bubble {
  padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); border: 1px solid var(--border);
}
.t-user .t-bubble {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
}
.t-msg.is-flagged .t-bubble { opacity: 0.7; }

/* ─── Auth pages ───────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { text-align: center; font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.auth-card .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); }
.auth-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 22px; }
.auth-card .card { margin-bottom: 16px; }

/* ─── Error page ───────────────────────────────────────────────────────── */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.error-card { text-align: center; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--primary); }
.error-message { color: var(--text-muted); margin-bottom: 20px; }

/* ─── Utilities ────────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.text-danger { color: var(--danger); }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-24 { margin-bottom: 24px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.right { text-align: right; }

/* ─── Job progress ─────────────────────────────────────────────────────── */
.job-status { margin-top: 12px; }
.job-progress-wrap {
  background: var(--border); border-radius: 6px; height: 8px; overflow: hidden;
}
.job-progress-bar {
  background: var(--accent); height: 100%; border-radius: 6px;
  transition: width 0.4s ease;
}
.job-progress-bar.done { background: #3a8; }
.job-progress-bar.error { background: #c44; }
.job-events {
  margin-top: 8px; max-height: 180px; overflow-y: auto;
  font-size: 12.5px; line-height: 1.5;
  padding: 6px 0;
}
.job-event { padding: 1px 0; color: var(--text2); }
.job-event.warn { color: #b58a00; }
.job-event.error { color: #c44; }
.job-cost { font-size: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }

/* ─── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .grid-2, .grid-sidebar, .test-layout { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { border-bottom: none; padding-bottom: 0; }
  .topbar .user-email { display: none; }
  .bar-chart { grid-template-rows: 150px auto; }
}
