/* 10Talents Learning — admin console chrome.
 *
 * DS-01. Values come from /brand/tokens.css; this file is the COMPONENT layer
 * shared by the two operator surfaces (public/admin.html and
 * public/admin-metrics.html), the same role site-chrome.css plays for the
 * marketing and legal pages. Both are served from admin.10talentslearning.com,
 * where /brand/<file>.css is allowlisted in src/worker.js.
 *
 * It is deliberately a mirror of the SPA's own component CSS
 * (public/index.html): the shell grid, .sidebar/.nav-item, .topbar/.crumb,
 * .scroll/.page-head, .btn, .card, .chip, the data tables and the modals. An
 * operator moving between app.10talentslearning.com and this host should not
 * feel they changed products — same canvas, same violet accent, same rounding,
 * same 34px control height, same off-canvas drawer under 768px.
 *
 * Class names the console's JS already emits (.tag, .tile, .kv, .filters,
 * .input, table.accounts, table.ledger, .modal-backdrop/.modal) are kept and
 * re-skinned rather than renamed, so the render code is untouched by this.
 *
 * Surface-only components stay inline on their surface: the console's
 * feedback queue, PII reveal and campaign editor live in admin.html.
 */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  accent-color: var(--accent);
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }
button, a, .nav-item, .btn { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
code { font-family: var(--font-mono); font-size: 0.9em; color: var(--ink-2); }
/* `display: none !important` so .hidden wins over later rules with their own
   display value (e.g. .modal-backdrop sets display:flex, which would
   otherwise override .hidden by source-order specificity and leave both
   modals visible on first paint). */
.hidden { display: none !important; }
/* Same reason, for the `hidden` ATTRIBUTE: the UA sheet's `[hidden]` rule is
   weaker than any author rule with a display of its own, so a hidden .app or
   .auth-shell would still paint (both set display). The metrics page toggles
   its two panes on this attribute. */
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -0.18em; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 2px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--font-display);
  flex: none;
}
.brand-name { font-family: var(--font-display); font-size: 20px; letter-spacing: -0.02em; line-height: 1; }
.brand-sub {
  font-size: 10.5px; color: var(--ink-3);
  letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px;
}

.nav-section {
  font-size: 10.5px; color: var(--ink-4);
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 14px 8px 6px; font-weight: var(--fw-medium);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer; user-select: none;
  border: none; background: none;
  text-align: left; width: 100%;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-soft-ink);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent) 20%, transparent);
  font-weight: var(--fw-semibold);
}
.nav-item .icon { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.nav-item.active .icon { color: var(--accent-soft-ink); }
.nav-item .nav-out { margin-left: auto; font-size: 11px; color: var(--ink-4); }

.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
/* The signed-in operator, shaped like the SPA's family chip: an initial
   avatar plus the identity, above the actions rather than floating in a
   page header. */
.who-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: var(--r-sm);
  min-width: 0;
}
.who-avatar {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-soft-ink);
  display: grid; place-items: center;
  font-size: 11px; font-weight: var(--fw-semibold);
  text-transform: uppercase;
}
.who-meta { min-width: 0; }
.who-role {
  font-size: 10.5px; color: var(--ink-4);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.who-email {
  font-size: 12px; color: var(--ink); font-weight: var(--fw-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 168px;
}

/* ── Main column ───────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); min-width: 0; }

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  flex: none;
  background: var(--bg);
}
.crumb {
  font-size: 13px; color: var(--ink-3);
  min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.crumb b { color: var(--ink); font-weight: var(--fw-medium); }
.crumb .sep { margin: 0 8px; color: var(--ink-4); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Standing reminder of what this console is: masked by default, every
   reveal audited. Warn tone, like the SPA's incognito flag — "what you are
   looking at is other people's data" is a thing to notice. */
.pii-flag {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--warn-soft); color: var(--gold-ink);
  font-size: 11px; font-weight: var(--fw-semibold);
}
.pii-flag .icon { width: 13px; height: 13px; }
@media (max-width: 900px) { .pii-flag .pii-flag-label { display: none; } }

/* Hamburger — hidden on desktop, shown in the mobile block below. */
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  flex: none; width: 44px; height: 44px; margin-right: 4px;
  border: none; background: transparent; color: var(--ink-2);
  border-radius: 8px; cursor: pointer;
}
.nav-toggle:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-scrim {
  position: fixed; inset: 0;
  background: oklch(0% 0 0 / 0.35);
  z-index: 30;
  animation: nav-scrim-in .18s ease;
}
@keyframes nav-scrim-in { from { opacity: 0; } to { opacity: 1; } }

