/* XPD Pay v13 console & checkout — design system from "XPD Pay Design Spec" (ink-on-paper ledger look).
   Navy ink, cool paper, one signal blue; money colours carry meaning (credit green, debit red, held amber).
   System fonts only, self-hosted, no third-party requests (works with CSP default-src 'self'). */

:root {
  --ink: #0b1f3f;
  --ink-2: #2c3b57;
  --muted: #5a6a84;
  --faint: #8a98ae;
  --rule: #dde4ee;
  --rule-strong: #c4cfde;
  --paper: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --signal: #1857f0;
  --signal-ink: #0f3eb5;
  --signal-wash: #e7eefe;
  --credit: #0a7550;
  --credit-wash: #e2f3eb;
  --debit: #b02e29;
  --debit-wash: #fbe8e6;
  --hold: #8a5800;
  --hold-wash: #fbf0d8;
  --info: #3a57a3;
  --info-wash: #e8edf8;
  --rail: #0b1f3f;
  --rail-ink: #c3d0e6;
  --rail-dim: #7f91b0;
  --rail-hover: #13294f;
  --shadow: 0 1px 2px rgba(11, 31, 63, .06), 0 4px 16px rgba(11, 31, 63, .05);
  --radius-s: 6px;
  --radius: 10px;
  --focus: 0 0 0 3px rgba(24, 87, 240, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --rail-w: 248px;
  color-scheme: light;
}

/* Dark theme: follows the device unless the user picked Light or Dark (v14 data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e5ebf5;
    --ink-2: #c3cddd;
    --muted: #93a2bb;
    --faint: #6d7d98;
    --rule: #22314d;
    --rule-strong: #30436a;
    --paper: #08111f;
    --surface: #0f1b31;
    --surface-2: #0c1628;
    --signal: #5b8cff;
    --signal-ink: #8fb0ff;
    --signal-wash: #142650;
    --credit: #43c597;
    --credit-wash: #0f2e26;
    --debit: #ff8079;
    --debit-wash: #3a1517;
    --hold: #f0b44c;
    --hold-wash: #33260b;
    --info: #9db4ff;
    --info-wash: #18244a;
    --rail: #050c18;
    --rail-ink: #b9c7df;
    --rail-dim: #6f81a1;
    --rail-hover: #0f1d36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e5ebf5;
  --ink-2: #c3cddd;
  --muted: #93a2bb;
  --faint: #6d7d98;
  --rule: #22314d;
  --rule-strong: #30436a;
  --paper: #08111f;
  --surface: #0f1b31;
  --surface-2: #0c1628;
  --signal: #5b8cff;
  --signal-ink: #8fb0ff;
  --signal-wash: #142650;
  --credit: #43c597;
  --credit-wash: #0f2e26;
  --debit: #ff8079;
  --debit-wash: #3a1517;
  --hold: #f0b44c;
  --hold-wash: #33260b;
  --info: #9db4ff;
  --info-wash: #18244a;
  --rail: #050c18;
  --rail-ink: #b9c7df;
  --rail-dim: #6f81a1;
  --rail-hover: #0f1d36;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--signal-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--signal); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .88em; font-variant-numeric: normal; }
img, svg { display: block; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.25rem 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-s); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.icon { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--rail) var(--rail-w), transparent var(--rail-w)); }
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; text-decoration: none; }
.rail-brand img { width: 34px; height: 34px; }
.rail-brand strong { font-size: 1.05rem; letter-spacing: .01em; }
.rail-brand small { display: block; color: var(--rail-dim); font-size: .75rem; font-weight: 500; }
.rail nav { padding: 4px 10px 16px; flex: 1; }
.rail-group { margin-top: 14px; }
.rail-group > span { display: block; padding: 0 10px 4px; color: var(--rail-dim); font-size: .75rem; font-weight: 600; }
.rail a.rail-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-s);
  color: var(--rail-ink);
  text-decoration: none;
  font-size: .92rem;
  position: relative;
}
.rail a.rail-link:hover { background: var(--rail-hover); color: #fff; }
.rail a.rail-link.is-active { background: var(--rail-hover); color: #fff; }
.rail a.rail-link.is-active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--signal); }
.rail .count { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--signal); color: #fff; font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center; }
.rail .count.is-warn { background: #d18a00; }
.rail-user { border-top: 1px solid rgba(255, 255, 255, .08); padding: 14px 18px 18px; font-size: .85rem; }
.rail-user strong { display: block; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user span { color: var(--rail-dim); }
.rail-user .row { display: flex; gap: 8px; margin-top: 10px; }
.rail-user a, .rail-user button { color: var(--rail-ink); background: none; border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--radius-s); padding: 5px 10px; font: inherit; font-size: .82rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.rail-user a:hover, .rail-user button:hover { border-color: rgba(255, 255, 255, .35); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px 32px 56px; max-width: 1320px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 6px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .crumb { font-size: .85rem; color: var(--muted); margin-bottom: 4px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.page-head .crumb:hover { color: var(--signal-ink); }
.page-head .crumb .icon { width: 15px; height: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 960px) {
  .shell { display: block; background: none; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s ease; }
  .shell.nav-open .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(5, 12, 24, .45); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--rail); color: #fff; padding: 10px 14px; }
  .topbar img { width: 28px; height: 28px; }
  .topbar strong { font-size: .98rem; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; margin-left: -6px; cursor: pointer; }
  .topbar .icon { width: 22px; height: 22px; }
  .content { padding: 20px 16px 48px; }
  h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }

/* ------------------------------------------------------------------ surfaces */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
/* Vertical rhythm: siblings in the page flow and in stacks are spaced; grid cells use the grid gap. */
.content > * + *, .stack > * + * { margin-top: 18px; }
.auth-card .flash { margin-bottom: 16px; }
.content > .flash + .flash { margin-top: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.panel-body { padding: 18px; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--rule); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.panel.is-danger { border-color: color-mix(in srgb, var(--debit) 35%, var(--rule)); }
.panel.is-danger .panel-head { background: var(--debit-wash); border-radius: var(--radius) var(--radius) 0 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

@media (max-width: 1100px) { .grid-main { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Figures strip: one surface divided into cells (not a row of floating cards). */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.figure { padding: 16px 18px; border-left: 1px solid var(--rule); min-width: 0; }
.figure:first-child { border-left: 0; }
.figure dt { color: var(--muted); font-size: .84rem; }
.figure dd { margin: 4px 0 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.figure dd small { font-size: .82rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.figure .delta { display: block; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.figure.is-key dd { color: var(--signal-ink); }
@media (max-width: 720px) { .figure { border-left: 0; border-top: 1px solid var(--rule); } .figure:first-child { border-top: 0; } }

/* Balance line: the passbook row shown on merchant pages */
.balance-line { display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: baseline; }
.balance-line .big { font-size: 2.1rem; font-weight: 750; letter-spacing: -.03em; }
.balance-line .label { color: var(--muted); font-size: .88rem; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--signal-wash) 45%, transparent); }
.table .num { text-align: right; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table td.sub { color: var(--muted); font-size: .84rem; }
.table a.row-link { font-weight: 600; text-decoration: none; }
.table a.row-link:hover { text-decoration: underline; }
.cell-sub { display: block; color: var(--muted); font-size: .8rem; }
.panel > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius); }
.amount-pos { color: var(--credit); }
.amount-neg { color: var(--debit); }
.amount-zero { color: var(--faint); }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--rule); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--credit-wash); color: var(--credit); border-color: transparent; }
.badge-warning { background: var(--hold-wash); color: var(--hold); border-color: transparent; }
.badge-danger { background: var(--debit-wash); color: var(--debit); border-color: transparent; }
.badge-info { background: var(--info-wash); color: var(--info); border-color: transparent; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--rule); font-size: .78rem; color: var(--muted); }

/* ------------------------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-s); border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--signal); color: #fff;
}
.btn:hover { background: var(--signal-ink); color: #fff; }
.btn .icon { width: 16px; height: 16px; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--muted); }
.btn-danger { background: var(--debit); }
.btn-danger:hover { background: color-mix(in srgb, var(--debit) 82%, #000); }
.btn-success { background: var(--credit); }
.btn-success:hover { background: color-mix(in srgb, var(--credit) 82%, #000); }
.btn-link { background: none; color: var(--signal-ink); padding: 0; border: 0; font-weight: 600; }
.btn-link:hover { background: none; color: var(--signal); text-decoration: underline; }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn-xs { padding: 3px 8px; font-size: .78rem; }
.btn-block { width: 100%; }
.btn.is-disabled, .btn:disabled { opacity: .45; pointer-events: none; }
form.inline { display: inline; }

.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: start; }
.form-row.wide { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .86rem; color: var(--ink-2); }
.field .help { color: var(--muted); font-size: .8rem; margin: 0; }
.field-error { color: var(--debit); font-size: .82rem; margin: 0; font-weight: 600; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--rule-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .93rem; min-height: 38px;
}
textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--signal); box-shadow: var(--focus); }
[aria-invalid=true] { border-color: var(--debit) !important; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--signal); flex: none; }
.check small { display: block; color: var(--muted); }
.input-code { font-family: var(--mono); letter-spacing: .3em; font-size: 1.25rem; text-align: center; max-width: 220px; }
.input-money { font-variant-numeric: tabular-nums; }
.totp-field { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 12px 14px; background: var(--signal-wash); border-radius: var(--radius-s); }
.totp-field .field { flex: 1; min-width: 180px; }
.totp-field input { max-width: 180px; letter-spacing: .25em; font-family: var(--mono); }
.sudo-note { display: flex; gap: 8px; align-items: center; color: var(--credit); font-size: .85rem; font-weight: 600; }

/* Filter bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 18px; border-bottom: 1px solid var(--rule); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filters .field { gap: 3px; }
.filters .field label { font-size: .76rem; color: var(--muted); }
.filters input, .filters select { min-height: 34px; padding: 6px 9px; font-size: .88rem; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .total { margin-left: auto; color: var(--muted); font-size: .85rem; align-self: center; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--ink); border-bottom-color: var(--signal); }
.tabs .pill { font-size: .72rem; padding: 0 7px; }

/* ------------------------------------------------------------------ flashes & callouts */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-s); font-size: .92rem; border: 1px solid transparent; }
.panel-body > .flash, .form > .flash { margin: 0; }
.flash .icon { margin-top: 1px; }
.flash-success { background: var(--credit-wash); color: var(--credit); }
.flash-error { background: var(--debit-wash); color: var(--debit); }
.flash-info { background: var(--info-wash); color: var(--info); }
.flash p { margin: 0; color: var(--ink); }
.callout { margin-bottom: 0; padding: 12px 14px; border-left: 3px solid var(--signal); background: var(--signal-wash); border-radius: 0 var(--radius-s) var(--radius-s) 0; font-size: .9rem; }
.callout p:last-child { margin: 0; }
.callout.is-warn { border-left-color: var(--hold); background: var(--hold-wash); }
.callout.is-danger { border-left-color: var(--debit); background: var(--debit-wash); }

