/* Web admin — tokens first; every colour below comes from them so both themes stay in sync. */
:root {
  color-scheme: dark;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #0b0d12;
  --surface: #12151c;
  --surface-2: #181c25;
  --surface-3: #1f2430;
  --border: #242a37;
  --border-strong: #323a4b;
  --fg: #e7e9ef;
  --fg-2: #b4bac8;
  --muted: #808799;
  --accent: #7c8cff;
  --accent-strong: #6474f5;
  --accent-soft: rgba(124, 140, 255, 0.14);
  --accent-fg: #ffffff;
  --primary: #5b6af0;
  --primary-hover: #6d7bf6;
  --good: #3ecf8e;
  --good-soft: rgba(62, 207, 142, 0.13);
  --warn: #f2b54a;
  --warn-soft: rgba(242, 181, 74, 0.14);
  --bad: #f36f80;
  --bad-soft: rgba(243, 111, 128, 0.14);
  --code-bg: rgba(255, 255, 255, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 3px rgba(124, 140, 255, 0.35);

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 236px;

  /* legacy names still referenced by inline styles in templates */
  --grid: var(--border);
  --row-alt: var(--surface-2);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef0f4;
    --border: #e3e6ec;
    --border-strong: #cfd4dd;
    --fg: #101322;
    --fg-2: #3b4254;
    --muted: #697084;
    --accent: #4f5ef0;
    --accent-strong: #3e4bd6;
    --accent-soft: rgba(79, 94, 240, 0.09);
    --primary: #4f5ef0;
    --primary-hover: #3e4bd6;
    --good: #14915a;
    --good-soft: rgba(20, 145, 90, 0.1);
    --warn: #a86b06;
    --warn-soft: rgba(214, 140, 18, 0.13);
    --bad: #d22f4b;
    --bad-soft: rgba(210, 47, 75, 0.09);
    --code-bg: rgba(16, 19, 34, 0.05);
    --shadow: 0 1px 2px rgba(16, 19, 34, 0.06), 0 1px 3px rgba(16, 19, 34, 0.04);
    --shadow-lg: 0 12px 32px -14px rgba(16, 19, 34, 0.25);
    --ring: 0 0 0 3px rgba(79, 94, 240, 0.25);
  }
}

