/* Manage Solutions Accounting
   Layout concept: a ledger workbench. Dark slate rail on the left, paper-toned work area,
   white sheets for lists and forms, and a dark light-table stage where the bill photo sits. */
:root {
  --paper: #f2f4f3;
  --sheet: #ffffff;
  --sheet-2: #f7f9f8;
  --ink: #15211c;
  --ink-2: #4d5c55;
  --ink-3: #7b8983;
  --rule: #dde4e0;
  --rule-2: #c9d3ce;
  --rail: #16242b;
  --rail-2: #1e3039;
  --rail-3: #28434f;
  --rail-ink: #b9c8cd;
  --rail-ink-strong: #f4f8f8;
  --accent: #1e7a57;
  --accent-hover: #186649;
  --accent-soft: #e3f1ea;
  --accent-ink: #ffffff;
  --review: #9a5b0b;
  --review-soft: #fbefd9;
  --posted: #2d5592;
  --posted-soft: #e5ecf7;
  --danger: #b42318;
  --danger-soft: #fce8e6;
  --margin: #e3a39b;
  --stage: #1b272d;
  --stage-2: #26353c;
  --stage-ink: #c7d2d6;
  --focus: #2f74d0;
  --stamp: #2bb57d;
  --on-strong: #ffffff;
  --shadow-1: 0 1px 2px rgba(21, 33, 28, 0.06);
  --shadow-2: 0 10px 30px rgba(21, 33, 28, 0.16);
  --backdrop: rgba(14, 22, 25, 0.42);

  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "IBM Plex Sans Condensed", "IBM Plex Sans", "Arial Narrow", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --t-xs: 11.5px;
  --t-sm: 12.5px;
  --t-md: 14px;
  --t-lg: 16px;
  --t-xl: 20px;
  --t-2xl: 26px;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --rail-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1517; --sheet: #141e21; --sheet-2: #19252a; --ink: #e3ebe7; --ink-2: #a7b6b0; --ink-3: #7d8c87;
    --rule: #243338; --rule-2: #31444b; --rail: #0a1113; --rail-2: #121d21; --rail-3: #1d323a; --rail-ink: #a9b9be; --rail-ink-strong: #f1f6f6;
    --accent: #3baa7b; --accent-hover: #4cbb8b; --accent-soft: #15372a; --accent-ink: #04130d;
    --review: #e2a84f; --review-soft: #3a2a12; --posted: #8eb1e8; --posted-soft: #1b2b45; --danger: #f2796e; --danger-soft: #3e1a16;
    --margin: #6e3a35; --stage: #090f11; --stage-2: #152024; --stage-ink: #b9c4c8; --focus: #6fa8f5; --on-strong: #10181b;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.55); --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1517; --sheet: #141e21; --sheet-2: #19252a; --ink: #e3ebe7; --ink-2: #a7b6b0; --ink-3: #7d8c87;
  --rule: #243338; --rule-2: #31444b; --rail: #0a1113; --rail-2: #121d21; --rail-3: #1d323a; --rail-ink: #a9b9be; --rail-ink-strong: #f1f6f6;
  --accent: #3baa7b; --accent-hover: #4cbb8b; --accent-soft: #15372a; --accent-ink: #04130d;
  --review: #e2a84f; --review-soft: #3a2a12; --posted: #8eb1e8; --posted-soft: #1b2b45; --danger: #f2796e; --danger-soft: #3e1a16;
  --margin: #6e3a35; --stage: #090f11; --stage-2: #152024; --stage-ink: #b9c4c8; --focus: #6fa8f5; --on-strong: #10181b;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-2: 0 12px 34px rgba(0, 0, 0, 0.55); --backdrop: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- base ---------- */
html, body, #app { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--t-md)/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; letter-spacing: 0.005em; }
h1 { font-size: var(--t-2xl); line-height: 1.15; }
h2 { font-size: var(--t-xl); line-height: 1.2; }
h3 { font-size: var(--t-lg); line-height: 1.25; }
p { margin: 0; }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.label {
  font: 600 var(--t-xs)/1.2 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg.ic.sm { width: 15px; height: 15px; }
svg.ic.lg { width: 24px; height: 24px; }

/* ---------- app frame ---------- */
.msa-frame { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); height: 100%; min-height: 0; }
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}
.rail-brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 16px; }
.rail-brand .mark { width: 34px; height: 34px; border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; overflow: hidden; }
.rail-brand .mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.rail-brand.stacked { flex-direction: column; align-items: stretch; gap: 10px; }
.rail-brand .mark.logo { width: 100%; height: 56px; padding: 6px 10px; background: #fff; border-radius: var(--r-md); }
.rail-brand .mark.logo img { width: auto; max-width: 100%; height: 100%; margin: 0 auto; display: block; }
.rail-brand .who { min-width: 0; }
.rail-brand .who b { display: block; color: var(--rail-ink-strong); font: 600 var(--t-md)/1.2 var(--font-display); letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-brand .who span { font: 500 var(--t-xs)/1.3 var(--font-mono); color: var(--rail-ink); opacity: 0.85; }
.rail-group { padding: 10px 10px 4px; display: grid; gap: 2px; }
.rail-group > .label { color: var(--rail-ink); opacity: 0.6; padding: 6px 8px 6px; }
.rail-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--rail-ink); cursor: pointer; text-align: left;
  font: 500 var(--t-md)/1.2 var(--font-body);
}
.rail-item:hover { background: var(--rail-2); color: var(--rail-ink-strong); }
.rail-item[aria-current="page"] { background: var(--rail-3); color: var(--rail-ink-strong); }
.rail-item .badge { margin-left: auto; }
.rail-scrim { display: none; }
.rail-foot { margin-top: auto; padding: 12px 10px 16px; display: grid; gap: 2px; border-top: 1px solid var(--rail-2); }
.badge {
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center;
  font: 600 11.5px/1 var(--font-mono); font-variant-numeric: tabular-nums;
  background: var(--review); color: var(--on-strong);
}
.badge.zero { background: transparent; color: inherit; opacity: 0.5; }
.badge.green { background: var(--accent); color: var(--accent-ink); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  border-bottom: 1px solid var(--rule); background: var(--sheet); min-height: 60px;
}
.topbar .title { min-width: 0; }
.topbar .title h1 { font-size: var(--t-xl); }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { flex: 1; overflow: auto; padding: 24px; min-height: 0; }
.content.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.page { display: grid; gap: 20px; max-width: 1280px; }
.page-head { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-head p { margin-top: 4px; color: var(--ink-2); max-width: 70ch; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: var(--r-md);
  border: 1px solid var(--rule-2); background: var(--sheet); color: var(--ink);
  font: 500 13.5px/1 var(--font-body); cursor: pointer; white-space: nowrap; text-decoration: none; vertical-align: middle;
}
.btn:hover { background: var(--sheet-2); border-color: var(--ink-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.approve { height: 42px; padding: 0 20px; font-size: 15px; font-weight: 600; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.approve:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.big { height: 42px; padding: 0 18px; font-size: 15px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sheet-2); border-color: var(--rule); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.solid-danger { background: var(--danger); border-color: var(--danger); color: var(--on-strong); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--rule-2); border-radius: var(--r-sm);
  background: var(--sheet); color: var(--ink);
}
.textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.input.mono { font-family: var(--font-mono); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > .label { color: var(--ink-2); }
.field .hint { font-size: var(--t-sm); color: var(--ink-3); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; min-width: 0; }
.search { position: relative; width: min(360px, 100%); }
.search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 34px; background: var(--sheet-2); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 22px; border-radius: 11px; background: var(--rule-2); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: var(--r-md); overflow: hidden; background: var(--sheet); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 32px; cursor: pointer; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.seg button + button { border-left: 1px solid var(--rule-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; padding: 10px 12px 9px; cursor: pointer;
  color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; gap: 8px; align-items: center;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- status marks ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 11px; font: 600 12px/1 var(--font-body); white-space: nowrap;
  background: var(--sheet-2); color: var(--ink-2); border: 1px solid var(--rule);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.review { background: var(--review-soft); color: var(--review); border-color: transparent; }
.pill.approved, .pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.posted { background: var(--posted-soft); color: var(--posted); border-color: transparent; }
.pill.danger, .pill.off { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.code {
  display: inline-block; font: 500 12.5px/1.2 var(--font-mono); letter-spacing: 0.02em;
  padding: 3px 6px; border-radius: var(--r-sm); border: 1px solid var(--rule-2);
  background: var(--sheet-2); color: var(--ink); white-space: nowrap;
}
.code.strong { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- sheets & tables ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-lg); min-width: 0; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.sheet-head .grow { flex: 1; min-width: 160px; }
.sheet-body { padding: 16px; }
.table-wrap { overflow-x: auto; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-md); }
.tbl th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  font: 600 var(--t-xs)/1.2 var(--font-display); text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); background: var(--sheet-2); padding: 10px 12px; border-bottom: 1px solid var(--rule);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--sheet-2); }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.selected td { background: var(--accent-soft); }
.tbl .num, .tbl th.num { text-align: right; }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .actions .btn + .btn { margin-left: 4px; }
.tbl input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.cell-main { font-weight: 500; }
.cell-sub { font-size: var(--t-sm); color: var(--ink-3); }
.tbl tfoot td { font-weight: 600; background: var(--sheet-2); border-top: 1px solid var(--rule-2); }

.empty { padding: 48px 20px; text-align: center; display: grid; justify-items: center; gap: 8px; color: var(--ink-2); }
.empty .ic { width: 36px; height: 36px; color: var(--ink-3); stroke-width: 1.5; }
.empty h3 { color: var(--ink); }
.empty p { max-width: 46ch; }

.meter { display: grid; gap: 6px; min-width: 200px; }
.meter .bar { height: 8px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.meter .bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter.full .bar span { background: var(--review); }
.meter .line { display: flex; justify-content: space-between; font-size: var(--t-sm); color: var(--ink-2); gap: 12px; }

.callout { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--sheet-2); border: 1px solid var(--rule); color: var(--ink-2); font-size: var(--t-sm); }
.callout .ic { margin-top: 1px; }
.callout.warn { background: var(--review-soft); border-color: transparent; color: var(--review); }
.callout.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.callout.good { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.callout b { color: inherit; }
.stat-row { display: flex; gap: 28px; flex-wrap: wrap; }
.stat b { display: block; font: 600 var(--t-xl)/1.1 var(--font-mono); font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--t-sm); color: var(--ink-3); }

/* ---------- overlays ---------- */
.backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 50; display: flex; animation: fade-in 0.12s ease-out; }
.modal {
  margin: auto; width: min(560px, calc(100% - 32px)); max-height: calc(100% - 48px); overflow: auto;
  background: var(--sheet); border-radius: var(--r-lg); box-shadow: var(--shadow-2); border: 1px solid var(--rule);
  display: flex; flex-direction: column;
}
.modal.wide { width: min(1100px, calc(100% - 32px)); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal-head h2 { flex: 1; font-size: var(--t-xl); }
.modal-body { padding: 4px 20px 16px; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-content: start; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.drawer {
  margin-left: auto; width: min(480px, 100%); height: 100%; background: var(--sheet);
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; animation: slide-in 0.16s ease-out;
}
.drawer .modal-body { flex: 1; overflow: auto; padding-top: 8px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0.6; } }

.toast-stack { position: fixed; right: 16px; top: calc(68px + env(safe-area-inset-top, 0px)); z-index: 80; display: grid; gap: 8px; width: min(380px, calc(100% - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--r-md);
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-2); font-size: var(--t-md);
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger); color: var(--on-strong); }
.toast.good .ic { color: var(--accent-soft); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- sign in ---------- */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 32px 16px;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, color-mix(in srgb, var(--rule) 70%, transparent) 31px 32px),
    var(--paper);
}
.auth-card { width: min(420px, 100%); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden; }
.auth-card .top { padding: 22px 24px 16px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--rule); }
.auth-card .top .mark { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.auth-card .top b { display: block; font: 600 var(--t-lg)/1.2 var(--font-display); }
.auth-card .top span { font-size: var(--t-sm); color: var(--ink-3); }
.auth-card form { padding: 20px 24px 24px; display: grid; gap: 14px; }
.auth-card .error { color: var(--danger); font-size: var(--t-sm); min-height: 1em; }
.auth-card .demo-hint { font-size: var(--t-sm); color: var(--ink-3); padding: 10px 12px; background: var(--sheet-2); border-radius: var(--r-md); }

/* ---------- Bills Review ---------- */
.review-screen { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.review-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--rule); background: var(--sheet);
}
.review-bar .client-pick { width: min(340px, 100%); }
.review-bar .pos { font: 500 var(--t-sm)/1 var(--font-mono); color: var(--ink-2); padding: 0 4px; white-space: nowrap; }
.review-bar .spacer { flex: 1; }
.review-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(330px, 420px) minmax(0, 1fr); }
.review-body.no-queue { grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); }
.review-body.no-queue .queue { display: none; }
.queue { border-right: 1px solid var(--rule); background: var(--sheet-2); overflow-y: auto; min-height: 0; }
.queue-head { position: sticky; top: 0; background: var(--sheet-2); padding: 12px 14px 8px; display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--rule); z-index: 1; }
.queue-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left;
  padding: 10px 14px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; cursor: pointer; color: var(--ink);
}
.queue-item:hover { background: var(--sheet); }
.queue-item[aria-current="true"] { background: var(--sheet); box-shadow: inset 3px 0 0 var(--accent); }
.queue-item .v { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-item .t { font: 500 var(--t-md)/1.3 var(--font-mono); font-variant-numeric: tabular-nums; }
.queue-item .s { font-size: var(--t-sm); color: var(--ink-3); display: flex; gap: 6px; align-items: center; overflow: hidden; white-space: nowrap; min-width: 0; }
.queue-item .s > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.queue-item .flags { display: flex; gap: 4px; justify-content: flex-end; align-items: center; font-size: var(--t-sm); color: var(--ink-3); white-space: nowrap; }
.queue-item .flags .ic { color: var(--review); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); display: inline-block; flex: none; }
.dot.done { background: var(--accent); }
.dot.pending, .dot.processing { background: var(--review); animation: pulse 1.2s ease-in-out infinite; }
.dot.failed { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.35; } }

