:root {
  --paper: #faf8f3;
  --paper-2: #f2eee5;
  --surface: #fffefb;
  --ink: #171a19;
  --ink-2: #3d4442;
  --muted: #626a67;
  --rule: #ded9cd;
  --rule-strong: #c8c1b1;
  --accent: #0f5f52;
  --accent-ink: #ffffff;
  --accent-soft: #e2ece8;
  --warn: #8a4b06;
  --warn-soft: #f7ead7;
  --danger: #8f2d24;
  --danger-soft: #f6e3df;
  --ok: #2c6146;
  --ok-soft: #e3efe6;
  --tier-easy: #a9c4b6;
  --tier-lower_medium: #79a191;
  --tier-upper_medium: #3f7466;
  --tier-hard: #1c4a40;
  --tier-easy-ink: #335141;
  --tier-lower_medium-ink: #275446;
  --tier-upper_medium-ink: #1f4c41;
  --tier-hard-ink: #173b33;
  --focus: #0f5f52;
  --radius: 4px;
  --font: "Be Vietnam Pro", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(23, 26, 25, .06), 0 12px 32px -12px rgba(23, 26, 25, .22);
}

html[data-theme="dark"] {
  --paper: #141816;
  --paper-2: #1c211f;
  --surface: #1a1f1d;
  --ink: #f1f0ea;
  --ink-2: #c9ccc7;
  --muted: #99a09b;
  --rule: #2e3633;
  --rule-strong: #444e49;
  --accent: #7fc3b2;
  --accent-ink: #10211d;
  --accent-soft: #22322d;
  --warn: #e6b273;
  --warn-soft: #33291b;
  --danger: #e79a8f;
  --danger-soft: #3a2522;
  --ok: #8fd0a9;
  --ok-soft: #22322a;
  --tier-easy: #587a6c;
  --tier-lower_medium: #6f9a88;
  --tier-upper_medium: #8dbdab;
  --tier-hard: #bfe0d3;
  --tier-easy-ink: #b3d0c4;
  --tier-lower_medium-ink: #bfd9ce;
  --tier-upper_medium-ink: #cfe6dd;
  --tier-hard-ink: #dcefe8;
  --focus: #7fc3b2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -16px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "ss01" 1;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); color: var(--ink); }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

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

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { caret-color: var(--accent); }

* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 6px; border: 3px solid var(--paper); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 14px; border-radius: var(--radius); text-decoration: none;
}
.skip:focus { top: 12px; }

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

/* ---------- rail ---------- */
.rail {
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  padding: 22px 16px 20px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 6px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 48px; height: 48px; flex: none; display: block; object-fit: contain; }
.brand-name { font-weight: 650; letter-spacing: -.01em; font-size: 15px; }
.brand-sub { display: block; font-size: 11px; color: var(--muted); letter-spacing: .01em; text-transform: uppercase; font-weight: 500; white-space: nowrap; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 0 8px 8px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: 3px; text-decoration: none;
  color: var(--ink-2); font-size: 14px; line-height: 1.35;
  border-left: 2px solid transparent;
}
.nav-link svg { width: 17px; height: 17px; flex: none; stroke-width: 1.6; }
.nav-link:hover { background: rgba(23,26,25,.045); color: var(--ink); }
html[data-theme="dark"] .nav-link:hover { background: rgba(255,255,255,.05); }
.nav-link[aria-current="page"] {
  background: var(--surface);
  border-left-color: var(--accent);
  color: var(--ink);
  font-weight: 600;
}
.nav-badge {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--warn-soft); color: var(--warn); padding: 1px 6px; border-radius: 999px; font-weight: 600;
}
.rail-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); line-height: 1.5; }
.rail-foot strong { color: var(--ink-2); font-weight: 600; }

/* ---------- top bar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.page-title { font-size: 16px; font-weight: 620; letter-spacing: -.01em; margin: 0; }
.crumb { color: var(--muted); font-size: 12.5px; margin-left: 2px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.balance-chip {
  display: flex; align-items: baseline; gap: 7px;
  padding: 5px 10px 5px 11px; border: 1px solid var(--rule-strong); border-radius: 3px;
  background: var(--surface);
  text-decoration: none; color: var(--ink);
}
.balance-chip .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.balance-chip .v { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.balance-chip:hover { border-color: var(--accent); }

.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; stroke-width: 1.6; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--rule-strong);
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
}
.avatar:hover { border-color: var(--accent); }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 3px;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-weight: 560; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn svg { width: 16px; height: 16px; stroke-width: 1.7; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(.94); border-color: var(--accent); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--paper-2); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--rule)); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input {
  height: 34px; padding: 0 10px; border: 1px solid var(--rule-strong); border-radius: 3px;
  background: var(--surface); color: var(--ink); min-width: 0;
}
.input:hover { border-color: var(--ink-2); }
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--accent); }
select.input { padding-right: 26px; }

/* ---------- layout ---------- */
.content { padding: clamp(18px, 2.6vw, 34px); max-width: 1220px; width: 100%; }
.page { display: none; animation: rise .18s ease-out; }
.page.is-active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .page { animation: none; } }

