/* Aight console components, palette A "Ink & clay". Reads tokens.css only.

   Colour allocation (handoff §2): at least 85% of every screen is neutral. Clay is
   the primary button, the selected nav item, links and focus. Money is dark ink on
   white. Extra earned may carry one small soft badge. State colours only ever
   appear next to words that name the state. The red is the logo's full stop only.

   References for layout decisions: Stripe Dashboard (balance card: one figure,
   its split beneath, actions top right), Mercury (calm ledger rows, right-aligned
   signed amounts), Linear and Vercel (224px sidebar, page title + actions row,
   quiet tables with horizontal rules only). */

/* ------------------------------------------------------------------ reset + explicit colours */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; background: var(--page); color: var(--ink); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 var(--text)/var(--text-lh) var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre, blockquote, fieldset { margin: 0; }
ul, ol { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
img, svg { display: block; max-width: 100%; }

/* every text element names its colour; nothing is left to the host or browser */
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 600; }
p, li, dt, dd, th, td, caption, label, legend, address, summary, figcaption, blockquote, output { color: var(--ink); }
address { font-style: normal; }
span, small, em, i, b { color: inherit; }
strong { color: var(--ink); font-weight: 600; }
small { font-size: var(--label); line-height: var(--label-lh); }
svg text { fill: var(--ink); }
a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }
code, kbd, pre, samp { font-family: var(--mono); font-size: 13px; color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s5) 0; }
::selection { background: var(--soft); color: var(--ink); }

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

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.money { font-family: var(--money); font-variant-numeric: tabular-nums; white-space: nowrap; }
.num { white-space: nowrap; }  /* dates and counts: DM Sans's own figures */
.mono { font-family: var(--mono); font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ logo */
.logo { display: inline-flex; align-items: center; line-height: 0; color: var(--logo-ink); text-decoration: none; padding: 4px 0; }
.logo:hover { color: var(--logo-ink); }
.logo svg { height: 28px; width: auto; }
.logo path { fill: currentColor; }
.logo .logo__dot { fill: var(--logo-dot); }

/* ------------------------------------------------------------------ app shell: 224px sidebar (Linear, Vercel) */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s5); padding: var(--s5) var(--s4); background: var(--page); border-right: 1px solid var(--rule); overflow-y: auto; }
.side__logo { padding: 0 var(--s2); }
.side__balance { display: grid; gap: 2px; padding: var(--s3); border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--surface); color: var(--ink); text-decoration: none; }
.side__balance:hover { border-color: var(--input); color: var(--ink); }
.side__balance-label { font-size: var(--small); color: var(--muted); }
.side__balance-figure { font: 600 16px/1.3 var(--money); font-variant-numeric: proportional-nums; color: var(--ink); }
.nav { display: grid; gap: 2px; }
.nav__item { display: flex; align-items: center; gap: var(--s3); min-height: 36px; padding: 0 var(--s2); border-radius: var(--r-control); color: var(--ink); font-weight: 500; text-decoration: none; }
.nav__item:hover { background: var(--tint); color: var(--ink); }
.nav__item[aria-current="page"] { background: var(--soft); color: var(--brand-hover); }
.nav__item[aria-current="page"] .i { stroke: var(--brand-hover); }
.nav__item--locked { color: var(--muted); cursor: default; }
.nav__item--locked:hover { background: none; color: var(--muted); }
.nav__item--locked .i { stroke: var(--muted); }
.nav__lock { margin-left: auto; font-size: var(--small); color: var(--muted); font-weight: 400; }
.nav__group { font-size: var(--small); color: var(--muted); padding: var(--s3) var(--s2) var(--s1); font-weight: 500; }
.side__spacer { flex: 1; }
.side__foot { display: grid; gap: 2px; border-top: 1px solid var(--rule); padding-top: var(--s3); }
.side__foot a { display: flex; align-items: center; gap: var(--s3); min-height: 32px; padding: 0 var(--s2); color: var(--ink); text-decoration: none; border-radius: var(--r-control); }
.side__foot a:hover { background: var(--tint); color: var(--ink); }
.side__account { display: grid; gap: var(--s2); border-top: 1px solid var(--rule); padding: var(--s3) var(--s2) 0; }
.side__account-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.side__account-email { font-size: var(--small); color: var(--muted); overflow-wrap: anywhere; }
.side__account form { margin: 0; }
.linkbutton { appearance: none; background: none; border: 0; padding: 0; font: inherit; font-weight: 500; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; text-align: left; }
.linkbutton:hover { color: var(--brand-hover); }

