/* claude-proxy control tower — base styles.
   Direction: an instrumentation console. Calm deep-petrol surfaces, a cool teal
   action accent, metrics set in monospace (the signature type move). Not the
   cream-serif, acid-green, or broadsheet AI defaults. */

:root {
  color-scheme: dark;
  /* Dark is the default operator theme. */
  --plane: #0b1316;
  --surface-1: #121d21;
  --surface-2: #182830;
  --surface-3: #1e333c;
  --ink: #eaf2f0;
  --ink-2: #9fb2b0;
  --ink-muted: #6b807e;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #34c6c0;
  --accent-ink: #052220;
  --accent-soft: rgba(52, 198, 192, 0.14);
  --signal: #e8a13a; /* live/warm signal */
  --good: #2dcf7a;
  --warning: #f0b83a;
  --critical: #ec6a67;
  --grid: #22312f;

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.28);
  --sidebar-w: 232px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --plane: #eef2f1;
  --surface-1: #ffffff;
  --surface-2: #f4f8f7;
  --surface-3: #eaf1ef;
  --ink: #0d1a1c;
  --ink-2: #4a5a58;
  --ink-muted: #7d8f8c;
  --border: rgba(13, 26, 28, 0.1);
  --border-strong: rgba(13, 26, 28, 0.18);
  --accent: #0d8a86;
  --accent-ink: #ffffff;
  --accent-soft: rgba(13, 138, 134, 0.1);
  --signal: #c8791a;
  --good: #0ca35b;
  --warning: #c98a10;
  --critical: #d03b3b;
  --grid: #e6e8e5;
  --shadow: 0 1px 2px rgba(13, 26, 28, 0.06), 0 8px 24px rgba(13, 26, 28, 0.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --plane: #eef2f1;
    --surface-1: #ffffff;
    --surface-2: #f4f8f7;
    --surface-3: #eaf1ef;
    --ink: #0d1a1c;
    --ink-2: #4a5a58;
    --ink-muted: #7d8f8c;
    --border: rgba(13, 26, 28, 0.1);
    --border-strong: rgba(13, 26, 28, 0.18);
    --accent: #0d8a86;
    --accent-ink: #ffffff;
    --accent-soft: rgba(13, 138, 134, 0.1);
    --signal: #c8791a;
    --good: #0ca35b;
    --warning: #c98a10;
    --critical: #d03b3b;
    --grid: #e6e8e5;
    --shadow: 0 1px 2px rgba(13, 26, 28, 0.06), 0 8px 24px rgba(13, 26, 28, 0.08);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--plane);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

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

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 3px;
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100%; }
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; }
.brand-name { font-weight: 650; letter-spacing: -0.01em; font-size: 15px; }
.brand-tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); }
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.outlet { flex: 1; padding: 26px 30px 60px; max-width: 1360px; width: 100%; margin: 0 auto; }
.outlet:focus { outline: none; }

/* Nav */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav__link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px;
  transition: background 0.14s, color 0.14s;
}
.nav__link:hover { background: var(--surface-2); color: var(--ink); }
.nav__link.is-active { background: var(--accent-soft); color: var(--accent); }
.nav__icon { width: 19px; height: 19px; display: inline-flex; }
.nav__icon svg { width: 100%; height: 100%; }
.sidebar__foot { display: flex; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); }

.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; background: var(--accent-soft); border-radius: 9px; }
.brand-mark--sm { width: 30px; height: 30px; }

/* Signature: multiplexed signal bars */
.sig-bars { display: flex; align-items: flex-end; gap: 2.5px; height: 17px; }
.sig-bar {
  width: 3px; height: calc(var(--h) * 100%);
  background: var(--accent); border-radius: 1.5px;
  animation: sig 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.18s);
  transform-origin: bottom;
}
@keyframes sig { 0%, 100% { transform: scaleY(0.5); opacity: 0.55; } 50% { transform: scaleY(1); opacity: 1; } }