.bill-panel { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--rule); background: var(--sheet); }
.bill-scroll { flex: 1; overflow-y: auto; padding: 16px 18px 12px; display: grid; gap: 14px; align-content: start; }
.bill-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.bill-head .grow { flex: 1; min-width: 0; }
.bill-head .client-name { font: 600 var(--t-lg)/1.25 var(--font-display); }
.bill-meta { font-size: var(--t-sm); color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; }
.ai-line { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); color: var(--ink-2); }
.ai-line .ic { color: var(--accent); }

/* the ledger card: labels left of a red margin rule, values right, ruled rows */
.ledger { border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; background: var(--sheet); }
.ledger-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: stretch; border-bottom: 1px solid var(--rule); min-height: 42px; }
.ledger-row:last-of-type { border-bottom: 0; }
.ledger-row > label {
  display: flex; align-items: center; padding: 0 12px;
  font: 600 var(--t-xs)/1.2 var(--font-display); text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3);
  border-right: 2px solid var(--margin); background: var(--sheet-2);
}
.ledger-row .cell { display: flex; align-items: center; padding: 4px 6px; min-width: 0; gap: 6px; }
.ledger-row .cell .input, .ledger-row .cell .select, .ledger-row .cell .textarea { border-color: transparent; background: transparent; height: 34px; padding: 0 6px; }
.ledger-row .cell .textarea { min-height: 34px; height: 34px; padding: 7px 6px; resize: none; }
.ledger-row.money .input { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 15px; }
.ledger-row.total .input { font-weight: 600; font-size: 17px; }
.ledger-row.total > label { color: var(--ink); }
.ledger.editing .ledger-row .cell .input, .ledger.editing .ledger-row .cell .select, .ledger.editing .ledger-row .cell .textarea { border-color: var(--rule-2); background: var(--sheet); }
.ledger.editing .ledger-row .cell .textarea { height: 64px; resize: vertical; }
.ledger-row.missing > label { color: var(--review); }
.ledger-row.missing .cell { background: color-mix(in srgb, var(--review-soft) 60%, transparent); }
.ledger .input[readonly], .ledger .textarea[readonly] { cursor: default; }
.ledger:not(.editing) .input::placeholder, .ledger:not(.editing) .textarea::placeholder { color: transparent; }
.ledger .input[readonly]:focus, .ledger .textarea[readonly]:focus { outline: none; }
.ledger .select:disabled { opacity: 1; appearance: none; -webkit-appearance: none; cursor: default; }