.i { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.btn .i { stroke: currentColor; }
.btn--primary .i { stroke: var(--on-brand); }

/* mobile bar + Menu drawer (below 900px) */
.mbar { display: none; }
.drawer { padding: 0; margin: 0; border: 0; width: min(304px, calc(100vw - 48px)); max-width: none; height: 100vh; max-height: none; background: var(--page); color: var(--ink); box-shadow: var(--lift); }
.drawer::backdrop { background: var(--scrim); }
.drawer__inner { display: flex; flex-direction: column; gap: var(--s5); min-height: 100%; padding: var(--s4); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; }

.main { min-width: 0; padding: var(--pad); }
.page { max-width: var(--content-max); margin: 0 auto; display: grid; gap: var(--s6); }
.page--narrow { max-width: 720px; }
.page__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); }
.page__title { display: grid; gap: var(--s1); }
h1, .h1 { font-size: var(--h1); line-height: var(--h1-lh); letter-spacing: -0.015em; color: var(--ink); font-weight: 600; }
.lede { color: var(--muted); font-size: 15px; }
h2, .h2 { font-size: var(--h2); line-height: var(--h2-lh); color: var(--ink); font-weight: 600; letter-spacing: -0.005em; }
h3, .h3 { font-size: var(--h3); line-height: 1.35; color: var(--ink); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.section { display: grid; gap: var(--s4); }
.section__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }

@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app > .side { display: none; }
  .mbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); position: sticky; top: 0; z-index: 5; min-height: 56px; padding: 0 var(--pad-m); background: var(--page); border-bottom: 1px solid var(--rule); }
  .mbar .logo svg { height: 24px; }
  .main { padding: var(--s5) var(--pad-m) var(--s7); }
  .page { gap: var(--s5); }
}

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s4); border-radius: var(--r-control); border: 1px solid var(--input); background: var(--surface); color: var(--ink); font: 500 14px/1.2 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { color: var(--ink); border-color: var(--ink); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--on-brand); }
.btn--danger { background: var(--error-ink); border-color: var(--error-ink); color: var(--on-brand); }
.btn--danger:hover { background: var(--error-hover); border-color: var(--error-hover); color: var(--on-brand); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--brand); padding: 0 var(--s2); }
.btn--quiet-danger { color: var(--error-ink); }
.btn--quiet-danger:hover { color: var(--error-hover); background: var(--error-tint); }
.btn--quiet:hover { border-color: transparent; color: var(--brand-hover); background: var(--brand-tint); }
.btn--sm { min-height: 32px; padding: 0 var(--s3); font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--page); border-color: var(--rule); color: var(--muted); cursor: not-allowed; }
.btn[disabled] .i { stroke: var(--muted); }
@media (pointer: coarse) { .btn, .btn--sm { min-height: var(--touch); } .nav__item, .side__foot a { min-height: var(--touch); } }
@media (max-width: 899px) { .btn { min-height: var(--touch); } }
.menu-button { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--touch); padding: 0 var(--s3); border: 1px solid var(--input); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font: 500 14px/1 var(--sans); cursor: pointer; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: var(--touch); height: var(--touch); border: 1px solid transparent; border-radius: var(--r-control); background: transparent; color: var(--ink); cursor: pointer; }
.icon-button:hover { background: var(--tint); }

