/* Leo admin console. Leo's own tokens (the sign-in page's), laptop first. */
:root {
  --bg: #FBFAF7; --card: #FFFFFF; --side: #F4F2EE; --ink: #15171B; --ink2: #4B525C; --ink3: #8F969F;
  --line: #E5E3DE; --line2: #EFEDE9; --accent: #15171B; --accent-ink: #FFFFFF;
  --ok: #067647; --ok-bg: #ECFDF3; --warn: #B54708; --warn-bg: #FFFAEB; --bad: #B42318; --bad-bg: #FEF3F2;
  --bar: #D9D6D0; --fill: #15171B;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101215; --card: #1A1D22; --side: #15181C; --ink: #F1F2F4; --ink2: #B4BAC2; --ink3: #8F969F;
    --line: #2A2E34; --line2: #23272C; --accent: #F1F2F4; --accent-ink: #15171B;
    --ok: #47CD89; --ok-bg: #0C2A1C; --warn: #FDB022; --warn-bg: #2E2209; --bad: #F97066; --bad-bg: #2D1412;
    --bar: #34383F; --fill: #F1F2F4;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 Inter, "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink2); }
.faint { color: var(--ink3); }
.mono { font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace; font-size: 12.5px; }

/* The environment band (Stripe's test-mode band): every screen says it is not production. */
.env-band {
  position: sticky; top: 0; z-index: 5; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 500;
}

/* ---------- sign-in ---------- */
.signin { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding-top: 16vh; }
.signin-card {
  width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 32px 28px;
}
.signin-card h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.signin-card p { margin: 0 0 20px; }
.signin-msg { min-height: 20px; font-size: 13px; color: var(--ink2); }
.signin-msg.bad { color: var(--bad); }
.fine { font-size: 12.5px; color: var(--ink3); margin: 0 !important; }
.signin-laptop { border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 16px; }
.signin-laptop .field { margin-bottom: 10px; }

/* ---------- shell: side navigation and main column ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: calc(100vh - var(--band, 0px)); }
.side {
  background: var(--side); border-right: 1px solid var(--line); padding: 20px 12px;
  display: flex; flex-direction: column; gap: 20px; position: sticky; top: var(--band, 0px);
  height: calc(100vh - var(--band, 0px));
}
.brand { padding: 0 10px; display: flex; flex-direction: column; }
.brand-name { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { font-size: 12.5px; color: var(--ink2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: 7px 10px; border-radius: 6px; text-decoration: none; color: var(--ink2); font-weight: 500;
}
.nav a:hover { background: var(--line2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.who-id { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 12.5px; color: var(--ink2); margin-bottom: 10px; }

.main { padding: 28px 36px 64px; outline: none; min-width: 0; }
.page { max-width: 1120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.page-head .meta { display: flex; align-items: center; gap: 12px; color: var(--ink3); font-size: 13px; }

/* ---------- cards and sections ---------- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.card-pad { padding: 18px 20px; }
.section { margin-bottom: 16px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.section-head .hint { color: var(--ink3); font-size: 13px; margin-left: 8px; font-weight: 400; }
.empty { padding: 18px 20px; color: var(--ink2); }

.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tile-head h2 { font-size: 13.5px; font-weight: 600; margin: 0; color: var(--ink2); }
.tile-big { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.tile-big .of { font-size: 14px; font-weight: 400; color: var(--ink2); margin-left: 6px; }
.tile-line { color: var(--ink2); font-size: 13px; margin-top: 8px; }

/* State labels: a dot and a word, as Cloudflare's and Stripe's status cells do. */
.state { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.ok { color: var(--ok); }
.state.warn { color: var(--warn); }
.state.bad { color: var(--bad); }
.state.off { color: var(--ink3); }

/* A meter: the bar, and a tick at each alert threshold. */
.meter { position: relative; height: 8px; border-radius: 4px; background: var(--bar); margin-top: 12px; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--fill); min-width: 0; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.bad { background: var(--bad); }
.meter-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--card); box-shadow: 0 0 0 1px var(--ink3); border-radius: 1px; }

