/* Layout: full left rail on desktop (≥1100px), icon rail on tablets (700–1099px), app bar + bottom tab bar on phones (<700px).
   Tables turn into cards on phones; modals become bottom sheets. Palette: deep teal workshop console on cool grey. */
:root {
  --bg: #f1f4f3; --surface: #ffffff; --surface2: #e8edec; --ink: #13201f; --muted: #566866; --line: #d6dedc;
  --accent: #0b6b69; --accent-ink: #ffffff; --accent-soft: #d5ebe9;
  --good: #2b7a4b; --good-soft: #dcefe3; --warn: #96600c; --warn-soft: #f6e8cc; --bad: #b0372b; --bad-soft: #f6dcd8;
  --c1: #0b6b69; --c2: #c98a1b; --c3: #5b6fb0; --c4: #b0372b; --c5: #7a8b89;
  --scrim: rgba(8, 20, 19, 0.55); --toast-bg: #13201f; --toast-ink: #f1f4f3;
  --f-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --bar-h: 64px; --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1716; --surface: #172221; --surface2: #1f2d2c; --ink: #e6efed; --muted: #94a8a5; --line: #2a3a38;
    --accent: #4cc2bd; --accent-ink: #082524; --accent-soft: #17403f;
    --good: #5fcb8a; --good-soft: #173625; --warn: #e5b25a; --warn-soft: #3a2d12; --bad: #f08a7d; --bad-soft: #3d1b17;
    --c1: #4cc2bd; --c2: #e5b25a; --c3: #8fa2e6; --c4: #f08a7d; --c5: #8fa3a0;
    --scrim: rgba(0, 0, 0, 0.6); --toast-bg: #e6efed; --toast-ink: #0f1716; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1716; --surface: #172221; --surface2: #1f2d2c; --ink: #e6efed; --muted: #94a8a5; --line: #2a3a38;
  --accent: #4cc2bd; --accent-ink: #082524; --accent-soft: #17403f;
  --good: #5fcb8a; --good-soft: #173625; --warn: #e5b25a; --warn-soft: #3a2d12; --bad: #f08a7d; --bad-soft: #3d1b17;
  --c1: #4cc2bd; --c2: #e5b25a; --c3: #8fa2e6; --c4: #f08a7d; --c5: #8fa3a0;
  --scrim: rgba(0, 0, 0, 0.6); --toast-bg: #e6efed; --toast-ink: #0f1716; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.tr { text-align: right; }
.grow { flex: 1; }
.sel { user-select: all; -webkit-user-select: all; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 20px; height: 20px; flex: none; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; height: 100dvh; align-self: start; overflow-y: auto; }
.brand { padding: 4px 8px 16px; display: flex; gap: 10px; align-items: center; }
.mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.mark .ic { width: 20px; height: 20px; }
.brand-t { min-width: 0; }
.brand b { font-family: var(--f-display); font-size: 17px; display: block; line-height: 1.15; }
.brand-t span { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); display: flex; align-items: center; gap: 10px; min-height: 40px; position: relative; }
.nav button .lbl-l { flex: 1; }
.nav button .lbl-s { display: none; }
.nav button:hover { background: var(--surface2); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; line-height: 1.5; }
.rail-foot { margin-top: auto; padding: 10px 8px; font-size: 12px; color: var(--muted); display: grid; gap: 8px; }
.rail-foot .btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.rail-foot .ic { width: 16px; height: 16px; }
.sync { display: flex; align-items: center; gap: 6px; }
.sync::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync.shared::before { background: var(--good); }
.sync.local::before { background: var(--c2); }
.appbar, .bottombar { display: none; }
.main { padding: 22px 28px 48px; min-width: 0; max-width: 1280px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { font-size: 26px; }
.head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { padding: 48px 0; max-width: 520px; }
.empty-state h1 { font-size: 24px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin: 0; }

/* ---------- controls ---------- */
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 13px; cursor: pointer; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; line-height: 1.2; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 12.5px; min-height: 30px; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.iconbtn { background: none; border: 0; width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; color: var(--muted); flex: none; }
.iconbtn:hover { background: var(--surface2); color: var(--ink); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, tr[tabindex]:focus-visible, label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 14px; display: grid; gap: 4px; align-content: start; }
.tile .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.tile .v { font-family: var(--f-display); font-size: 26px; font-weight: 600; line-height: 1.15; }
.tile .s { font-size: 12.5px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; margin-bottom: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 16px; min-width: 0; }
.card h2 { font-size: 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h3, .modal h3 { font-size: 14px; margin: 14px 0 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sub-h { margin: 4px 0 8px; font-size: 14px; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--warn-soft); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; margin-bottom: 14px; }

/* ---------- tables ---------- */
.card.tablecard { padding: 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--surface2); }
td.r, th.r { text-align: right; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.mute { background: var(--surface2); color: var(--muted); }

.bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row > div, .row > span { min-width: 0; }
.row-end { display: flex; gap: 8px; align-items: center; flex: none; }
.hb-top { display: flex; justify-content: space-between; gap: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
svg text { fill: var(--muted); font-family: var(--f-body); font-size: 11px; }
svg .grid { stroke: var(--line); stroke-width: 1; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 10px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: 42px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar input, .toolbar select, .field input, .field select, .field textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; min-height: 40px; }
.toolbar input { max-width: 300px; }
.toolbar select { width: auto; }
.field { display: grid; gap: 4px; margin-bottom: 12px; align-content: start; }
.field label, .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 0 12px; }
.kvgrid { gap: 12px; margin-bottom: 12px; }
.kv { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; }
.kv > div { display: grid; gap: 2px; }
.checks { display: flex; gap: 8px 16px; flex-wrap: wrap; padding: 4px 0 8px; }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--ink); font-size: 13.5px; min-height: 32px; }
.checks input, .pick input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.svc-group { margin: 8px 0; }
.svc-cat { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.svc-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 6px; margin-top: 4px; }
.pick { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; cursor: pointer; min-height: 44px; }
.pick span:nth-child(2) { flex: 1; }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.totals { display: grid; gap: 2px; margin: 12px 0 0 auto; max-width: 320px; }
.steps { margin: 0; padding-left: 18px; display: grid; gap: 8px; }

