/* LLM Gateway Console — light, clean, calm. System fonts only (no CDN).
   Type system: the machine's own tokens (keys, aliases, model routes, IPs,
   config) wear MONO; the human narration around them wears the UI sans. That
   pairing is the personality — a gateway console is mostly identifiers, so the
   mono voice is load-bearing, not decoration. Restraint elsewhere: one accent,
   hairline rules over boxes, whitespace over borders. The one loud element is
   the burn gauge. */

:root {
  color-scheme: light;

  /* surfaces — white content planes floating on a cool near-white page */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f6f8fb;   /* inset code/inputs */
  --border: #e4e8ee;           /* hairline */
  --border-strong: #d2d9e2;    /* hover / active hairline */

  /* ink */
  --text: #1a1e26;
  --text-dim: #55606f;
  --text-faint: #838c99;

  /* brand + reserved status */
  --accent: #2560cf;
  --accent-weak: rgba(37, 96, 207, 0.09);
  --danger: #cc3626;
  --success: #0f8a4d;
  --warn: #b06a08;
  --violet: #5a44c4;           /* fable / mantle retention hue */

  /* meter tracks: a faint tint of the fill hue so severity reads across the
     whole bar, not just the filled part */
  --success-track: rgba(15, 138, 77, 0.14);
  --warn-track: rgba(176, 106, 8, 0.16);
  --danger-track: rgba(204, 54, 38, 0.13);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* categorical chart slots — validated (dataviz six checks, WHITE surface):
     worst adjacent CVD ΔE 36.9, all 5 ≥3:1 on the surface. Hue identities
     carried over from the retired dark theme so a model keeps its family.
     Fixed identity order; econ buckets use 1–4, model mix cycles 1–5. */
  --chart-1: #2a78d6;   /* blue    */
  --chart-2: #eb6834;   /* orange  */
  --chart-3: #1596a0;   /* teal    */
  --chart-4: #4a3aa7;   /* violet  */
  --chart-5: #c14b8a;   /* magenta */
  --chart-line: #256abf;
  --chart-area: rgba(42, 120, 214, 0.11);

  /* elevation — soft, low, to lift white planes off the page without noise */
  --shadow-sm: 0 1px 2px rgba(24, 33, 54, 0.05), 0 1px 3px rgba(24, 33, 54, 0.05);
  --shadow-md: 0 2px 6px rgba(24, 33, 54, 0.06), 0 6px 20px rgba(24, 33, 54, 0.07);
  --shadow-lg: 0 18px 48px rgba(24, 33, 54, 0.20);
}

* {
  box-sizing: border-box;
}

/* author display rules (e.g. .field's flex) must never defeat hidden */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.console-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.console-header__title {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
}

/* a quiet dot + wordmark reads as a mark without a logo asset */
.console-header__title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: baseline;
}

.console-header__nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.console-header__link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
}

.console-header__link:hover {
  color: var(--text);
}

.console-header__logout {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
}

.console-header__logout:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.console-header__logout:hover {
  color: var(--text);
}

.console-main {
  padding: 34px 28px;
  max-width: 980px;
  margin: 0 auto;
}

.console-placeholder {
  color: var(--text-dim);
}

/* ═══════════════ Passwordless sign-in ═══════════════ */

.console-main--auth {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

/* The one deliberate flourish on the auth card: a thin accent rule across its
   top edge — the console's signature, echoed by the header mark. */
.authcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 392px;
  padding: 36px 34px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.authcard__eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.authcard__title {
  margin: 2px 0 0;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.authcard__lede {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

.authcard__lede--error {
  color: var(--danger);
}

.authcard__input--code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
}

/* authenticator (TOTP) setup page */
.authcard--totp form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.totpqr {
  align-self: center;
  margin: 6px auto;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  width: fit-content;
}

.totpqr svg {
  display: block;
  width: 190px;
  height: 190px;
}

.totpmanual {
  font-size: 13px;
  color: var(--text-dim);
}

.totpmanual__key code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 14px;
  letter-spacing: 0.06em;
  word-break: break-all;
  user-select: all;
}

.totpmanual__meta {
  margin: 6px 0 0;
  font-size: 12px;
}

/* portal: one-time Bedrock-cleanup card */
.setupfix__steps {
  margin: 8px 0 12px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-dim);
}