/* ------------------------------------------------------------------ cards and figures (Stripe balance card) */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); padding: var(--s5); display: grid; gap: var(--s3); align-content: start; min-width: 0; }
.card--flush { padding: 0; gap: 0; overflow: hidden; }
.card__label { font-size: var(--label); line-height: var(--label-lh); color: var(--muted); font-weight: 500; }
.card__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.figure { font: 600 var(--money-hero)/var(--money-hero-lh) var(--money); font-variant-numeric: proportional-nums; letter-spacing: -0.02em; color: var(--ink); }  /* a lone figure: proportional (tabular 1s read as gaps at this size); columns stay tabular */
.figure--card { font-size: var(--money-card); line-height: 1.2; letter-spacing: -0.01em; }
.figure--unavailable { font: 500 18px/1.3 var(--sans); color: var(--muted); letter-spacing: 0; }
@media (max-width: 899px) { .figure { font-size: var(--money-hero-m); } }
.split { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); padding-top: var(--s3); border-top: 1px solid var(--rule); }
.split div { display: grid; gap: 2px; }
.split dt { font-size: var(--small); color: var(--muted); }
.split dd { font: 500 15px/1.3 var(--money); font-variant-numeric: proportional-nums; color: var(--ink); }
.meta { font-size: var(--label); color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: var(--s1); padding: 2px var(--s2); border-radius: 4px; font-size: var(--small); font-weight: 500; line-height: 1.5; background: var(--page); color: var(--ink); border: 1px solid var(--rule); white-space: nowrap; }
.badge--extra { background: var(--soft); color: var(--brand-hover); border-color: transparent; }
.grid { display: grid; gap: var(--s4); }
.grid--hero { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1099px) { .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 759px) { .grid--hero, .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); } }

/* first-use panel */
.firstuse { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s4); padding: var(--s5); border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--surface); }
.firstuse ol { display: grid; gap: var(--s2); counter-reset: step; }
.firstuse li { display: flex; gap: var(--s3); align-items: baseline; color: var(--ink); }
@media (max-width: 759px) { .firstuse { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ notices, flashes, status */
.notice { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-card); border: 1px solid transparent; background: var(--surface); color: var(--ink); }
.notice p { color: inherit; }
.notice__body { display: grid; gap: var(--s1); flex: 1; min-width: 0; }
.notice__text { font-weight: 500; }
.notice__actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.notice .i { margin-top: 2px; stroke: currentColor; }
.notice a { color: inherit; font-weight: 600; }
.notice--info { background: var(--surface); border-color: var(--rule); color: var(--ink); }
.notice--success { background: var(--success-bg); color: var(--success-ink); }
.notice--warning { background: var(--warning-bg); color: var(--warning-ink); }
.notice--error { background: var(--error-bg); color: var(--error-ink); }
.notices { display: grid; gap: var(--s2); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--label); font-weight: 500; white-space: nowrap; color: var(--ink); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.status--ok { color: var(--success-ink); } .status--ok::before { background: var(--success-ink); }
.status--warn { color: var(--warning-ink); } .status--warn::before { background: var(--warning-ink); }
.status--bad { color: var(--error-ink); } .status--bad::before { background: var(--error-ink); }
.status--neutral { color: var(--muted); } .status--neutral::before { background: var(--input); }

.tag { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--rule); background: var(--page); color: var(--ink); font-size: var(--small); font-weight: 500; line-height: 1.5; white-space: nowrap; }

/* ------------------------------------------------------------------ empty, loading, error blocks */
.empty { display: grid; justify-items: start; gap: var(--s3); padding: var(--s6) var(--s5); border: 1px dashed var(--rule); border-radius: var(--r-card); background: var(--surface); }
.empty p { color: var(--ink); font-weight: 500; }
.empty--inline { padding: var(--s5); border-style: solid; }
.loading { display: flex; align-items: center; gap: var(--s2); color: var(--muted); }
.loading::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--brand); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading::before { animation: none; } }