.page-head { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(22px, 2.3vw, 27px); line-height: 1.2; letter-spacing: -.022em; font-weight: 640; margin: 0; }
.page-head p { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; max-width: 62ch; }
.page-head .spacer { margin-left: auto; }

section { margin: 0 0 30px; }
.section-head { display: flex; align-items: baseline; gap: 12px; padding-top: 14px; border-top: 1px solid var(--rule); margin-bottom: 14px; }
.section-head h2 { font-size: 14px; font-weight: 640; letter-spacing: .01em; margin: 0; }
.section-head .meta { margin-left: auto; color: var(--muted); font-size: 12.5px; }

.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 34px; align-items: start; }
/* minmax(0, 1fr) rather than 1fr: the code blocks in these columns would
   otherwise push the column past the viewport on phones. */
@media (max-width: 980px) { .split { grid-template-columns: minmax(0, 1fr); gap: 28px; } }

/* ---------- balance block ---------- */
.balance-block { border-top: 1px solid var(--rule); padding-top: 14px; }
.balance-block .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.balance-amount { font-size: clamp(30px, 3.4vw, 38px); font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0 2px; }
.balance-note { color: var(--muted); font-size: 12.5px; }
.balance-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat {
  --stat-ink: var(--ink-2);
  --stat-soft: var(--paper-2);
  position: relative; min-width: 0; overflow: hidden;
  padding: 13px 14px 12px; border: 1px solid var(--rule); border-radius: 4px;
  background: linear-gradient(160deg, var(--surface) 12%, color-mix(in srgb, var(--stat-soft) 34%, var(--surface)) 100%);
}
.stat::after {
  content: ""; position: absolute; width: 74px; height: 74px; right: -27px; top: -29px;
  border-radius: 50%; background: color-mix(in srgb, var(--stat-ink) 8%, transparent); pointer-events: none;
}
.stat-spend { --stat-ink: var(--warn); --stat-soft: var(--warn-soft); }
.stat-cache { --stat-ink: var(--ok); --stat-soft: var(--ok-soft); }
.stat-token { --stat-ink: var(--accent); --stat-soft: var(--accent-soft); }
.stat-head { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.stat-icon {
  width: 27px; height: 27px; flex: none; display: grid; place-items: center; border-radius: 4px;
  color: var(--stat-ink); background: var(--stat-soft);
  border: 1px solid color-mix(in srgb, var(--stat-ink) 18%, var(--rule));
}
.stat-icon svg { width: 15px; height: 15px; stroke-width: 1.7; }
.stat .k { font-size: 11px; color: var(--muted); display: block; text-transform: uppercase; letter-spacing: .065em; font-weight: 650; }
.stat .v { position: relative; z-index: 1; font-size: 22px; line-height: 1.18; font-weight: 650; letter-spacing: -.025em; font-variant-numeric: tabular-nums; display: block; }
.stat .d { position: relative; z-index: 1; display: block; font-size: 11.5px; margin-top: 3px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .stats { grid-template-columns: 1fr 1fr; gap: 8px; } }

/* ---------- chart ---------- */
.chart-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.chart-head h3 { font-size: 13px; margin: 0; font-weight: 620; }
.chart-head .legend { margin-left: auto; display: flex; gap: 12px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 10px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { transition: opacity .12s ease; cursor: default; }
.chart .bar:hover { opacity: .78; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0;
  background: var(--ink); color: var(--paper); padding: 7px 9px; border-radius: 3px;
  font-size: 12px; line-height: 1.45; box-shadow: var(--shadow); max-width: 240px;
  transition: opacity .1s ease;
}
.chart-tip.is-on { opacity: 1; }

/* ---------- tier composition ---------- */
.tier-bar { display: flex; height: 10px; border-radius: 2px; overflow: hidden; margin: 12px 0 14px; }
.tier-bar span { display: block; height: 100%; }
.tier-rows { display: grid; gap: 0; }
.tier-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.tier-row:last-child { border-bottom: 0; }
.tier-row .n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.tier-row .amt { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--rule); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.data.compact { min-width: 0; }
table.data caption { text-align: left; color: var(--muted); font-size: 12.5px; padding: 0 0 10px; }
table.data th {
  text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 9px 12px 8px; border-bottom: 1px solid var(--rule-strong);
  background: var(--paper); position: sticky; top: 0; white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 42%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.2px; letter-spacing: -.01em; }
.dim { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 1.5px 7px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-easy, .badge-lower_medium, .badge-upper_medium, .badge-hard {
  background: color-mix(in srgb, var(--_tier) 24%, var(--surface));
  border-color: color-mix(in srgb, var(--_tier) 28%, transparent);
}
.badge-easy::before, .badge-lower_medium::before, .badge-upper_medium::before, .badge-hard::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--_tier); flex: none;
}
.badge-easy { --_tier: var(--tier-easy); color: var(--tier-easy-ink); }
.badge-lower_medium { --_tier: var(--tier-lower_medium); color: var(--tier-lower_medium-ink); }
.badge-upper_medium { --_tier: var(--tier-upper_medium); color: var(--tier-upper_medium-ink); }
.badge-hard { --_tier: var(--tier-hard); color: var(--tier-hard-ink); }
.badge-cache-hit { background: var(--ok-soft); color: var(--ok); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--paper-2); color: var(--ink-2); }