/* plain multi-line script now (never base64 — Defender/AMSI blocks encoded
   one-liners); scrolls both ways so long lines don't blow the card open */
.setupfix__cmd {
  max-height: 240px;
  overflow: auto;
  white-space: pre;
  font-size: 11px;
  line-height: 1.45;
  user-select: all;
}

.setupfix .keycard__actions form {
  display: inline;
}

.authcard__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-dim);
}

.authcard__input {
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.authcard__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.authcard__submit {
  margin-top: 6px;
  padding: 11px 16px;
  background: var(--accent);
  border: none;
  border-radius: 9px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.authcard__submit:hover { background: #1f55bb; }
.authcard__submit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.authcard--message { gap: 8px; }

.authcard__back {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-dim);
}
.authcard__back:hover { color: var(--text); }

/* ── portal: the "your key" card + one-time reveal ── */
.keycard__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.keyconfig {
  margin: 14px 0 0;
  padding: 15px 16px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
}

/* once the real key is in the block, mark it live so it reads as a readout */
.keyconfig--revealed {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-weak);
}

/* the Fable default variant — a second, clearly-labelled block */
.keyconfig--variant {
  margin-top: 8px;
  border-style: dashed;
}

.keycard__variant-label {
  margin: 18px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--violet);
}

.keycard__hint {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.keycard__models {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}

.keycard__models code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.keycard__hint code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.keycard__warn {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--warn);
}

/* ═══════════════ Dashboard ═══════════════ */

.console-main--dash {
  max-width: 1180px;
  display: flex;
  flex-direction: column;
  gap: 46px;
  padding-top: 30px;
  padding-bottom: 84px;
}