/* One-time secret reveal */
.reveal { border: 2px solid var(--signal); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.reveal h2 { padding: 12px 16px; background: var(--signal-wash); font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.reveal dl { margin: 0; padding: 14px 16px; display: grid; gap: 10px; }
.reveal dt { font-size: .8rem; color: var(--muted); font-weight: 600; }
.reveal dd { margin: 2px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reveal dd code { font-size: .95rem; background: var(--surface-2); border: 1px solid var(--rule); padding: 6px 9px; border-radius: var(--radius-s); word-break: break-all; }
.reveal p { margin: 0; padding: 0 16px 14px; color: var(--muted); font-size: .86rem; }

/* ------------------------------------------------------------------ key-value lists */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid var(--rule); margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); padding-right: 12px; }
.kv dd { word-break: break-word; }
.kv > :nth-last-child(-n+2) { border-bottom: 0; }
.kv-tight dt, .kv-tight dd { padding: 6px 0; }
.kv-num { grid-template-columns: 1fr auto; }
.kv-num dd { text-align: right; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--rule-strong); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--rule); }
.timeline li:last-child::after { display: none; }
.timeline li.is-paid::before { background: var(--credit); }
.timeline li.is-bad::before { background: var(--debit); }
.timeline time { display: block; color: var(--muted); font-size: .78rem; }
.timeline .who { color: var(--faint); font-size: .78rem; }