/* ---------- code block ---------- */
.codebox { border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.codebox-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--rule); }
.codebox-head .tabs { display: flex; gap: 2px; }
.codebox-head .tab { background: none; border: 0; padding: 3px 8px; font-size: 12px; color: var(--muted); cursor: pointer; border-radius: 3px; }
.codebox-head .tab[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; }
.codebox-head .copy { margin-left: auto; }
.codebox pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 12.3px; line-height: 1.65; color: var(--ink-2); }
.codebox pre .c { color: var(--muted); }

/* ---------- lists / panels ---------- */
.panel { border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); padding: 16px 18px; }
.panel + .panel { margin-top: 12px; }
.panel h3 { margin: 0 0 4px; font-size: 14px; font-weight: 620; }
.panel p { margin: 0; color: var(--muted); font-size: 13px; }

.rows { display: grid; }
.row-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--rule); }
.row-item:last-child { border-bottom: 0; }
.row-item .title { font-weight: 560; font-size: 13.5px; }
.row-item .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.row-item .val { font-variant-numeric: tabular-nums; font-weight: 620; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Support offers three channels. The panel that holds this row is narrow, so
   the buttons sit under the label instead of squeezing the text column. */
.row-item.support-row { grid-template-columns: 1fr; gap: 8px; }
.support-row .row-actions { justify-content: flex-start; }
@media (max-width: 640px) {
  .support-row .row-actions .btn { flex: 1 1 auto; }
}

/* ---------- plans ---------- */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .plans { grid-template-columns: 1fr; } }
.plan {
  position: relative; overflow: hidden; text-align: left; padding: 15px 16px 14px;
  border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--surface); cursor: pointer;
  display: flex; flex-direction: column; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.plan::after {
  content: ""; position: absolute; width: 92px; height: 92px; right: -37px; bottom: -46px;
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent); border-radius: 50%; pointer-events: none;
}
.plan:hover { border-color: var(--ink-2); transform: translateY(-1px); box-shadow: 0 9px 24px -20px rgba(23, 26, 25, .7); }
.plan[aria-pressed="true"],
.plan.is-featured {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 46%, var(--surface));
}
.plan-head { position: relative; z-index: 1; display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.plan-icon {
  width: 31px; height: 31px; flex: none; display: grid; place-items: center; border-radius: 50%;
  color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--rule));
}
.plan-icon svg { width: 16px; height: 16px; stroke-width: 1.7; }
.plan-tier { font-size: 11px; line-height: 1.3; letter-spacing: .065em; text-transform: uppercase; font-weight: 650; color: var(--muted); }
.plan[aria-pressed="true"] .plan-icon,
.plan.is-featured .plan-icon { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.plan .amount { position: relative; z-index: 1; font-size: 24px; line-height: 1.15; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.plan .desc { position: relative; z-index: 1; font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------- QR ---------- */
.qr-grid { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 560px) { .qr-grid { grid-template-columns: 1fr; } }
.qr-frame { border: 1px solid var(--rule-strong); padding: 10px; background: #fff; border-radius: 3px; }
.qr-frame svg { display: block; width: 100%; height: auto; }
.kv { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.countdown { font-family: var(--mono); font-size: 13px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 140px; }
.filters .search { flex: 1 1 220px; }

/* ---------- empty / skeleton / error ---------- */
.state { padding: 34px 18px; text-align: center; border: 1px dashed var(--rule-strong); border-radius: 3px; background: var(--surface); }
.state h3 { margin: 0 0 4px; font-size: 14px; font-weight: 620; }
.state p { margin: 0 auto; color: var(--muted); font-size: 13px; max-width: 46ch; }
.state .btn { margin-top: 12px; }
.skeleton { height: 14px; border-radius: 2px; background: linear-gradient(90deg, var(--paper-2), var(--rule), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- banner ---------- */
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--warn); background: var(--warn-soft); color: var(--warn); border-radius: 3px; font-size: 13px; margin-bottom: 18px; }
.banner svg { width: 17px; height: 17px; flex: none; stroke-width: 1.8; }
.banner .btn { margin-left: auto; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(14, 20, 18, .42); backdrop-filter: blur(2px); }
.dialog-head { padding: 16px 18px 10px; }
.dialog-head h2 { margin: 0; font-size: 16px; font-weight: 640; letter-spacing: -.01em; }
.dialog-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.dialog-body { padding: 4px 18px 16px; display: grid; gap: 12px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--rule); background: var(--paper); }
.key-reveal { display: flex; gap: 6px; align-items: center; background: var(--paper-2); border: 1px solid var(--rule-strong); border-radius: 3px; padding: 8px 10px; }
.key-reveal code { font-family: var(--mono); font-size: 12.5px; overflow-x: auto; flex: 1; }
.callout { display: flex; gap: 8px; font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border-radius: 3px; padding: 9px 11px; }
.callout svg { width: 16px; height: 16px; flex: none; stroke-width: 1.8; margin-top: 1px; }

/* ---------- popover / menu ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 50;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 3px; box-shadow: var(--shadow); padding: 5px;
}
.menu[hidden] { display: none; }
.menu button, .menu a {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 9px; border: 0; border-radius: 3px;
  background: none; text-align: left; font-size: 13px; color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--paper-2); color: var(--ink); }
.menu .sep { height: 1px; background: var(--rule); margin: 5px 3px; }
.menu .hint { font-size: 12px; color: var(--muted); padding: 4px 9px 6px; display: block; }
.menu .switch { margin-left: auto; font-size: 11px; color: var(--muted); }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); }
@media (max-width: 860px) { .signin { grid-template-columns: 1fr; } .signin .brand-side { display: none; } }
.brand-side { background: var(--paper-2); border-right: 1px solid var(--rule); padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; }
.brand-side .big { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.16; letter-spacing: -.03em; font-weight: 640; max-width: 18ch; margin: 0; }
.brand-side .big em { font-style: normal; color: var(--accent); }
.brand-side .note { color: var(--muted); font-size: 13px; max-width: 64ch; }
.signin-panel { display: flex; align-items: center; justify-content: center; padding: clamp(24px, 5vw, 48px); }
.signin-card { width: 100%; max-width: 340px; }
.signin-card h1 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 4px; }
.signin-card p { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.oauth-btn { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 3px; cursor: pointer; font-size: 13.5px; font-weight: 550; }
.oauth-btn + .oauth-btn { margin-top: 8px; }
.oauth-btn:hover { border-color: var(--ink-2); }
.oauth-btn svg { width: 17px; height: 17px; }
.signin-fine { margin-top: 22px; font-size: 12px; color: var(--muted); line-height: 1.6; }

.signin-story { display: grid; gap: clamp(18px, 2.2vw, 26px); max-width: 560px; }
.signin-story .big, .signin-story .note { margin: 0; }
.signin-benefits { list-style: none; display: grid; gap: 7px; margin: 0; padding: 0; }
.signin-benefits li {
  display: flex; align-items: flex-start; gap: 9px;
  color: var(--ink-2); font-size: 13px; line-height: 1.45;
}
.benefit-icon {
  width: 21px; height: 21px; flex: none; margin-top: -1px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
}
.benefit-icon svg { width: 12px; height: 12px; stroke-width: 2; }
.smr-flow { width: min(100%, 560px); margin: 0; }
.smr-flow svg { display: block; width: 100%; height: auto; overflow: visible; }
.smr-flow text { font-family: var(--font); }

.flow-frame { fill: var(--surface); stroke: var(--rule); stroke-width: 1; }
.flow-eyebrow {
  fill: var(--muted); font-size: 8.5px; font-weight: 600;
  letter-spacing: .12em;
}
.flow-source-card { fill: var(--paper-2); stroke: var(--rule-strong); stroke-width: 1; }
.flow-window-dot { fill: var(--rule-strong); }
.flow-source-label { fill: var(--muted); font-size: 8px; font-weight: 500; letter-spacing: .01em; }
.flow-source-line { fill: var(--rule-strong); opacity: .72; }
.flow-source-chip { fill: var(--accent-soft); }
.flow-source-chip-label { fill: var(--accent); font-size: 7.5px; font-weight: 650; letter-spacing: .04em; }
.flow-scan {
  fill: var(--accent); opacity: 0; transform-box: view-box;
  animation: flowScan 4.8s cubic-bezier(.4, 0, .2, 1) infinite;
}

.flow-spine, .flow-branch {
  fill: none; stroke: var(--rule-strong); stroke-width: 1; stroke-linecap: round; opacity: .7;
}
.flow-bus {
  fill: none; stroke: var(--rule-strong); stroke-width: 1; stroke-linecap: round;
  stroke-dasharray: 2 5; opacity: .72;
}
.flow-tier--easy { --flow-tier: var(--tier-easy); }
.flow-tier--lower_medium { --flow-tier: var(--tier-lower_medium); }
.flow-tier--upper_medium { --flow-tier: var(--tier-upper_medium); }
.flow-tier--hard { --flow-tier: var(--tier-hard); }

.flow-route {
  fill: none; stroke: var(--flow-tier); stroke-width: 1.5; stroke-linecap: round;
  stroke-dasharray: 4 5; opacity: 0;
  animation: flowFocus 8s linear infinite, flowDash 1.2s linear infinite;
  animation-delay: calc(var(--i) * 2s), 0s;
}
.flow-packet {
  fill: var(--flow-tier); opacity: 0; offset-rotate: 0deg;
  animation: flowPacket 8s linear infinite;
  animation-delay: calc(var(--i) * 2s);
}
.flow-tier--easy .flow-packet { offset-path: path("M142 118H270Q278 118 278 110V51Q278 43 286 43H314"); }
.flow-tier--lower_medium .flow-packet { offset-path: path("M142 118H270Q278 118 278 110V101Q278 93 286 93H314"); }
.flow-tier--upper_medium .flow-packet { offset-path: path("M142 118H270Q278 118 278 126V135Q278 143 286 143H314"); }
.flow-tier--hard .flow-packet { offset-path: path("M142 118H270Q278 118 278 126V185Q278 193 286 193H314"); }

.flow-hub__orbit {
  fill: none; stroke: var(--rule-strong); stroke-width: 1; stroke-dasharray: 2 5; opacity: .8;
  transform-box: view-box; transform-origin: 204px 118px;
  animation: flowOrbit 24s linear infinite;
}
.flow-hub__halo {
  fill: none; stroke: var(--accent); stroke-width: 1.25; opacity: 0;
  transform-box: view-box; transform-origin: 204px 118px;
  animation: flowHalo 2s cubic-bezier(.16, 1, .3, 1) infinite;
}
.flow-hub__disc {
  fill: var(--accent-soft); stroke: color-mix(in srgb, var(--accent) 30%, transparent); stroke-width: 1;
}
.flow-hub__mark { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.flow-hub__mark--inner { opacity: .62; stroke-width: 2.1; }
.flow-hub__label { fill: var(--muted); font-size: 8.5px; font-weight: 650; letter-spacing: .12em; }

.flow-tile__base { fill: var(--paper); stroke: var(--rule); stroke-width: 1; }
.flow-tile__tint {
  fill: color-mix(in srgb, var(--flow-tier) 18%, var(--surface));
  opacity: 0; animation: flowFocus 8s linear infinite;
  animation-delay: calc(var(--i) * 2s);
}
.flow-tile__edge {
  fill: none; stroke: var(--flow-tier); stroke-width: 1.15; opacity: 0;
  animation: flowFocus 8s linear infinite; animation-delay: calc(var(--i) * 2s);
}
.flow-tier__dot { fill: var(--flow-tier); }
.flow-tier__label { fill: var(--ink-2); font-size: 13px; font-weight: 550; letter-spacing: -.005em; }
.flow-tile__model { fill: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .005em; }

/* Vertical variant for phones. The wide diagram shrinks below the size where its
   labels stay readable, so narrow screens get the same flow stacked instead. */
.smr-flow--compact { display: none; }
.smr-flow--compact .flow-source-label { font-size: 11px; }
.smr-flow--compact .flow-source-chip-label { font-size: 8.5px; }
.smr-flow--compact .flow-tier__label { font-size: 12px; }
.smr-flow--compact .flow-tile__model { font-size: 9.5px; }
.smr-flow--compact .flow-hub__label { font-size: 9px; }
.smr-flow--compact .flow-hub__orbit { transform-origin: 150px 108px; }
.smr-flow--compact .flow-hub__halo { transform-origin: 150px 108px; }

@keyframes flowFocus {
  0%, 21% { opacity: 1; }
  25%, 100% { opacity: 0; }
}
@keyframes flowDash { to { stroke-dashoffset: -18; } }
@keyframes flowPacket {
  0% { offset-distance: 0%; opacity: 0; }
  2% { opacity: 1; }
  18% { offset-distance: 100%; opacity: 1; }
  22%, 100% { offset-distance: 100%; opacity: 0; }
}
@keyframes flowHalo {
  0% { opacity: .32; transform: scale(.9); }
  100% { opacity: 0; transform: scale(1.55); }
}
@keyframes flowOrbit { to { transform: rotate(360deg); } }
@keyframes flowScan {
  0%, 10% { opacity: 0; transform: translateY(0); }
  15% { opacity: .8; }
  70% { opacity: .48; transform: translateY(68px); }
  76%, 100% { opacity: 0; transform: translateY(68px); }
}

.signin[hidden] .smr-flow * { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .flow-route, .flow-packet, .flow-tile__tint, .flow-tile__edge,
  .flow-hub__orbit, .flow-hub__halo, .flow-scan { animation: none; }
  .flow-packet, .flow-scan, .flow-hub__halo { display: none; }
  .flow-route { opacity: 0; }
  .flow-tier--upper_medium .flow-route { opacity: .9; }
  .flow-tier--upper_medium .flow-tile__tint,
  .flow-tier--upper_medium .flow-tile__edge { opacity: 1; }
}

/* ---------- misc ---------- */
.inline { display: inline-flex; align-items: center; gap: 6px; }
.stack-sm { display: grid; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .two-col { grid-template-columns: 1fr; } }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-top: 12px; font-size: 12.5px; color: var(--muted); }
.pager .btn { height: 28px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pill-toggle { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 3px; overflow: hidden; }
.pill-toggle button { border: 0; background: var(--surface); padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.pill-toggle button + button { border-left: 1px solid var(--rule); }
.pill-toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 268px; height: 100dvh; z-index: 70;
    transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow);
  }
  .rail.is-open { transform: none; }
  .rail-scrim { position: fixed; inset: 0; background: rgba(14,20,18,.4); z-index: 65; }
  .rail-scrim[hidden] { display: none; }
  .content { padding-bottom: 48px; }
}

@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 10px 14px; }
  .balance-chip { padding: 4px 8px; }
  .balance-chip .k { display: none; }
}