/* Topbar (mobile) */
.topbar { display: none; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-1); position: sticky; top: 0; z-index: 30; }
.topbar__brand { font-weight: 650; flex: 1; }
.menu-btn { display: none; }
.nav-scrim { display: none; }

/* ---------- Section head ---------- */
.sect-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.sect-title { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.sect-sub { color: var(--ink-2); font-size: 13px; margin-top: 4px; max-width: 64ch; }
.sect-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0.7; }
.tile--alert::before { background: var(--critical); }
.tile__label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-muted); }
.tile__value { display: flex; align-items: baseline; gap: 5px; margin-top: 8px; }
.tile__num { font-family: var(--mono); font-size: 27px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile__unit { font-family: var(--mono); font-size: 12px; color: var(--ink-muted); }
.tile__sub { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; }

.grid--charts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid--cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-bottom: 20px; }

/* ---------- Charts ---------- */
.chart { padding: 15px 16px 12px; display: flex; flex-direction: column; }
.chart--wide { grid-column: 1 / -1; }
.chart__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.chart__title { font-size: 14.5px; font-weight: 600; }
.chart__tools { display: flex; gap: 8px; }
.chart__plot { position: relative; min-height: 240px; width: 100%; }
.chart__legend { margin-top: 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); font-family: var(--mono); }
.legend__sw { width: 11px; height: 3px; border-radius: 2px; background: var(--sw); display: inline-block; }
.legend__sw--dash { background: repeating-linear-gradient(90deg, var(--sw) 0 4px, transparent 4px 7px); }

/* Interactive legend: each item is a button that solos its series. */
button.legend__item { border: 1px solid transparent; background: transparent; padding: 2px 7px 2px 5px; border-radius: 999px; cursor: pointer; transition: opacity 0.14s, background 0.14s, border-color 0.14s; }
button.legend__item:hover { background: var(--surface-2); }
button.legend__item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.legend__item.is-dim { opacity: 0.4; }
button.legend__item.is-solo { border-color: var(--border-strong); background: var(--surface-2); }
button.legend__item.is-solo .legend__lbl { color: var(--ink); font-weight: 600; }

.ceiling {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px dashed var(--critical);
  font-family: var(--mono); font-size: 9.5px; color: var(--critical);
  padding-left: 4px; pointer-events: none;
}
.ceiling::after { content: ""; }

/* ---------- Meters (signature) ---------- */
.sub-card { padding: 15px 16px 14px; display: flex; flex-direction: column; gap: 13px; }
.sub-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sub-card__name { font-weight: 620; font-size: 14.5px; }
.sub-card__meta { font-family: var(--mono); font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.sub-card__meters { display: flex; flex-direction: column; gap: 12px; }
.sub-card__foot { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); border-top: 1px solid var(--border); padding-top: 9px; }
/* Observed-token rows, shown where the utilization meters go for providers with
   no usage API (see usage.js). Same top line as .meter; no bar, because there
   is no published allowance to fill against. */
/* Probe report inside the custom-host modal. */
.probe { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.probe:empty { display: none; }
.probe__row { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 11px; }
.probe__k { color: var(--ink-muted); }
.probe__v { color: var(--ink); }
.probe__v--good { color: var(--good); }
.probe__v--warn { color: var(--warning); }
.probe__v--bad { color: var(--critical); }

.metered__break { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); margin-top: 3px; }

.meter { display: flex; flex-direction: column; gap: 5px; }
.meter__top { display: flex; justify-content: space-between; align-items: baseline; }
.meter__label { font-size: 12px; color: var(--ink-2); }
.meter__pct { font-family: var(--mono); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter__pct--good { color: var(--good); }
.meter__pct--warning { color: var(--warning); }
.meter__pct--critical { color: var(--critical); }
.meter__bar { display: flex; gap: 2px; height: 12px; }
.meter__seg { flex: 1; background: var(--surface-3); border-radius: 1.5px; transition: background 0.2s; }
.meter__seg--ceil { position: relative; }
.meter__seg--ceil::after { content: ""; position: absolute; inset: -2px -1px; border: 1px solid var(--border-strong); border-radius: 3px; pointer-events: none; }
.meter__bar--good .meter__seg.is-on { background: var(--good); }
.meter__bar--warning .meter__seg.is-on { background: var(--warning); }
.meter__bar--critical .meter__seg.is-on { background: var(--critical); }
.meter__resets { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); }