.overline {
  margin: 0 0 6px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.section-head__spacer { flex: 1; }

.section-count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* ── pulse strip ── the compact "is anything wrong" band, on the page plane */

.pulse__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.pulse__hero {
  margin: 0;
  line-height: 1.05;
}

.pulse__dollars {
  font-size: 46px;
  font-weight: 680;
  letter-spacing: -0.025em;
}

.pulse__cents {
  font-size: 22px;
  font-weight: 550;
  color: var(--text-dim);
}

.pulse__of {
  display: inline-block;
  margin-left: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.pulse__actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.pulse__ui-link {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 13px;
  white-space: nowrap;
  background: var(--surface);
}

.pulse__ui-link:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

/* the burn gauge — the page's one loud element */
.burnbar {
  display: block;
}

.burnbar__track { fill: var(--success-track); }
.burnbar__fill { fill: var(--success); }
.burnbar.sev-warn .burnbar__track { fill: var(--warn-track); }
.burnbar.sev-warn .burnbar__fill { fill: var(--warn); }
.burnbar.sev-over .burnbar__track { fill: var(--danger-track); }
.burnbar.sev-over .burnbar__fill { fill: var(--danger); }

/* ticks are cut from the page/surface behind the bar, splitting it into segments */
.burnbar__tick {
  stroke: var(--surface);
  stroke-width: 2;
}

.pulse .burnbar__tick { stroke: var(--bg); }

.burnbar__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.pulse__tiles {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 26px;
  border-top: 1px solid var(--border);
}

.tile {
  padding: 15px 18px 2px 18px;
  border-left: 1px solid var(--border);
}

.tile:first-child {
  border-left: none;
  padding-left: 0;
}

.tile__label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.tile__value {
  margin: 5px 0 0 0;
  font-size: 23px;
  font-weight: 640;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.tile__sub {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.tile__sub--warn {
  color: var(--warn);
  font-weight: 600;
}

/* ── team table ── the centerpiece */

.team-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.team-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 14px 10px 14px;
  border-bottom: 1px solid var(--border);
}

.team-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.member-row[data-userhref] { cursor: pointer; }

.member-row:hover td {
  background: var(--surface-sunken);
}

.member-row--offboarded .member-name,
.member-row--offboarded .cell-team,
.member-row--offboarded .cell-activity {
  color: var(--text-faint);
}

/* the aggregate ledger line for permanently deleted accounts — visibly not a
   person: muted, no hover affordance, no actions */
.member-row--deleted td {
  background: var(--surface-sunken);
}

.member-row--deleted .member-name,
.member-row--deleted .cell-team,
.member-row--deleted .cell-activity,
.member-row--deleted .spend-figures {
  color: var(--text-faint);
}

.member-row--deleted:hover td { background: var(--surface-sunken); }

.member-name {
  display: block;
  font-weight: 620;
  color: var(--text);
}

a.member-name--link { text-decoration: none; }
a.member-name--link:hover { color: var(--accent); }

.member-alias {
  display: block;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-faint);
}

.cell-team {
  color: var(--text-dim);
}

.cell-spend .meter {
  display: block;
  margin-bottom: 6px;
}

.meter__track { fill: var(--success-track); }
.meter__fill { fill: var(--success); }
.meter.sev-warn .meter__track { fill: var(--warn-track); }
.meter.sev-warn .meter__fill { fill: var(--warn); }
.meter.sev-over .meter__track { fill: var(--danger-track); }
.meter.sev-over .meter__fill { fill: var(--danger); }
.meter.sev-none .meter__track { fill: var(--border); }

.spend-figures {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.spend-cap {
  color: var(--text-faint);
}

.spend-pct {
  margin-left: 6px;
  font-size: 12px;
  color: var(--text-faint);
}

.spend-pct--warn { color: var(--warn); font-weight: 600; }
.spend-pct--over { color: var(--danger); font-weight: 600; }

.cell-badges {
  min-width: 120px;
}

.badge {
  display: inline-block;
  margin: 1px 4px 1px 0;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 99px;
  border: 1px solid;
  background: var(--surface);
}

.badge--fable { color: var(--violet); border-color: rgba(90, 68, 196, 0.35); background: rgba(90, 68, 196, 0.06); }
.badge--gpt { color: #0f766e; border-color: rgba(15, 118, 110, 0.35); background: rgba(15, 118, 110, 0.06); }
.badge--openrouter { color: #b45309; border-color: rgba(180, 83, 9, 0.35); background: rgba(180, 83, 9, 0.06); }
.badge--pinned { color: var(--accent); border-color: rgba(37, 96, 207, 0.30); background: var(--accent-weak); }
.badge--blocked { color: var(--danger); border-color: rgba(204, 54, 38, 0.32); background: rgba(204, 54, 38, 0.06); }
.badge--off { color: var(--text-faint); border-color: var(--border-strong); }
.badge--override { color: var(--accent); border-color: rgba(37, 96, 207, 0.30); background: var(--accent-weak); }

.cell-activity {
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.team-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 34px 12px;
}

/* ── buttons ── */

.btn {
  display: inline-block;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 550;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: var(--text);
}

.btn:focus-visible,
.rowmenu__item:focus-visible,
.cidr-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text-dim);
  background: var(--surface);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.btn--primary:hover { background: #1f55bb; }

.btn--primary:disabled {
  background: var(--border);
  color: var(--text-faint);
  cursor: not-allowed;
}

.btn--danger {
  background: var(--danger);
  color: #ffffff;
  font-weight: 600;
}

.btn--danger:hover { background: #b52e20; }

.btn[data-busy="1"] {
  opacity: 0.55;
  pointer-events: none;
}

/* row overflow menu (native <details>) */
.rowmenu {
  display: inline-block;
  position: relative;
}

.rowmenu summary {
  list-style: none;
}

.rowmenu summary::-webkit-details-marker { display: none; }

.rowmenu[open] summary {
  color: var(--text);
  border-color: var(--text-faint);
}

.rowmenu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 20;
  min-width: 184px;
  padding: 5px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  text-align: left;
}

.rowmenu__item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.rowmenu__item:hover { background: var(--surface-sunken); }

.rowmenu__item--danger { color: var(--danger); }
.rowmenu__item--danger:hover { background: rgba(204, 54, 38, 0.06); }

/* ── cards ── light content panels; used sparingly, grouped, never scattered */

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

/* the dashboard's office-IPs + add-user pair size to their own content
   (they differ in height) rather than stretching to a shared tall row */
.cards--admin { align-items: start; }

.card {
  padding: 22px 24px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.card .section-title { margin-bottom: 5px; }

.card__note {
  margin: 4px 0 16px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.card--soon {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

/* office IP allowlist */
.cidr-list {
  list-style: none;
  margin: 0 0 14px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cidr-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cidr {
  font-family: var(--mono);
  font-size: 13px;
}

.cidr-remove {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
}

.cidr-remove:hover { color: var(--danger); }

.cidr-list__empty {
  font-size: 13px;
  color: var(--text-faint);
  padding: 6px 0;
}

.cidr-add {
  display: flex;
  gap: 8px;
}

.cidr-add .input { flex: 1; }

/* fields & inputs (shared with dialogs) */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 13px;
}

.field__label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 550;
}

.field__hint {
  font-size: 11px;
  color: var(--text-faint);
}

/* A model override that is broken (missing/unentitled target) or rides a
   retention / off-AWS backend — must not read as ordinary helper text. */
.field__hint--warn { color: var(--danger); }

.input {
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.input--mono { font-family: var(--mono); font-size: 13px; }

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.add-user__pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  margin: 10px 0 0 0;
  font-size: 13px;
  color: var(--danger);
}

.form-ok {
  margin: 10px 0 0 0;
  font-size: 13px;
  color: var(--success);
}

/* checkbox rows (add-user access + invite/email toggles) */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 0;
}

.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.checkbox__sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* the add-user select shows the native picker indicator */
select.input {
  appearance: auto;
  cursor: pointer;
}

.add-user .btn--primary { margin-top: 4px; }

/* ── models: the alias → backend routing map ── */
/* The signature of this card is the patch-panel arrow: an alias on the left is
   physically wired to a backend on the right. Legibility over decoration —
   which alias currently routes where is the one thing this card must make
   unmissable, so the arrow carries the accent and nothing else competes. */

.models__note {
  margin: 4px 0 20px 0;
  font-size: 13px;
  color: var(--text-dim);
  max-width: 74ch;
}

.models__note code { font-family: var(--mono); font-size: 12.5px; color: var(--text); }

.routemap__legend {
  margin: 0 0 8px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.routemap {
  list-style: none;
  margin: 0 0 20px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.route {
  display: grid;
  /* max-content on the alias column = every arrow lands at the same x (posts
     line up like a patch panel) while names stay left-aligned and scannable */
  grid-template-columns: max-content 16px minmax(170px, 1.4fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.route--fixed {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.route--empty, .route--empty code {
  display: block;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-faint);
}

.route--empty code { display: inline; font-family: var(--mono); color: var(--text-dim); }

.route__alias {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* the patch-panel wire — the card's one loud stroke */
.route__arrow {
  color: var(--accent);
  font-size: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.route--fixed .route__arrow { color: var(--text-faint); }

.route__to {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.route__backend {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.route__prov {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  white-space: nowrap;
}

/* mantle = the one retention-sharing path (Fable) — flag it in the Fable hue */
.route__prov--mantle { color: var(--violet); border-color: rgba(90, 68, 196, 0.35); }
/* openrouter = the off-AWS path (pinned Azure/Google/Amazon ZDR) */
.route__prov--openrouter { color: #b45309; border-color: rgba(180, 83, 9, 0.35); }

.route__groups { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.badge--std { color: var(--text-dim); border-color: var(--border-strong); }

.route__actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.routemap__catalog { margin-bottom: 20px; }

.routemap__catalog > .routemap { margin-top: 10px; margin-bottom: 0; }

.routemap__legend--toggle {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.routemap__legend--toggle::-webkit-details-marker { display: none; }
.routemap__legend--toggle::before { content: "▸"; color: var(--text-faint); font-size: 10px; }
.routemap__catalog[open] > .routemap__legend--toggle::before { content: "▾"; }

.routemap__hint { font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-faint); }

/* add-alias form — sits on the same surface as the map, quietly set apart */
.model-add {
  padding: 18px 18px 16px 18px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.model-add__title {
  margin: 0 0 12px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.model-add__grid {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 0.8fr;
  gap: 12px;
}

.model-add__grid .field { margin-bottom: 0; }

.model-add__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.model-add__foot .form-error { margin: 0; }

/* ── dialogs ── */

.dlg {
  width: min(448px, calc(100vw - 48px));
  padding: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.dlg--wide { width: min(540px, calc(100vw - 48px)); }

.dlg::backdrop {
  background: rgba(24, 30, 42, 0.34);
}

.dlg__form {
  padding: 24px 26px;
}

.dlg__title {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 650;
}

.dlg__sub {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.dlg__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.bump-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.bump-preset input {
  position: absolute;
  opacity: 0;
}

.bump-preset span {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.bump-preset input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-weak);
  font-weight: 600;
}

.bump-preset input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.ipmode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.ipmode__opt input {
  position: absolute;
  opacity: 0;
}

.ipmode__opt span {
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.35;
}

.ipmode__opt small { color: var(--text-faint); }

.ipmode__opt input:checked + span {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.ipmode__opt input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.recent-ips { margin-bottom: 6px; }

.recent-ips__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.ip-chip {
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 9px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  color: var(--text-dim);
  cursor: pointer;
}

.ip-chip:hover { color: var(--text); border-color: var(--text-faint); }

.newkey {
  display: block;
  padding: 12px 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}

/* ═══════════════ User drill-down ═══════════════ */

.backlink {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
}

.backlink:hover { color: var(--text); }

.user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.user-head__name {
  margin: 0;
  font-size: 27px;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.user-head__meta {
  margin: 5px 0 8px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.user-head__meta code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding-top: 26px;
}

/* burn hero — the house gauge at user scale */
.burnhero__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.burnhero__head .overline { margin-bottom: 0; }

.burnhero__fig {
  margin: 0 0 16px 0;
  line-height: 1.05;
}

.burnhero__dollars {
  font-size: 42px;
  font-weight: 680;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.burnhero__cents {
  font-size: 20px;
  font-weight: 550;
  color: var(--text-dim);
}

.burnhero__of {
  display: inline-block;
  margin-left: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.burnhero .pulse__tiles { grid-template-columns: repeat(4, 1fr); }

/* ── month-rhythm charts ── */

.chart-scroll { overflow-x: auto; }

.chart {
  display: block;
  width: 100%;
  height: auto;
  min-width: 640px;
}

.chart__overline {
  margin: 18px 0 4px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chart__overline:first-child { margin-top: 0; }

.gridline {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.axisline {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.grid-label, .x-label, .end-label, .peak-label, .cap-label {
  fill: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.peak-label, .end-label { fill: var(--text-dim); }

.daybar { fill: var(--chart-1); }

.cum-line {
  fill: none;
  stroke: var(--chart-line);
  stroke-width: 2;
  stroke-linejoin: round;
}

.cum-area { fill: var(--chart-area); }

.end-dot { fill: var(--chart-line); }

.cap-line {
  stroke: var(--warn);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}

.cap-label { fill: var(--warn); }

.hoverzone { fill: transparent; }

.hoverzone:hover { fill: rgba(37, 96, 207, 0.07); }

/* ── token economics / model mix ── */

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 7px;
  vertical-align: baseline;
}

.swatch--1 { background: var(--chart-1); }
.swatch--2 { background: var(--chart-2); }
.swatch--3 { background: var(--chart-3); }
.swatch--4 { background: var(--chart-4); }
.swatch--5 { background: var(--chart-5); }

/* the signature: one slim bar partitioning the month's dollars exactly */
.anatomy {
  display: flex;
  gap: 2px;
  height: 13px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--border);
  margin: 14px 0 18px 0;
}

.anatomy__seg { min-width: 2px; }
.anatomy__seg--1 { background: var(--chart-1); }
.anatomy__seg--2 { background: var(--chart-2); }
.anatomy__seg--3 { background: var(--chart-3); }
.anatomy__seg--4 { background: var(--chart-4); }

.econ-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 18px;
}

.bucket__label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.bucket__dollars {
  margin: 2px 0 0 0;
  font-size: 17px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

.bucket__share {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
}

.bucket__tokens {
  margin: 1px 0 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.cache-callout {
  margin: 18px 0 0 0;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(21, 150, 160, 0.07);
  border: 1px solid rgba(21, 150, 160, 0.22);
  border-radius: 10px;
}

.cache-callout strong { color: var(--text); }

.mix-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.mix-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.mix-row .swatch { margin-top: 4px; flex: none; }

.mix-row__body { flex: 1; min-width: 0; }

.mix__name {
  margin: 0 0 4px 0;
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.mix__bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.mix__fill {
  display: block;
  height: 6px;
  border-radius: 3px;
  min-width: 2px;
}

.mix__fill--1 { background: var(--chart-1); }
.mix__fill--2 { background: var(--chart-2); }
.mix__fill--3 { background: var(--chart-3); }
.mix__fill--4 { background: var(--chart-4); }
.mix__fill--5 { background: var(--chart-5); }

.mix__meta {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.mix__failed { color: var(--warn); font-weight: 600; }

/* ── budget history ── */

.bumps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bumps-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--border);
}

.bumps-table td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}

.bumps-table td:first-child { color: var(--text); }

/* ── request log ── */

.filterbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filterbar .field { margin-bottom: 0; }

.filterbar__clear {
  font-size: 13px;
  color: var(--text-dim);
  align-self: center;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.log-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.log-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.log-table .th-num, .log-table .cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.log-table .cell-time {
  white-space: nowrap;
  color: var(--text-dim);
}

.log-table .cell-model {
  font-family: var(--mono);
  font-size: 12px;
}

.log-row--failed td { color: var(--text-faint); }

.log-ok { color: var(--text-faint); font-size: 12px; }

.badge--failed { color: var(--danger); border-color: rgba(204, 54, 38, 0.32); background: rgba(204, 54, 38, 0.06); }

.log-note {
  margin: 10px 0 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

/* ── responsive ── */

@media (max-width: 900px) {
  .pulse__tiles { grid-template-columns: repeat(2, 1fr); }
  .burnhero .pulse__tiles { grid-template-columns: repeat(2, 1fr); }
  .tile { padding-left: 0; border-left: none; }
  .cards { grid-template-columns: 1fr; }
  .team { overflow-x: auto; }
  .team-table { min-width: 760px; }
  .user-head { flex-direction: column; }
  .user-actions { padding-top: 0; }
  .econ-grid { grid-template-columns: 1fr; }
  .reqlog { overflow-x: auto; }
  .log-table { min-width: 720px; }
  .route {
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
  }
  .route__arrow { display: none; }
  .route__to { grid-column: 1 / -1; }
  .route__groups { grid-column: 1; justify-content: flex-start; }
  .route__actions { grid-column: 2; grid-row: 3; }
  .model-add__grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .burnbar__fill, .meter__fill, .mix__fill { transition: width 0.5s ease; }
}

/* ═══════════════ Tab navigation ═══════════════ */
/* Underline tabs — quiet until active. Top-level (Overview·Users·Models) sits
   under the header; the user page's Usage·Chats sub-tabs reuse the same look a
   notch smaller. Panels toggle client-side; the server renders all of them so
   the page works before JS and each tab stays a real anchor (#hash). */

.tabnav {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 4px 0 34px 0;
}

.tabnav__tab {
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tabnav__tab:hover { color: var(--text); }

.tabnav__tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

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

.tabpanel {
  display: flex;
  flex-direction: column;
  gap: 44px;
}

/* sub-tabs on the user drill-down (Usage · Chats) */
.subtabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 14px 0 6px 0;
}

.subtabs__tab {
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subtabs__tab:hover { color: var(--text); }
.subtabs__tab--active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Overview: needs-attention ── */
.attention {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attention__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.attention__item--over { border-left-color: var(--danger); }
.attention__item--blocked { border-left-color: var(--text-faint); }

.attention__name { font-weight: 620; }
.attention__name a { color: inherit; text-decoration: none; }
.attention__name a:hover { color: var(--accent); }

.attention__why {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.attention__spacer { flex: 1; }

.attention__link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.attention__link:hover { text-decoration: underline; }

.attention--clear {
  padding: 20px 16px;
  color: var(--text-dim);
  font-size: 14px;
  background: rgba(15, 138, 77, 0.06);
  border: 1px solid rgba(15, 138, 77, 0.22);
  border-radius: 10px;
}

.attention--clear strong { color: var(--success); }

/* ── portal: "Your models" (alias → real model) ── */
.yourmodels {
  list-style: none;
  margin: 14px 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.yourmodel {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.yourmodel__alias {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.yourmodel__arrow { color: var(--accent); font-size: 14px; }
.yourmodel__real { font-size: 13.5px; color: var(--text-dim); }

.yourmodel__prov {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
}

.yourmodel__prov--mantle { color: var(--violet); border-color: rgba(90, 68, 196, 0.35); }
.yourmodel__prov--mantle-openai { color: #0f766e; border-color: rgba(15, 118, 110, 0.35); }

/* ── models card: the alias → real model line ── */
.route__real {
  font-size: 13px;
  color: var(--text);
  font-weight: 550;
}

/* ── add-user: portal-first hierarchy ── */
.add-user__primary {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--accent-weak);
  border: 1px solid rgba(37, 96, 207, 0.22);
  border-radius: 10px;
}

.add-user__fallback {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.add-user__fallback-label {
  margin: 0 0 2px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* the PDF fallback is a <details> in the add-user dialog — collapsed by
   default so the portal-first path stays the visually obvious one */
summary.add-user__fallback-label {
  cursor: pointer;
  padding: 2px 0;
}

summary.add-user__fallback-label:hover { color: var(--text-dim); }

/* the one-time PDF password reveal (add-user + rotate result) */
.pwreveal { margin: 14px 0 0 0; }

.pwreveal__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
}

.pwreveal__value {
  display: block;
  margin-top: 5px;
  padding: 10px 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--text);
  user-select: all;
}

/* a quiet note under a picker when Bedrock's live list isn't available */
.picker-note {
  margin: 6px 0 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ═══════════════ Chat viewer ═══════════════ */

/* a narrower shell than the dashboard — this is a reading surface, not a panel */
.console-main--chats {
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 80px;
}

/* quiet link that sits at the right of a section head (e.g. "Read conversations") */
.section-link {
  margin-left: auto;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.section-link:hover { text-decoration: underline; }

.chats-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.chats-head__name {
  margin: 2px 0 0 0;
  font-size: 27px;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.chats-head__meta { margin: 5px 0 0 0; font-size: 13px; color: var(--text-dim); }
.chats-head__meta code { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

.daynav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 6px;
}

.daynav__label,
.monthnav__label {
  min-width: 128px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.daynav__step,
.monthnav__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 17px;
  line-height: 1;
  background: var(--surface);
}

.daynav__step:hover,
.monthnav__step:hover { color: var(--text); border-color: var(--text-faint); }
.daynav__step--off,
.monthnav__step--off { opacity: 0.35; pointer-events: none; }

/* ── month switcher ── the ‹ July 2026 › control on every spend surface.
   Same geometry as the chats day-nav above (shared rules); it sits inline in
   the pulse actions / a section head, so it carries no padding of its own. */
.monthnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.monthnav__label { min-width: 104px; }

.monthnav__now {
  margin-left: 4px;
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.monthnav__now:hover { text-decoration: underline; }

.chats-summary {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

/* banners (audit not configured / unreachable) */
.notice {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-faint);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.notice--warn { border-left-color: var(--warn); }
.notice__title { margin: 0 0 3px 0; font-size: 13px; font-weight: 650; }
.notice__body { margin: 0; font-size: 13px; color: var(--text-dim); }
.notice__body code { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

.chat-sessions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty, .chat-missing {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
}

.chat-missing { padding: 14px 0 4px 0; }

/* one session = one collapsible conversation */
.chatsession {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chatsession__sum {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
}

.chatsession__sum::-webkit-details-marker { display: none; }
.chatsession[open] .chatsession__sum { border-bottom: 1px solid var(--border); }

.chatsession__range {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chatsession__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.chatsession__model {
  font-family: var(--mono);
  color: var(--text-dim);
}

.chatsession__failed { color: var(--warn); font-weight: 600; }

.chatsession__id {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}

/* the reading column */
.transcript {
  padding: 8px 20px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.turn {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.turn:first-child { border-top: none; }

.turn__role {
  margin: 0 0 6px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* role distinction: a quiet left spine, accent for the model's replies.
   The negative margin pulls the spine to the card edge; content indents past it. */
.turn--user, .turn--assistant, .turn--tool {
  border-left: 2px solid var(--border-strong);
  margin-left: -20px;
  padding-left: 34px;
}

.turn--assistant { border-left-color: var(--accent); }
.turn--assistant .turn__role { color: var(--accent); }
.turn--tool { border-left-color: var(--chart-3); }

.turn__body { display: flex; flex-direction: column; gap: 8px; }

.msgtext {
  margin: 0;
  max-width: 68ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.62;
  color: var(--text);
}

.msgtext--error { color: var(--danger); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }

.msg-omitted {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

/* collapsed system prompt + tool blocks — recede so the conversation reads through */
.turn--system {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.turn--system > .turn__body { padding-top: 8px; }
.turn--system .msgtext { color: var(--text-dim); font-size: 13px; }

.disclosure__sum {
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}

.disclosure__sum::-webkit-details-marker { display: none; }
.disclosure__sum::before { content: "▸ "; color: var(--text-faint); }
details[open] > .disclosure__sum::before { content: "▾ "; }

.turn--system > .disclosure__sum { text-transform: uppercase; color: var(--text-faint); }

.toolblock {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface-sunken);
  max-width: 68ch;
}

.toolblock--use > .disclosure__sum { color: var(--violet); }
.toolblock--result > .disclosure__sum { color: var(--chart-3); }
.toolblock--err { border-color: rgba(204, 54, 38, 0.35); }
.toolblock--err > .disclosure__sum { color: var(--danger); }
.toolblock--thinking > .disclosure__sum { color: var(--text-faint); }

.toolio {
  margin: 8px 0 2px 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 340px;
  overflow: auto;
}

/* the raw request list at a session's foot */
.rawreqs {
  padding: 12px 18px 16px 18px;
  border-top: 1px solid var(--border);
}

.rawreqs > .disclosure__sum { color: var(--text-faint); }

.rawreqs__list {
  list-style: none;
  margin: 10px 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rawreqs__row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.rawreqs__row--failed { color: var(--text-faint); }
.rawreqs__time { min-width: 92px; }
.rawreqs__model { font-family: var(--mono); flex: 1; overflow-wrap: anywhere; }
.rawreqs__cost { min-width: 72px; text-align: right; }

@media (max-width: 900px) {
  .chats-head { flex-direction: column; }
  .daynav { padding-top: 0; }
  .chatsession__id { margin-left: 0; width: 100%; }
  .turn--user, .turn--assistant, .turn--tool { margin-left: 0; padding-left: 14px; }
  .toolblock, .msgtext { max-width: 100%; }
}

/* ─── foldable long messages (chat viewer) ─── */

.foldable {
  position: relative;
}

.foldable--folded > .msgtext {
  max-height: 340px; /* ~ FOLD_LINES of body text */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent);
  mask-image: linear-gradient(to bottom, #000 72%, transparent);
}

.foldable__toggle {
  background: none;
  border: none;
  padding: 2px 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
}

.foldable__toggle:hover {
  text-decoration: underline;
}

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

/* fable retention warning on the portal keycard */
.keycard__warn-box {
  margin: 14px 0 4px 0;
}