/* A multi-column table cannot fit a phone: 720px of columns inside a 360px
   viewport used to hide every cell past the third, with nothing telling the
   reader to scroll. Below 760px those tables become stacked cards and each
   cell prints its own column name. Templates opt in with
   class="data responsive" plus a data-label on every cell. */
@media (max-width: 760px) {
  table.data.responsive { min-width: 0; display: block; }
  table.data.responsive thead { display: none; }
  table.data.responsive tbody { display: block; }
  table.data.responsive tr { display: block; padding: 11px 0 9px; border-bottom: 1px solid var(--rule); }
  table.data.responsive tr:last-child { border-bottom: 0; }
  table.data.responsive td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 2px 0; border: 0; text-align: right; overflow-wrap: anywhere;
  }
  table.data.responsive td[data-label]::before {
    content: attr(data-label); flex: none; text-align: left;
    color: var(--muted); font-size: 10.5px; font-weight: 650;
    letter-spacing: .05em; text-transform: uppercase;
  }
  table.data.responsive td:first-child { font-weight: 600; }
  table.data.responsive td:first-child.mono { font-size: 12.4px; }
  table.data.responsive td:not([data-label]) { justify-content: flex-end; padding-top: 7px; }
  table.data.responsive td:not([data-label]) form { flex: 1; }
  table.data.responsive td:not([data-label]) .btn { width: 100%; }
  table.data.responsive tr.sub-row { padding-bottom: 0; }
  table.data.responsive tr.sub-row td { display: block; text-align: left; }
}
/* ============================================================
   Application components
   ============================================================ */