.hist-wrap { margin-top: 4px; }

/* Sub-card selection metric + saturated badge */
.sub-card__badges { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sub-card__sel { display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); font-size: 11px; border-top: 1px solid var(--border); padding-top: 9px; }
.sub-card__sel-lbl { color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }
.sub-card__sel-val { font-size: 13px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.sub-card__sel-score { margin-left: auto; color: var(--ink-muted); }
.sub-card__sel--sat .sub-card__sel-val { color: var(--critical); }

/* Subscriptions charts section (scoped period picker) */
.usage-charts { margin-top: 22px; }
.usage-charts__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.usage-charts__note { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; max-width: 46ch; }

/* Per-user prompts modal */
.prompts { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.prompt { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; background: var(--surface-1); }
.prompt__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.prompt__time { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); }
.prompt__model { font-family: var(--mono); font-size: 10px; color: var(--ink-2); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; text-transform: none; }
.prompt__text { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; word-break: break-word; margin: 0; }

.prompt__conv { font-family: var(--mono); font-size: 10px; color: var(--ink-muted); margin-left: auto; letter-spacing: 0.04em; }

/* ---------- Full-capture switch (Users table) ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
/* The input covers the whole control: invisible, but it is what gets clicked,
   focused and read out — the track/thumb below are pure decoration. */
.switch__input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch__track {
  position: relative; flex: none; width: 34px; height: 19px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  transition: background 0.16s, border-color 0.16s;
}
.switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--ink-muted); transition: transform 0.16s, background 0.16s;
}
.switch__state { font-family: var(--mono); font-size: 11px; color: var(--ink-muted); min-width: 2.2em; }
.switch.is-on .switch__track { background: color-mix(in srgb, var(--signal) 34%, transparent); border-color: color-mix(in srgb, var(--signal) 60%, transparent); }
.switch.is-on .switch__thumb { transform: translateX(15px); background: var(--signal); }
.switch.is-on .switch__state { color: var(--signal); }
.switch:hover .switch__track { border-color: var(--border-strong); }
.switch__input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.is-busy { opacity: 0.6; cursor: progress; }

/* ---------- Usage limit cell (Users table) ---------- */
/* Reuses .meter wholesale — no second meter idiom. Only the surrounding
   layout, the unlimited default and the blocked tint live here. */