.scroll {
  flex: 1; overflow-y: auto;
  padding: 28px 32px 60px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.scroll::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: var(--r-pill);
  border: 3px solid transparent; background-clip: content-box;
}
.scroll::-webkit-scrollbar-thumb:hover, .sidebar::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
h1, .page-title {
  font-family: var(--font-display);
  font-size: 36px; line-height: 1.05; letter-spacing: -0.02em;
  margin: 0; font-weight: var(--fw-semibold); color: var(--ink);
}
.page-sub { color: var(--ink-3); font-size: 13px; margin: 6px 0 0; max-width: 68ch; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; min-height: 34px;
  font-size: 13px; font-weight: var(--fw-medium);
  white-space: nowrap; flex-shrink: 0;
  border-radius: var(--r-btn);
  border: 1px solid var(--line-2);
  background: var(--bg-raised); color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:hover { background: var(--bg-sunken); border-color: var(--line-strong); }
.btn:active { transform: translateY(0.5px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: var(--shadow-btn); }
.btn.primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-btn-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--bg-sunken); }
.btn.danger { color: var(--error-ink); }
.btn.danger:not(.ghost) { border-color: var(--error-soft); }
.btn.danger:hover { background: var(--error-soft); color: var(--error-ink); }
.btn.danger:not(.ghost):hover { border-color: var(--error); }
.btn.sm { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.btn .icon { width: 15px; height: 15px; flex: none; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn:disabled:hover, .btn[disabled]:hover { background: var(--bg-raised); border-color: var(--line-2); }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--pad-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--space-4);
}
.card:last-child { margin-bottom: 0; }
/* Section heading inside a card. Display face, sentence case — the console
   used a micro uppercase overline here, which is the SPA's *label* style and
   made every section read as a form legend. */
.card h2 {
  font-family: var(--font-display);
  font-size: 16px; line-height: 1.3;
  margin: 0 0 var(--space-2); font-weight: var(--fw-semibold);
  letter-spacing: -0.01em; color: var(--ink);
}
.card h3 {
  font-family: var(--font-display);
  font-size: 15px; line-height: 1.3;
  margin: 0 0 var(--space-2); font-weight: var(--fw-semibold);
  letter-spacing: -0.01em; color: var(--ink);
}
/* A section divider inside a long card — the account panel runs to eight of
   them, and as a stack of bare <h2>s with an inline margin it read as one
   undifferentiated scroll of definition lists. */
.card .sub-head {
  font-family: var(--font-display);
  font-size: 14px; line-height: 1.3;
  font-weight: var(--fw-semibold); letter-spacing: -0.01em; color: var(--ink);
  margin: var(--space-5) 0 var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.card p { margin: var(--space-2) 0; color: var(--ink-2); font-size: 13px; }
.card > p.muted:first-of-type { margin-top: 0; }
/* Header row: title on the left, a control or export link on the right. */
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin-bottom: 0; }
.card-head .filters { margin: 0; }
.card a:not(.btn):not(.nav-item) {
  color: var(--accent-soft-ink); text-decoration: none; font-weight: var(--fw-medium);
}
.card a:not(.btn):not(.nav-item):hover { text-decoration: underline; }
.muted { color: var(--ink-3); font-size: 13px; }
.error { color: var(--error-ink); font-size: var(--fs-small); }
.coming-soon { opacity: 0.5; }
.coming-soon a { pointer-events: none; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Overview launcher tiles — the console's front door, shaped like the SPA's
   clickable dashboard cards rather than a stack of paragraphs each ending in
   a button. */
.launch {
  display: flex; flex-direction: column; gap: 10px;
  margin: 0; padding: var(--pad-lg);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.launch:hover {
  border-color: color-mix(in oklch, var(--accent) 40%, var(--line));
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.launch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.launch-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-soft-ink);
}
.launch-ico .icon { width: 22px; height: 22px; }
.launch-ico[data-tone="sage"] { background: var(--sage-soft); color: var(--sage-ink); }
.launch-ico[data-tone="gold"] { background: var(--gold-soft); color: var(--gold-ink); }
.launch-ico[data-tone="sky"]  { background: var(--sky-soft);  color: var(--sky-ink); }
.launch-ico[data-tone="clay"] { background: var(--clay-soft); color: var(--clay-ink); }
.launch-ico[data-tone="plum"] { background: var(--plum-soft); color: var(--plum-ink); }
.launch-title {
  font-family: var(--font-display); font-size: 16px; font-weight: var(--fw-semibold);
  letter-spacing: -0.01em; color: var(--ink);
}
.launch-body { font-size: 12.5px; line-height: 1.5; color: var(--ink-3); margin: 0; }

/* ── Chips / status pills ──────────────────────────────────────────────── */
.tag, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: 0.01em;
  background: var(--accent-soft); color: var(--accent-soft-ink);
  border: 1px solid transparent;
  vertical-align: middle;
}
.chip.neutral { background: var(--bg-sunken); color: var(--ink-2); border-color: var(--line); }
/* Work-queue states. Semantic token families only — rulebook §4: the whole
   question the Feedback tab answers is "who is still waiting", and that has
   to be legible without reading. */