[hidden] { display: none !important; }

.menu-btn { display: none; }
@media (max-width: 900px) { .menu-btn { display: inline-grid; } }

.action-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.action-row .spacer { margin-left: auto; }
.inline-note { font-size: 12.5px; color: var(--muted); }
.section-note { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; max-width: 70ch; }
.rule-top { border-top: 1px solid var(--rule); padding-top: 14px; }
.mt-0 { margin-top: 0; }
.mt-12 { margin-top: 12px; }
.mt-18 { margin-top: 18px; }
.mt-24 { margin-top: 24px; }

.balance-block.is-low .balance-amount { color: var(--warn); }
.balance-block.is-low .balance-note { color: var(--warn); }
.balance-side-note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.balance-side-note strong { color: var(--ink-2); font-weight: 600; }

.status-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: currentColor; }
.status-dot.ok { color: var(--ok); }
.status-dot.warn { color: var(--warn); }
.status-dot.danger { color: var(--danger); }
.status-dot.muted { color: var(--muted); }

.chart-panel { border-top: 1px solid var(--rule); padding-top: 14px; }
.chart-panel .chart-head { margin-bottom: 4px; }
.chart-scroll { overflow-x: auto; }
.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; }
.chart-note { margin-top: 4px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.chart-empty { min-height: 210px; display: grid; place-items: center; border: 1px dashed var(--rule-strong); border-radius: 3px; color: var(--muted); font-size: 13px; }

.summary-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px 34px; }
@media (max-width: 760px) { .summary-grid { grid-template-columns: 1fr; } }
.summary-item { border-bottom: 1px solid var(--rule); padding: 0 0 12px; }
.summary-item .k { color: var(--muted); font-size: 12px; display: block; }
.summary-item .v { font-size: 18px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -.015em; display: block; margin-top: 1px; }
.summary-item .d { color: var(--muted); font-size: 12px; }

