/* Design tokens. Brand: flame orange on ink navy. Light is the default;
   dark follows the device unless the visitor picked a theme. */
:root {
  --flame-400: #ff8a47; --flame-600: #e0500a; --flame-700: #c2410c; --ink-900: #0a1330; --ink-950: #060c1c;

  --bg: #f6f8fb; --surface: #ffffff; --raised: #f1f5f9; --text: #0a1330; --muted: #51607a; --line: #e2e8f0; --line-strong: #cbd5e1;
  --accent: #c2410c; --accent-hover: #a83608; --on-accent: #ffffff; --accent-soft: #fff1e8; --link: #c2410c;
  --ok: #15803d; --ok-soft: #e8f6ed; --bad: #b91c1c; --bad-soft: #fdecec; --warn: #a16207; --warn-soft: #fff6dd; --warn-line: #ecd28a;
  --code: #eef2f7; --ring: #e0500a;
  --side-bg: #0a1330; --side-text: #c5cee0; --side-muted: #8492ad; --side-line: #1b2748; --side-hover: #142046; --side-on: #1a2752;
  --shadow: 0 1px 2px rgba(10, 19, 48, .06), 0 1px 3px rgba(10, 19, 48, .04);
  --radius: 12px; --radius-sm: 8px; --side-w: 264px;
  --sans: 'Be Vietnam Pro', ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #060c1c; --surface: #0c1630; --raised: #111d3d; --text: #e9eef8; --muted: #9aa8c2; --line: #1c2a4d; --line-strong: #2a3a63;
    --accent: #ff8a47; --accent-hover: #ffa06a; --on-accent: #0a1330; --accent-soft: #2a1a12; --link: #ff9a5f;
    --ok: #4ade80; --ok-soft: #0f2a22; --bad: #f87171; --bad-soft: #2d1418; --warn: #facc15; --warn-soft: #2a2411; --warn-line: #5c4d14;
    --code: #121e3e; --ring: #ff8a47;
    --side-bg: #080f24; --side-line: #18244a; --side-hover: #101c40; --side-on: #16234c;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme=dark] {
  --bg: #060c1c; --surface: #0c1630; --raised: #111d3d; --text: #e9eef8; --muted: #9aa8c2; --line: #1c2a4d; --line-strong: #2a3a63;
  --accent: #ff8a47; --accent-hover: #ffa06a; --on-accent: #0a1330; --accent-soft: #2a1a12; --link: #ff9a5f;
  --ok: #4ade80; --ok-soft: #0f2a22; --bad: #f87171; --bad-soft: #2d1418; --warn: #facc15; --warn-soft: #2a2411; --warn-line: #5c4d14;
  --code: #121e3e; --ring: #ff8a47;
  --side-bg: #080f24; --side-line: #18244a; --side-hover: #101c40; --side-on: #16234c;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; font-weight: 700; margin: 0 0 6px; letter-spacing: -.015em; text-wrap: balance; }
h2 { font-size: 16px; line-height: 1.35; font-weight: 600; margin: 32px 0 12px; }
.card > h2:first-child, .card > div > h2:first-child { margin-top: 0; }
.card h2 + h2, .card form + h2, .card .row + h2 { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
p { margin: 0 0 12px; }
ul { margin: 0 0 12px; padding-left: 20px; }
li { margin-bottom: 6px; }
small { color: var(--muted); font-size: 12.5px; }
b, strong { font-weight: 600; }
code { background: var(--code); padding: 2px 6px; border-radius: 6px; font: 500 12.5px/1.5 var(--mono); overflow-wrap: anywhere; }
pre { background: var(--ink-900); color: #e9eef8; padding: 16px; border-radius: var(--radius); overflow-x: auto; border: 1px solid var(--side-line); margin: 0 0 16px; }
pre code { background: none; padding: 0; overflow-wrap: normal; color: inherit; font-weight: 400; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); color: var(--text); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); }
.skip:focus { top: 8px; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.num, .r, .stat b, .pill, .balance b { font-variant-numeric: tabular-nums; }

/* ---------- shell: sidebar flush to the left edge ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; border-right: 1px solid var(--side-line); z-index: 40; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--flame-400), var(--flame-600)); color: var(--ink-900); }
.mark .ic { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.brand { min-width: 0; }
.brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { height: 32px; width: auto; max-width: 44px; object-fit: contain; flex: none; display: block; }
.logo.wide { height: 34px; max-width: 190px; }
.brand-preview { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 14px 16px; border-radius: 10px; background: var(--ink-900); color: #c5cee0; margin: 4px 0 8px; }
.brand-preview small { color: inherit; }
.brand-preview.light { background: var(--raised); color: var(--muted); border: 1px solid var(--line); }
.favicon { width: 32px; height: 32px; object-fit: contain; }
input[type=file] { padding: 7px 8px; font-size: 13px; cursor: pointer; }
input[type=file]::file-selector-button { font: 600 12.5px var(--sans); margin-right: 10px; padding: 5px 12px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--raised); color: var(--text); cursor: pointer; }
label.color { flex-direction: row; align-items: center; gap: 12px; }
input[type=color]:not([type=checkbox]):not([type=radio]) { width: 64px; min-height: 40px; padding: 3px; cursor: pointer; }
textarea.prose { font: 400 14px/1.5 var(--sans); }
fieldset > label:not(.check) { margin: 4px 0; }
.side-nav { flex: 1; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; scrollbar-color: var(--side-line) transparent; }
.side-label { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }
.side-label:first-child { margin-top: 6px; }
.side-nav a { display: flex; align-items: center; gap: 12px; flex: none; min-height: 36px; padding: 6px 10px; border-radius: 9px; color: var(--side-text); font-weight: 500; font-size: 13.5px; position: relative; transition: background-color .15s ease, color .15s ease; }
.side-nav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.side-nav a .ic { color: var(--side-muted); transition: color .15s ease; }
.side-nav a:hover .ic { color: #fff; }
.side-nav a.on { background: var(--side-on); color: #fff; font-weight: 600; }
.side-nav a.on .ic { color: var(--flame-400); }
.side-nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--flame-400); }
.side-foot { padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--side-line); display: flex; flex-direction: column; gap: 10px; }
.balance { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--side-hover); border: 1px solid var(--side-line); border-radius: 10px; padding: 10px 12px; }
.balance span { display: block; font-size: 12px; color: var(--side-muted); }
.balance b { display: block; color: #fff; font-size: 15px; font-weight: 700; }
.side .btn { background: var(--flame-400); border-color: var(--flame-400); color: var(--ink-900); }
.side .btn:hover { background: color-mix(in srgb, var(--flame-400) 82%, white); border-color: color-mix(in srgb, var(--flame-400) 82%, white); }
.side-user { display: flex; align-items: center; gap: 4px; }
.side-user form { margin: 0; }
.who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 8px; border-radius: 9px; color: var(--side-text); font-size: 13px; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who:hover, .who.on { background: var(--side-hover); color: #fff; text-decoration: none; }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 9px; background: transparent; color: inherit; cursor: pointer; transition: background-color .15s ease, color .15s ease; }
.side .iconbtn, .topbar .iconbtn { color: var(--side-text); }
.side .iconbtn:hover, .topbar .iconbtn:hover { background: var(--side-hover); color: #fff; }
.side-close { display: none; }
.when-dark { display: none; }
.when-light, .when-dark { line-height: 0; }
:root[data-theme=dark] .when-dark { display: inline; }
:root[data-theme=dark] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) .when-dark { display: inline; }
  :root:not([data-theme=light]) .when-light { display: none; }
}

.topbar { display: none; }
.scrim { display: none; }
.main { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; padding: 32px 36px 48px; }
.guestbar { display: flex; justify-content: flex-end; gap: 10px; margin: -8px 0 20px; }
.foot { color: var(--muted); font-size: 12.5px; padding: 18px 36px 28px; border-top: 1px solid var(--line); }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--muted); max-width: 70ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.backlink { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); font-weight: 500; font-size: 13px; }
.backlink:hover { color: var(--text); text-decoration: none; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); margin-bottom: 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 9px; padding: 8px 16px; font: 600 13.5px/1.3 var(--sans); cursor: pointer; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn:hover { text-decoration: none; background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--raised); border-color: var(--line-strong); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
button:disabled, .btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }

/* ---------- cards, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid .card { margin-bottom: 0; }
.stack > .grid { margin-bottom: 0; }
.stat { display: flex; flex-direction: column; gap: 2px; position: relative; }
.stat > span { color: var(--muted); font-size: 12.5px; font-weight: 500; padding-right: 44px; }
.stat b { font-size: 21px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.stat small, .stat a { font-size: 12.5px; }
.stat a { font-weight: 600; }
.stat .stat-ic { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); padding: 0; }
.stat.hot { border-color: var(--flame-400); }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.row:last-child { margin-bottom: 0; }
.row form { margin: 0; }
.row > .row { margin-bottom: 0; }
.grow { flex: 1; min-width: 200px; }
form.inline { display: inline; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
label small { font-weight: 400; line-height: 1.45; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; min-height: 32px; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; flex: none; accent-color: var(--flame-600); cursor: pointer; }
input:not([type=checkbox]):not([type=radio]), textarea { font: 400 14px/1.4 var(--sans); min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); width: 100%; transition: border-color .15s ease, box-shadow .15s ease; }
textarea { font: 12.5px/1.55 var(--mono); resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:not([type=checkbox]):not([type=radio]):hover, textarea:hover { border-color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):focus, textarea:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
input.short { max-width: 170px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 0; display: flex; flex-direction: column; gap: 4px; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
tr:last-child td { border-bottom: 0; }
thead th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; background: var(--raised); }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--raised) 60%, transparent); }
.r { text-align: right; }
td.r { white-space: nowrap; }
td .btn + form, td form + form, td .btn + .btn { margin-left: 4px; }
td small { display: inline-block; line-height: 1.4; }
td code { white-space: nowrap; overflow-wrap: normal; }
/* row actions stay in view while a wide table scrolls sideways */
td.act { position: sticky; right: 0; background: var(--surface); box-shadow: -1px 0 0 var(--line); }
tbody tr:hover td.act { background: var(--raised); }
.card form + form, .card form + p { margin-top: 12px; }
.content > table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }

/* ---------- badges, tags, messages ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--raised); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 6px; white-space: nowrap; vertical-align: middle; }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tag.bad { color: var(--bad); border-color: var(--bad); }
.pill { display: inline-flex; align-items: center; min-height: 36px; background: var(--side-hover); border: 1px solid var(--side-line); border-radius: 999px; padding: 4px 14px; font-weight: 600; font-size: 13px; color: #fff; }
.pill:hover { text-decoration: none; border-color: var(--flame-400); }
.flash, .note { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.flash .ic, .note > .ic { margin-top: 3px; }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-soft); color: var(--ok); }
.flash.err { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-soft); color: var(--bad); }
.flash span, .note span { color: var(--text); }
.note { display: block; background: var(--warn-soft); border-color: var(--warn-line); color: var(--text); }
.note.verify { display: flex; align-items: center; flex-wrap: wrap; }
.note.verify > span { flex: 1; min-width: 220px; }
.note.verify > .ic { color: var(--warn); margin-top: 0; }
.verify form { margin: 0; }
.empty { color: var(--muted); padding: 32px 20px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.copy { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.copy > code { padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line); flex: 0 1 auto; min-width: 0; }
.newkey { border-color: var(--ok); background: var(--ok-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 12px; font: 500 12.5px var(--mono); background: var(--surface); color: var(--text); transition: border-color .15s ease, background-color .15s ease; }
.chip:hover { text-decoration: none; border-color: var(--accent); background: var(--accent-soft); }
.wait { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--flame-600); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- home / pricing ---------- */
.hero { background: var(--ink-900); color: #e9eef8; border: 1px solid var(--side-line); border-radius: 16px; padding: 40px 36px; margin-bottom: 28px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--flame-400) 28%, transparent), transparent); pointer-events: none; }
.hero h1 { font-size: 28px; line-height: 1.2; color: #fff; max-width: 18ch; margin-bottom: 12px; }
.hero .lead { font-size: 15px; color: #c5cee0; max-width: 60ch; margin-bottom: 22px; }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .btn { background: var(--flame-400); border-color: var(--flame-400); color: var(--ink-900); }
.hero .btn:hover { background: color-mix(in srgb, var(--flame-400) 82%, white); border-color: color-mix(in srgb, var(--flame-400) 82%, white); }
.hero .btn.ghost { background: transparent; color: #fff; border-color: #33426e; }
.hero .btn.ghost:hover { background: #142046; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--flame-400); margin-bottom: 10px; }
.lead { font-size: 15px; color: var(--muted); }

/* ---------- top-up payment ---------- */
.pay { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; }
.pay .card { margin-bottom: 0; }
.qr { text-align: center; }
.qr img { max-width: 100%; height: auto; background: #fff; border-radius: 10px; padding: 8px; border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 0 0 16px; align-items: center; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv dd b { font-size: 18px; }
.narrow { max-width: 440px; }

/* ---------- sign-in pages ---------- */
body.auth { min-height: 100vh; display: flex; flex-direction: column; background: var(--ink-950); background-image: radial-gradient(700px 420px at 90% -10%, color-mix(in srgb, var(--flame-400) 10%, transparent), transparent), radial-gradient(700px 500px at -10% 110%, rgba(47, 98, 230, .18), transparent); }
.auth-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; color: #c5cee0; }
.auth-top .iconbtn:hover { background: #142046; color: #fff; }
.auth-main { flex: 1; width: 100%; max-width: 440px; margin: 0 auto; padding: 24px 20px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-main .card { padding: 28px; margin-bottom: 0; border-radius: 16px; }
.auth-main h1 { font-size: 21px; margin-bottom: 18px; }
.auth-main .card p.muted { margin: 14px 0 0; }
.auth-main .btn { width: 100%; }
.auth-foot { text-align: center; padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); font-size: 13px; color: #8492ad; }
.auth-foot a { color: #c5cee0; }

/* ---------- small screens: the sidebar slides in over the page ---------- */
@media (max-width: 960px) {
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); background: var(--side-bg); border-bottom: 1px solid var(--side-line); }
  .topbar .brand { flex: 1; min-width: 0; font-size: 15px; }
  .topbar .iconbtn { width: 44px; height: 44px; }
  .topbar .btn { background: var(--flame-400); border-color: var(--flame-400); color: var(--ink-900); min-height: 36px; }
  .side { transform: translateX(-100%); transition: transform .22s ease; width: min(300px, 86vw); visibility: hidden; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  body.nav-open .side { transform: none; visibility: visible; }
  .side-close { display: inline-grid; width: 44px; height: 44px; }
  .side-nav a { min-height: 46px; font-size: 14.5px; }
  .side .iconbtn, .who { min-height: 44px; }
  .side .iconbtn { width: 44px; height: 44px; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(3, 7, 18, .6); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .main { margin-left: 0; }
  .guestbar { display: none; }
  .content { padding: 20px 16px 36px; }
  .foot { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .hero { padding: 28px 20px; border-radius: 14px; }
  .hero h1 { font-size: 22px; }
  .pay { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  /* 16px inputs stop iOS from zooming the page on focus; 44px targets for fingers */
  input:not([type=checkbox]):not([type=radio]), textarea { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 36px; padding: 6px 12px; }
  input.short { max-width: none; }
  .grid, .grid.two { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid.four { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 18px; }
  .stat .stat-ic { display: none; }
  .stat > span { padding-right: 0; }
  th, td { padding: 10px 12px; }
  .page-head { margin-bottom: 18px; }
  .row > label, .row > .grow, .row > form.row { flex: 1 1 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}
@media (max-width: 380px) { .grid.stats, .grid.four { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print { .side, .topbar, .scrim, .foot { display: none; } .main { margin: 0; } }

/* token plans */
.grid.plans { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: stretch; }
.plan { display: flex; flex-direction: column; gap: 12px; }
.plan h3 { margin: 0; font-size: 15px; font-weight: 600; }
.plan-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.plan-price b { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.plan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.plan-list li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.plan-list svg { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--accent); }
.plan p { margin: 0; font-size: 12.5px; }
.plan form { margin: 0; }
.plan-now { border-color: var(--flame-400); }
.plan-now-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.plan-now-head h2 { margin: 2px 0 0; }
.plan-now-head .muted { font-size: 12.5px; font-weight: 500; }
.plan-meter { margin-bottom: 12px; }
.plan-meter-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.plan-meter-top b { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 10px; border: 0; border-radius: 999px; overflow: hidden; background: var(--line); }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.plan-renew { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.plan-renew form { margin: 0; }
.plan-renew .muted { font-size: 12.5px; flex: 1; min-width: 220px; }
.row.tight { margin: 0; gap: 6px; flex-wrap: nowrap; align-items: center; }
select { font: 400 14px/1.4 var(--sans); min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); width: 100%; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
select:hover { border-color: var(--muted); }
select:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
select.short { max-width: 220px; }
.row.tight select { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13px; }
@media (max-width: 720px) { select { font-size: 16px; min-height: 44px; } }
.row.tight input.short { min-height: 34px; padding: 4px 10px; font-size: 13px; width: 170px; }

/* ---------- usage chart ---------- */
:root { --s-in: #257de0; --s-out: #f47230; --s-cache: #00b894; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { --s-in: #338ced; --s-out: #e76624; --s-cache: #00a888; } }
:root[data-theme=dark] { --s-in: #338ced; --s-out: #e76624; --s-cache: #00a888; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h2 { margin: 0 0 4px; }
.chart-head p { margin: 0; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 2px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.sw.s-in, .chart .s-in { background: var(--s-in); fill: var(--s-in); }
.sw.s-out, .chart .s-out { background: var(--s-out); fill: var(--s-out); }
.sw.s-cache, .chart .s-cache { background: var(--s-cache); fill: var(--s-cache); }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .base-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 500 11px var(--sans); font-variant-numeric: tabular-nums; }
.chart .col { fill: transparent; }
.chart .bar:hover .col, .chart .bar.on .col { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.chart-tip { position: absolute; z-index: 5; top: 0; left: 0; pointer-events: none; min-width: 190px; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 6px 20px rgba(10, 19, 48, .16); padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.chart-tip b.day { display: block; margin-bottom: 4px; }
.chart-tip span.r { display: flex; align-items: center; gap: 6px; text-align: left; }
.chart-tip span.r em { font-style: normal; margin-left: auto; padding-left: 14px; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip span.sum { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.chart-table { margin-top: 10px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 13px; width: fit-content; padding: 4px 0; }
.chart-table .scroll { margin-top: 8px; box-shadow: none; }
/* The drawing whose width is closest to the room there is, so that the axis
   text stays near its 11px instead of scaling with the card. */
.chart { container-type: inline-size; }
.chart svg { display: none; }
.chart svg.c720 { display: block; }
@container (max-width: 319.98px) { .chart svg.c720 { display: none; } .chart svg.c290 { display: block; } }
@container (min-width: 320px) and (max-width: 429.98px) { .chart svg.c720 { display: none; } .chart svg.c360 { display: block; } }
@container (min-width: 430px) and (max-width: 609.98px) { .chart svg.c720 { display: none; } .chart svg.c520 { display: block; } }
@container (min-width: 850px) and (max-width: 1189.98px) { .chart svg.c720 { display: none; } .chart svg.c1000 { display: block; } }
@container (min-width: 1190px) and (max-width: 1639.98px) { .chart svg.c720 { display: none; } .chart svg.c1400 { display: block; } }
@container (min-width: 1640px) { .chart svg.c720 { display: none; } .chart svg.c1900 { display: block; } }
@container (max-width: 609.98px) { .chart-tip { position: static; margin-top: 8px; box-shadow: none; } }

/* ---------- model names that copy on click ---------- */
.copy-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; background: none; border: 0; padding: 4px 0; margin: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; min-height: 32px; }
.copy-chip code { transition: background-color .15s; }
.copy-chip .ic { width: 15px; height: 15px; color: var(--muted); flex: none; }
.copy-chip:hover code, .copy-chip:focus-visible code { background: var(--accent-soft); }
.copy-chip:hover .ic { color: var(--accent); }
.copy-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.copy-chip .copied { font-size: 12px; font-weight: 600; color: var(--ok); white-space: nowrap; }
.copy-chip.done .ic { display: none; }
.filter-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar input { flex: 1; min-width: 220px; max-width: 420px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

[hidden] { display: none !important; }

/* ---------- chart tabs and the by-model lines ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--raised); border: 1px solid var(--line); border-radius: 999px; }
.tabs button { border: 0; background: none; color: var(--muted); font: 600 13px/1.3 var(--sans); padding: 6px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; min-height: 32px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.tabs button:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
[data-panel] > .legend { margin: 4px 0 10px; }
:root { --m1: #257de0; --m2: #f47230; --m3: #00b894; --m4: #f2a600; --m5: #ee7fac; --m-other: #7c8798; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { --m1: #338ced; --m2: #e76624; --m3: #00a888; --m4: #d28e05; --m5: #e24d8b; --m-other: #8794ab; } }
:root[data-theme=dark] { --m1: #338ced; --m2: #e76624; --m3: #00a888; --m4: #d28e05; --m5: #e24d8b; --m-other: #8794ab; }
.m1 { --c: var(--m1); } .m2 { --c: var(--m2); } .m3 { --c: var(--m3); } .m4 { --c: var(--m4); } .m5 { --c: var(--m5); } .m-other { --c: var(--m-other); }
.sw.m1, .sw.m2, .sw.m3, .sw.m4, .sw.m5, .sw.m-other { background: var(--c); }
.chart .line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--c); fill-opacity: .1; stroke: none; }
.chart .dot { fill: var(--c); stroke: var(--surface); stroke-width: 2; display: none; }
.chart .guide { stroke: var(--line-strong); stroke-width: 1; display: none; }
.chart .bar:hover .dot, .chart .bar.on .dot, .chart .bar:hover .guide, .chart .bar.on .guide { display: inline; }
.chart-tip span.r .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chart-tip span.r .sw { align-self: flex-start; margin-top: 4px; }