.limit-col { min-width: 168px; }
.limit-cell { display: flex; flex-direction: column; gap: 3px; max-width: 220px; }
.limit-cell .meter__label { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.limit-cell .meter__top { gap: 10px; }
.limit-cell__win { font-family: var(--mono); font-size: 10px; color: var(--ink-muted); letter-spacing: 0.04em; }
/* Blocked is the one state with a time in it: rolling windows have no reset
   instant, so nothing time-like is shown while the user is under the cap. */
.limit-cell.is-blocked .meter__resets { color: var(--critical); font-weight: 600; }
/* Unlimited is the default, not a fault — muted, never tinted like a warning. */
.limit-none { font-family: var(--mono); font-size: 11.5px; color: var(--ink-muted); }

/* ---------- Limit editor ---------- */
/* Sized to its presets rather than stretched across the dialog. */
.limit-form .seg { flex-wrap: wrap; align-self: flex-start; }
.limit-echo { font-family: var(--mono); font-size: 11.5px; color: var(--accent); margin: 0; min-height: 17px; }
.limit-hint { font-size: 11.5px; color: var(--ink-2); margin: 2px 0 0; line-height: 1.45; }
/* Current usage over the selected window — the number that makes a cap a
   decision rather than a guess. */
.limit-usage {
  font-size: 12px; color: var(--ink-1); margin: 6px 0 0; line-height: 1.45;
  min-height: 17px;
}
.limit-usage.is-error { color: var(--critical, #d24); }
.cell-muted { color: var(--ink-2); }
.limit-formula {
  font-family: var(--mono); font-size: 11px; color: var(--ink-2); margin: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--r-sm);
  padding: 8px 11px; line-height: 1.5; overflow-wrap: anywhere;
}

.th-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 5px; border-radius: 50%;
  border: 1px solid var(--border-strong); color: var(--ink-muted);
  font-size: 9px; line-height: 1; vertical-align: 1px; cursor: help;
}
.table-note {
  font-size: 11.5px; color: var(--ink-2); line-height: 1.5;
  padding: 11px 14px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.table-note strong { color: var(--ink); font-weight: 600; }

/* ---------- Capture browser modal (prompts / conversations) ---------- */
/* Wins over .modal--wide regardless of source order (both classes are set). */
.modal.modal--xwide { max-width: 780px; }
.cap { display: flex; flex-direction: column; gap: 12px; }
.cap__tabs { display: flex; }
.cap__tabs .seg { width: 100%; }
.cap__tabs .seg__btn { flex: 1; }
.cap__panel { display: flex; flex-direction: column; gap: 10px; min-height: 180px; }
.cap__bar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.cap__bar-id { font-family: var(--mono); font-size: 12px; color: var(--ink); letter-spacing: 0.04em; }
.cap__bar-spacer { flex: 1 1 auto; }
.cap__note {
  font-size: 12px; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--border); border-left: 3px solid var(--signal);
  border-radius: var(--r-sm); padding: 8px 11px;
}

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; border-top: 1px solid var(--border); }
.pager__range { font-family: var(--mono); font-size: 11px; color: var(--ink-muted); text-align: center; flex: 1 1 auto; }

/* Conversation list */
.convs { display: flex; flex-direction: column; gap: 6px; max-height: 56vh; overflow-y: auto; }
.conv {
  display: flex; flex-direction: column; gap: 5px; width: 100%; text-align: left;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 9px 11px; cursor: pointer; color: inherit; font-family: inherit; font-size: 13px;
  transition: background 0.14s, border-color 0.14s;
}
.conv:hover { background: var(--surface-2); border-color: var(--border-strong); }
.conv__main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.conv__id { font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; }
.conv__meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.conv__counts { font-size: 11.5px; color: var(--ink-2); }
.conv__time { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); }

/* Message viewer */
.msgs { display: flex; flex-direction: column; gap: 9px; max-height: 56vh; overflow-y: auto; }
.msg { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 9px 11px; background: var(--surface-1); border-left-width: 3px; }
.msg--user { border-left-color: var(--accent); }
.msg--assistant { border-left-color: var(--ink-muted); background: var(--surface-2); }
.msg__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 6px; }
.msg__role { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.msg--user .msg__role { color: var(--accent); }
.msg--assistant .msg__role { color: var(--ink-2); }
.msg__seq { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); }
.msg__time { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); margin-left: auto; }
.msg__text { font-family: var(--mono); font-size: 12px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; margin: 0; }

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-card__note {
  margin: 0; padding: 11px 14px; font-size: 11.5px; line-height: 1.45;
  color: var(--ink-muted); background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table-card__note--error { color: var(--critical); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); font-weight: 500; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num { font-family: var(--mono); }
.cell-strong { display: block; font-weight: 560; }
.cell-id { display: block; font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); }
.cell-warn { color: var(--critical); }
td.actions { text-align: right; white-space: nowrap; }
/* Keep actions on one line and let .table-scroll handle any overflow — wrapping
   them turns every row into a multi-line block once a column is added. */