.amount-strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.amount-muted { color: var(--muted); font-variant-numeric: tabular-nums; }
.amount-plus { color: var(--ok); font-variant-numeric: tabular-nums; }

.stack-actions { display: grid; gap: 8px; }
.stack-actions .btn { justify-content: flex-start; }

.notice {
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 11px 13px;
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.55;
}
.notice strong { color: var(--ink); font-weight: 620; }
.notice.is-info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 32%, var(--rule)); color: var(--ink-2); }
.notice.is-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, var(--rule)); color: var(--warn); }

.empty-line { padding: 28px 0; text-align: center; color: var(--muted); font-size: 13px; }

.plan[aria-pressed="true"] .amount,
.plan.is-featured .amount { color: var(--accent); }
.plan .plan-note {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 6px;
  margin-top: auto; padding-top: 12px; border-top: 1px dashed color-mix(in srgb, var(--rule-strong) 72%, transparent);
  font-size: 12px; color: var(--muted);
}
.plan .plan-note::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.plan[aria-pressed="true"] .plan-note,
.plan.is-featured .plan-note { color: var(--accent); font-weight: 600; }

.qr-side { min-width: 0; }
.qr-side h3 { margin: 0 0 3px; font-size: 16px; letter-spacing: -.01em; }
.qr-side .qr-desc { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.qr-code-label { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; }
.qr-timer { margin-top: 12px; display: flex; align-items: center; gap: 7px; color: var(--warn); font-size: 12px; }
.qr-timer svg { width: 16px; height: 16px; flex: none; }
.qr-timer .countdown { color: var(--ink); }
.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.qr-transfer-note { margin-top: 10px; font-size: 11px; color: var(--muted); }
.qr-await { display: flex; align-items: flex-start; gap: 12px; border: 1px dashed var(--rule-strong); border-radius: 3px; padding: 18px; background: var(--paper-2); }
.qr-await > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--accent); }
.qr-await h3 { margin: 0 0 3px; font-size: 14px; font-weight: 640; }
.qr-await p { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 64ch; }
.paid-receipt,
.expired-receipt { max-width: 620px; }
.paid-receipt .qr-actions,
.expired-receipt .qr-actions { margin-top: 18px; }
.expired-receipt .qr-desc { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; max-width: 64ch; }