.tag.is-new      { background: var(--warn-soft);    color: var(--warn-ink); }
.tag.is-open     { background: var(--info-soft);    color: var(--info-ink); }
.tag.is-answered { background: var(--success-soft); color: var(--success-ink); }
.tag.is-closed   { background: var(--bg-sunken);    color: var(--ink-3); }
.tag.is-failed   { background: var(--error-soft);   color: var(--error-ink); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
/* Native controls, tokenized — the SPA's .ff-control by another name. `select`
   is styled bare rather than by class: the console's selects are written
   straight into the markup (the diagnostics window picker, the campaign
   audience filters) and a class-scoped rule left half of them wearing the
   platform's own chrome next to a token-styled input. */
.input, select, textarea, .login-form input {
  background: var(--bg-raised);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  font-family: inherit;
  font-size: var(--fs-small); line-height: var(--lh-small);
  color: var(--ink);
  min-height: 34px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input, textarea, .login-form input { width: 100%; }
select { width: auto; cursor: pointer; }
.input::placeholder, textarea::placeholder { color: var(--ink-4); }
.input:hover:not(:disabled):not(:focus),
select:hover:not(:focus),
textarea:hover:not(:disabled):not(:focus) { border-color: var(--line-strong); }
.input:focus, select:focus, textarea:focus, .login-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.filters { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); align-items: center; flex-wrap: wrap; }
.filters .input { flex: 1; min-width: 200px; max-width: 360px; }
.filters select { width: auto; min-width: 150px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
table.accounts, table.ledger, .card table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
table.accounts th, table.accounts td,
table.ledger th, table.ledger td,
.card table th, .card table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
}
table.accounts th, table.ledger th, .card table th {
  font-size: 12px; font-weight: var(--fw-semibold); color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  position: sticky; top: 0; background: var(--bg-raised); z-index: 1;
}
table.accounts tbody tr { cursor: pointer; }
table.accounts tbody tr:hover, .card table tbody tr:hover { background: var(--bg-sunken); }
/* Read-only ledgers (the AI-quota grant history, the feedback queue): same
   grid, minus the pointer affordance — these rows don't go anywhere. */
table.ledger tbody tr { cursor: default; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.pager {
  display: flex; gap: var(--space-2); align-items: center;
  margin-top: var(--space-3); justify-content: flex-end;
  color: var(--ink-3); font-size: var(--fs-small);
}

/* ── Stat tiles + key/value ────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.tile { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--r); padding: var(--space-4); }
.tile dt { font-size: var(--fs-micro); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: var(--fw-semibold); }
.tile dd {
  margin: var(--space-1) 0 0;
  font-family: var(--font-display); font-size: 19px; line-height: 1.25;
  font-variant-numeric: tabular-nums; color: var(--ink); font-weight: var(--fw-semibold);
  /* Tile values are not all numbers — `legacy_per_child` is a plan type, and
     at display size it is wider than a 170px tile. Wrap it rather than let it
     run out of the box. */
  overflow-wrap: anywhere;
}
.kv { display: grid; grid-template-columns: 200px 1fr; gap: var(--space-1) var(--space-3); font-size: var(--fs-small); margin-top: var(--space-3); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); }