.switch { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 12px; transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- modal / sheet ---------- */
.overlay { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 16px; overflow-y: auto; z-index: 40; overscroll-behavior: contain; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: min(720px, 100%); padding: 20px; }
.modal.wide { width: min(920px, 100%); }
.modal > h2 { font-size: 20px; margin-bottom: 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.modal > h2 > span { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.modal .tablecard { margin-top: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + var(--sab)); transform: translateX(-50%); background: var(--toast-bg); color: var(--toast-ink); padding: 10px 16px; border-radius: 9px; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }
.msg { background: var(--surface2); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 6px 0; }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.tl { display: grid; gap: 0; }
.tl div { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; }
.tl div::before { content: ''; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.note { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
.copybox { width: 100%; font-family: var(--f-mono); font-size: 12px; background: var(--surface2); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 8px; }
.sheet-more { display: none; }


/* ---------- workshop board ---------- */
.board-card { padding-bottom: 8px; margin-bottom: 14px; }
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.jcol { background: var(--surface2); border-radius: 9px; padding: 8px; display: grid; gap: 8px; align-content: start; min-height: 120px; scroll-snap-align: start; }
.jcol header { display: flex; justify-content: space-between; align-items: center; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 2px 4px; }
.jcol .count { background: var(--surface); border-radius: 9px; padding: 0 7px; font-variant-numeric: tabular-nums; color: var(--ink); }
.jempty { padding: 6px 4px; margin: 0; }
.jlater { justify-self: start; }
.jcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 3px; cursor: pointer; min-width: 0; }
.jcard:hover { border-color: var(--accent); }
.jcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.jc-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.plate { background: var(--surface2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-weight: 500; white-space: nowrap; }
.jc-svc { font-size: 12.5px; margin-top: 2px; }
.jc-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.jc-flags:empty { display: none; }
.jc-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.stepper { list-style: none; display: flex; gap: 4px; padding: 0; margin: 0 0 14px; overflow-x: auto; }
.stepper li { flex: 1 0 auto; font-size: 11.5px; padding: 6px 8px; border-radius: 6px; background: var(--surface2); color: var(--muted); text-align: center; white-space: nowrap; }
.stepper li.done { background: var(--accent-soft); color: var(--accent); }
.stepper li.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.panels { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 6px; margin-top: 4px; }
.bayrow { justify-content: flex-start; }
.bay-n { width: 84px; flex: none; font-weight: 600; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.linkish:hover { color: var(--accent); }
.arr { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.arr-t { font-family: var(--f-mono); font-size: 13px; color: var(--accent); font-weight: 500; padding-top: 1px; width: 44px; flex: none; }
.wchips { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 6px; }


/* ---------- clickable tiles, payment QR, logo, quick add ---------- */
button.tile { font: inherit; color: inherit; text-align: left; cursor: pointer; position: relative; width: 100%; }
button.tile:hover { border-color: var(--accent); }
button.tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile-go { position: absolute; top: 10px; right: 12px; color: var(--muted); font-size: 18px; line-height: 1; }
.jcol.flash { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow 0.2s; }
.paybox { display: flex; gap: 14px; align-items: center; background: var(--surface2); border-radius: 9px; padding: 12px; margin: 4px 0 10px; }
.paybox .qr { flex: none; border-radius: 6px; background: #fff; }
.paybox b { font-family: var(--f-display); font-size: 17px; }
.inv-sum-row { display: flex; gap: 24px; margin-bottom: 8px; }
.inv-sum-row > div { display: grid; }
.inv-sum-row b { font-family: var(--f-display); font-size: 20px; }
.logo-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.logo-prev { width: 180px; height: 90px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.foot-sub { display: flex; gap: 6px; margin-right: auto; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
.fab { display: none; }
.sheet-more button small { display: block; font-size: 12.5px; font-weight: 400; }


/* ---------- login / signup ---------- */
.app.is-auth { display: block; }
.auth-wrap { max-width: none; padding: 0; }
.auth { min-height: 100vh; min-height: 100dvh; background: var(--surface); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.au-brand { background: var(--accent); color: var(--accent-ink); padding: 56px clamp(24px, 6vw, 72px); display: grid; align-content: center; gap: 14px; }
.au-brand h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.05; }
.au-brand p { margin: 0; font-size: 17px; opacity: 0.92; max-width: 34ch; }
.au-brand ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; max-width: 42ch; }
.au-brand li { padding-left: 22px; position: relative; }
.au-brand li::before { content: ''; position: absolute; left: 0; top: 0.55em; width: 10px; height: 10px; border-radius: 3px; background: var(--accent-ink); opacity: 0.85; }
.au-mark { width: 48px; height: 48px; border-radius: 13px; background: var(--accent-ink); color: var(--accent); }
.au-mark .ic { width: 28px; height: 28px; }
.au-free { font-size: 13.5px !important; opacity: 0.8 !important; margin-top: 10px !important; }
.au-card { background: var(--surface); padding: 48px clamp(20px, 5vw, 64px); display: grid; align-content: center; gap: 4px; max-width: 560px; width: 100%; justify-self: center; }
.au-card h2 { font-size: 24px; margin: 6px 0 10px; }
.au-tabs { margin-bottom: 4px; }
.au-wide { width: 100%; min-height: 48px; font-size: 15.5px; margin-top: 4px; }
.au-google { background: var(--surface); gap: 10px; }
.au-google .ic { width: 20px; height: 20px; }
.au-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 14px 0 8px; }
.au-or::before, .au-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.au-phone { display: flex; align-items: stretch; }
.au-cc { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line); border-right: 0; border-radius: 7px 0 0 7px; background: var(--surface2); color: var(--muted); font-variant-numeric: tabular-nums; }
.au-phone input { border-radius: 0 7px 7px 0 !important; }
.au-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.au-links .linkish, .au-terms .linkish { color: var(--accent); font-weight: 600; }
.au-terms { margin-top: 18px; }
.au-onb { grid-column: 1 / -1; max-width: 640px; }
.acct { display: grid; gap: 6px; }
.acct-who { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct .btn .ic { width: 16px; height: 16px; }
@media (max-width: 899px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .au-brand { padding: calc(28px + var(--sat)) 20px 24px; margin-top: calc(-1 * var(--sat)); gap: 8px; }
  .au-brand h1 { font-size: 26px; }
  .au-brand p { font-size: 15px; }
  .au-brand ul, .au-free { display: none; }
  .au-card { padding: 24px 20px calc(32px + var(--sab)); align-content: start; }
}
@media (max-width: 1099px) and (min-width: 700px) { .acct-who { display: none; } }

/* ---------- customer portal ---------- */
.portal { display: grid; gap: 12px; }
.portal-frame { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.p-head h2 { font-size: 22px; margin-top: 2px; }
.p-eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 600; }
.p-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.p-card h3 { font-size: 15px; margin: 0 0 8px; }
.p-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.p-row:last-child { border-bottom: 0; }
.p-due { background: var(--surface2); border-radius: 8px; padding: 2px 10px; margin-bottom: 8px; }
.p-owed { display: grid; gap: 2px; background: var(--accent-soft); color: var(--ink); border-radius: 10px; padding: 12px 14px; }
.p-owed b { font-family: var(--f-display); font-size: 24px; color: var(--accent); }
.p-foot { color: var(--muted); font-size: 12.5px; }

/* ---------- tablet: icon rail ---------- */
@media (max-width: 1099px) and (min-width: 700px) {
  .board { grid-template-columns: repeat(5, minmax(210px, 1fr)); }
  .app { grid-template-columns: 84px minmax(0, 1fr); }
  .rail { padding: 14px 8px; align-items: stretch; }
  .brand { justify-content: center; padding: 2px 0 12px; }
  .brand-t, .rail-foot .lbl-l, .sync { display: none; }
  .nav button { flex-direction: column; gap: 3px; padding: 8px 2px; font-size: 11px; text-align: center; min-height: 54px; }
  .nav button .lbl-l { display: none; }
  .nav button .lbl-s { display: block; }
  .nav .badge { position: absolute; top: 4px; right: 10px; font-size: 10px; padding: 0 5px; }
  .rail-foot { padding: 8px 0; }
  .rail-foot .btn { padding: 8px; }
  .main { padding: 20px 22px 40px; }
}

/* ---------- phone: app bar + bottom tabs, cards, sheets ---------- */
@media (max-width: 699px) {
  body { font-size: 15px; }
  .app { display: block; }
  .rail { display: none; }
  .appbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding: calc(8px + var(--sat)) 12px 8px 16px; margin-top: calc(-1 * var(--sat)); }
  .appbar .mark { width: 30px; height: 30px; border-radius: 8px; }
  .appbar-t { flex: 1; min-width: 0; display: grid; }
  .appbar-t b { font-family: var(--f-display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .appbar-t span { font-size: 12px; color: var(--muted); }
  .bottombar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--sab)); }
  .bottombar button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 6px 0; min-height: 52px; position: relative; cursor: pointer; border-radius: 8px; }
  .bottombar button[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .bottombar button[aria-current="page"] .ic { background: var(--accent-soft); border-radius: 12px; width: 44px; padding: 0 12px; box-sizing: content-box; margin: 0 -12px; }
  .bottombar .badge { position: absolute; top: 2px; left: calc(50% + 6px); font-size: 10px; padding: 0 5px; }
  .main { padding: 16px 16px calc(var(--bar-h) + 96px + var(--sab)); }
  .head { margin-bottom: 14px; }
  .head h1 { font-size: 23px; }
  .head .actions { width: 100%; }
  .head .actions .btn { flex: 1; min-height: 44px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; }
  .tile .v { font-size: 21px; }
  .card { padding: 14px; }
  .btn { min-height: 42px; }
  .btn.small { min-height: 34px; padding: 5px 11px; }
  .toolbar input { max-width: none; flex: 1 1 100%; }
  .toolbar input, .toolbar select, .field input, .field select, .field textarea { font-size: 16px; min-height: 44px; }
  .toast { bottom: calc(var(--bar-h) + 14px + var(--sab)); }
  .clamp { max-width: none; }
  .fab { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(var(--bar-h) + 16px + var(--sab)); width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); z-index: 31; cursor: pointer; }
  .fab .ic { width: 26px; height: 26px; }
  .fab[aria-expanded="true"] .ic { transform: rotate(45deg); }
  .head .actions .qa { display: none; }
  .tiles { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; margin: 0 -16px 14px; padding: 0 16px 4px; scrollbar-width: none; }
  .tiles::-webkit-scrollbar { display: none; }
  .tiles > .tile { flex: 0 0 46%; scroll-snap-align: start; min-height: 112px; }
  .foot-sub { width: 100%; margin: 0; }
  .foot-sub .btn { flex: 1; }
  .paybox .qr { width: 112px; height: 112px; }
  .toast { bottom: calc(var(--bar-h) + 84px + var(--sab)); }

  .board { grid-template-columns: repeat(5, 82%); margin: 0 -14px; padding: 0 14px 8px; scroll-padding: 0 14px; }
  .board-card h2 .small { display: none; }
  .row-end { flex-wrap: wrap; justify-content: flex-end; }

  /* responsive tables → cards */
  .rt thead { display: none; }
  .rt, .rt tbody { display: block; }
  .rt tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 14px; border-bottom: 1px solid var(--line); }
  .rt tbody tr:last-child { border-bottom: 0; }
  .rt td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .rt td.r { text-align: left; }
  .rt td::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 1px; }
  .rt td.lead, .rt td.wide, .rt td.nolabel { grid-column: 1 / -1; }
  .rt td.lead { font-size: 15.5px; }
  .rt td.lead::before, .rt td.nolabel::before { display: none; }
  .rt td:empty { display: none; }
  .rt tr.none { display: block; }
  .rt tr.none td::before { display: none; }
  tbody tr.click:active { background: var(--surface2); }
  tbody tr.click:hover td { background: none; }

  /* modal → bottom sheet */
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { width: 100%; border-radius: 16px 16px 0 0; border-bottom: 0; padding: 18px 16px calc(18px + var(--sab)); max-height: calc(100dvh - 24px - var(--sat)); overflow-y: auto; overscroll-behavior: contain; }
  .modal > h2 { font-size: 19px; position: sticky; top: -18px; background: var(--surface); padding: 10px 0 8px; margin: -10px 0 8px; z-index: 1; }
  .modal .foot { position: sticky; bottom: calc(-18px - var(--sab)); background: var(--surface); padding: 10px 0 calc(10px + var(--sab)); margin: 12px 0 calc(-18px - var(--sab)); border-top: 1px solid var(--line); }
  .modal .foot .btn { flex: 1 1 auto; }
  .modal .foot .grow { display: none; }
  .totals { max-width: none; }
  .sheet-ov { align-items: flex-end; }
  .sheet-more { display: grid; width: 100%; background: var(--surface); border-radius: 16px 16px 0 0; padding: 8px 10px calc(var(--bar-h) + 12px + var(--sab)); gap: 2px; }
  .sheet-more .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; }
  .sheet-more button { display: flex; align-items: center; gap: 14px; background: none; border: 0; padding: 12px; border-radius: 10px; font-size: 15.5px; color: var(--ink); cursor: pointer; text-align: left; min-height: 50px; }
  .sheet-more button span { flex: 1; }
  .sheet-more button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .sheet-ov { z-index: 25; }
}
@media (max-width: 380px) { .tiles > .tile { flex-basis: 62%; } }
@media (prefers-reduced-motion: reduce) { .switch span, .switch span::after { transition: none; } }

/* ---------- print: only the invoice ---------- */
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  body { background: #fff; }
  @page { margin: 12mm; }
}