/* Work queue (admin dashboard) */
.queue { list-style: none; margin: 0; padding: 0; }
.queue li + li { border-top: 1px solid var(--rule); }
.queue a { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 18px; text-decoration: none; color: var(--ink); }
.queue a:hover { background: var(--surface-2); }
.queue .q-count { font-size: 1.35rem; font-weight: 750; text-align: center; color: var(--faint); }
.queue .is-hot .q-count { color: var(--signal); }
.queue .is-bad .q-count { color: var(--debit); }
.queue small { display: block; color: var(--muted); font-size: .82rem; }
.queue .icon { color: var(--faint); }

/* Health dots */
.health { display: flex; gap: 8px; align-items: center; font-size: .88rem; color: var(--ink-2); text-decoration: none; }
a.health:hover { color: var(--ink); }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; }
.health-healthy .health-dot { background: var(--credit); box-shadow: 0 0 0 3px var(--credit-wash); }
.health-degraded .health-dot, .health-never .health-dot { background: var(--hold); box-shadow: 0 0 0 3px var(--hold-wash); }
.health-stale .health-dot { background: var(--debit); box-shadow: 0 0 0 3px var(--debit-wash); }

/* Chart */
.chart { width: 100%; height: auto; }
.chart .bar-in { fill: var(--signal); }
.chart .bar-out { fill: var(--rule-strong); }
.chart .axis { stroke: var(--rule); }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--signal); }
.legend i.out { background: var(--rule-strong); }