.row-actions { display: inline-flex; gap: 4px; flex-wrap: nowrap; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; padding: 3px 9px 3px 8px; border-radius: 20px; border: 1px solid var(--border); text-transform: capitalize; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.badge--warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent); }
.badge--critical { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.badge--muted { color: var(--ink-muted); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 540; padding: 7px 13px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); cursor: pointer; transition: background 0.14s, border-color 0.14s, transform 0.05s; white-space: nowrap; }
.btn[hidden] { display: none; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--critical); color: #fff; border-color: transparent; }
.btn--danger:hover { background: color-mix(in srgb, var(--critical) 86%, #000); }
.btn--danger-ghost { background: transparent; color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn--danger-ghost:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; transition: background 0.14s, color 0.14s; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg__btn { border: none; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 540; padding: 5px 11px; border-radius: 5px; cursor: pointer; font-family: var(--mono); letter-spacing: 0.02em; transition: background 0.14s, color 0.14s; }
.seg__btn:hover { color: var(--ink); }
.seg__btn.is-active { background: var(--surface-1); color: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }

/* ---------- Period control (presets + custom range) ---------- */
.period-ctl { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.period-ctl__panel[hidden] { display: none; }
.period-ctl__panel { width: 100%; }
.period-ctl__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; justify-content: flex-end; }
.period-ctl__f { display: flex; flex-direction: column; gap: 4px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.input--dt { width: auto; font-family: var(--mono); font-size: 12.5px; padding: 6px 9px; color-scheme: light dark; }
.btn--sm { font-size: 12px; padding: 6px 12px; }
.period-ctl__err { color: var(--critical); font-family: var(--mono); font-size: 11.5px; text-align: right; }
.period-ctl__err[hidden] { display: none; }

/* ---------- Forms & modals ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; opacity: 0; transition: opacity 0.2s; }
.modal-overlay.is-in { opacity: 1; }
.modal { background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-lg); width: 100%; max-width: 440px; box-shadow: 0 20px 70px rgba(0, 0, 0, 0.5); transform: translateY(8px) scale(0.99); transition: transform 0.2s; max-height: 90vh; display: flex; flex-direction: column; }
.modal-overlay.is-in .modal { transform: none; }
.modal--wide { max-width: 560px; }
.modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal__title { font-size: 16px; font-weight: 640; }
.modal__sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.modal__head .icon-btn { font-size: 22px; line-height: 1; }
.modal__body { padding: 4px 20px 8px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
.confirm-msg { color: var(--ink-2); font-size: 13.5px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.codex-oauth { display: flex; flex-direction: column; gap: 12px; }
.codex-oauth[hidden] { display: none; }
.codex-oauth__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
.field-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }
.input { width: 100%; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); color: var(--ink); font-size: 13.5px; padding: 9px 11px; font-family: var(--sans); transition: border-color 0.14s, background 0.14s; }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface-1); }
.input--code { font-family: var(--mono); font-size: 12px; line-height: 1.55; resize: vertical; }
.input--sm { }

.token-box { display: flex; gap: 8px; align-items: stretch; }
.token-reveal { flex: 1; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 10px 12px; word-break: break-all; color: var(--accent); }

/* ---------- States ---------- */
.loading { display: flex; align-items: center; gap: 10px; padding: 34px; color: var(--ink-muted); font-size: 13px; justify-content: center; }
.loading__ring { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 24px; text-align: center; }
.empty__mark { font-size: 24px; color: var(--ink-muted); letter-spacing: 3px; }
.empty__title { font-weight: 600; font-size: 14px; }
.empty__hint { color: var(--ink-2); font-size: 12.5px; max-width: 44ch; }
.empty--error .empty__title { color: var(--critical); }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px; cursor: pointer; transform: translateX(20px); opacity: 0; transition: transform 0.2s, opacity 0.2s; max-width: 340px; }
.toast.is-in { transform: none; opacity: 1; }
.toast__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast--good .toast__dot { background: var(--good); }
.toast--warning .toast__dot { background: var(--warning); }
.toast--critical .toast__dot { background: var(--critical); }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: flex; }
.login { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 14px; background: radial-gradient(1200px 600px at 50% -10%, var(--surface-2), var(--plane)); }
.login__card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 26px 26px 24px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.login__brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.login__title { font-weight: 660; font-size: 17px; letter-spacing: -0.01em; }
.login__tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); }
.login__form { display: flex; flex-direction: column; gap: 8px; }
.login__input { padding: 11px 13px; }
.login__btn { margin-top: 6px; padding: 11px; font-size: 14px; }
.login__err { color: var(--critical); font-size: 12.5px; min-height: 16px; }
.form-err { color: var(--critical); font-size: 12.5px; min-height: 16px; margin: 0; }
/* Per-field guidance. Empty by default and collapsed via :empty so a field
   without help does not leave a gap. */