.bill-actions { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--rule); background: var(--sheet); flex-wrap: wrap; }
.bill-actions .spacer { flex: 1; }
.kbd { font: 500 11px/1 var(--font-mono); padding: 2px 5px; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 4px; color: var(--ink-3); }

.stage { position: relative; background: var(--stage); min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.stage-tools { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3; display: flex; gap: 2px; padding: 4px; border-radius: 8px; background: color-mix(in srgb, var(--stage-2) 92%, transparent); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); }
.stage-tools button { width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--stage-ink); display: grid; place-items: center; cursor: pointer; }
.stage-tools button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.stage-tools .zoom { font: 500 12px/32px var(--font-mono); color: var(--stage-ink); min-width: 48px; text-align: center; }
.stage-view {
  flex: 1; position: relative; overflow: hidden; cursor: grab; touch-action: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0);
  background-size: 22px 22px;
}
.stage-view.dragging { cursor: grabbing; }
.stage-view img { position: absolute; left: 50%; top: 50%; transform-origin: center center; max-width: none; user-select: none; -webkit-user-drag: none; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); background: #fff; }
.stage-view iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--stage-ink); text-align: center; padding: 20px; }
.stamp {
  position: absolute; left: 50%; top: 42%; z-index: 4; pointer-events: none;
  font: 700 46px/1 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--stamp); border: 5px solid var(--stamp); border-radius: 10px; padding: 10px 22px;
  background: rgba(10, 30, 22, 0.25);
  transform: translate(-50%, -50%) rotate(-12deg) scale(1);
  animation: stamp 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
}
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(1.9); }
  25% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(0.96); }
  35% { transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

/* ---------- Clients Order ---------- */
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.pick-list { display: grid; }
.pick-list button {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 2px 10px; text-align: left; padding: 11px 14px;
  border: 0; border-bottom: 1px solid var(--rule); background: transparent; cursor: pointer; color: var(--ink);
}
.pick-list .sub { grid-column: 1 / -1; }
.pick-list button:last-child { border-bottom: 0; }
.pick-list button:hover { background: var(--sheet-2); }
.pick-list button[aria-current="true"] { background: var(--accent-soft); }
.pick-list .sub { font-size: var(--t-sm); color: var(--ink-3); }
.order-list { display: grid; gap: 6px; }
.order-item {
  display: grid; grid-template-columns: 24px 26px 22px 1fr auto; align-items: center; gap: 8px;
  padding: 7px 10px; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--sheet);
}
.order-item.off { background: var(--sheet-2); color: var(--ink-3); border-style: dashed; }
.order-item.dragging { opacity: 0.45; }
.order-item.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.order-item .grip { cursor: grab; color: var(--ink-3); display: grid; place-items: center; }
.order-item .pos { font: 600 var(--t-sm)/1 var(--font-mono); color: var(--accent); text-align: center; }
.order-item.off .pos { color: var(--ink-3); }
.order-item input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.order-item .name { font-weight: 500; }
.order-item .name small { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.columns-preview { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule-2); border-radius: var(--r-sm); overflow: hidden; width: fit-content; max-width: 100%; }
.columns-preview span { padding: 6px 10px; font: 600 var(--t-xs)/1.2 var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; background: var(--accent-soft); color: var(--accent); border-right: 1px solid var(--rule-2); white-space: nowrap; }
.columns-preview span:last-child { border-right: 0; }
.columns-preview span b { font-family: var(--font-mono); margin-right: 6px; opacity: 0.7; }