/* ── base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { color: var(--fg); letter-spacing: -0.015em; line-height: 1.25; }
h2 { font-size: 1.6rem; font-weight: 650; margin: 0 0 0.5rem; }
h2 small { font-size: 0.55em; font-weight: 450; letter-spacing: 0; margin-left: 0.35em; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 2.2rem 0 0.75rem; }
h4 { font-size: 0.85rem; font-weight: 600; margin: 0 0 0.5rem; color: var(--fg-2); }
p { margin: 0.5rem 0 1rem; }
main > p.muted, section > p.muted { max-width: 78ch; }
b, strong { font-weight: 600; }
code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--code-bg); color: var(--fg-2);
  padding: 0.12em 0.4em; border-radius: 5px;
  overflow-wrap: anywhere;
}
ul, ol { margin: 0.3em 0; padding-left: 1.4em; }
li { margin: 0.2em 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85em; margin-top: 1.5em; }
.num { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); }

/* ── shell: sidebar + content ────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
/* Paint the sidebar column on the shell so it reaches the bottom of long pages. */
body.with-nav .shell {
  background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--border) calc(var(--sidebar-w) - 1px), var(--border) var(--sidebar-w), transparent var(--sidebar-w));
}
.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); height: 100vh;
  display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.1rem 0.8rem;
  background: var(--surface); border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.25rem 0.5rem; color: var(--fg); font-weight: 650; font-size: 0.98rem;
  letter-spacing: -0.01em; min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #b26cf0);
  color: #fff; font-size: 0.85rem; font-weight: 700;
  box-shadow: 0 2px 8px -2px rgba(124, 140, 255, 0.6);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-heading {
  margin: 1rem 0.6rem 0.35rem; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.nav-link {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.45rem 0.6rem; border-radius: var(--radius-sm);
  color: var(--fg-2); font-weight: 500; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.nav-link .ico { color: var(--muted); flex: 0 0 auto; transition: color 0.12s; }
.nav-link:hover { background: var(--surface-3); color: var(--fg); text-decoration: none; }
.nav-link:hover .ico { color: var(--fg-2); }
.nav-link.active { background: var(--accent-soft); color: var(--fg); }
.nav-link.active .ico { color: var(--accent); }
.sidebar-foot {
  margin-top: auto; padding: 0.75rem 0.6rem 0;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.clock { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.signout {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--fg-2); font-size: 0.85rem; font-weight: 500;
}
.signout:hover { color: var(--bad); text-decoration: none; }

.content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 2.25rem 2.5rem 2rem; flex: 1 0 auto; }
footer {
  width: 100%; max-width: 1280px; margin: 0 auto;
  padding: 1.25rem 2.5rem 2rem; color: var(--muted);
}
footer small { font-size: 0.78rem; }
footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* Signed-out pages (login) have no nav: brand on top, content centred. */
body.no-nav .shell { flex-direction: column; }
body.no-nav .sidebar {
  position: static; width: 100%; height: auto; flex: none;
  flex-direction: row; align-items: center; justify-content: space-between;
  background: transparent; border: 0; padding: 1.25rem 1.5rem;
}
body.no-nav .sidebar-foot { margin: 0; padding: 0; border: 0; }

/* ── buttons ─────────────────────────────────────────────────────────── */
button, .btn, a.button, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
  font: inherit; font-size: 0.86rem; font-weight: 500; line-height: 1.2;
  padding: 0.5rem 0.9rem; min-height: 34px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
button:hover, .btn:hover, a.button:hover, .btn-secondary:hover {
  background: var(--surface-3); border-color: var(--border-strong); text-decoration: none;
}
button:focus-visible, .btn:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); }
button:active { transform: translateY(0.5px); }
.btn-primary, a.button {
  background: var(--primary); border-color: var(--primary); color: var(--accent-fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover, a.button:hover {
  background: var(--primary-hover); border-color: var(--primary-hover); color: var(--accent-fg);
}
.btn-danger, button.btn-danger {
  background: transparent; color: var(--bad); border-color: var(--border-strong); box-shadow: none;
}
.btn-danger:hover, button.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
button.toggle-on { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: var(--good-soft); box-shadow: none; }
button.toggle-off { color: var(--muted); }
.btn-sm, button.btn-sm, a.btn.btn-sm { padding: 0.3rem 0.65rem; min-height: 28px; font-size: 0.8rem; }

/* ── inputs ──────────────────────────────────────────────────────────── */
input:not([type]), input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], input[type="url"], select, textarea {
  font: inherit; font-size: 0.88rem; color: var(--fg);
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0.45rem 0.65rem; min-height: 34px;
  max-width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: var(--ring); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23808799' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.65rem center;
}
textarea { display: block; width: 100%; line-height: 1.55; resize: vertical; font-family: var(--mono); font-size: 0.84rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
label { color: var(--fg-2); font-size: 0.86rem; }
label small { color: var(--muted); font-size: 0.8rem; }
label.field small, td label small { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* Forms laid out as a single wrapping row of controls. */
form { margin: 0; }
.form-row, table td form, .controls form, .inline-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
}
.inline-card {
  margin: 0.5rem 0 1rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}

form.stack, table td form.stack { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; }
form.stack > button { align-self: flex-start; }
form.stack + form.stack { margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px dashed var(--border); }
label.field { display: flex; flex-direction: column; gap: 0.3rem; }
.secret-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
table.integrations td { vertical-align: top; }
table.integrations td:first-child { min-width: 14rem; max-width: 26rem; }
table.integrations td:first-child small:not(.muted) { color: var(--fg-2); display: inline-block; margin-top: 0.2rem; }
table.integrations textarea { min-width: 18rem; }

/* ── cards & tables ──────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem;
}
.table-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-x: auto; margin: 0.75rem 0 1rem;
  -webkit-overflow-scrolling: touch;
}
.table-card > table { margin: 0; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.88rem; }
th, td { padding: 0.7rem 1rem; text-align: left; vertical-align: middle; }
thead th {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th small { text-transform: none; letter-spacing: 0; }
tbody td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { border-top: 1px solid var(--border-strong); background: var(--surface-2); }
td small { font-size: 0.8rem; }
td .muted, td small.muted { font-size: 0.8rem; }
table .num, th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td input:not([type="checkbox"]), td select { min-height: 32px; padding-top: 0.35rem; padding-bottom: 0.35rem; }
td button { min-height: 32px; padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* Wide tables outside a .table-card still scroll inside themselves at narrow widths. */
@media (max-width: 900px) {
  main table:not(.agent-cost-table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-card > table { display: table; }
}

table.agents .focus, table.agents .models { color: var(--muted); font-size: 0.82rem; }
table.agents .cost, .cost { color: var(--accent); }
table.agents tr.dead td:nth-child(2) { color: var(--bad); }
table.agents tr.paused { opacity: 0.6; }
table.agents tr.remote td:nth-child(2) { color: var(--muted); }
tr.state-paused, tr.state-dormant { opacity: 0.6; }
tr.state-DEAD td:first-child a { color: var(--bad); }
table.agents td form { display: inline-flex; }
table.agents td small.muted { margin-left: 0.35rem; }

/* Access grid: checkbox columns centred. */
table.grid td:not(:first-child):not(:last-child), table.grid th:not(:first-child):not(:last-child) { text-align: center; }

/* ── status pills ────────────────────────────────────────────────────── */
.badge, .state, span.ok, small.ok, span.warn, small.warn, .pill {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.15em 0.6em; border-radius: 999px;
  font-size: 0.76rem; font-weight: 550; line-height: 1.5; white-space: nowrap;
  background: var(--surface-3); color: var(--fg-2);
  border: 1px solid transparent;
}
.badge::before, .state::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9;
}
span.ok, small.ok, .badge.state-active, .state.active, .state.up, .badge.state-up { background: var(--good-soft); color: var(--good); }
span.warn, small.warn, .badge.state-paused, .state.paused { background: var(--warn-soft); color: var(--warn); }
.badge.state-idle, .state.idle, .badge.state-remote, .state.remote { background: var(--accent-soft); color: var(--accent); }
.badge.state-dormant, .state.dormant { background: var(--surface-3); color: var(--muted); }
.badge.state-DEAD, .state.DEAD { background: var(--bad-soft); color: var(--bad); }
h2 .badge { vertical-align: middle; font-size: 0.75rem; letter-spacing: 0; }

/* Callouts: <p class="ok|warn"> */
p.ok, p.warn, .d-hi:is(p) {
  display: block; padding: 0.7rem 0.95rem; border-radius: var(--radius-sm);
  border: 1px solid; font-size: 0.88rem; max-width: 78ch;
}
p.ok { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
p.warn, p.d-hi { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.d-ok { color: var(--good); }
.d-hi { color: var(--warn); font-weight: 600; }

/* ── page header block ───────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-bottom: 0.5rem; }
.page-head h2 { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1.25rem; }
.back { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.84rem; color: var(--muted); margin: 0 0 1rem; }
.back a { color: var(--muted); }
.back a:hover { color: var(--fg); }

/* ── home tiles ──────────────────────────────────────────────────────── */
.home-links {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.85rem; margin: 0.5rem 0 2.5rem;
}
.home-links .tile {
  position: relative; display: flex; flex-direction: column; gap: 0.3rem;
  padding: 1.1rem 1.15rem 1.15rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--fg); text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.home-links .tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); text-decoration: none; }
.home-links .tile .tile-ico {
  display: grid; place-items: center; width: 32px; height: 32px; margin-bottom: 0.45rem;
  border-radius: 8px; background: var(--accent-soft); color: var(--accent);
}
.home-links .tile strong { font-size: 0.95rem; font-weight: 600; }
.home-links .tile small { color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.home-links .tile::after {
  content: "→"; position: absolute; top: 1.05rem; right: 1.1rem; color: var(--muted);
  opacity: 0; transform: translateX(-4px); transition: opacity 0.15s, transform 0.15s;
}
.home-links .tile:hover::after { opacity: 1; transform: none; }

/* ── key/value lists ─────────────────────────────────────────────────── */
dl.kv {
  display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: 0;
  margin: 0.75rem 0 1rem; padding: 0.25rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
dl.kv dt, dl.kv dd { padding: 0.6rem 0; border-bottom: 1px solid var(--border); margin: 0; min-width: 0; }
dl.kv dt { color: var(--muted); font-size: 0.84rem; padding-right: 1rem; }
dl.kv dd { overflow-wrap: anywhere; }
dl.kv dt:last-of-type, dl.kv dd:last-of-type { border-bottom: 0; }
dl.kv ul { padding-left: 1.1em; }

/* ── agent controls ──────────────────────────────────────────────────── */
.controls {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.controls > form, .controls > p { margin: 0; padding: 0.95rem 1.25rem; border-bottom: 1px solid var(--border); }
.controls > :last-child { border-bottom: 0; }
.controls form { gap: 0.6rem 0.75rem; }
.controls small { color: var(--muted); font-size: 0.82rem; flex: 1 1 18rem; }
.controls label { font-weight: 500; }
.controls button.pause { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); }
.controls button.unpause { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, transparent); background: var(--good-soft); }
.controls input[type="password"] { flex: 1 1 16rem; }

/* ── dashboard ───────────────────────────────────────────────────────── */
section.burn, section.agents-section { margin-bottom: 2.5rem; }
section.burn h2, section.agents-section h2 { margin-top: 0; }
section.burn h3 { margin: 1.5rem 0 0.6rem; font-size: 0.9rem; font-weight: 600; color: var(--fg-2); }
.cost-totals { font-size: 0.9rem; color: var(--muted); margin: 0 0 1rem; }
.cost-totals strong { color: var(--fg); font-size: 1.05rem; }
.cost-panels, .rolling-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 0.75rem; margin: 0.75rem 0 1.5rem;
}
.cost-panel, .rolling-card {
  padding: 1rem 1.1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 0;
}
.cost-panel.cap-amber, .rolling-card.cap-amber { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); background: linear-gradient(var(--warn-soft), transparent 70%), var(--surface); }
.cost-panel.cap-red, .rolling-card.cap-red { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); background: linear-gradient(var(--bad-soft), transparent 70%), var(--surface); }
.panel-title, .rolling-label { color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.panel-total, .rolling-num { font-size: 1.65rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--fg); margin: 0.15rem 0 0.3rem; }
.rolling-sub { color: var(--muted); font-size: 0.8em; }
.rolling-cost { font-size: 0.95em; font-variant-numeric: tabular-nums; color: var(--accent); margin-top: 0.2em; }
.cap-bar-wrap { background: var(--surface-3); height: 6px; margin: 0.5rem 0 0.2rem; border-radius: 999px; overflow: hidden; }
.cap-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.cap-amber .cap-bar { background: var(--warn); }
.cap-red .cap-bar { background: var(--bad); }
.cap-pct { color: var(--muted); font-size: 0.75rem; }
.calibration-note { font-size: 0.8em; color: var(--muted); margin: -0.6em 0 1em; }
table.agent-cost-table { width: 100%; margin-top: 0.6rem; font-size: 0.8rem; border-top: 1px solid var(--border); }
table.agent-cost-table td { padding: 0.25rem 0.3rem 0.1rem 0; white-space: nowrap; border: 0; }
table.agent-cost-table tr:hover { background: none; }
table.agent-cost-table .agent-name { width: 100%; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; max-width: 0; }
table.agent-cost-table .num { color: var(--fg); text-align: right; }
table.agent-cost-table .pct { text-align: right; min-width: 3.2em; }