.field-help { font-size: 11.5px; line-height: 1.45; color: var(--ink-muted); margin: 0; }
.field-help:empty { display: none; }
/* Endpoint combobox: an editable URL field plus an always-complete preset menu.
   The native <input list> was replaced because a datalist filters against the
   current value, which a prefilled field makes useless. */
.combo { position: relative; display: flex; align-items: stretch; gap: 0; }
.combo__input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.combo__toggle {
  flex: 0 0 auto; width: 34px; cursor: pointer;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--border-strong); border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 12px; line-height: 1;
  transition: background 0.14s, color 0.14s;
}
.combo__toggle:hover { background: var(--surface-2); color: var(--ink); }
.combo__toggle[hidden] { display: none; }
/* When the toggle is hidden the field is a plain input again. */
.combo__toggle[hidden] + .combo__menu ~ * , .combo:has(.combo__toggle[hidden]) .combo__input {
  border-top-right-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm);
}
.combo__menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
}
.combo__menu[hidden] { display: none; }
.combo__opt { padding: 7px 9px; border-radius: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.combo__opt:hover, .combo__opt:focus-visible { background: var(--accent-soft); }
.combo__opt-name { font-size: 12.5px; color: var(--ink); }
.combo__opt-url { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); word-break: break-all; }
/* Optional settings, folded away so the common path is short. */
.form-adv { border-top: 1px solid var(--border); padding-top: 10px; }
.form-adv > summary { cursor: pointer; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); list-style: none; }
.form-adv > summary::-webkit-details-marker { display: none; }
.form-adv > summary::before { content: "▸ "; }
.form-adv[open] > summary::before { content: "▾ "; }
.form-adv > summary:hover { color: var(--ink-2); }
.form-adv__body { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
/* A hidden form row must not still occupy its flex gap. */
.form-row[hidden] { display: none; }
.login__foot { font-family: var(--mono); font-size: 10.5px; color: var(--ink-muted); letter-spacing: 0.04em; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform 0.22s; box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; }
  .topbar { display: flex; }
  .menu-btn { display: inline-flex; }
  .grid--charts { grid-template-columns: 1fr; }
  .outlet { padding: 20px 18px 50px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .modal-overlay { padding: 10px; align-items: flex-start; padding-top: 24px; }
  .modal__head, .modal__foot { padding-left: 14px; padding-right: 14px; }
  .modal__body { padding-left: 14px; padding-right: 14px; }
  .prompt__head { flex-wrap: wrap; gap: 6px; }
  .prompt__conv { margin-left: 0; }
  .msg__time { margin-left: 0; }
  /* Prev + range + Next still fit on one line down to ~360px; keep them there
     so the controls never get pushed below the scroll area. */
  .pager { gap: 6px; }
  .pager .btn { padding: 7px 9px; }
  .pager__range { font-size: 10.5px; }
  .convs, .msgs, .prompts { max-height: 50vh; }
  .switch__state { min-width: 0; }
  /* The window presets get their own line rather than squeezing to 4 tiny hit
     targets. */
  .limit-form .seg { width: 100%; }
  .limit-form .seg__btn { flex: 1; padding: 6px 8px; }
}
@media (max-width: 480px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile__num { font-size: 22px; }
  .sect-actions .seg { flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .outlet { padding: 16px 12px 44px; }
  .grid--cards { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .tiles { grid-template-columns: 1fr; }
  .cap__bar { gap: 6px; }
  .cap__bar-spacer { display: none; }
  .conv__meta { flex-direction: column; gap: 2px; }
  /* The table already scrolls horizontally; keep the meter legible rather than
     letting the column collapse under it. */
  .limit-col { min-width: 150px; }
  .limit-cell { max-width: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