/* Needs you: the first thing on Today. */
.needs { margin-bottom: 16px; border-left: 3px solid var(--warn); }
.needs.clear { border-left-color: var(--ok); }
.needs h2 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.needs ul { margin: 0; padding-left: 18px; }
.needs li { margin: 2px 0; }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; }
.t th, .t td { text-align: left; padding: 10px 20px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.t th { font-size: 12.5px; font-weight: 500; color: var(--ink3); background: transparent; }
.t tr:last-child td { border-bottom: none; }
.t td.actions { text-align: right; white-space: nowrap; width: 1%; }
.t td.num, .t th.num { text-align: right; }
.t .sub { display: block; color: var(--ink3); font-size: 12.5px; }

/* ---------- buttons and forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--ink3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--bad); color: #FFFFFF; border-color: var(--bad); }
.btn.quiet { background: transparent; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.wide { width: 100%; height: 40px; }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px;
}

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; }
.field .help { font-size: 12.5px; color: var(--ink3); }
.field input, .field select {
  height: 34px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit;
}

/* ---------- dialog ---------- */
.dialog {
  width: 480px; max-width: calc(100vw - 32px); border: 1px solid var(--line); border-radius: 12px; padding: 0;
  background: var(--card); color: var(--ink); box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
}
.dialog::backdrop { background: rgba(16, 18, 21, .35); }
.dialog-body { padding: 20px 22px 6px; }
.dialog h2 { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.dialog .lead { color: var(--ink2); margin: 0 0 16px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
.dialog .error { color: var(--bad); background: var(--bad-bg); border-radius: 7px; padding: 8px 10px; margin: 0 0 14px; font-size: 13px; }
.dialog .error ul { margin: 4px 0 0; padding-left: 18px; }

.notice { padding: 10px 14px; border-radius: 8px; background: var(--bad-bg); color: var(--bad); margin-bottom: 16px; }
.footnote { color: var(--ink3); font-size: 12.5px; margin-top: 20px; }
.footnote ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Accounts ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 16px; }
.search { flex: 1; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; }
.search:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.searchbar .btn { height: 38px; }
.rowlink { font-weight: 600; text-decoration: none; }
.rowlink:hover { text-decoration: underline; }
.back { display: inline-block; margin-bottom: 10px; color: var(--ink2); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--ink); }
.head-sub { color: var(--ink2); font-size: 13px; margin-top: 4px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line2); }
.fact-label { font-size: 12.5px; color: var(--ink3); }
.requests { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 16px 20px; }
.requests p { margin: 4px 0 10px; }
.empty.bad { color: var(--bad); }
.section-gap { border-top: 1px solid var(--line); margin-top: 8px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Routes ---------- */
.page.wide { max-width: 1240px; }
.editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px 0; }
.tabs { display: flex; gap: 4px; }
.btn.tab { background: transparent; border-color: transparent; }
.btn.tab.on { background: var(--card); border-color: var(--line); }
.palette { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 12px 20px; border-bottom: 1px solid var(--line2); }
.palette-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.palette-name { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink2); margin-right: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--card); font-size: 12.5px; white-space: nowrap; cursor: grab; list-style: none;
}
.chip[draggable="false"] { cursor: default; }
.chip.unknown { border-color: var(--bad); color: var(--bad); }
.chip-n { color: var(--ink3); font-variant-numeric: tabular-nums; }
.chip-id { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chip .plogo { width: 12px; height: 12px; }
.btn.chip-x { flex: none; height: 18px; width: 16px; padding: 0; border: 0; background: transparent; color: var(--ink3); font-size: 14px; }
.btn.chip-x:hover { color: var(--bad); }
.grid-wrap { overflow-x: auto; }
table.routes { width: 100%; border-collapse: collapse; table-layout: fixed; }
.routes th, .routes td { border-bottom: 1px solid var(--line2); border-right: 1px solid var(--line2); padding: 8px; vertical-align: top; text-align: left; }
.routes th:last-child, .routes td:last-child { border-right: 0; }
.routes thead th { font-size: 12.5px; font-weight: 500; color: var(--ink3); }
.routes thead th:first-child, .routes th.task { width: 120px; }
.routes th.task { font-weight: 600; padding-left: 20px; }
.routes th.task .sub { display: block; font-weight: 400; color: var(--ink3); font-size: 12px; }
.routes .cell { min-height: 60px; }
.routes .cell.inherit { background: var(--line2); }
.routes .cell.empty-cell { background: var(--bad-bg); }
.routes .cell.drop { outline: 2px dashed var(--ink2); outline-offset: -3px; }
.chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.chain .chip { justify-content: flex-start; max-width: 100%; }
/* In the grid every preset name should fit whole beside its mark, number and remove button. */
.routes td { padding-left: 6px; padding-right: 6px; }
.chain .chip { gap: 4px; padding: 0 4px; font-size: 12px; }
.chain .btn.chip-x { width: 12px; }
.inherit-note { font-size: 12px; color: var(--ink3); padding: 2px 0; }
.inherit-note.bad { color: var(--bad); }
.btn.link { border: 0; background: transparent; color: var(--ink2); padding: 0; height: 20px; font-size: 12px; text-decoration: underline; }
select.add { margin-top: 6px; width: 100%; height: 26px; border-radius: 6px; border: 1px dashed var(--line); background: transparent;
  color: var(--ink3); font: inherit; font-size: 12px; }
.result { margin: 12px 20px 16px; padding: 10px 14px; border-radius: 8px; background: var(--line2); }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.bad { background: var(--bad-bg); color: var(--bad); }
.result ul { margin: 6px 0 0; padding-left: 18px; }
.t tr.current td { background: var(--line2); }
.explain-form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.explain-form .field { margin: 0; }
.explain-form .field span { font-size: 13px; font-weight: 500; }
.explain-form input, .explain-form select { height: 34px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; }
.explained { margin-top: 16px; border-top: 1px solid var(--line2); }
.why { margin: 12px 0; padding-left: 18px; color: var(--ink2); }
.server-only { border-top: 1px solid var(--line); }

/* Waitlist */
.t td.pick, .t th:first-child:has(input[type=checkbox]) { width: 1%; padding-right: 0; }
.t input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }
.small { font-size: 13px; }