/* ---------- logo & backup ---------- */
.logo-box { width: 220px; height: 140px; border: 1px dashed var(--rule-2); border-radius: var(--r-md); display: grid; place-items: center; background: var(--sheet-2); overflow: hidden; }
.logo-box img { max-width: 90%; max-height: 90%; object-fit: contain; }
.drop-zone { border: 1.5px dashed var(--rule-2); border-radius: var(--r-md); padding: 20px; text-align: center; color: var(--ink-2); display: grid; gap: 8px; justify-items: center; cursor: pointer; }
.drop-zone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tree { font: 400 var(--t-sm)/1.7 var(--font-mono); color: var(--ink-2); background: var(--sheet-2); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; white-space: pre; }
.tree b { color: var(--ink); font-weight: 600; }
.tree i { font-style: normal; color: var(--accent); }
.progress { height: 10px; border-radius: 5px; background: var(--rule); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }

/* ---------- excel preview (demo) ---------- */
.xl { border: 1px solid var(--rule-2); border-radius: var(--r-sm); overflow: auto; max-height: 360px; }
.xl table { border-collapse: collapse; font-size: var(--t-sm); min-width: 100%; }
.xl th, .xl td { border: 1px solid var(--rule); padding: 5px 8px; white-space: nowrap; }
.xl th { background: var(--accent-soft); color: var(--ink); font-weight: 600; text-align: left; }
.xl td.n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.xl .rn { background: var(--sheet-2); color: var(--ink-3); text-align: center; font-family: var(--font-mono); }