/* ------------------------------------------------------------------ forms */
.form { display: grid; gap: var(--s4); }
.field { display: grid; gap: 6px; min-width: 0; }
.field__label, .label { font-size: var(--label); line-height: var(--label-lh); font-weight: 500; color: var(--ink); }
.field__help { font-size: var(--label); line-height: var(--label-lh); color: var(--muted); }
.field__error { display: flex; gap: 6px; align-items: flex-start; font-size: var(--label); line-height: var(--label-lh); color: var(--error-ink); font-weight: 500; }
.field__error .i { stroke: var(--error-ink); margin-top: 1px; }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 8px var(--s3); border: 1px solid var(--input); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font: 400 14px/1.4 var(--sans); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-color: var(--brand); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--error-ink); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--page); color: var(--ink); border-color: var(--rule); }
.input:disabled { color: var(--muted); }
@media (max-width: 899px) { .input, .select { min-height: var(--touch); font-size: 16px; } }
.prefix { display: flex; align-items: stretch; border: 1px solid var(--input); border-radius: var(--r-control); background: var(--surface); }
.prefix:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; border-color: var(--brand); }
.prefix__sign { display: flex; align-items: center; padding: 0 0 0 var(--s3); color: var(--muted); font-weight: 500; }
.prefix .input { border: 0; min-height: 38px; font-family: var(--money); }
.prefix .input:focus-visible { outline: none; }
.prefix--invalid { border-color: var(--error-ink); }
.choice { display: flex; align-items: center; gap: var(--s2); min-height: 32px; color: var(--ink); cursor: pointer; }
.choice input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.choices { display: grid; gap: var(--s1); }
.choices--row { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s5); }
.checklist { display: grid; gap: 2px; max-height: 220px; overflow-y: auto; padding: var(--s2) var(--s3); border: 1px solid var(--rule); border-radius: var(--r-control); background: var(--surface); }
.form__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 599px) { .form__row { grid-template-columns: minmax(0, 1fr); } }
.form__actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.presets { display: flex; flex-wrap: wrap; gap: var(--s2); }
.preset { min-height: 36px; padding: 0 var(--s3); border: 1px solid var(--rule); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font: 500 13px/1 var(--money); cursor: pointer; }
.preset { display: inline-flex; align-items: center; text-decoration: none; }
.preset:hover { border-color: var(--input); color: var(--ink); }
.preset[aria-current="true"] { border-color: var(--brand); background: var(--soft); color: var(--brand-hover); }
@media (max-width: 899px) { .preset { min-height: var(--touch); } }

/* ------------------------------------------------------------------ toolbar (search + filters) */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
.toolbar .field { flex: 1 1 180px; max-width: 280px; }
.toolbar .field--search { flex: 2 1 240px; max-width: 360px; }
.search { position: relative; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); stroke: var(--muted); pointer-events: none; }
.search .input { padding-left: 36px; }
@media (max-width: 599px) { .toolbar .field, .toolbar .field--search { max-width: none; flex-basis: 100%; } }

/* ------------------------------------------------------------------ tables: horizontal rules, labels left, money right */
.table-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text); }
.table th { text-align: left; font-size: var(--label); font-weight: 500; color: var(--muted); padding: 10px var(--s4); border-bottom: 1px solid var(--rule); background: var(--surface); white-space: nowrap; }
.table code { white-space: nowrap; }
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); color: var(--ink); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .r, .table th.r { text-align: right; }
.table td.money { font-family: var(--money); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.r { white-space: nowrap; }
.stackcell .sub { text-align: right; }
.table .sub { display: block; font-size: var(--small); color: var(--muted); }
.table .actions { justify-content: flex-end; flex-wrap: nowrap; gap: var(--s1); }
.amount--in { color: var(--success-ink); }
.table caption { text-align: left; }
/* a genuinely wide staff table scrolls inside its own labelled region, never the page */
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: -2px; }
/* narrow widths: each row becomes a labelled block (no horizontal page scroll) */
@media (max-width: 759px) {
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 4px 0; border: 0; text-align: right; white-space: normal; }
  .table--stack td::before { content: attr(data-label); flex: none; font-size: var(--label); color: var(--muted); font-weight: 500; text-align: left; font-family: var(--sans); }
  .table--stack td.lead { display: block; text-align: left; font-weight: 600; padding-bottom: var(--s1); }
  .table--stack td.lead::before { content: none; }
  .table--stack td .actions { justify-content: flex-end; flex-wrap: wrap; }
  .table--stack td[data-label=""]::before { content: none; }
  .table--stack td:empty { display: none; }
  .table--stack .stackcell { display: grid; justify-items: end; }
}

/* ------------------------------------------------------------------ money summaries (Recharge, refund, success) */
.summary { display: grid; }
.summary__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: 10px 0; border-bottom: 1px solid var(--rule); }
.summary__row dt { color: var(--ink); }
.summary__row dd { font-family: var(--money); font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; white-space: nowrap; }
.summary__row--total dt, .summary__row--total dd { font-weight: 600; }
.summary__row--total { border-bottom: 1px solid var(--ink); }
.summary__row--rate dt, .summary__row--rate dd { color: var(--muted); font-size: var(--label); }
.summary__row--added { border-bottom: 0; padding-top: var(--s3); }
.summary__row--added dt { font-weight: 600; }
.summary__row--added dd { font-size: 20px; font-weight: 600; }
.summary__group { font-size: var(--small); color: var(--muted); font-weight: 500; padding-top: var(--s4); }
.summary--compact .summary__row { padding: 6px 0; }

