:root {
  --bg: #eef1f4; --card: #fff; --ink: #16202a; --muted: #5b6875; --line: #d5dbe1;
  --accent: #0b5c8a; --accent-ink: #fff; --warn-bg: #fff4d6; --warn-ink: #7a5200;
  --ok: #1c7a45; --danger: #a63a2b; --field: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161c; --card: #1a232c; --ink: #e8edf2; --muted: #9aa7b4; --line: #2e3a46;
    --accent: #4aa8d8; --accent-ink: #06202e; --warn-bg: #3b2f0c; --warn-ink: #f3d27a;
    --ok: #5cc48a; --danger: #ee8b7c; --field: #121a21;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .78rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

.shell { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
/* minmax(0, …) lets long unbroken text truncate instead of widening the page */
.stack { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 0; min-width: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 10px 14px; min-height: 44px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--danger); }
a.button { display: block; text-align: center; text-decoration: none; color: inherit; border-radius: 10px; border: 1px solid var(--line); padding: 10px 14px; min-height: 44px; }
a.button.primary, label.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
label.filepick { display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; color: var(--ink); font-size: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-height: 52px; padding: 10px 14px; }
label.filepick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
label.filepick:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
summary { cursor: pointer; color: var(--accent); min-height: 32px; }
div.item { cursor: default; }
button.link { border: 0; background: none; padding: 4px; min-height: 0; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select, textarea { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 120px; resize: vertical; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); }
label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 1rem; }
.pw { position: relative; }
.pw input { padding-right: 76px; }
.pw button { position: absolute; right: 4px; top: 4px; min-height: 36px; padding: 4px 10px; border: 0; color: var(--accent); background: none; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1 1 0; max-width: 160px; padding: 10px 2px; border: 0; border-radius: 0; background: none; min-height: 60px; color: var(--muted); font-size: .85rem; }
nav.tabs button[aria-current=page] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

.mic { width: 100%; min-height: 76px; font-size: 1.15rem; font-weight: 700; border-radius: 14px; }
.mic.live { background: var(--danger); border-color: var(--danger); color: #fff; }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 12px; font-size: .92rem; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); }
.item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); text-align: left; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0; }
.list > .item:first-child { border-top: 0; }
.item .main { min-width: 0; flex: 1 1 0; }
.item .main strong, .item .main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; text-align: right; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; color: var(--muted); }
.pill.flag { color: var(--warn-ink); background: var(--warn-bg); border-color: transparent; }
.pill.paid, .pill.accepted { color: var(--ok); }
.pill.void { color: var(--danger); }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.todo.done span { text-decoration: line-through; color: var(--muted); }
.todo span { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }

.line { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.line.flagged { border-color: var(--warn-ink); }
.line .nums { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }
.totals { margin-left: auto; width: min(100%, 260px); font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; padding: 2px 0; }
.totals .grand { font-weight: 700; font-size: 1.15rem; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; }
.chips button { min-height: 36px; padding: 6px 14px; border-radius: 999px; white-space: nowrap; }
.chips button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }

#toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
#toast.show { opacity: 1; }
@media (max-width: 420px) { .two { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
