/* Class LLM gateway. One quiet neutral ramp, one teal accent, system fonts.
   Status dots for the lab computers are the one signature detail.
   Custom property names start with two hyphens because CSS requires it. */

:root {
  color-scheme: light dark;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #efefef;
  --line: #e0e0e0;
  --line-strong: #c9c9c9;
  --text: #1b1b1d;
  --text-2: #4f5054;
  --text-3: #66676c;
  --accent: #0e6b62;
  --accent-hover: #0a5a52;
  --accent-soft: #e2f1ee;
  --on-accent: #ffffff;
  --ok: #17703a;
  --ok-soft: #e4f3e8;
  --warn: #7d5200;
  --warn-soft: #fbf0d7;
  --bad: #b3261e;
  --bad-soft: #fcebe9;
  --focus: #0b57d0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --r-control: 8px;
  --r-card: 12px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314;
    --surface: #1b1b1d;
    --surface-2: #252527;
    --line: #2e2e31;
    --line-strong: #444448;
    --text: #ececee;
    --text-2: #b4b4ba;
    --text-3: #92929a;
    --accent: #55c4b6;
    --accent-hover: #6fd3c6;
    --accent-soft: #17302d;
    --on-accent: #0a1f1c;
    --ok: #73d092;
    --ok-soft: #173023;
    --warn: #f0c36b;
    --warn-soft: #33290f;
    --bad: #ff9088;
    --bad-soft: #3a1c1a;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 24px; font-weight: 600; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
code, pre, .mono { font-family: var(--mono); font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 14px; line-height: 20px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }

.skip {
  position: absolute; left: 16px; top: -64px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 16px;
  border-radius: var(--r-control); border: 1px solid var(--line-strong);
}
.skip:focus { top: 16px; }

/* boot and full page states */
.boot {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.boot-inner { width: min(420px, 100%); }

/* shell */
.shell {
  display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh;
}
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 20px 16px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 0 8px 20px;
  font-weight: 600; font-size: 16px; color: var(--text); text-decoration: none;
}
.brand svg { color: var(--accent); flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px;
  border-radius: var(--r-control); color: var(--text-2); text-decoration: none; font-size: 15px;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] {
  background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line);
}
.nav svg, .btn svg, .icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav .count {
  margin-left: auto; min-width: 22px; padding: 0 6px; height: 20px; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font-size: 13px; line-height: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.account { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.account-name { font-weight: 500; overflow-wrap: anywhere; }
.account-sub { color: var(--text-3); font-size: 14px; margin-bottom: 8px; overflow-wrap: anywhere; }

main { padding: 32px; min-width: 0; }
.page { max-width: 1040px; margin: 0 auto; display: grid; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 24px; display: grid; gap: 16px; align-content: start; min-width: 0;
}
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.card-pad { padding: 24px; }
.card .lead { color: var(--text-2); }
.section-note { color: var(--text-2); font-size: 14px; line-height: 20px; max-width: 64ch; }

/* banner */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner.bad { background: var(--bad-soft); border-color: transparent; }
.banner .text { flex: 1; min-width: 0; }
.banner .text strong { font-weight: 500; }
.dots { display: inline-flex; gap: 6px; flex: none; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; display: inline-block;
}
.dot.down { background: transparent; box-shadow: inset 0 0 0 2px var(--bad); }
.dot.idle { background: var(--line-strong); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 500 15px/1 var(--font); white-space: nowrap; cursor: pointer; text-decoration: none; touch-action: manipulation;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.6; cursor: default; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn.block { width: 100%; }
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
}

/* forms */
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 500; font-size: 15px; }
.hint { color: var(--text-3); font-size: 14px; line-height: 20px; }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-control);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: 16px/24px var(--font);
}
.input.mono { font-family: var(--mono); font-size: 15px; }
.textarea { min-height: 120px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; min-height: 40px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.form-error {
  display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-control);
  background: var(--bad-soft); color: var(--bad); font-size: 15px;
}
.form-error .icon { margin-top: 3px; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; }
.filters .field { min-width: 160px; }
.file-list { display: grid; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2);
}
.file-item .name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 15px; }
.num-field .input { max-width: 240px; }