/* ------------------------------------------------------------------ key-value details */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: var(--s2) var(--s5); }
.kv dt { color: var(--muted); font-size: var(--label); }
.kv dd { color: var(--ink); overflow-wrap: anywhere; }
@media (max-width: 599px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: var(--s2); } }

/* ------------------------------------------------------------------ dialogs (native <dialog>: focus trap + Escape) */
.dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--rule); border-radius: var(--r-dialog); background: var(--surface); color: var(--ink); box-shadow: var(--lift); overflow: auto; }
.dialog--wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--scrim); }
.dialog[open]:not(:modal) { position: relative; margin: 0 0 var(--s5); inset: auto; width: 100%; max-width: 640px; }
.dialog__form { display: grid; gap: 0; margin: 0; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: var(--s5) var(--s5) 0; }
.dialog__head h2 { font-size: 18px; line-height: 1.3; }
.dialog__body { display: grid; gap: var(--s4); padding: var(--s4) var(--s5) var(--s5); }
.dialog__body p { color: var(--ink); }
.dialog__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s3); padding: var(--s4) var(--s5); border-top: 1px solid var(--rule); background: var(--page); }
@media (max-width: 599px) { .dialog__foot { flex-direction: column-reverse; } .dialog__foot .btn { width: 100%; } }
.secret { display: flex; align-items: center; gap: var(--s2); padding: var(--s3); border: 1px solid var(--rule); border-radius: var(--r-control); background: var(--page); }
.secret code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; color: var(--ink); user-select: all; }

/* ------------------------------------------------------------------ flash toast (role=status, stays in flow) */
.flash { display: flex; align-items: center; gap: var(--s2); padding: 10px var(--s4); border-radius: var(--r-card); font-weight: 500; }
.flash .i { stroke: currentColor; }
.flash--success { background: var(--success-bg); color: var(--success-ink); }
.flash--error { background: var(--error-bg); color: var(--error-ink); }
.toast { position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); z-index: 20; padding: 10px var(--s4); border-radius: var(--r-card); background: var(--ink); color: var(--surface); font-weight: 500; box-shadow: var(--lift); }

/* ------------------------------------------------------------------ access screens (sign in, sign up, code, review) */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--page); }
.auth__top { padding: var(--s5) var(--pad); }
.auth__main { display: grid; place-items: start center; padding: var(--s6) var(--pad-m) var(--s7); }
.auth__card { width: min(420px, 100%); display: grid; gap: var(--s5); padding: var(--s6); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); }
.auth__card h1 { font-size: 24px; }
.auth__foot { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); justify-content: center; padding: var(--s5) var(--pad-m); font-size: var(--label); color: var(--muted); }
.auth__foot a { color: var(--ink); }
.auth__fine { font-size: var(--label); color: var(--muted); }
.auth__fine a { color: var(--ink); }
.auth__alt { font-size: 14px; color: var(--ink); }
@media (max-width: 599px) { .auth__top { padding: var(--s4) var(--pad-m); } .auth__main { padding-top: var(--s4); } .auth__card { padding: var(--s5); } }
.code-input { font: 500 22px/1 var(--sans); letter-spacing: 0.3em; text-align: center; }

/* ------------------------------------------------------------------ payment result */
.result { display: grid; gap: var(--s5); padding: var(--s6); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); }
.result__head { display: grid; gap: var(--s2); }
.result__mark { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.result__mark .i { width: 20px; height: 20px; stroke-width: 1.8; }
.result__mark--ok { background: var(--success-bg); } .result__mark--ok .i { stroke: var(--success-ink); }
.result__mark--wait { background: var(--warning-bg); } .result__mark--wait .i { stroke: var(--warning-ink); }
.result__mark--bad { background: var(--error-bg); } .result__mark--bad .i { stroke: var(--error-ink); }
.result__mark--neutral { background: var(--page); } .result__mark--neutral .i { stroke: var(--ink); }
.result__ref { font-size: var(--label); color: var(--muted); }
@media (max-width: 599px) { .result { padding: var(--s5); } }

/* ------------------------------------------------------------------ recharge layout */
.recharge { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 400px); gap: var(--s5); align-items: start; }
.recharge__summary { position: sticky; top: var(--s5); }
@media (max-width: 999px) { .recharge { grid-template-columns: minmax(0, 1fr); } .recharge__summary { position: static; } }

