/* Reck Router admin UI */
:root {
  --canvas: #eef0ec;
  --surface: #ffffff;
  --sunken: #f5f6f3;
  --ink: #1d2321;
  --ink-2: #48514d;
  --muted: #6b746f;
  --line: #d9ddd7;
  --line-strong: #c3c9c2;
  --accent: #0f6e5a;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --danger: #b42318;
  --danger-soft: #fbe7e5;
  --warn: #9a5b06;
  --warn-soft: #fbf0dc;
  --focus: #3456c8;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 0 rgba(29, 35, 33, .04), 0 1px 3px rgba(29, 35, 33, .06);
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #141917;
    --surface: #1c2220;
    --sunken: #181e1c;
    --ink: #e8ece9;
    --ink-2: #c3cbc6;
    --muted: #8f9a94;
    --line: #2c3431;
    --line-strong: #3a4440;
    --accent: #3fb394;
    --accent-ink: #08201a;
    --accent-soft: #1d3a32;
    --danger: #f2766b;
    --danger-soft: #3a1f1c;
    --warn: #e2a443;
    --warn-soft: #382c17;
    --focus: #8aa4ff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
code, .mono { font-family: var(--mono); font-size: .88em; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--ink); text-decoration: none; }
.brand svg { flex: none; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.brand-name span { color: var(--muted); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin-top: 12px; padding: 0 10px 4px; font-size: 12px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.nav a[aria-current="page"]::after { content: ""; width: 6px; height: 6px; border-radius: 3px; background: var(--accent); }
.side-foot { margin-top: auto; padding: 0 10px; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.side-foot form { margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.main { min-width: 0; padding: 30px 36px 64px; }
.page { max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.panel-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.panel-body { padding: 16px 18px 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .panel + .panel { margin-top: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.split > .panel + .panel { margin-top: 0; }

/* ---------- flashes ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius-s); margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.flash.error { background: var(--danger-soft); border-color: transparent; color: var(--ink); }
.flash.error::before { content: "Problem: "; font-weight: 650; color: var(--danger); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 14px/1.2 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

form.fields { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 400 14px/1.4 var(--sans);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 14px; max-height: 260px; overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--sunken); }
.pick-list .check { font-family: var(--mono); font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; }
legend { font-weight: 650; padding: 0; margin-bottom: 4px; }
.prefix { display: flex; align-items: stretch; }
.prefix span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius-s) 0 0 var(--radius-s); background: var(--sunken); color: var(--muted); font-weight: 500; }
.prefix input { border-radius: 0 var(--radius-s) var(--radius-s) 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--sunken); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td a.rowlink { color: var(--ink); font-weight: 600; text-decoration: none; }
td a.rowlink:hover { color: var(--accent); text-decoration: underline; }
.empty { padding: 28px 18px; color: var(--muted); }
.empty strong { color: var(--ink); display: block; margin-bottom: 4px; }

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 3px; background: currentColor; opacity: .8; }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { color: var(--muted); }
.status { font-variant-numeric: tabular-nums; font-weight: 600; }
.status.bad { color: var(--danger); }

/* ---------- dashboard ---------- */
.summary { font-size: 22px; line-height: 1.45; font-weight: 500; letter-spacing: -.01em; max-width: 46ch; margin: 0; }
.summary b { font-weight: 700; }
.range { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; }
.range a { padding: 6px 12px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.range a + a { border-left: 1px solid var(--line-strong); }
.range a[aria-current="true"] { background: var(--ink); color: var(--surface); }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border-top: 1px solid var(--line); margin-top: 18px; }
.figure { padding: 14px 18px; }
.figure + .figure { border-left: 1px solid var(--line); }
.figure .v { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.figure .l { font-size: 13px; color: var(--muted); }

.chart { padding: 8px 18px 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart .gridline { stroke: var(--line); stroke-dasharray: 2 4; }
.chart text { fill: var(--muted); font: 11px var(--sans); }
.chart rect.bar:hover { opacity: .8; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 6px 18px 16px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.meter { height: 6px; background: var(--sunken); border-radius: 3px; overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.hot i { background: var(--warn); }
.meter.over i { background: var(--danger); }

.steps { display: grid; gap: 10px; counter-reset: step; margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.steps li::before { counter-increment: step; content: counter(step); width: 26px; height: 26px; border-radius: 13px; display: grid; place-items: center; background: var(--sunken); font-weight: 700; font-size: 13px; }
.steps li.done::before { content: "✓"; background: var(--accent-soft); color: var(--accent); }
.steps li.done { color: var(--muted); }

/* ---------- providers ---------- */
.provider-list { display: grid; gap: 12px; }
.provider { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; }
.provider .mark { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 750; font-size: 15px; color: #fff; }
.provider .meta { font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.kind-option { position: relative; }
.kind-option input { position: absolute; opacity: 0; }
.kind-option span { display: block; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); font-weight: 600; cursor: pointer; background: var(--surface); }
.kind-option input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.kind-option input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.callout { padding: 12px 14px; border-radius: var(--radius-s); background: var(--sunken); border: 1px solid var(--line); font-size: 14px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; }

/* ---------- key reveal ---------- */
.secret { display: flex; gap: 8px; align-items: stretch; }
.secret code { flex: 1; display: block; padding: 12px 14px; border-radius: var(--radius-s); background: var(--ink); color: var(--canvas); font-size: 14px; word-break: break-all; }
pre.snippet { margin: 0; padding: 14px 16px; border-radius: var(--radius-s); background: var(--sunken); border: 1px solid var(--line); overflow-x: auto; font: 13px/1.55 var(--mono); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { background: none; border: 0; padding: 8px 12px; font: 600 13px var(--sans); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

/* ---------- logs ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters label { min-width: 140px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- playground ---------- */
.play { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.thread { display: grid; gap: 12px; padding: 18px; min-height: 360px; align-content: start; }
.msg { max-width: 78ch; }
.msg .who { font-size: 12.5px; font-weight: 650; color: var(--muted); margin-bottom: 3px; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.msg.user .body { background: var(--sunken); border: 1px solid var(--line); padding: 10px 12px; border-radius: var(--radius-s); }
.msg .thinking { color: var(--muted); font-size: 13px; white-space: pre-wrap; border-left: 2px solid var(--line-strong); padding-left: 10px; margin-bottom: 8px; }
.msg .stats { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.composer { display: grid; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 70px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .panel { width: min(420px, 100%); }
.auth .brand { margin-bottom: 20px; padding: 0; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { display: none; }
  .side-foot { margin: 0 0 0 auto; }
  .main { padding: 20px 16px 48px; }
  .grid-2, .split, .play { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
}

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

/* ---------- layout fixes ---------- */
[hidden] { display: none !important; }
.grid-2 > .panel, .split > .panel, .split > .stack, .play > .panel, .provider-list > .panel { margin-top: 0; }
.row > label { align-content: end; }
@media (max-width: 640px) {
  .chart { overflow-x: auto; }
  .chart svg { min-width: 640px; }
}

.snippet-wrap { position: relative; }
.snippet-wrap .snippet-copy { position: absolute; top: 8px; right: 8px; }