/* ---------- approved bills footer ---------- */
.action-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--sheet); border-top: 1px solid var(--rule); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.action-bar .grow { flex: 1; min-width: 180px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .select, .toolbar .input { width: auto; min-width: 150px; }

/* viewer modal: data left, image right */
.viewer { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); min-height: 440px; border-top: 1px solid var(--rule); }
.viewer .bill-scroll { border-right: 1px solid var(--rule); }
.viewer .stage { min-height: 440px; }

/* ---------- phone app ---------- */
.phone { min-height: 100%; display: flex; flex-direction: column; background: var(--paper); }
.phone-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--rail); color: var(--rail-ink-strong); }
.phone-head .mark { width: 40px; height: 40px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; overflow: hidden; flex: none; }
.phone-head .mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.phone-head .mark.logo { width: auto; min-width: 44px; max-width: 132px; padding: 4px 8px; background: #fff; }
.phone-head .mark.logo img { width: auto; max-width: 116px; height: 32px; }
.phone-head b { display: block; font: 600 var(--t-lg)/1.2 var(--font-display); }
.phone-head span { font-size: var(--t-sm); color: var(--rail-ink); }
.phone-body { flex: 1; padding: 18px; display: grid; gap: 16px; align-content: start; }
.phone-card { background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; padding: 18px; display: grid; gap: 12px; }
.phone-card h2 { font-size: var(--t-xl); }
.shoot {
  display: grid; justify-items: center; gap: 8px; width: 100%; padding: 24px 16px; border-radius: 14px;
  border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; font: 600 18px/1.2 var(--font-display); letter-spacing: 0.01em;
}
.shoot:hover { background: var(--accent-hover); }
.shoot .ic { width: 40px; height: 40px; stroke-width: 1.6; }
.shoot-alt { width: 100%; }
.uploads { display: grid; gap: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; }
.upload-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.upload-row:last-child { border-bottom: 0; }
.upload-row .thumb { width: 46px; height: 46px; border-radius: 6px; background: var(--sheet-2); border: 1px solid var(--rule); overflow: hidden; display: grid; place-items: center; color: var(--ink-3); }
.upload-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-row .meta { min-width: 0; }
.upload-row .meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .meta span { font-size: var(--t-sm); color: var(--ink-3); }
.upload-row .progress { margin-top: 6px; height: 6px; }
.device-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--rule); background: var(--sheet);
}
.device-bar .label { color: var(--ink-3); }
.device-bar .device-code { font: 600 20px/1 var(--font-mono); letter-spacing: 0.08em; color: var(--ink); }
.big-code { font: 600 30px/1 var(--font-mono); letter-spacing: 0.1em; text-align: center; padding: 14px; border-radius: 10px; background: var(--sheet-2); border: 1px dashed var(--rule-2); }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .review-body { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .review-body .queue { display: none; }
  .review-body.show-queue { grid-template-columns: 240px minmax(300px, 360px) minmax(0, 1fr); }
  .review-body.show-queue .queue { display: block; }
}
@media (max-width: 900px) {
  .msa-frame { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: 60; transform: translateX(-100%); transition: transform 0.18s ease-out; }
  .msa-frame.rail-open .rail { transform: none; box-shadow: var(--shadow-2); }
  .msa-frame.rail-open .rail-scrim { display: block; position: fixed; inset: 0; background: var(--backdrop); z-index: 55; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar .search { display: none; }
  .content { padding: 16px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .viewer { grid-template-columns: minmax(0, 1fr); }
  .viewer .stage { min-height: 360px; }
  .review-screen { height: auto; }
  .content.flush { overflow: auto; }
  .review-body, .review-body.show-queue, .review-body.no-queue { display: flex; flex-direction: column; }
  .review-body .queue { display: none; }
  .review-body.show-queue .queue { display: block; max-height: 260px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .review-body { flex: none; }
  .review-body > .queue, .review-body > .bill-panel, .review-body > .stage { flex: none; }
  .bill-panel { border-right: 0; min-height: auto; }
  .bill-scroll { flex: none; overflow: visible; }
  .bill-actions { position: sticky; bottom: 0; z-index: 2; box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.06); }
  .review-body .stage { height: 72vh; min-height: 420px; }
}
@media (max-width: 520px) {
  .ledger-row { grid-template-columns: 104px minmax(0, 1fr); }
  .stamp { font-size: 32px; }
  h1 { font-size: var(--t-xl); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