/* ── Modals ────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: oklch(0% 0 0 / 0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
  animation: nav-scrim-in .18s ease;
}
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--pad-lg);
  max-width: 560px; width: 100%;
  max-height: calc(100dvh - 40px); overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal h3 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display); font-size: var(--fs-h2); line-height: var(--lh-h2);
  font-weight: var(--fw-medium); letter-spacing: -0.01em; color: var(--ink);
}
.modal label { display: block; margin: var(--space-3) 0 var(--space-1); font-size: var(--fs-small); color: var(--ink); font-weight: var(--fw-medium); }
.modal label.checkbox { display: flex; align-items: center; gap: var(--space-2); color: var(--ink); font-size: 13.5px; margin: var(--space-2) 0; font-weight: var(--fw-regular); }
.modal textarea { min-height: 84px; line-height: var(--lh-body); resize: vertical; }
/* Checkboxes sit inside label rows, not on the control grid. */
input[type="checkbox"], input[type="radio"] { min-height: 0; width: auto; }
.modal .actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }

/* ── Sign-in ───────────────────────────────────────────────────────────── */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5); }
.auth-panel { width: 100%; max-width: 420px; text-align: center; }
.auth-panel .brand { justify-content: center; padding: 0 0 var(--space-5); }
.auth-panel .brand > div:last-child { text-align: left; }
.login-form { margin: 0; }
.login-form h2 {
  font-family: var(--font-display); font-size: var(--fs-h2); line-height: var(--lh-h2);
  font-weight: var(--fw-semibold); letter-spacing: -0.01em; margin: 0 0 var(--space-2); color: var(--ink);
}
.login-form .btn { width: 100%; }
.auth-note { margin: var(--space-4) 0 0; font-size: var(--fs-micro); color: var(--ink-4); }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; border-left: 3px solid var(--ink-3);
  background: var(--bg-raised); color: var(--ink);
  font-size: var(--fs-small); line-height: 1.45; text-align: left;
}
.alert--error   { background: var(--error-soft);   border-left-color: var(--error);   color: var(--error-ink); }
.alert--warn    { background: var(--warn-soft);    border-left-color: var(--warn);    color: var(--gold-ink); }
.alert--info    { background: var(--info-soft);    border-left-color: var(--info);    color: var(--info-ink); }
.alert--success { background: var(--success-soft); border-left-color: var(--success); color: var(--success-ink); }
.alert strong { display: block; margin-bottom: 2px; }
.alert p { margin: 0; font-size: var(--fs-small); color: inherit; opacity: 0.9; }

/* ── Touch + responsive ────────────────────────────────────────────────── */
/* This console shipped no (pointer: coarse) block at all, so its filters — at
   14px — made iOS Safari zoom the whole page on focus, and the account tables
   run to seven columns with nothing to scroll inside. Superadmins do open
   this on a phone. */
@media (pointer: coarse) {
  .input, .filters select, input, select, textarea { font-size: 16px; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 264px; max-width: 84vw;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .22s ease, visibility .22s;
    z-index: 40;
    box-shadow: 0 10px 40px oklch(0% 0 0 / 0.18);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
  }
  .app[data-nav-open="true"] .sidebar { transform: translateX(0); visibility: visible; }
  .app[data-nav-open="true"] .scroll { overflow: hidden; }
  @media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

  .nav-toggle { display: inline-flex; }
  .topbar {
    padding: 0 12px; gap: 10px;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(52px + env(safe-area-inset-top, 0px));
  }
  .scroll {
    padding: 20px 16px 40px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  h1, .page-title { font-size: 26px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .page-actions { margin-left: 0; width: 100%; }

  /* Tap targets */
  .btn, .btn.sm { min-height: 44px; min-width: 44px; padding: 10px 14px; }
  .nav-item { padding: 12px 10px; font-size: 15px; }
  input, select, textarea { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; }
  .kv { grid-template-columns: 1fr; gap: var(--space-1); }
  .kv dt { margin-top: var(--space-2); }

  /* Seven-column tables have nowhere to go on a 390px screen; scroll them
     inside their own card rather than pushing the page wide. */
  table.accounts, table.ledger, .card table {
    display: block; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  table.accounts th, table.ledger th, .card table th { position: static; }
  body { overflow-x: hidden; }
}
