:root {
  --bg: #f3f3ef;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --ink: #111110;
  --ink-2: #4b4b47;
  --muted: #8b8b85;
  --line: #e5e5df;
  --line-strong: #cdcdc6;
  --red: #d71921;
  --red-soft: #fbeaea;
  --green: #17734a;
  --green-soft: #e4f2ea;
  --amber: #9a6200;
  --amber-soft: #fbf0d9;
  --blue: #2752c9;
  --blue-soft: #e7edfb;
  --sheet-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 18px 40px -18px rgba(0, 0, 0, 0.22);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.03), 0 10px 30px -16px rgba(0, 0, 0, 0.16);
  --radius-s: 9px;
  --radius: 14px;
  --radius-l: 22px;
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  --dot: 'Doto', 'Space Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 140ms;
  --rail: 236px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0a0a0a; --surface: #141414; --surface-2: #1a1a1a; --ink: #f1f1ed; --ink-2: #b8b8b2;
    --muted: #7b7b76; --line: #252525; --line-strong: #363636; --red-soft: #2b1112; --green: #4cc38a;
    --green-soft: #0f2419; --amber: #e3a234; --amber-soft: #2a1f0b; --blue: #7d9cf0; --blue-soft: #141c33;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 10px 30px -16px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0a0a0a; --surface: #141414; --surface-2: #1a1a1a; --ink: #f1f1ed; --ink-2: #b8b8b2;
  --muted: #7b7b76; --line: #252525; --line-strong: #363636; --red-soft: #2b1112; --green: #4cc38a;
  --green-soft: #0f2419; --amber: #e3a234; --amber-soft: #2a1f0b; --blue: #7d9cf0; --blue-soft: #141c33;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 10px 30px -16px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); }
