/* A19 Closing: one stylesheet for the cashier and owner apps.
   Colours are tokens with light-dark(), so the phone's own light/dark setting picks the set.
   A19 red is kept for the brand mark; red for "doesn't match" is its own status token, and primary buttons
   are ink so a red button never reads as an error. No glows, no pure #000 / #fff (QR code excepted).
   Corners: containers (cards, hero, tiles, lists, skeletons) 20px, controls (inputs, buttons, check rows,
   summaries, toasts) 14px, small controls 12px, pills and keypad keys fully round, sheets 28px.
   The segmented control is the one nested case: 16px outside, 12px inside. */

:root {
  color-scheme: light dark;
  interpolate-size: allow-keywords;

  --bg: light-dark(#F2F2F4, #070709);
  --surface: light-dark(#FDFDFE, #121215);
  --surface-2: light-dark(#F6F6F8, #1A1A1E);
  --surface-3: light-dark(#ECECF0, #232328);
  --ink: light-dark(#0B0B0D, #F5F5F7);
  --ink-2: light-dark(#3A3A41, #D2D2D8);
  --muted: light-dark(#6A6A73, #9C9CA6);
  --line: light-dark(#E5E5EA, #25252B);
  --line-strong: light-dark(#D2D2D9, #34343B);
  --on-ink: light-dark(#FAFAFB, #0B0B0D);
  --on-bad: light-dark(#FFF8F8, #1F0707);

  --brand: #E3101A;
  --brand-deep: #9A0000;

  --good: light-dark(#12783A, #5BE08C);
  --good-bg: light-dark(#E5F5EA, #0D2817);
  --bad: light-dark(#C41C1C, #FF8080);
  --bad-bg: light-dark(#FCEBEB, #3A1313);
  --warn: light-dark(#9A5800, #FFC24D);
  --warn-bg: light-dark(#FFF3DD, #36280B);
  --focus: light-dark(#2563EB, #8AB4FF);
  --bar: light-dark(#4A4A52, #BDBDC6);
  --bar-hover: light-dark(#0B0B0D, #F5F5F7);

  /* Shadows are tinted toward the cool neutral of the page, not pure black. */
  --shadow-base: light-dark(#1A1A2E, #020203);
  --shadow-1: 0 1px 2px color-mix(in srgb, var(--shadow-base) 6%, transparent), 0 1px 1px color-mix(in srgb, var(--shadow-base) 4%, transparent);
  --shadow-2: 0 18px 40px -18px color-mix(in srgb, var(--shadow-base) 38%, transparent);
  --scrim: color-mix(in srgb, var(--shadow-base) 42%, transparent);
  --radius: 20px;
  --radius-sm: 14px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: linear(0, 0.02 1.6%, 0.084 3.3%, 0.336 7.4%, 0.704 12.6%, 0.869 15.5%, 0.987 18.5%, 1.064 21.6%, 1.098 24.3%, 1.106 26.5%, 1.096 29.5%, 1.036 37.6%, 1.006 43.6%, 0.993 50.5%, 0.999 68.4%, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 650; letter-spacing: -0.02em; }
p { margin: 0; text-wrap: pretty; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.icon { width: 1.25em; height: 1.25em; flex: none; display: block; }

/* ---------- layout ---------- */

.app { width: min(100%, 560px); margin-inline: auto; padding: 0 16px calc(120px + var(--safe-bottom)); container-type: inline-size; }
.app.wide { width: min(100%, 760px); }
.stack { display: grid; gap: 14px; }
.stack-lg { display: grid; gap: 22px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  margin: 0 -16px 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  view-transition-name: topbar;
}
@supports (animation-timeline: scroll()) {
  .topbar { animation: topbar-lift linear both; animation-timeline: scroll(); animation-range: 0 48px; }
  @keyframes topbar-lift { to { box-shadow: 0 1px 0 var(--line), 0 10px 30px -22px color-mix(in srgb, var(--shadow-base) 50%, transparent); } }
}
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 19px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { width: 38px; height: 38px; object-fit: contain; flex: none; }

.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 650; color: var(--ink-2);
  margin: 6px 4px -4px;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-1);
  container-type: inline-size;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; flex: 1; }
.card-icon {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--ink-2);
}
.card-icon .icon { width: 20px; height: 20px; }
.card:has(.pill.bad) { border-color: color-mix(in oklab, var(--bad) 35%, var(--line)); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2.after-check { margin-top: 16px; }
.bills-wrap { margin-top: 12px; }
@container (width < 330px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- fields ---------- */

.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.input {
  width: 100%; min-height: 52px; padding: 0 14px;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 19px; font-weight: 550; font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--muted); font-weight: 450; }
.input:focus { outline: none; border-color: var(--ink); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in oklab, var(--ink) 8%, transparent); }
.input.text { font-size: 17px; font-weight: 500; }
textarea.input { padding-block: 14px; min-height: 80px; field-sizing: content; max-height: 40dvh; resize: none; line-height: 1.4; }
.money { position: relative; }
.money .input { padding-left: 32px; }
.money::before { content: '₹'; position: absolute; left: 14px; top: 50%; translate: 0 -50%; font-size: 18px; color: var(--muted); pointer-events: none; }
.field-error { font-size: 13px; color: var(--bad); font-weight: 550; }
.field:has(.field-error:not(:empty)) .input { border-color: var(--bad); background: var(--bad-bg); }
.hint { font-size: 13px; color: var(--muted); }

.stepper { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 6px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; }
.stepper .input { min-height: 44px; text-align: center; padding: 0 4px; background: transparent; }
.stepper .input:focus { background: var(--surface); }
.stepper button { height: 44px; border: 0; border-radius: 11px; background: var(--surface); color: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow-1); transition: scale 0.12s var(--ease); }
.stepper button:active { scale: 0.92; }
.field:has(.field-error:not(:empty)) .stepper { outline: 1.5px solid var(--bad); background: var(--bad-bg); }

/* ---------- checks & pills ---------- */

.check { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); margin-top: 14px; }
.check .what { flex: 1 1 210px; min-width: 0; font-size: 14px; color: var(--ink-2); }
.check .what b { color: var(--ink); font-weight: 650; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 5px 10px 5px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 650; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.pill .icon { width: 16px; height: 16px; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.pop { animation: pop 0.45s var(--spring); }
@keyframes pop { from { scale: 0.7; opacity: 0; } }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 22px; border: 0; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--on-ink);
  font-size: 16px; font-weight: 650; white-space: nowrap;
  transition: scale 0.15s var(--ease), opacity 0.15s, background 0.15s;
}
.btn:active:not(:disabled) { scale: 0.97; }
.btn:disabled { opacity: 0.45; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-3); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: var(--bad); color: var(--on-bad); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn .icon { width: 20px; height: 20px; }
.btn.busy { pointer-events: none; }
.btn.busy::after { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { rotate: 1turn; } }
.icon-btn {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 14px; flex: none;
  display: grid; place-items: center; background: transparent; color: var(--ink-2);
  transition: background 0.15s, scale 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { scale: 0.92; }
.icon-btn .icon { width: 22px; height: 22px; }
.link-btn { border: 0; background: none; padding: 6px 2px; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }

.add-row {
  width: 100%; min-height: 50px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.add-row:hover { border-color: var(--ink-2); color: var(--ink); }

/* segmented control (radio buttons) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--surface-3); }
.segmented label {
  position: relative; display: grid; place-items: center; gap: 0; min-height: 52px; padding: 6px 8px; border-radius: 12px;
  font-weight: 650; text-align: center; cursor: pointer; color: var(--ink-2); line-height: 1.15;
  transition: background 0.2s var(--ease), color 0.2s, box-shadow 0.2s;
}
.segmented label small { font-size: 12px; font-weight: 500; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 4px 14px -8px color-mix(in srgb, var(--shadow-base) 30%, transparent); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
.segmented label:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

/* ---------- bottom bars ---------- */

.bottom-bar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(20px);
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  border-top: 1px solid var(--line);
}
.bottom-bar .inner { width: min(100%, 528px); margin-inline: auto; display: flex; align-items: center; gap: 12px; }
.bottom-bar .status { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.bottom-bar .status b { display: block; font-size: 15px; }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: color-mix(in oklab, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(20px);
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  border-top: 1px solid var(--line);
  view-transition-name: tabbar;
}
.tabbar nav { width: min(100%, 560px); margin-inline: auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tabbar button {
  border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 0;
  font-size: 11.5px; font-weight: 600; color: var(--muted); border-radius: 14px;
}
.tabbar button .icon { width: 26px; height: 26px; transition: scale 0.3s var(--spring); }
.tabbar button[aria-current='page'] { color: var(--ink); }
.tabbar button[aria-current='page'] .icon { scale: 1.08; }

/* ---------- sheets (dialog) ---------- */

dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto;
  width: min(100%, 560px); max-width: 100%; max-height: min(94dvh, 900px);
  padding: 0; border: 0; border-radius: 28px 28px 0 0;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 -20px 60px -20px color-mix(in srgb, var(--shadow-base) 45%, transparent);
  overflow: hidden; overscroll-behavior: contain;
  translate: 0 0;
  transition: translate 0.42s var(--ease), overlay 0.42s allow-discrete, display 0.42s allow-discrete;
}
dialog.sheet:not([open]) { translate: 0 105%; }
@starting-style { dialog.sheet[open] { translate: 0 105%; } }
dialog.sheet::backdrop {
  background: transparent; backdrop-filter: blur(0);
  transition: background 0.42s, backdrop-filter 0.42s, overlay 0.42s allow-discrete, display 0.42s allow-discrete;
}
dialog.sheet[open]::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
@starting-style { dialog.sheet[open]::backdrop { background: transparent; backdrop-filter: blur(0); } }
@media (min-width: 640px) {
  dialog.sheet { inset: 0; margin: auto; border-radius: 28px; max-height: min(88dvh, 860px); }
  dialog.sheet:not([open]) { translate: 0 24px; opacity: 0; }
  @starting-style { dialog.sheet[open] { translate: 0 24px; opacity: 0; } }
  dialog.sheet { transition: translate 0.32s var(--ease), opacity 0.32s, overlay 0.32s allow-discrete, display 0.32s allow-discrete; }
}
.sheet-body { display: flex; flex-direction: column; max-height: inherit; }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 10px auto 0; flex: none; }
@media (min-width: 640px) { .sheet-grab { display: none; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 8px 20px; flex: none; }
.sheet-head h2 { flex: 1; font-size: 20px; }
.sheet-scroll { overflow-y: auto; padding: 4px 20px 20px; flex: 1; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); flex: none; background: var(--surface); }
.sheet-foot .btn { flex: 1; }

/* ---------- toast (popover) ---------- */

.toast {
  position: fixed; inset: auto 16px calc(96px + var(--safe-bottom)) 16px; margin: 0 auto;
  width: fit-content; max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px; border: 0; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--on-ink); font-weight: 600; font-size: 15px;
  display: none; align-items: center; gap: 10px;
  box-shadow: var(--shadow-2);
  translate: 0 0; opacity: 1;
  transition: translate 0.35s var(--ease), opacity 0.35s, overlay 0.35s allow-discrete, display 0.35s allow-discrete;
}
.toast:popover-open { display: flex; }
@starting-style { .toast:popover-open { translate: 0 20px; opacity: 0; } }
.toast:not(:popover-open) { translate: 0 20px; opacity: 0; }
.toast.bad { background: var(--bad); color: var(--on-bad); }

/* ---------- PIN pad ---------- */

.login { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 22px; padding: 28px 20px calc(28px + var(--safe-bottom)); text-align: center; }
.login .brand { display: grid; justify-items: center; gap: 10px; }
.login .brand img { width: 92px; height: 82px; object-fit: contain; }
.login h1 { font-size: 28px; }
.login .who { width: min(100%, 320px); }
.login .who .input { text-align: center; }
.dots { display: flex; gap: 14px; justify-content: center; height: 18px; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); transition: background 0.15s, border-color 0.15s, scale 0.25s var(--spring); }
.dots span.on { background: var(--ink); border-color: var(--ink); scale: 1.12; }
.dots.shake { animation: shake 0.42s var(--ease); }
.dots.shake span { border-color: var(--bad); }
@keyframes shake { 20%, 60% { translate: -10px 0; } 40%, 80% { translate: 10px 0; } }
.keypad { display: grid; grid-template-columns: repeat(3, 78px); gap: 14px 22px; justify-content: center; }
.keypad button {
  width: 78px; height: 78px; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1);
  font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
  transition: background 0.12s, scale 0.12s var(--ease);
}
.keypad button:active { scale: 0.92; background: var(--surface-3); }
.keypad button.fn { background: transparent; box-shadow: none; color: var(--ink-2); }
.keypad button.fn .icon { width: 28px; height: 28px; }
.error { min-height: 22px; color: var(--bad); font-weight: 600; font-size: 15px; }
.error:empty { visibility: hidden; }
.pin-sheet { display: grid; justify-items: center; gap: 18px; padding: 8px 0 16px; text-align: center; }

/* ---------- done screen ---------- */

.done { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 16px; padding: 32px 24px; text-align: center; }
.done svg.tick { width: 112px; height: 112px; }
.done .ring { fill: var(--good-bg); stroke: var(--good); stroke-width: 3; stroke-dasharray: 302; stroke-dashoffset: 302; animation: draw 0.7s var(--ease) forwards; }
.done .tickpath { fill: none; stroke: var(--good); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.4s 0.5s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h1 { font-size: 30px; }
.done .ref { display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.done .countdown { font-size: 14px; color: var(--muted); }

/* ---------- review / detail lists ---------- */

.kv { display: grid; gap: 0; border-radius: var(--radius-sm); background: var(--surface-2); padding: 4px 14px; }
.kv .row { display: flex; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv .row:last-child { border-bottom: 0; }
.kv .k { flex: 1; color: var(--ink-2); font-size: 15px; }
.kv .v { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 16px; text-align: right; }
.kv .row.total .k, .kv .row.total .v { font-weight: 750; color: var(--ink); }
.kv-title { font-size: 15px; font-weight: 650; color: var(--ink-2); margin: 18px 4px 8px; }
.confirm-box { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius-sm); background: var(--bad-bg); color: var(--bad); margin-top: 14px; font-weight: 600; }
.confirm-box input { width: 22px; height: 22px; accent-color: var(--bad); margin: 0; flex: none; }
.confirm-box label { flex: 1; cursor: pointer; }

/* bills rows */
.bill { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; align-items: start; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.bill .note-input { grid-column: 1 / 3; }
.bill .input { background: var(--surface); min-height: 46px; font-size: 17px; }
.bill .icon-btn { margin-top: 23px; color: var(--muted); }
.bills { display: grid; gap: 10px; }
.bill { animation: rise 0.3s var(--ease); }
@keyframes rise { from { opacity: 0; translate: 0 8px; } }
.stack-sm { display: grid; gap: 8px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
button.chip { font: inherit; font-weight: 600; font-size: 14px; }
.cash-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.cash-line .what { display: grid; gap: 2px; }
.cash-line .what small { font-size: 13px; }
.cash-line .big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.bill.taken.single { grid-template-columns: 1fr 44px; }
/* Cash taken rows: the name gets the full width, the amount sits under it, delete stays top right. */
.bill.taken { grid-template-columns: 1fr 44px; }
.bill.taken > .field:nth-child(1) { grid-column: 1; grid-row: 1; }
.bill.taken > .field:nth-child(2) { grid-column: 1; grid-row: 2; }
.bill.taken > .icon-btn { grid-column: 2; grid-row: 1; }
.select { position: relative; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.select .icon { position: absolute; right: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 4px 0; font-weight: 650; }

/* ---------- owner: hero, tiles, lists ---------- */

.hero { padding: 22px 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; box-shadow: var(--shadow-1); }
.hero > .label { font-size: 14px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero .figure { font-size: clamp(44px, 13cqi, 64px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; margin: 6px 0 4px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--ink-2); font-size: 14px; }
.waiting { display: flex; align-items: center; gap: 12px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 0 color-mix(in oklab, var(--warn) 60%, transparent); animation: pulse 1.8s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, calc(50% - 6px)), 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1); min-width: 0; }
.tile .label { font-size: 13px; color: var(--muted); font-weight: 550; display: flex; gap: 6px; align-items: flex-start; line-height: 1.25; }
.tile .label .icon { width: 16px; height: 16px; }
.tile .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .foot { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.month-switch { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2px; }
.month-switch span { min-width: 92px; text-align: center; font-weight: 650; font-size: 15px; }
.month-switch .icon-btn { width: 38px; height: 38px; }

.list { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1); }
.list-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; width: 100%;
  border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
  transition: background 0.15s;
}
.list-row:last-child { border-bottom: 0; }
button.list-row:hover { background: var(--surface-2); }
.list-row .main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list-row .main b { font-weight: 650; }
.list-row .main small { color: var(--muted); font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.list-row .end { text-align: right; display: grid; gap: 4px; justify-items: end; }
.list-row .end b { font-variant-numeric: tabular-nums; font-weight: 700; }
.list-row.void { opacity: 0.55; }
.list-row.void .end b { text-decoration: line-through; }
.date-chip { width: 50px; height: 54px; border-radius: 14px; background: var(--surface-2); display: grid; place-content: center; text-align: center; line-height: 1.05; flex: none; }
.date-chip small { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 650; letter-spacing: 0.05em; }
.date-chip b { font-size: 21px; font-weight: 700; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty .icon { width: 36px; height: 36px; color: var(--line-strong); }
.tag { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

.search { position: relative; }
.search .icon { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--muted); width: 20px; height: 20px; }
.search .input { padding-left: 44px; font-size: 17px; }

/* timeline of corrections */
.timeline { display: grid; gap: 12px; }
.change { border-left: 3px solid var(--line-strong); padding: 2px 0 2px 14px; display: grid; gap: 4px; }
.change.void { border-color: var(--bad); }
.change .when { font-size: 13px; color: var(--muted); }
.change .diff { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.change .diff s { color: var(--muted); }

details.more { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
details.more summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 16px 18px; cursor: pointer; font-weight: 650; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary .icon.caret { margin-left: auto; transition: rotate 0.3s var(--ease); color: var(--muted); }
details.more[open] summary .icon.caret { rotate: 180deg; }
details.more::details-content { block-size: 0; overflow-y: clip; transition: block-size 0.35s var(--ease), content-visibility 0.35s allow-discrete; }
details.more[open]::details-content { block-size: auto; }
details.more .inner { padding: 0 18px 18px; }

.activity { display: grid; gap: 0; }
.activity .item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.activity .item:last-child { border-bottom: 0; }
.activity .item .icon { width: 20px; height: 20px; color: var(--muted); margin-top: 1px; }
.activity .item.bad .icon { color: var(--bad); }
.activity .when { color: var(--muted); font-size: 12.5px; }

/* The QR code stays pure black on white so every phone camera reads it. */
.qr { display: grid; place-items: center; padding: 16px; background: #fff; border-radius: var(--radius); width: fit-content; margin: 8px auto; }
.qr svg { width: 200px; height: 200px; display: block; }
.secret { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 15px; letter-spacing: 0.08em; word-break: break-all; background: var(--surface-2); padding: 12px 14px; border-radius: 12px; text-align: center; }
.otp { text-align: center; letter-spacing: 0.5em; font-size: 26px; font-weight: 650; padding-left: calc(14px + 0.5em); }
.steps { display: flex; gap: 6px; justify-content: center; }
.steps span { width: 28px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.steps span.on { background: var(--ink); }

/* ---------- chart ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--bar); transition: fill 0.15s; }
.chart .bar.flag { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .col:hover .bar, .chart .col:focus-visible .bar, .chart .col.active .bar { fill: var(--bar-hover); }
.chart .col:focus-visible { outline: none; }
.chart .flag-dot { fill: var(--bad); stroke: var(--surface); stroke-width: 2; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  padding: 8px 12px; border-radius: 12px; background: var(--ink); color: var(--on-ink);
  font-size: 13px; line-height: 1.35; white-space: nowrap; translate: -50% calc(-100% - 10px);
  box-shadow: var(--shadow-2);
}
.chart-tip b { font-size: 15px; font-variant-numeric: tabular-nums; }
.chart-key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; }

/* ---------- expenses ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.field > .label { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.field .chips + .input { margin-top: 8px; }
.day-group { display: grid; gap: 8px; }
.day-head { display: flex; justify-content: space-between; padding: 0 4px; font-size: 14px; font-weight: 650; color: var(--ink-2); }
.list.flat { box-shadow: none; border: 0; border-radius: 0; background: transparent; }
.list.flat .list-row { padding-inline: 0; }
.list-row .end small { font-size: 12px; }
.spaced-bottom { margin-bottom: 12px; }

/* ---------- summary ---------- */

.totals .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative; }
.totals .label { font-size: 14px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.totals .label .icon { width: 18px; height: 18px; }
.totals .figure { font-size: clamp(24px, 8cqi, 40px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 4px; }
.totals .meta { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.breakdown { margin-top: 14px; }
.breakdown summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 6px 0; }
.breakdown summary::-webkit-details-marker { display: none; }
.breakdown summary .caret { width: 16px; height: 16px; transition: rotate 0.3s var(--ease); }
.breakdown[open] summary .caret { rotate: 180deg; }
.breakdown::details-content { block-size: 0; overflow-y: clip; transition: block-size 0.35s var(--ease), content-visibility 0.35s allow-discrete; }
.breakdown[open]::details-content { block-size: auto; }
.breakdown .kv { margin-top: 8px; }
.breakdown .hint { margin-top: 8px; }

.ledger-card { padding: 6px 16px 14px; }
.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 12px 0; text-align: right; white-space: nowrap; }
.ledger th:first-child { text-align: left; }
.ledger thead th { font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 0 8px; }
.ledger tbody tr + tr th, .ledger tbody tr + tr td { border-top: 1px solid var(--line); }
.ledger tbody th { font-weight: 500; color: var(--ink-2); }
.ledger tbody th .wd { display: inline-block; width: 2.6em; color: var(--muted); font-size: 13px; }
.ledger tbody td { font-weight: 650; }
.ledger tbody tr[tabindex] { cursor: pointer; }
.ledger tbody tr[tabindex]:hover th, .ledger tbody tr[tabindex]:hover td { background: var(--surface-2); }
.ledger tbody tr[tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.ledger tr.missing td { color: var(--muted); font-weight: 450; font-size: 14px; }
.ledger tfoot th, .ledger tfoot td { font-weight: 750; border-top: 1.5px solid var(--ink); padding-top: 14px; }
.ledger .flag { display: inline-block; width: 15px; height: 15px; color: var(--bad); margin-left: 6px; vertical-align: -2px; }
.hint.key { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.hint.key .flag { width: 15px; height: 15px; color: var(--bad); }

/* ---------- skeleton ---------- */

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

/* ---------- view transitions ---------- */

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; animation-timing-function: var(--ease); }
::view-transition-group(topbar), ::view-transition-group(tabbar) { animation-duration: 0s; }

/* Frosted bars and sheets fall back to solid fills when the phone asks for less transparency. */
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .bottom-bar, .tabbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  dialog.sheet[open]::backdrop { backdrop-filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*) { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- owner extras ---------- */

.owner-login .card { width: min(100%, 420px); text-align: left; }
.owner-login { align-content: start; padding-top: max(40px, 8dvh); }
.hero .tiles { margin: 18px 0 14px; position: relative; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero .tile { padding: 12px 14px; }
.hero .tile { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.hero .tile .value { font-size: 20px; }
.waiting { padding: 16px 18px; }
.waiting p { font-size: 14px; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; }
.spaced { margin-top: 14px; }
.price-row { display: flex; gap: 10px; align-items: center; }
.price-row .money { flex: 1; }
.pin-big { font-size: 40px; font-weight: 700; letter-spacing: 0.14em; padding: 20px; }
.card-head .btn.small { margin-left: auto; }