/* callouts */
.callout {
  display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--r-control);
  background: var(--surface-2); color: var(--text); font-size: 15px; line-height: 22px;
}
.callout .icon { margin-top: 2px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.info { background: var(--accent-soft); color: var(--text); }
.callout strong { font-weight: 600; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 13px; font-weight: 500; white-space: nowrap; border: 1px solid var(--line-strong); color: var(--text-2);
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 2px currentColor; }
.chip.progress { color: var(--accent); border-color: transparent; background: var(--accent-soft); }
.chip.progress::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); box-shadow: inset 0 0 0 2px currentColor; }
.chip.resolved { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.chip.resolved::before { background: currentColor; }
.chip.up { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.chip.up::before { background: currentColor; }
.chip.down, .chip.revoked { color: var(--bad); border-color: transparent; background: var(--bad-soft); }
.chip.active { color: var(--text-2); }
.unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; display: inline-block;
}

/* stats */
.stat { display: grid; gap: 4px; }
.stat .label { color: var(--text-2); font-size: 14px; font-weight: 400; }
.stat .value { font-size: 28px; line-height: 32px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat .note { color: var(--text-3); font-size: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px 20px;
}

/* allowance meter: the one bright element on the overview */
.meter-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.meter-figure .big { font-size: 40px; line-height: 44px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.meter-figure .of { color: var(--text-2); font-size: 16px; }
.bar { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.bar > span { display: block; height: 100%; border-radius: 6px; background: var(--accent); min-width: 0; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }
.bar-scale { display: flex; justify-content: space-between; color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 12px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table thead th { font-weight: 500; font-size: 14px; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody th { font-weight: 500; }
.table th small, .table td small { display: block; font-weight: 400; color: var(--text-3); font-size: 13px; line-height: 18px; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.is-revoked td { color: var(--text-3); }
.table.compact th, .table.compact td { padding: 8px 12px; font-size: 14px; }
.table.compact td time { white-space: nowrap; }
.table.dense th, .table.dense td { padding: 12px; }
.table.dense .actions { flex-wrap: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; }
.status-bad { color: var(--bad); font-weight: 500; }

/* lists */
.rows > li { border-bottom: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 0; }
.row-link {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 16px 20px; color: var(--text); text-decoration: none; transition: background-color 120ms var(--ease);
}
.row-link:hover { background: var(--surface-2); color: var(--text); }
.row-link .main { display: grid; gap: 2px; min-width: 0; }
.row-link .title { font-weight: 500; overflow-wrap: anywhere; }
.row-link .meta { color: var(--text-3); font-size: 14px; }
.row-link .side-meta { display: flex; align-items: center; gap: 12px; }
.row-link .gutter { width: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; font-size: 15px; }
.kv dt { color: var(--text-2); }
.kv dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* code */
.code { border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface-2); overflow: hidden; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 4px 4px 12px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 14px;
}
.code pre { margin: 0; padding: 12px; overflow-x: auto; font-size: 14px; line-height: 22px; white-space: pre; }
.copy-line {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--surface-2); padding: 4px 4px 4px 12px;
}
.copy-line code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 15px; }

/* ticket thread */
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.thread { display: grid; gap: 12px; }
.msg { display: grid; gap: 4px; padding: 12px 16px; border-radius: var(--r-control); border: 1px solid var(--line); background: var(--surface); max-width: 640px; }
.msg.theirs { background: var(--accent-soft); border-color: transparent; }
.msg.mine { justify-self: end; background: var(--surface-2); }
.msg-head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; font-size: 14px; }
.msg-head strong { font-weight: 600; }
.msg-head time { color: var(--text-3); }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; }
.thumbs { display: flex; flex-wrap: wrap; gap: 12px; }
.thumb {
  display: block; width: 160px; height: 120px; border-radius: var(--r-control); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-missing { display: grid; place-items: center; width: 160px; height: 120px; padding: 8px; text-align: center; color: var(--text-3); font-size: 14px; border: 1px dashed var(--line-strong); border-radius: var(--r-control); }

/* loading, error, empty */
.state { display: grid; gap: 12px; justify-items: start; padding: 24px; }
.state.center { justify-items: center; text-align: center; padding: 48px 24px; }
.state p { max-width: 52ch; }
.state .icon { width: 24px; height: 24px; }
.state.error > .icon { color: var(--bad); }
.state.error { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.card > .state.error { border: 0; padding: 0; }
.state.empty .icon { color: var(--text-3); }
.loading { display: grid; gap: 12px; padding: 24px; }
.skel { height: 16px; border-radius: 4px; background: var(--line); }
.skel.w25 { width: 25%; } .skel.w40 { width: 40%; } .skel.w60 { width: 60%; } .skel.w80 { width: 80%; }
.skel.tall { height: 40px; }
.skel.block { height: 96px; border-radius: var(--r-control); }
.loading-text { color: var(--text-3); font-size: 14px; }

/* dialog and toast */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line-strong);
  border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.dlg { display: grid; gap: 16px; padding: 24px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast {
  padding: 12px 16px; border-radius: var(--r-control); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow); font-size: 15px;
}
.toast.bad { background: var(--bad); color: var(--surface); }

/* login */
.login-card { display: grid; gap: 24px; padding: 32px; }
.login-card .brand { padding: 0; }
.login-steps { display: grid; gap: 4px; color: var(--text-2); font-size: 15px; }

/* responsive */
@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split > aside { order: -1; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 12px 16px 0; border-right: 0; border-bottom: 1px solid var(--line); gap: 0 12px;
  }
  .brand { padding: 0 0 12px; }
  .account {
    margin: 0 0 12px auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; order: 2;
  }
  .account-name, .account-sub { display: none; }
  .nav {
    order: 3; flex-direction: row; width: 100%; gap: 4px; overflow-x: auto; padding-bottom: 8px;
  }
  .nav a { flex: none; }
  main { padding: 20px 16px 32px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  .card-pad { padding: 16px; }
  .meter-figure .big { font-size: 32px; line-height: 36px; }
  .row-link { padding: 12px 16px; grid-template-columns: 12px minmax(0, 1fr); }
  .row-link .side-meta { grid-column: 2; }
  .banner { align-items: flex-start; }
  .login-card { padding: 24px 20px; }
  .table.stack-sm-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table.stack-sm-table tr { display: grid; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.stack-sm-table tbody tr:last-child { border-bottom: 0; }
  .table.stack-sm-table th, .table.stack-sm-table td { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; border: 0; text-align: right; }
  .table.stack-sm-table td::before { content: attr(data-label); color: var(--text-3); text-align: left; font-weight: 400; }
  .table.stack-sm-table th[scope="row"] { font-size: 16px; justify-content: flex-start; text-align: left; }
  .table.stack-sm-table .actions { justify-content: flex-end; }
}

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