.chart-block {
  margin: 0.75rem 0 1.25rem; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
section.burn .chart-block h3 { margin-top: 0; }
.chart-block canvas { max-width: 100%; }
.chart { display: block; width: 100%; height: auto; max-height: 150px; background: transparent; }
.chart .bar { fill: var(--accent); opacity: 0.85; }
.chart .bar.zero { fill: var(--border); }
.chart .bar.hot { fill: var(--warn); }
.chart .bar.ok { fill: var(--accent); }
.chart .bar:hover { opacity: 1; fill: var(--good); }
.chart .tick, .chart .peak { fill: var(--muted); font-size: 9px; font-family: var(--font); }

.routines, .dreaming {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin: 0.75rem 0; padding: 0.85rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.routines > span, .dreaming > span { margin-right: 0.4rem; font-size: 0.86rem; }

/* ── usage windows ───────────────────────────────────────────────────── */
.uw-headline {
  font-size: 1.05rem; margin: 0 0 1rem; padding: 1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.usage-windows .uw-table { font-size: 0.84rem; }
.usage-windows .uw-table th, .usage-windows .uw-table td { padding: 0.55rem 0.85rem; white-space: nowrap; }

/* ── auth ────────────────────────────────────────────────────────────── */
.auth-box {
  max-width: 400px; margin: 6vh auto 2rem; padding: 2rem 2rem 1.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.auth-box h2 { font-size: 1.35rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1.25rem; }
.auth-form label { font-size: 0.82rem; font-weight: 500; color: var(--fg-2); }
.auth-form input[type="email"] { width: 100%; min-height: 40px; font-size: 0.95rem; }
.auth-form button, .auth-box form button { width: 100%; min-height: 40px; margin-top: 0.4rem; }

/* ── transcripts / chat ──────────────────────────────────────────────── */
.transcript { max-height: 600px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5em; margin: 0.5em 0; }
.turn { margin: 0.4em 0; padding: 0.4em 0.6em; border-left: 3px solid var(--border); }
.turn-assistant { border-left-color: var(--accent); }
.turn-user { border-left-color: var(--good); }
.turn-meta { color: var(--muted); font-size: 0.78em; display: block; margin-bottom: 0.2em; }
.turn-content { font-size: 0.88em; white-space: pre-wrap; word-break: break-word; }

/* ── connect steps ───────────────────────────────────────────────────── */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 1rem 0; display: grid; gap: 0.85rem; max-width: 760px; }
ol.steps > li {
  counter-increment: step; position: relative; margin: 0;
  padding: 1rem 1.15rem 1rem 3.4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
ol.steps > li::before {
  content: counter(step); position: absolute; left: 1.1rem; top: 1rem;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 0.8rem;
}
ol.steps form { display: flex; flex-wrap: wrap; gap: 0.5rem; }
ol.steps input { flex: 1 1 14rem; min-width: 0; width: 100%; }
ol.steps > li { min-width: 0; }

/* ── screen ──────────────────────────────────────────────────────────── */
#screen { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

/* ── narrow screens: sidebar becomes a top bar with a scrolling nav ─── */
@media (max-width: 860px) {
  html, body { font-size: 14px; }
  .shell { flex-direction: column; }
  body.with-nav .shell { background: none; }
  .sidebar {
    position: sticky; top: 0; z-index: 10;
    width: 100%; height: auto; flex: none;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand foot" "nav nav";
    gap: 0.5rem 0.75rem; padding: 0.6rem 1rem 0.5rem;
    border-right: 0; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  }
  .brand { grid-area: brand; padding: 0.15rem 0; }
  .sidebar-foot { grid-area: foot; margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .sidebar-foot .clock { display: none; }
  .nav {
    grid-area: nav; flex-direction: row; gap: 0.25rem;
    overflow-x: auto; scrollbar-width: none; margin: 0 -1rem; padding: 0 1rem 0.1rem;
    -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-heading { display: none; }
  .nav-link { padding: 0.38rem 0.65rem; font-size: 0.84rem; }
  .nav-link .ico { width: 14px; height: 14px; }
  main { padding: 1.25rem 1rem 1.5rem; }
  footer { padding: 1rem 1rem 1.5rem; }
  h2 { font-size: 1.35rem; }
  h3 { margin-top: 1.75rem; }
  dl.kv { grid-template-columns: minmax(6.5rem, 38%) 1fr; padding: 0.15rem 1rem; }
  .controls > form, .controls > p { padding: 0.85rem 1rem; }
  .home-links { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .home-links .tile { padding: 0.9rem; }
  .home-links .tile small { font-size: 0.78rem; }
  .auth-box { margin-top: 2rem; padding: 1.5rem; }
  body.no-nav .sidebar { display: flex; position: static; background: transparent; backdrop-filter: none; border: 0; padding: 1rem; }
  body.no-nav .sidebar-foot .clock { display: inline; }
  input:not([type]), input[type="text"], input[type="email"], input[type="password"], select { max-width: 100%; }
  input[size] { width: auto; min-width: 0; }
}
@media (max-width: 520px) {
  .home-links { grid-template-columns: 1fr; gap: 0.5rem; }
  .home-links .tile { display: grid; grid-template-columns: auto 1fr; column-gap: 0.85rem; row-gap: 0.1rem; align-items: center; padding: 0.8rem 0.9rem; }
  .home-links .tile .tile-ico { grid-row: span 2; margin: 0; }
  .home-links .tile::after { opacity: 1; transform: none; top: 50%; margin-top: -0.7em; }
  .home-links .tile strong, .home-links .tile small { padding-right: 1.2rem; }
  table td form { flex-wrap: nowrap; }
}