.dotf { font-family: var(--dot); font-weight: 900; }
.muted { color: var(--muted); }
.label {
  font: 400 11px/1.3 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.led { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
.led--pulse { animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; text-decoration: none; }
.brand-name { font: 900 24px/1 var(--dot); letter-spacing: 0.02em; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background var(--fast), color var(--fast);
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-link.active { background: var(--ink); color: var(--bg); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.share-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 999px;
  border: 1px solid var(--line); font: 11px var(--mono); letter-spacing: 0.06em; text-decoration: none; color: var(--ink-2);
}
.share-pill .led { background: var(--line-strong); }
.share-pill.on .led { background: var(--green); }
.rail-actions { display: flex; gap: 6px; }

.main { min-width: 0; padding: 28px clamp(16px, 3.4vw, 48px) 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { margin: 6px 0 0; font-size: clamp(28px, 3vw, 38px); font-weight: 600; letter-spacing: -0.025em; line-height: 1.05; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabbar { display: none; }
.topbar { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 500; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform var(--fast) var(--ease), background var(--fast), border-color var(--fast);
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--red)); }
.btn--red { background: var(--red); border-color: var(--red); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface); border-color: var(--line); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--icon { width: 40px; padding: 0; }
.btn--sm.btn--icon { width: 32px; }
.btn--danger:hover { border-color: var(--red); color: var(--red); }
.btn--block { width: 100%; }

/* ---------- cards & panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.card-pad { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.hero-kpi {
  grid-column: span 7; position: relative; overflow: hidden;
  padding: 26px 28px; display: flex; flex-direction: column; justify-content: space-between; min-height: 250px;
  background: var(--ink); color: var(--bg); border: 0;
}
.hero-kpi::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(color-mix(in srgb, var(--bg) 16%, transparent) 1px, transparent 1.4px);
  background-size: 12px 12px; mask-image: linear-gradient(115deg, transparent 40%, #000);
}
.hero-kpi .label { color: color-mix(in srgb, var(--bg) 60%, transparent); }
.hero-value { font: 900 clamp(44px, 6vw, 76px)/0.95 var(--dot); letter-spacing: 0.01em; margin: 18px 0 8px; position: relative; z-index: 1; word-break: break-all; }
.hero-sub { display: flex; gap: 18px; flex-wrap: wrap; position: relative; z-index: 1; font-size: 14px; }
.hero-sub b { font-weight: 600; }
.kpi-stack { grid-column: span 5; display: grid; grid-template-rows: 1fr 1fr; gap: 16px; }
.kpi { padding: 20px 22px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; }
.kpi-value { font: 900 34px/1 var(--dot); }
.kpi--red .kpi-value { color: var(--red); }
.kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { grid-column: span 7; }
.chart { padding: 18px 22px 22px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font: 10px var(--mono); fill: var(--muted); letter-spacing: 0.08em; }
.quick-card { grid-column: span 5; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick {
  display: flex; flex-direction: column; gap: 22px; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); text-decoration: none;
  transition: border-color var(--fast), transform var(--fast) var(--ease);
}
.quick:hover { border-color: var(--ink); transform: translateY(-2px); }
.quick b { font-weight: 600; }
.quick .label { font-size: 10px; }
.attention-card { grid-column: span 7; }
.activity-card { grid-column: span 5; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 13px 22px; border-bottom: 1px solid var(--line); text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-row .t { font-weight: 500; }
.list-row .s { font-size: 13px; color: var(--muted); }
@media (max-width: 560px) {
  .attention-card .list-row { grid-template-columns: 1fr; gap: 10px; }
  .attention-card .list-row > .row { justify-content: space-between; }
}
.empty { padding: 36px 22px; text-align: center; color: var(--muted); }
.empty .dotf { display: block; font-size: 28px; color: var(--ink); margin-bottom: 6px; }
.feed-row { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 11px 22px; font-size: 14px; }
.feed-row .led { margin-top: 7px; background: var(--line-strong); }
.feed-row.k-viewed .led, .feed-row.k-claimed .led { background: var(--blue); }
.feed-row.k-payment .led, .feed-row.k-paid .led, .feed-row.k-accepted .led { background: var(--green); }
.feed-row.k-error .led { background: var(--red); }
.feed-row time { display: block; font: 11px var(--mono); color: var(--muted); }

/* ---------- status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  font: 500 12px/1 var(--font); white-space: nowrap; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill--sent, .pill--viewed { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.pill--claimed { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill--partial { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill--paid, .pill--accepted { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill--overdue, .pill--declined { background: var(--red-soft); color: var(--red); border-color: transparent; }
.pill--void { text-decoration: line-through; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg button, .seg a {
  border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--ink-2); white-space: nowrap; text-decoration: none;
}
.seg .on { background: var(--ink); color: var(--bg); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px dashed var(--line-strong); background: none; border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2);
}
.chip.on { border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--surface); }
.search {
  flex: 1; min-width: 180px; height: 40px; padding: 0 14px 0 38px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b8b85' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m14 14-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center;
}
.search:focus { outline: none; border-color: var(--ink); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font: 400 10.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; transition: background var(--fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table .num { font-family: var(--mono); font-size: 13.5px; white-space: nowrap; }
.table .strong { font-weight: 600; }
.table .sub { font-size: 12.5px; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); transition: border-color var(--fast), box-shadow var(--fast);
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); }
.input.mono { font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); margin-top: 2px; flex: none; }

.section { padding: 22px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 13px; font-weight: 600; }
.section-title .idx { font: 11px var(--mono); color: var(--red); }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 600px) minmax(0, 1fr); gap: 24px; align-items: start; }
.editor-preview { position: sticky; top: 20px; }
.preview-frame {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 22px;
  max-height: calc(100dvh - 40px); overflow: auto;
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1.2px); background-size: 14px 14px;
}
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-fit { position: relative; margin: 0 auto; }
.sheet-fit > .nd { position: absolute; top: 0; left: 0; transform-origin: 0 0; box-shadow: var(--sheet-shadow); border-radius: 2px; }

.formats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.format-opt { position: relative; cursor: pointer; display: flex; }
.format-opt input { position: absolute; opacity: 0; }
.format-opt .box {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 6px 10px; border-radius: var(--radius-s);
  border: 1px solid var(--line); text-align: center; font-size: 12px; font-weight: 500; transition: border-color var(--fast), background var(--fast);
}
.format-opt .paper { background: var(--surface-2); border: 1.5px solid var(--line-strong); border-radius: 2px; }
.format-opt input:checked + .box { border-color: var(--ink); background: var(--surface-2); }
.format-opt input:checked + .box .paper { border-color: var(--ink); background: var(--surface); }
.format-opt input:focus-visible + .box { outline: 2px solid var(--ink); outline-offset: 2px; }
.format-opt .hint { font: 9.5px var(--mono); color: var(--muted); letter-spacing: 0.04em; }

.lines { display: flex; flex-direction: column; gap: 10px; }
.line {
  display: grid; grid-template-columns: 22px 1fr 70px 110px 64px 30px; gap: 8px; align-items: start;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.line .idx { font: 11px var(--mono); color: var(--red); padding-top: 12px; }
.line .wide { display: flex; flex-direction: column; gap: 6px; }
.line .input { height: 38px; background: var(--surface); min-width: 0; width: 100%; }
.line .desc { height: 34px; font-size: 13px; color: var(--ink-2); }
.line .amount { grid-column: 2 / -1; display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.line .amount b { font: 13px var(--mono); color: var(--ink); }
.line .rm { margin-top: 3px; }
.line .cell { display: contents; }
.line .ml { display: none; }
.line-labels { display: grid; grid-template-columns: 22px 1fr 70px 110px 64px 30px; gap: 8px; padding: 0 13px; }
.totals-mini { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; padding: 16px; border-radius: var(--radius); border: 1px dashed var(--line-strong); }
.totals-mini .row-between { font-size: 14px; }
.totals-mini .grand { font: 900 26px/1 var(--dot); }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px;
}
.combo-opt { display: flex; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.combo-opt small { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.combo-opt.on, .combo-opt:hover { background: var(--surface-2); }

.save-state { display: inline-flex; align-items: center; gap: 8px; font: 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.save-state .led { background: var(--green); }
.save-state.dirty .led { background: var(--amber); }
.save-state.err .led { background: var(--red); }

/* ---------- detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.detail-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.amount-big { font: 900 40px/1 var(--dot); margin: 10px 0 6px; word-break: break-all; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.claim { padding: 16px 18px; border-radius: var(--radius); background: var(--amber-soft); color: var(--amber); display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.claim b { color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 8px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 13px; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 200px minmax(0, 720px); gap: 28px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 20px; }
.settings-nav a { padding: 8px 12px; border-radius: var(--radius-s); text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.settings-nav a.on { background: var(--surface); color: var(--ink); box-shadow: inset 2px 0 0 var(--red); }
.logo-drop {
  display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.logo-drop img { max-height: 48px; max-width: 140px; object-fit: contain; }
.share-box { padding: 20px; border-radius: var(--radius); background: var(--ink); color: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.share-url { font: 14px var(--mono); word-break: break-all; }
.qr-box { background: #fff; padding: 10px; border-radius: 10px; width: 150px; }
.qr-box img { width: 100%; display: block; }

/* ---------- auth ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1.3px); background-size: 16px 16px;
}
.auth-card { width: min(420px, 100%); padding: 34px 30px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow); }
.auth-title { font: 900 44px/1 var(--dot); margin: 6px 0 0; }

/* ---------- modal & toast ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, #000 42%, transparent); backdrop-filter: blur(3px);
  animation: fade var(--fast) ease-out;
}
.modal {
  width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--surface); border-radius: var(--radius-l); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
  animation: rise 260ms var(--ease);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 22px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

.toasts { position: fixed; z-index: 200; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); animation: rise 260ms var(--ease);
  pointer-events: auto; max-width: calc(100vw - 32px);
}
.toast .led { background: var(--green); }
.toast.err .led { background: var(--red); }
.toast.info .led { background: var(--blue); }

.menu { position: relative; }
.menu-list {
  position: absolute; z-index: 50; right: 0; top: calc(100% + 6px); min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: rise 200ms var(--ease);
}
.menu-list a, .menu-list button {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 9px 12px;
  border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer; text-decoration: none; font-size: 14px;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); }
.menu-list small { font: 10px var(--mono); color: var(--muted); letter-spacing: 0.06em; }

.skeleton { height: 240px; border-radius: var(--radius-l); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- print host ---------- */
#print-host { display: none; }

/* Businesses */
.biz-switch { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.biz-list { list-style: none; margin: 0; padding: 4px 22px; }
.biz-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 18px; align-items: start; padding: 18px 0; border-bottom: 1px dashed var(--line); }

.biz-row:last-child { border-bottom: 0; }
.biz-id { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.biz-code { font: 900 30px/1 var(--dot); letter-spacing: 0.02em; }
.biz-main .t { font-weight: 600; font-size: 16px; }
.biz-main .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.biz-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px 14px; margin: 12px 0 0; }
.biz-stats div { min-width: 0; }
.biz-stats dt { font: 10px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.biz-stats dd { margin: 2px 0 0; font: 600 14px var(--mono); overflow-wrap: anywhere; }
.biz-stats dd.due { color: var(--red); }
.biz-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

/* Payment proofs */
.proof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.proof-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); color: inherit; text-decoration: none; box-shadow: var(--shadow);
  transition: transform var(--fast) var(--ease), border-color var(--fast);
}
.proof-tile:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.proof-tile:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.proof-tile svg { width: 16px; height: 16px; }
.proof-tile-amt { font: 900 34px/1.1 var(--dot); margin: 6px 0 4px; overflow-wrap: anywhere; }
.proof-tile .t { font-size: 18px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.proof-tile .s { font-size: 13px; color: var(--muted); }
.proof-preview { max-width: 520px; margin: 0 auto; width: 100%; }
.proof-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; }
.font-samples { display: grid; gap: 10px; }
.font-samples > div { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); }
.font-samples strong, .font-samples span { display: block; }
.font-samples span { margin-top: 8px; font-size: 20px; }
.shot-drop {
  display: block; padding: 18px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); cursor: pointer;
  background: var(--surface-2); transition: border-color var(--fast), background var(--fast);
}
.shot-drop:hover, .shot-drop.over, .shot-drop:focus-within { border-color: var(--ink); background: var(--surface); }
.shot-drop > span { display: flex; gap: 14px; align-items: center; }
.shot-drop > span > svg { width: 28px; height: 28px; flex: none; color: var(--muted); }
.shot-drop img { max-height: 220px; max-width: 60%; border-radius: var(--radius-s); border: 1px solid var(--line); object-fit: contain; }
.shot-thumb img { display: block; width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface-2); }
.shot-status { margin: 12px 0; padding: 12px 14px; border-radius: var(--radius-s); background: var(--surface-2); color: var(--muted); font-size: 13px; line-height: 1.6; }
.shot-status[aria-busy="true"] { color: var(--ink); border-left: 3px solid #4cc38a; }
.bulk-list { display: flex; flex-direction: column; gap: 12px; }
.bulk-row {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); transition: opacity var(--fast), border-color var(--fast);
}
.bulk-row:focus-within { border-color: var(--line-strong); }
.bulk-row.is-off { opacity: 0.55; }
.bulk-shot { margin: 0; display: grid; place-items: center; min-height: 120px; border-radius: var(--radius-s); background: var(--surface-2); overflow: hidden; }
.bulk-shot img { display: block; width: 100%; max-height: 240px; object-fit: contain; }
.bulk-shot svg { width: 24px; height: 24px; color: var(--muted); }
.bulk-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bulk-status { margin: 0; font-size: 13px; color: var(--muted); }
.bulk-status--reading, .bulk-status--saving { color: var(--ink); }
.bulk-status--warn { color: var(--amber); }
.bulk-status--created { color: var(--green); }
@media (max-width: 640px) { .bulk-row { grid-template-columns: 1fr; } .bulk-shot { min-height: 0; max-height: 200px; } }