/* History */
select.filter { height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; font-size: 13px; }
.t tr.details td { background: var(--bg); }
.t tr.details pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.more { display: flex; justify-content: center; margin: 8px 0 24px; }

/* Settings */
.form { display: grid; gap: 14px; max-width: 640px; }
.form .field input, .form .field select, .admin-row input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
.form .field { display: grid; gap: 4px; }
.form .field label { font-weight: 500; font-size: 13.5px; }
.form .field .help { color: var(--ink3); font-size: 12.5px; }
.form-foot { display: flex; justify-content: flex-end; }
.admin-row { display: grid; grid-template-columns: minmax(0, 1fr) 220px auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.admin-row select { height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; font-size: 13px; }

/* Money */
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 160px; border-bottom: 1px solid var(--line); }
.bar { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bar:hover .bar-fill { opacity: 0.75; }
.bar-fill { width: 100%; background: var(--fill); border-radius: 4px 4px 0 0; min-height: 0; }
.bars-axis { display: flex; justify-content: space-between; color: var(--ink3); font-size: 12px; margin-top: 6px; }
.chart-note { padding: 0 20px 14px; margin: 0; }

/* Models */
.price { white-space: nowrap; font-size: 13px; line-height: 1.6; }

/* Support */
.words { white-space: pre-wrap; word-break: break-word; max-width: 70ch; }
.transcript { display: grid; gap: 12px; }
.transcript .section-head.plain { padding: 0; border: 0; }
.turn { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.turn-label { font-size: 12px; font-weight: 600; color: var(--ink3); text-transform: uppercase; letter-spacing: 0.04em; }
.turn-q .words { color: var(--ink); }
.turn-a .words { color: var(--ink2); }

/* ---------- Conversations and Problems ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.filters .search { width: 260px; }
.filter-label { color: var(--ink2); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); padding: 0 6px; }
.h1-id { font-size: 14px; font-weight: 400; color: var(--ink2); }
.timeline { display: grid; }
.turn-block { padding: 14px 20px; border-top: 1px solid var(--line2); display: grid; gap: 10px; }
.turn-block:first-child { border-top: 0; }
.turn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.turn-head .grow { flex: 1; }
.broke { color: var(--bad); font-size: 13px; }
.turn-block table.t { border: 1px solid var(--line2); border-radius: 8px; }
.lines { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.lines li.bad { color: var(--bad); }
.lines pre, pre.record, .problem-detail pre { margin: 4px 0 0; padding: 8px 10px; background: var(--side); border-radius: 6px;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; color: var(--ink); }
.pad { padding: 6px 0; }
.problem-detail { display: grid; gap: 6px; padding: 4px 0 8px; }
.conv-links { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-size: 13px; }
.page.full { max-width: 1400px; }
.nowrap { white-space: nowrap; }
.errs { color: var(--bad); font-size: 12.5px; line-height: 1.35; white-space: nowrap; }
.t.dense th, .t.dense td { padding: 9px 10px; }
.t.dense th:first-child, .t.dense td:first-child { padding-left: 20px; }
.t.dense th:last-child, .t.dense td:last-child { padding-right: 20px; }

/* Provider marks: each provider's own logo beside its name, its models and its route chips. */
.plogo { width: 14px; height: 14px; flex: none; display: inline-block; vertical-align: -2px; pointer-events: none; user-select: none; }
.plogo.none { width: 8px; height: 8px; border-radius: 50%; background: var(--ink3); vertical-align: 1px; }
.plabel { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.section-head h2 > .plogo { margin-right: 8px; vertical-align: -3px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .plogo.p-openai { filter: invert(1); } }