/* Empty state */
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: .9rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--rule-strong); flex: none; display: grid; place-items: center; }
.checklist .done .tick { background: var(--credit); border-color: var(--credit); color: #fff; }
.checklist .done .tick .icon { width: 12px; height: 12px; }
.checklist .done a { color: var(--muted); }

/* Code & copy */
.code { position: relative; margin: 0 0 1rem; }
.code pre { margin: 0; padding: 14px 16px; background: #0b1f3f; color: #dbe5f7; border-radius: var(--radius-s); overflow-x: auto; font-size: .82rem; line-height: 1.55; }
.code .code-copy { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .1); color: #dbe5f7; border-color: rgba(255, 255, 255, .2); }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { font-family: var(--mono); font-size: .85rem; }
pre.json { margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-s); overflow-x: auto; font-size: .8rem; max-height: 360px; white-space: pre-wrap; word-break: break-word; }

/* Pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--rule); }
.pager-page { color: var(--muted); font-size: .85rem; }

/* Notices */
.notice { padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.notice:last-child { border-bottom: 0; }
.notice strong { display: block; }
.notice p { margin: 2px 0 0; color: var(--ink-2); font-size: .9rem; white-space: pre-line; }
.notice time { color: var(--muted); font-size: .78rem; }

/* QR block in portal */
.qr-box { background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px; width: 220px; max-width: 100%; }
.qr-box svg { width: 100%; height: auto; }

/* Danger zone list */
.zone { display: grid; gap: 0; }
.zone > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.zone > div:last-child { border-bottom: 0; }
.zone p { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }

details.disclose { border-top: 1px solid var(--rule); }
details.disclose > summary { cursor: pointer; padding: 12px 18px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::before { content: "+"; width: 18px; height: 18px; border: 1px solid var(--rule-strong); border-radius: 4px; display: grid; place-items: center; font-size: .8rem; color: var(--muted); }
details.disclose[open] > summary::before { content: "–"; }
details.disclose > div { padding: 0 18px 18px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.gap-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gap-row > .grow, .copy-row > input { flex: 1 1 220px; min-width: 0; width: auto; }
.gap-row > input, .gap-row > select { width: auto; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }

/* ------------------------------------------------------------------ auth & plain pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-side { background: var(--rail); color: var(--rail-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.auth-side .brand img { width: 44px; height: 44px; }
.auth-side .brand strong { font-size: 1.2rem; }
.auth-side h2 { color: #fff; font-size: 1.9rem; font-weight: 700; max-width: 15em; line-height: 1.2; letter-spacing: -.02em; }
.auth-side p { color: var(--rail-ink); max-width: 30em; }
.auth-side .ledger-lines { font-family: var(--mono); font-size: .82rem; color: var(--rail-dim); border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 16px; display: grid; gap: 6px; }
.auth-side .ledger-lines span { display: flex; justify-content: space-between; gap: 16px; }
.auth-side .ledger-lines b { color: #7ee2b8; font-weight: 500; }
.auth-side .ledger-lines b.out { color: #f3a6a2; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.55rem; margin-bottom: 6px; }
.auth-card > p { color: var(--muted); margin-bottom: 22px; }
.auth-card .form { gap: 16px; }
.auth-card .foot { margin-top: 22px; font-size: .85rem; color: var(--muted); }
.auth-qr { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.auth-qr .qr-box { width: 170px; }
.auth-qr code { display: block; margin-top: 6px; word-break: break-all; font-size: .82rem; background: var(--surface-2); border: 1px solid var(--rule); padding: 6px 8px; border-radius: var(--radius-s); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 22px 20px; }
  .auth-side h2, .auth-side p, .auth-side .ledger-lines { display: none; }
}

.plain { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }
.plain-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 36px; }
.plain-head a.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); }
.plain-head img { width: 36px; height: 36px; }
.error-page { max-width: 520px; margin: 12vh auto 0; text-align: left; }
.error-page .code-no { font-family: var(--mono); color: var(--faint); font-size: .9rem; }
.error-page h1 { margin: 6px 0 10px; }
.error-page p { color: var(--ink-2); }

/* Docs */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }
.docs-toc { position: sticky; top: 20px; font-size: .86rem; max-height: calc(100vh - 40px); overflow-y: auto; }
.docs-toc a { display: block; padding: 4px 0; color: var(--muted); text-decoration: none; }
.docs-toc a:hover { color: var(--signal-ink); }
.docs-toc a.l3 { padding-left: 12px; font-size: .82rem; }
.prose { max-width: 820px; }
.prose h1 { font-size: 2rem; margin-bottom: 10px; }
.prose h2 { font-size: 1.35rem; margin: 2.2rem 0 .8rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.prose h3 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
.prose p, .prose li { line-height: 1.65; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1rem; }
.prose code { background: var(--surface-2); border: 1px solid var(--rule); padding: 1px 5px; border-radius: 4px; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose .callout { margin: 0 0 1rem; }
.prose .table-wrap { margin: 0 0 1rem; border: 1px solid var(--rule); border-radius: var(--radius-s); }
.prose .table th { background: var(--surface-2); }
@media (max-width: 900px) { .docs { grid-template-columns: 1fr; } .docs-toc { position: static; max-height: none; } }

/* Landing */
.landing { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 48px; align-items: center; min-height: 60vh; }
.landing h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.03em; line-height: 1.08; margin-bottom: 16px; }
.landing p.lead { font-size: 1.1rem; color: var(--ink-2); max-width: 32em; }
.landing .ticket { background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; }
.landing .ticket .amt { font-size: 2.3rem; font-weight: 750; letter-spacing: -.03em; }
.landing .ticket .amt .paisa { color: var(--signal); }
.landing .ticket ol { margin: 14px 0 0; padding-left: 1.2rem; color: var(--ink-2); font-size: .92rem; }
@media (max-width: 860px) { .landing { grid-template-columns: 1fr; } }

.page-head h1.mono { font-size: 1.3rem; }

@media (max-width: 960px) {
  .figure dd { font-size: 1.15rem; white-space: normal; }
}

@media print {
  .rail, .topbar, .actions, .filters, .pager, form { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}

/* ================================================================== checkout */

.co-body { background: var(--paper); min-height: 100vh; }
.co { max-width: 460px; margin: 0 auto; padding: 14px 14px calc(28px + env(safe-area-inset-bottom)); }
.co-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 2px 14px; font-size: .88rem; }
.co-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.co-brand img { width: 28px; height: 28px; }
.co-merchant { color: var(--muted); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-merchant strong { color: var(--ink); }

.co-card { background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; box-shadow: var(--shadow); padding: 22px 20px; }
.co-label { margin: 0; color: var(--muted); font-size: .88rem; font-weight: 600; }
.co-amount { margin: 2px 0 6px; font-size: clamp(2.3rem, 11vw, 3rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; color: var(--ink); }
.co-cur { font-size: .5em; font-weight: 700; color: var(--muted); letter-spacing: 0; vertical-align: .55em; margin-right: .1em; }
.co-amount .paisa, .landing .paisa {
  display: inline-block; margin-left: .04em; padding: 0 .14em; border-radius: .14em;
  background: var(--signal); color: #fff;
}
.co-why { margin: 0 0 12px; color: var(--ink-2); font-size: .88rem; line-height: 1.45; }
.co-copy { display: inline-flex; align-items: center; gap: 6px; background: var(--signal-wash); color: var(--signal-ink); border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; }
.co-copy .icon { width: 15px; height: 15px; }

.co-timer { margin: 18px 0 16px; }
.co-timer-row { display: flex; justify-content: space-between; align-items: baseline; font-size: .86rem; color: var(--muted); }
.co-timer-row strong { font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.co-bar { height: 5px; margin-top: 6px; border-radius: 99px; background: var(--rule); overflow: hidden; }
.co-bar span { display: block; height: 100%; width: 100%; background: var(--signal); border-radius: 99px; transform-origin: left center; transition: transform 1s linear; }
.co-timer.is-low .co-bar span { background: var(--debit); }
.co-timer.is-low strong { color: var(--debit); }

.co-qr { margin: 0; text-align: center; }
.co-qr-frame { background: #fff; border-radius: 14px; padding: 12px; margin: 0 auto; width: min(100%, 300px); border: 1px solid var(--rule); }
.co-qr-frame svg { width: 100%; height: auto; }
.co-qr figcaption { margin-top: 10px; font-size: .86rem; color: var(--muted); line-height: 1.45; }
.co-qr figcaption strong { color: var(--ink); }
.co-save { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 12px auto 0; font-weight: 600; font-size: .9rem; text-decoration: none; }

.co-steps { margin: 20px 0 0; padding: 16px 0 0 1.3rem; border-top: 1px solid var(--rule); font-size: .9rem; color: var(--ink-2); display: grid; gap: 8px; }
.co-steps li::marker { color: var(--signal); font-weight: 700; }

.co-live { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; padding: 11px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--rule); font-size: .9rem; font-weight: 600; color: var(--ink-2); }
.co-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--signal); animation: co-pulse 1.6s ease-in-out infinite; flex: none; }
@keyframes co-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.75); } }
@media (prefers-reduced-motion: reduce) { .co-pulse { animation: none; } .co-bar span { transition: none; } }

.co-state { text-align: center; padding: 30px 22px; }
.co-state h1 { font-size: 1.35rem; margin: 12px 0 8px; }
.co-state p { color: var(--ink-2); font-size: .93rem; }
.co-state .btn { margin-top: 8px; }
.co-mark { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.co-mark .icon { width: 30px; height: 30px; stroke-width: 2.2; }
.is-paid .co-mark { background: var(--credit-wash); color: var(--credit); }
.co-amount-sm { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink) !important; margin: 0 0 4px; }

.co-foot { margin-top: 14px; padding: 0 4px; font-size: .8rem; color: var(--muted); }
.co-foot dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.co-foot dt { font-size: .74rem; }
.co-foot dd { margin: 0; color: var(--ink-2); font-family: var(--mono); font-size: .8rem; word-break: break-all; }
.co-foot p { margin: 0; text-align: center; }

/* ================================================================== v13 additions for the XPD Pay PKR build */

/* Rail search (admin) */
.rail-search { padding: 4px 18px 6px; }
.rail-search input { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: #fff; min-height: 34px; font-size: .86rem; padding: 6px 10px; }
.rail-search input::placeholder { color: var(--rail-dim); }
.rail-search input:focus { border-color: var(--signal); background: rgba(255, 255, 255, .1); }
.rail-support { margin: 0 18px 14px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--radius-s); font-size: .82rem; color: var(--rail-dim); display: flex; align-items: center; gap: 8px; }
.rail-support a { color: #fff; text-decoration: none; font-weight: 600; }
.rail-support .icon { width: 16px; height: 16px; }

/* Status strip (health dots in a row, dashboard) */
.strip { display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 12px 18px; align-items: center; }
.strip .health small { color: var(--muted); }

/* Inline expandable payloads in tables */
details.inline > summary { cursor: pointer; color: var(--signal-ink); font-size: .82rem; font-weight: 600; list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline > summary::after { content: " ▸"; }
details.inline[open] > summary::after { content: " ▾"; }
details.inline pre.json { margin-top: 8px; max-width: 640px; }
.table td .badge + .cell-sub { margin-top: 3px; }
.table tr.is-muted td { color: var(--muted); }
.table .actions-cell { white-space: nowrap; text-align: right; }
.table .actions-cell form { display: inline-flex; gap: 6px; align-items: center; }
.table .actions-cell input { min-height: 30px; padding: 4px 8px; font-size: .82rem; width: 150px; }

/* Payout approval cards */
.approve { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--rule); align-items: start; }
.approve:last-child { border-bottom: 0; }
.approve .amt { font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; }
.approve .who { color: var(--muted); font-size: .86rem; }
.bene { display: inline-flex; gap: 8px; align-items: center; margin-top: 6px; padding: 6px 10px; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--rule); font-family: var(--mono); font-size: .9rem; }
.bene strong { font-family: var(--font); }
.approve .decide { display: grid; gap: 8px; min-width: 260px; }
.approve .decide form { display: flex; gap: 6px; }
.approve .decide input { min-height: 34px; padding: 6px 9px; font-size: .86rem; }
@media (max-width: 720px) { .approve { grid-template-columns: 1fr; } .approve .decide { min-width: 0; } }

/* Big payable amount on order pages */
.payable-big { font-size: 1.9rem; font-weight: 780; letter-spacing: -.03em; line-height: 1.1; }
.payable-big .paisa, .paisa-inline .paisa { display: inline-block; margin-left: .04em; padding: 0 .14em; border-radius: .14em; background: var(--signal); color: #fff; }

/* QR in portal (rendered client-side by qrcode-local.js) */
.qr-box [data-qr] svg, .qr-box svg { width: 100%; height: auto; }
.qr-box.small { width: 170px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.share-row input { flex: 1 1 260px; font-family: var(--mono); font-size: .82rem; }

/* Onboarding steps */
.steps { list-style: none; counter-reset: s; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: .9rem; color: var(--ink-2); }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--signal-wash); color: var(--signal-ink); font-weight: 700; display: grid; place-items: center; font-size: .82rem; }
.steps li strong { color: var(--ink); display: block; }

/* Reconciliation */
.recon-ok { color: var(--credit); font-weight: 600; }
.recon-bad { color: var(--debit); font-weight: 700; }

/* Signature tester */
.tester textarea { min-height: 180px; }
.tester output { display: block; font-family: var(--mono); font-size: .85rem; word-break: break-all; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-s); min-height: 40px; }
.tester output.is-big { font-size: 1.05rem; font-weight: 700; color: var(--signal-ink); }

/* Login extras */
.auth-card .lang { color: var(--muted); font-size: .9rem; margin: -2px 0 18px; }
.auth-side .support { color: var(--rail-ink); font-size: .9rem; display: inline-flex; gap: 8px; align-items: center; }
.auth-side .support a { color: #fff; font-weight: 600; text-decoration: none; }

/* Misc */
.kbd { font-family: var(--mono); font-size: .8rem; padding: 1px 6px; border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }
.dot-sep::before { content: "·"; margin: 0 6px; color: var(--faint); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list code { background: var(--surface-2); border: 1px solid var(--rule); padding: 2px 7px; border-radius: 5px; }
.warn-text { color: var(--hold); }
.danger-text { color: var(--debit); }
.success-text { color: var(--credit); }
.hidden { display: none !important; }
.w-auto { width: auto !important; }
.mw-480 { max-width: 480px; }
.mw-640 { max-width: 640px; }
.mt-8 { margin-top: 8px !important; }
.mt-14 { margin-top: 14px !important; }
.qr-print { text-align: center; }
.qr-print .qr-box { margin: 14px auto; width: 300px; }

@media print {
  .rail, .topbar, .actions, .filters, .pager, form, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}
.co-ur { margin: 12px 0 0; font-size: .95rem; color: var(--ink-2); line-height: 1.8; }
.figure dd.small-figure { font-size: 1.12rem; }
.table td.reason { min-width: 230px; }
.code pre.wrap { white-space: pre-wrap; word-break: break-all; padding-right: 84px; }
.table .actions-cell details.inline { display: inline-block; margin-left: 6px; }

/* ================================================================== v14 additions */

/* Theme / language switches in the rail */
.rail-prefs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 18px 12px; }
.seg { display: inline-flex; border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--radius-s); overflow: hidden; }
.seg a { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; padding: 4px 8px; color: var(--rail-dim); text-decoration: none; font-size: .78rem; font-weight: 600; }
.seg a + a { border-left: 1px solid rgba(255, 255, 255, .1); }
.seg a:hover { color: #fff; background: var(--rail-hover); }
.seg a.is-on { color: #fff; background: var(--signal); }
.seg .icon { width: 15px; height: 15px; }
.auth-prefs { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 18px; }
.auth-prefs .seg { border-color: var(--rule-strong); }
.auth-prefs .seg a { color: var(--muted); }
.auth-prefs .seg a + a { border-left-color: var(--rule); }
.auth-prefs .seg a:hover { background: var(--surface-2); color: var(--ink); }
.auth-prefs .seg a.is-on { color: #fff; background: var(--signal); }

/* Urdu and Chinese text (layout stays left-to-right; each Urdu paragraph runs right-to-left) */
html[lang="ur"] body { font-family: "Noto Naskh Arabic UI", "Noto Naskh Arabic", "Segoe UI", Tahoma, var(--font); }
html[lang="ur"] :is(p, h1, h2, h3, label, li, .help, .callout, .empty, .figure dt, .delta, .rail-link span, .cell-sub, th) { unicode-bidi: plaintext; }
html[lang="ur"] .content { line-height: 1.7; }
html[lang="zh"] body { font-family: system-ui, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", var(--font); }

/* Role chip, misc */
.role-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--info-wash); color: var(--info); }
.role-chip.is-owner { background: var(--signal-wash); color: var(--signal-ink); }
.kv-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; min-height: 32px; padding: 4px 8px; font-size: .85rem; }
.approvals { margin-top: 6px; font-size: .82rem; color: var(--hold); font-weight: 600; }
.approvals.is-two { color: var(--signal-ink); }
.big-code { font-family: var(--mono); font-size: .9rem; word-break: break-all; }
.result-box { border: 1px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; }
.result-box > div { padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.result-box > div:last-child { border-bottom: 0; }

/* Sandbox */
.sbx-banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius-s); background: repeating-linear-gradient(135deg, var(--hold-wash), var(--hold-wash) 12px, transparent 12px, transparent 24px); border: 1px dashed var(--hold); color: var(--hold); font-weight: 700; font-size: .9rem; }
.sbx-actions { display: flex; gap: 8px; margin-top: 12px; }
.sbx-actions form { flex: 1; }
.sbx-actions .btn { width: 100%; }
.co-test { margin: 0 0 12px; }

/* Checkout copy row */
.co-copyrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* Phone: compact top bar title, bottom tab bar, stacked tables */
.topbar .topbar-title { margin-left: auto; color: var(--rail-ink); font-size: .85rem; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar { display: none; }
@media (max-width: 960px) {
  .tabbar { display: flex; position: sticky; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--rule); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; border-radius: var(--radius-s); }
  .tabbar a.is-on { color: var(--signal-ink); background: var(--signal-wash); }
  .tabbar .icon { width: 20px; height: 20px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
}
@media (max-width: 640px) {
  .table.stack-sm thead { display: none; }
  .table.stack-sm, .table.stack-sm tbody, .table.stack-sm tr, .table.stack-sm td { display: block; width: 100%; }
  .table.stack-sm tr { padding: 10px 14px; border-bottom: 1px solid var(--rule); }
  .table.stack-sm tbody tr:last-child { border-bottom: 0; }
  .table.stack-sm td { border: 0; padding: 2px 0; text-align: left; }
  .table.stack-sm td.num { text-align: left; }
  .table.stack-sm td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 110px; color: var(--muted); font-size: .78rem; font-weight: 600; }
  .table.stack-sm td:first-child { font-size: .95rem; margin-bottom: 4px; }
  .filters { padding: 10px 12px; }
  .filters .field, .filters .grow { flex: 1 1 140px; min-width: 0; }
  .figure dd { font-size: 1.1rem; }
  .balance-line .big { font-size: 1.7rem; }
}
@media print { .tabbar, .rail-prefs { display: none !important; } }
.offline-logo { margin: 0 auto 8px; width: 72px; height: 72px; }

/* ------------------------------------------------------------------ v15: phones & small tablets */
/* Grid/flex children may shrink below their content (wide tables scroll or stack instead of
   widening the page, which made mobile browsers zoom the whole console out). */
.grid > *, .stack > *, .content > *, .panel, .panel-body, .panel-head > div, .main > * { min-width: 0; }
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { border-left: 0; border-top: 1px solid var(--rule); padding: 12px 14px; }
  .figure:nth-child(-n+2) { border-top: 0; }
  .figure:nth-child(2n) { border-left: 1px solid var(--rule); }
  .figure:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
svg.chart, .chart svg { max-width: 100%; height: auto; }
.content { overflow-wrap: break-word; }
@media (max-width: 960px) {
  .content { padding: 16px 12px 24px; }
  .panel-head { padding: 12px 14px; }
  .panel-body { padding: 14px; }
  .panel-foot { padding: 10px 14px; }
  .page-head h1 { font-size: 1.3rem; }
  .btn { min-height: 40px; }
  .btn-sm, .btn-xs { min-height: 32px; }
  input, select, textarea { font-size: 16px; } /* no iOS zoom on focus */
  .kv { grid-template-columns: minmax(0, 40%) minmax(0, 60%); }
  .kv dd { overflow-wrap: anywhere; }
  pre, .code pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .callout { padding: 10px 12px; }
  .topbar { min-height: 52px; }
  .topbar .topbar-title { color: #fff; opacity: .85; }
}
@media (max-width: 640px) {
  /* app.js labels every cell from the table head and adds .stack-sm, so each row becomes a card. */
  .table.stack-sm td { display: block; text-align: right; overflow-wrap: anywhere; }
  .table.stack-sm td::after { content: ""; display: table; clear: both; }
  .table.stack-sm td[data-label]::before { float: left; min-width: 0; max-width: 45%; margin-right: 10px; text-align: left; line-height: 1.9; }
  .table.stack-sm td .badge { vertical-align: middle; }
  .table.stack-sm td.num, .table.stack-sm td.sub, .table.stack-sm td.mono { text-align: right; }
  .table.stack-sm td[data-label]::before { font-family: var(--font); letter-spacing: 0; }
  .table.stack-sm td:first-child { text-align: left; }
  .table.stack-sm td:first-child::before { display: none; }
  .table.stack-sm td[data-label=""]::before, .table.stack-sm td[colspan]::before { display: none; }
  .table.stack-sm td[colspan] { display: block; }
  .table.stack-sm td:empty { display: none; }
  .table.stack-sm tr { padding: 12px 14px; }
  .table.stack-sm .cell-sub { display: block; }
  .table.stack-sm td .inline-form, .table.stack-sm td form { flex-wrap: wrap; justify-content: flex-end; text-align: left; }
  .table.stack-sm td .actions { justify-content: flex-end; }
  .table.stack-sm td details { width: 100%; }
  .table.stack-sm tr.is-muted { opacity: .7; }
  .page-head { gap: 10px; }
  .filters .actions { width: 100%; }
}
/* Admin console gets the same bottom tab bar as the merchant portal on phones. */
.tabbar .count { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--signal); color: #fff; font-size: .62rem; line-height: 16px; text-align: center; }
.tabbar .count.is-warn { background: #d18a00; }
.tabbar a { position: relative; }

.checks-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 18px; margin-bottom: 14px; }