/* ------------------------------------------------------------------ invoice document (print-ready) */
.invoice { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-card); padding: var(--s7); display: grid; gap: var(--s6); max-width: 820px; }
.invoice__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s5); }
.invoice__head .logo svg { height: 30px; }
.invoice__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); }
.invoice__note { padding: var(--s4); border: 1px solid var(--rule); border-radius: var(--r-card); background: var(--page); display: grid; gap: var(--s2); }
.invoice__legal { font-size: var(--small); color: var(--muted); }
@media (max-width: 759px) { .invoice { padding: var(--s5); } .invoice__cols { grid-template-columns: minmax(0, 1fr); } }
@media print {
  body { background: var(--surface); }
  .app { display: block; }
  .side, .mbar, .no-print { display: none !important; }
  .main { padding: 0; }
  .invoice { border: 0; padding: 0; max-width: none; }
}

/* ------------------------------------------------------------------ playground */
.play { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.play__out { min-height: 280px; display: grid; grid-template-rows: auto 1fr auto; gap: var(--s3); }
.play__text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); font-size: 14px; line-height: 1.6; }
.play__empty { color: var(--muted); }
@media (max-width: 999px) { .play { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ staff shell accent: same palette, a label on the sidebar */
.side__staff { font-size: var(--small); font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; padding: 0 var(--s2); }
.check-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 999px) { .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 499px) { .check-grid { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ error page */
.lost { display: grid; gap: var(--s4); justify-items: start; padding: var(--s8) 0; }
.lost__code { font: 600 14px/1 var(--money); color: var(--muted); }

/* ------------------------------------------------------------------ pager / small links row */
.linkrow { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; }

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

/* segmented links (Display prices US$ / ₹) */
.seg { display: inline-flex; border: 1px solid var(--input); border-radius: var(--r-control); background: var(--surface); overflow: hidden; }
.seg__opt { display: inline-flex; align-items: center; min-height: 38px; padding: 0 var(--s4); color: var(--ink); text-decoration: none; font-weight: 500; font-family: var(--money); }
.seg__opt + .seg__opt { border-left: 1px solid var(--input); }
.seg__opt[aria-current="true"] { background: var(--ink); color: var(--surface); }
.seg__opt:hover { color: var(--ink); background: var(--page); }
.seg__opt[aria-current="true"]:hover { background: var(--ink); color: var(--surface); }
.prices { display: grid; gap: 2px; }
.prices span { white-space: nowrap; }
.prices .money { color: var(--ink); }
.model-name { display: grid; gap: 2px; }
.model-name code { font-size: 12px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: var(--s1); }

.nowrap { white-space: nowrap; }
.rowlinks { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-top: var(--s1); font-size: var(--label); }
.linkbutton--sm { font-size: var(--label); min-height: 24px; }
@media (pointer: coarse), (max-width: 899px) { .linkbutton--sm, .rowlinks a { min-height: var(--touch); display: inline-flex; align-items: center; } }

/* D51 staff refunds: the review reason, readable beside its status */
.review-reason { margin: var(--s2) 0 0; padding: var(--s2) var(--s3); max-width: 52ch; border-radius: var(--r-control); background: var(--warning-bg); color: var(--warning-ink); font-size: var(--label); text-align: left; white-space: normal; }
.review-reason__label { display: block; font-weight: 600; }
.table--stack td.has-reason { flex-wrap: wrap; }
@media (max-width: 759px) { .table--stack td.has-reason .review-reason { flex-basis: 100%; max-width: none; } }

/* Model picker search (keys dialog) */
.checklist__search { width: 100%; margin: 0 0 8px; position: sticky; top: 0; z-index: 1; background: var(--surface); }
.checklist__none { color: var(--muted); margin: 4px 0; }
.checklist .choice[hidden] { display: none; }

/* Staff nav groups (owner, 30 Sep): Accounts, Money, Tax, Settings */
.nav__group { margin: var(--s4) 0 var(--s1); padding: 0 var(--s2); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.actions__help { margin: 4px 0 0; font-size: 13px; color: var(--muted); max-width: 32ch; text-align: left; }