@media print {
  body.printing > *:not(#print-host) { display: none !important; }
  body.printing { background: #fff; }
  body.printing #print-host { display: block; }
  #print-host .nd { box-shadow: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .editor, .detail { grid-template-columns: minmax(0, 1fr); }
  .editor-preview, .detail-side { position: static; }
  .preview-frame { max-height: none; }
}
@media (max-width: 980px) {
  .dash > * { grid-column: 1 / -1 !important; }
  .settings { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .settings-nav a { white-space: nowrap; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30;
    padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; }
  .main { padding: 20px 16px 110px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; z-index: 30; left: 12px; right: 12px; bottom: 12px;
    padding: 6px; border-radius: 20px; background: var(--ink); box-shadow: var(--shadow);
    padding-bottom: calc(6px + env(safe-area-inset-bottom) / 2);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border-radius: 14px; color: color-mix(in srgb, var(--bg) 60%, transparent); text-decoration: none; font-size: 10.5px; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a.active { color: var(--bg); background: color-mix(in srgb, var(--bg) 14%, transparent); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .formats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr) 30px; row-gap: 10px; }
  .line .idx, .line-labels { display: none; }
  .line .wide { grid-column: 1 / -1; }
  .line .cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .line .ml { display: block; font: 10px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .line .rm { align-self: end; margin: 0 0 4px; }
  .line .amount { grid-column: 1 / -1; }
  .kpi-row { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }
  .card-pad, .section { padding: 18px; }
  .preview-frame { padding: 12px; }
}
@media (max-width: 560px) {
  .biz-list { padding: 0 18px; }
  .biz-row { grid-template-columns: 1fr; gap: 10px; }
  .biz-id { flex-direction: row; align-items: center; }
  .biz-actions { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .formats { grid-template-columns: repeat(2, 1fr); }
  .action-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- clickable rows ---------- */
.table tr[data-href], .table tr[data-id] { cursor: pointer; transition: background var(--fast) var(--ease); }
.table tr[data-href]:hover, .table tr[data-id]:hover, .table tr[data-href]:focus-visible, .table tr[data-id]:focus-visible { background: var(--surface-2); }
.table tr[data-href]:focus-visible, .table tr[data-id]:focus-visible { outline: none; box-shadow: inset 2px 0 0 var(--red); }
