:root {
  --bg: #0a0a0a;
  --fg: #e6e6e6;
  --dim: #8a8a8a;
  --faint: #3a3a3a;
  --line: #262626;
  --accent: #ffffff;
  --pos: #7ee787;
  --neg: #ff7b72;
  --warn: #e3b341;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--mono); -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
.top { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: 0.02em; }
.tag { color: var(--dim); font-size: 12px; }
main { max-width: 760px; margin: 0 auto; padding: 24px 16px 80px; }
h1 { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 12px; font-weight: 400; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; margin: 28px 0 8px; }
p { margin: 0 0 12px; color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .dim { color: var(--dim); }
input, select, textarea, button { font: inherit; color: inherit; background: transparent; border: 1px solid var(--faint); border-radius: 2px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fg); }
textarea { width: 100%; min-height: 64px; resize: vertical; }
input[type="file"] { border: 1px dashed var(--faint); width: 100%; padding: 18px 10px; }
label { display: block; color: var(--dim); font-size: 12px; margin: 14px 0 4px; }
button { cursor: pointer; border-color: var(--fg); }
button:hover { background: var(--fg); color: var(--bg); }
button:disabled { opacity: 0.4; cursor: default; }
button.ghost { border-color: var(--faint); color: var(--dim); }
button.ghost:hover { background: var(--faint); color: var(--fg); }
button.danger { border-color: var(--neg); color: var(--neg); }
button.danger:hover { background: var(--neg); color: var(--bg); }
.actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 400; color: var(--dim); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th.num, td.num { text-align: right; }
tr.link { cursor: pointer; } tr.link:hover td { background: #111; }
.list > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.err { color: var(--neg); border: 1px solid var(--neg); padding: 8px 10px; margin: 12px 0; }
.warn { color: var(--warn); border: 1px solid var(--warn); padding: 8px 10px; margin: 12px 0; }
.banner { color: var(--warn); border-bottom: 1px solid var(--warn); padding: 6px 16px; margin: -24px -16px 20px; font-size: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--faint); padding: 2px 8px; border-radius: 2px; cursor: text; }
.chip input { border: none; padding: 0; width: 8ch; }
.code { color: var(--dim); font-size: 12px; }
/* split grid */
.gridwrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.grid td.cell, .grid th.cell { padding: 4px; }
.grid input.cell { width: 100%; min-width: 9ch; border-color: transparent; padding: 6px 4px; }
.grid input.cell:hover, .grid input.cell:focus { border-color: var(--faint); }
.grid input.cell.num { min-width: 7ch; text-align: right; }
.grid th.tog, .grid td.tog { text-align: center; width: 44px; }
.grid td.tog { padding: 0; }
.grid th:first-child, .grid td:first-child { position: sticky; left: 0; background: var(--bg); z-index: 1; }
.grid th.tog { writing-mode: vertical-rl; transform: rotate(180deg); padding: 6px 0; height: 80px; }
button.w { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; width: 44px; height: 44px; padding: 0; border: none; background: none; display: grid; place-items: center; }
button.w .dot { width: 30px; height: 30px; border-radius: 50%; border: 1px solid #666; display: grid; place-items: center; color: var(--fg); }
button.w.on .dot { border-color: var(--fg); }
button.w.auto .dot { border-style: dashed; color: var(--dim); }
button.w:hover { background: none; color: var(--fg); } button.w:hover .dot { background: var(--faint); }
button.x { border: none; color: var(--dim); padding: 4px 8px; min-width: 44px; height: 44px; } button.x:hover { color: var(--neg); background: none; }
.totals { margin-top: 12px; }
.receipt img { max-width: 100%; border: 1px solid var(--line); margin-top: 8px; }
.busy { color: var(--dim); } .busy::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { to { content: '...'; } }
@media (max-width: 480px) { main { padding: 16px 12px 80px; } .banner { margin: -16px -12px 16px; } .gridwrap { margin: 0 -12px; padding: 0 12px; } }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes scan { from { top: -4px; } to { top: calc(100% - 2px); } }
@keyframes draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* enter and stagger only play on navigation (#app.enter), never on in-place re-renders */
#app.enter > :not(.banner) { animation: rise 220ms cubic-bezier(.2,.7,.2,1) both; }
#app.enter .stagger > * { animation: rise 260ms cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 30ms); }
button.w .dot { transition: border-color 150ms, color 150ms; }
button.w.pop .dot { animation: pop 180ms cubic-bezier(.2,.8,.3,1.3); }
.num[data-total], #subtotal, #total, .num[data-key] { transition: color 150ms; }
.num.bump { color: var(--accent); }
#copy { transition: opacity 150ms; } #copy.swap { opacity: 0; }
.arrow { display: inline-block; width: 2.5ch; height: 1px; background: var(--dim); vertical-align: middle; margin: 0 6px; transform-origin: left; }
#app.enter .arrow { animation: draw 300ms cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 30ms + 120ms); }
.scanwrap { position: relative; overflow: hidden; border: 1px solid var(--line); margin-top: 12px; }
.scanwrap img { display: block; max-width: 100%; opacity: 0.55; }
.scanwrap .scan { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); box-shadow: 0 0 12px 2px rgba(255,255,255,0.6); animation: scan 1.6s ease-in-out infinite alternate; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- grid v2 ---------- */
.seg button { border-color: var(--faint); color: var(--dim); } .seg button.on { border-color: var(--fg); color: var(--fg); }
button.small { padding: 2px 8px; font-size: 12px; }
@media (max-width: 767px) { input, select, textarea { font-size: 16px; } }