.status-line { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.status-line .badge { margin-left: 1px; }

.filter-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.filter-summary { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.filter-summary strong { color: var(--ink-2); font-weight: 600; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0 10px; flex-wrap: wrap; }
.table-toolbar .left { color: var(--muted); font-size: 12.5px; }
.table-toolbar .left strong { color: var(--ink-2); font-weight: 620; }

.key-name { font-weight: 580; }
.key-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.key-masked { display: inline-block; font-family: var(--mono); font-size: 12px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 2px; padding: 1px 5px; white-space: nowrap; }
.key-revoked { color: var(--muted); text-decoration: line-through; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(240px, .65fr); gap: 34px; align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; gap: 25px; } }
.form-section { border-top: 1px solid var(--rule); padding-top: 14px; margin-top: 24px; }
.form-section:first-of-type { margin-top: 0; }
.form-section h2 { margin: 0 0 3px; font-size: 14px; letter-spacing: .01em; font-weight: 640; }
.form-section > p { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; max-width: 66ch; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grid, .form-grid.three { grid-template-columns: 1fr; } }
.form-grid .field { min-width: 0; }
.input-wrap { display: flex; gap: 6px; }
.input-wrap .input { flex: 1; }
.inline-control { display: flex; align-items: center; gap: 9px; min-height: 34px; font-size: 13px; color: var(--ink-2); }
.inline-control input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.formula {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  overflow-x: auto;
}
.formula strong { color: var(--accent); font-weight: 600; }

.setting-surface { border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); padding: 15px 16px; }
.setting-surface + .setting-surface { margin-top: 12px; }
.setting-surface h3 { margin: 0 0 3px; font-size: 13.5px; font-weight: 620; }
.setting-surface p { margin: 0; color: var(--muted); font-size: 12.5px; }
.setting-surface .btn { margin-top: 12px; }

.oauth-link { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.oauth-link:last-child { border-bottom: 0; }
.oauth-link svg { width: 18px; height: 18px; flex: none; }
.oauth-link .name { font-weight: 560; }
.oauth-link .sub { color: var(--muted); font-size: 12px; }
.oauth-link .right { margin-left: auto; color: var(--muted); font-size: 12px; }

.admin-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin-bottom: 22px; }
.admin-summary > div { padding: 12px 14px 12px 0; border-right: 1px solid var(--rule); }
.admin-summary > div:last-child { border-right: 0; }
.admin-summary .k { color: var(--muted); font-size: 12px; display: block; }
.admin-summary .v { font-size: 18px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -.015em; }
@media (max-width: 720px) { .admin-summary { grid-template-columns: 1fr 1fr; } .admin-summary > div:nth-child(2) { border-right: 0; } }

.audit-before { color: var(--muted); text-decoration: line-through; }
.audit-after { color: var(--ink); }
.audit-arrow { color: var(--muted); margin: 0 5px; }
.reason-label { font-size: 12px; color: var(--muted); }
.amount-mismatch { color: var(--warn); font-weight: 620; }

.pill-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); }
.badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-expired { background: var(--paper-2); color: var(--muted); }
.badge-review { background: var(--danger-soft); color: var(--danger); }

.kbd { display: inline-block; border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.5; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  max-width: min(390px, calc(100vw - 28px));
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: 3px; box-shadow: var(--shadow);
  padding: 10px 13px; font-size: 13px; line-height: 1.45;
  transform: translateY(10px); opacity: 0; transition: opacity .16s ease, transform .16s ease;
}
.toast.is-on { opacity: 1; transform: none; }
@media (max-width: 640px) { .toast { right: 14px; bottom: 14px; } }

dialog { max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog-body .field { min-width: 0; }
.dialog-body .notice { margin: 0; }
.dialog-foot .btn { min-width: 84px; }

.signin-card .brand { margin-bottom: 34px; }
.signin-fine { border-top: 1px solid var(--rule); padding-top: 15px; }
.signin-footnote { margin: 0; }
.signin .brand-side { min-height: 100vh; }

@media (min-width: 861px) and (max-height: 840px) {
  .signin .brand-side { padding-top: 36px; padding-bottom: 36px; gap: 22px; }
  .signin-story { gap: 18px; }
  .smr-flow { width: min(100%, 500px); }
}

@media (max-width: 860px) {
  .signin { min-height: 100vh; }
  .signin .brand-side { display: none; }
  .smr-flow *, .smr-flow { animation: none; }
  .signin .signin-panel { min-height: 100vh; align-items: flex-start; padding: 38px 24px; }
  .signin-card { max-width: 380px; margin: 0 auto; }
}

.page-head .page-date { color: var(--muted); font-size: 12px; margin-top: 7px; }
.page-head .head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .page-head { align-items: flex-start; }
  .page-head .head-actions { margin-left: 0; width: 100%; }
  .page-head .head-actions .btn { flex: 1; }
  .page-head h1 { font-size: 23px; }
}

@media (max-width: 420px) {
  .topbar { gap: 5px; padding: 9px 11px; }
  .top-actions { gap: 3px; }
  .page-title { font-size: 14px; max-width: min(46vw, 180px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crumb { display: none; }
  .balance-chip { padding: 4px 6px; gap: 0; }
  .balance-chip .v { font-size: 13px; }
  .balance-chip .k { display: none; }
  .content { padding-left: 13px; padding-right: 13px; }
  .stat { padding: 11px 11px 10px; }
  .stat .v { font-size: 20px; }
  .stat .d { font-size: 11px; }
  .qr-grid { grid-template-columns: 1fr; }
  .qr-frame { max-width: 210px; }
}

/* ---------- phone layout fixes ----------
   Filter bars, chart labels and long shell commands each break the 360-390px
   layout in their own way, so they are handled together here. */
@media (max-width: 640px) {
  /* Filter forms live inside the page header: give them the whole row and put
     every control on its own line instead of wrapping mid-row. */
  .page-head .filters { flex: 1 1 100%; width: 100%; }
  .filters.action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: end;
  }
  .filters .field { min-width: 0; }
  .filters .btn { grid-column: 1 / -1; width: 100%; }

  /* The chart is a 760-unit SVG, so its axis text would render around 6px once
     the viewBox is scaled to phone width. Keep the bars, drop the unreadable
     labels; the date range stays visible in the chart note. */
  .chart .grid text,
  .chart .axis-label { display: none; }
  .chart .grid line { stroke: color-mix(in srgb, var(--rule) 70%, transparent); }

  /* Install commands are long single lines: wrap them instead of clipping. */
  .codebox pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .key-reveal { flex-wrap: wrap; }
}
