:root {
  --bg: #f5f3f9;
  --card: #ffffff;
  --ink: #1b1530;
  --ink-2: #463f5c;
  --muted: #6b6484;
  --line: #e2dcee;
  --brand: #2f1160;
  --brand-2: #5b21b6;
  --brand-soft: #efe8fb;
  --track: #e2d8f6;
  --focus: #8b5cf6;
  --ok: #0f7a4f;   --ok-bg: #e2f5eb;
  --warn: #8f5200; --warn-bg: #fff1d6;
  --bad: #b42318;  --bad-bg: #fde8e7;
  --bad-solid: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #110b1b;
    --card: #1b1328;
    --ink: #f3effa;
    --ink-2: #d4cae6;
    --muted: #a296ba;
    --line: #32274a;
    --brand: #26104a;
    --brand-2: #7c4ddb;
    --brand-soft: #2a1d40;
    --track: #34255a;
    --ok: #63d69e;   --ok-bg: #11301f;
    --warn: #f2b44f; --warn-bg: #33240c;
    --bad: #ff8b80;  --bad-bg: #3b1517;
    color-scheme: dark;
  }
}

* { 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;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.noscroll { overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--brand-2); }
button { font-family: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- header, tabs ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: #fff; }
.top img { border-radius: 6px; flex: none; }
.top-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.top-text small { opacity: .85; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sync.ok { background: #4ade80; }
.sync.down { background: #f87171; }
.offline { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 12; margin: 0; padding: 10px 16px; background: var(--bad-solid); color: #fff; font-weight: 700; font-size: 15px; text-align: center; }
#view { max-width: 720px; margin: 0 auto; padding: 0 16px 90px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; min-height: 60px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: 600 12px system-ui, sans-serif; color: var(--muted); cursor: pointer; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--brand-2); }

/* ---------- people list ---------- */
.tools { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 8px; }
.search { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 2px 0 14px; }
.search:focus-within { border-color: var(--brand-2); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font-size: 17px; padding: 12px 0; }
.search input::-webkit-search-cancel-button { display: none; }
.chips-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.chips { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink-2); font: 600 14px system-ui, sans-serif; cursor: pointer; }
.chip b { color: var(--muted); font-weight: 600; margin-left: 2px; }
.chip.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.chip.on b { color: rgba(255, 255, 255, .85); }
#sort { flex: none; max-width: 40%; min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink-2); font-size: 14px; }
.banner { margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--brand-soft); font-weight: 600; font-size: 15px; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { width: 100%; min-height: 66px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; background: var(--card); color: inherit; border: 1px solid var(--line); border-radius: 14px; font: inherit; cursor: pointer; }
.row:active { background: var(--brand-soft); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-name { font-weight: 700; font-size: 17px; }
.row-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.here-count { font-size: 13px; color: var(--muted); }
.here-count.some { color: var(--warn); font-weight: 600; }
.here-count.all { color: var(--ok); font-weight: 700; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--ink-2); font-weight: 700; font-size: 13px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 8; border: 0; border-radius: 999px; padding: 14px 22px; background: var(--brand-2); color: #fff; font: 800 17px system-ui, sans-serif; box-shadow: 0 6px 18px rgba(40, 10, 80, .35); cursor: pointer; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: 700 16px system-ui, sans-serif; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 8px 12px; font-size: 15px; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--brand-2); }
.btn.here { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.btn.danger-ghost { background: transparent; border-color: var(--bad-bg); color: var(--bad); margin-top: 4px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: none; color: inherit; font-size: 20px; cursor: pointer; }
.icon.sm { width: 36px; height: 36px; font-size: 15px; color: var(--muted); }
.icon:disabled { opacity: .3; cursor: default; }
.linkish { display: block; margin: -4px 0 12px; padding: 6px 0; border: 0; background: none; color: var(--brand-2); font: 600 15px system-ui, sans-serif; text-align: left; text-decoration: underline; cursor: pointer; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(15, 5, 30, .5); }
.sheet-panel { width: 100%; max-width: 600px; height: 100%; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); }
@media (min-width: 640px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-panel { height: auto; max-height: calc(100vh - 48px); border-radius: 18px; }
}
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 10px 6px 6px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { padding: 14px 16px calc(32px + env(safe-area-inset-bottom)); }
.sheet-body section { margin: 0 0 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.sheet-body section.collect { border: 2px solid var(--warn); }
.sheet-body h3, .card h3, .form h3 { margin: 0 0 10px; font-size: 16px; }
.status { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; padding: 14px; border-radius: 14px; }
.status b { font-size: 22px; }
.status span { font-size: 14px; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.bad { background: var(--bad-bg); color: var(--bad); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.sec-head h3 { margin: 0; }
.guests, .pays, .users, .log { list-style: none; margin: 0; padding: 0; }
.guest, .pays li, .users li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.guest:first-child, .pays li:first-child, .users li:first-child { border-top: 0; }
.g-text, .pays li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.g-text small, .pays small { color: var(--muted); font-size: 13px; }
.guest.in .g-text b { color: var(--ok); }
.notes { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 10px 12px; }

.bill .bl { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; font-size: 15px; }
.bill .bl small { color: var(--muted); }
.bill .tot { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 700; }
.bill .bal b { font-size: 18px; }
.bill .bal.owe { color: var(--bad); }
.stepper { display: inline-flex; align-items: center; margin: 0 4px; vertical-align: middle; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 40px; height: 36px; border: 0; background: none; color: var(--brand-2); font: 700 20px system-ui, sans-serif; cursor: pointer; }
.stepper button:disabled { color: var(--line); cursor: default; }
.stepper output { min-width: 28px; text-align: center; font-weight: 700; }

.pay { display: flex; flex-direction: column; gap: 10px; }
.pay-row { display: flex; gap: 8px; align-items: stretch; }
.money-in { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.money-in:focus-within { border-color: var(--brand-2); }
.money-in span { color: var(--muted); font-weight: 700; font-size: 20px; }
.money-in input { width: 100%; min-width: 0; padding: 8px 6px; border: 0; outline: 0; background: none; color: var(--ink); font: 700 22px system-ui, sans-serif; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; min-height: 42px; padding: 10px 4px; text-align: center; background: var(--card); color: var(--ink-2); border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 15px; cursor: pointer; }
.seg input:checked + span { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .login-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.form label small, .lbl small { font-weight: 400; color: var(--muted); }
.form input:not([type=radio]):not([type=checkbox]), .form textarea, .form select, .pay input[name=ref], .login-card input, .eg select {
  width: 100%; min-height: 46px; padding: 11px 12px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; font: 16px system-ui, sans-serif;
}
.form textarea { resize: vertical; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 16px; color: var(--ink); }
.check input { width: 22px; height: 22px; accent-color: var(--brand-2); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lbl { display: flex; flex-direction: column; font-weight: 600; font-size: 15px; }
.total-row b { font-size: 24px; }
.warn-text { margin: 0; color: var(--bad); font-weight: 600; font-size: 14px; }
.warn-text:empty { display: none; }
.guest-inputs { display: flex; flex-direction: column; gap: 6px; }
.form label.gi { flex-direction: row; align-items: center; gap: 8px; }
.gi span { width: 22px; text-align: right; color: var(--muted); font-weight: 600; }
fieldset.paid-now { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
legend { padding: 0 6px; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.eg { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.eg input { flex: 1; min-width: 0; }
.form .eg select { width: auto; flex: none; padding: 11px 6px; }
.form .eg.in input { border-color: var(--ok); }

/* ---------- totals ---------- */
.view-title { margin: 16px 0 12px; font-size: 22px; }
.hero-fig { display: flex; flex-direction: column; margin: 16px 0 12px; padding: 18px; background: var(--brand); color: #fff; border-radius: 16px; }
.hero-fig small { font-weight: 600; opacity: .9; }
.hero-fig b { font-size: 52px; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; }
.hero-fig span { font-size: 15px; opacity: .9; }
.card { margin: 0 0 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; }
.meter-head b { font-size: 20px; }
.meter { height: 12px; border-radius: 6px; background: var(--track); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 6px; background: var(--brand-2); }
.meter.over span { background: var(--bad); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { display: flex; flex-direction: column; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.tile small { color: var(--muted); font-weight: 600; font-size: 13px; }
.tile b { font-size: 26px; font-weight: 800; }
.tile span { color: var(--muted); font-size: 13px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl td { padding: 8px 0; border-top: 1px solid var(--line); }
.tbl tr:first-child td { border-top: 0; }
.tbl .tot td { font-weight: 800; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- activity, more ---------- */
.log li { display: flex; flex-direction: column; margin-bottom: 6px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.log li small { color: var(--muted); font-size: 13px; }
.log li.click { cursor: pointer; }
.menu { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.menu-item { display: flex; flex-direction: column; padding: 14px 16px; text-align: left; background: none; color: var(--ink); border: 0; border-top: 1px solid var(--line); font: 600 16px system-ui, sans-serif; text-decoration: none; cursor: pointer; }
.menu-item:first-child { border-top: 0; }
.menu-item small { color: var(--muted); font-weight: 400; font-size: 13px; }
.menu-item.danger { color: var(--bad); }

/* ---------- login, toast ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--brand); }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--card); border-radius: 18px; }
.login-card img { align-self: center; border-radius: 14px; }
.login-card h1 { margin: 0; text-align: center; font-size: 24px; }
.login-card p.muted { margin: 0; text-align: center; }
.form-err { margin: 0; color: var(--bad); font-weight: 600; }
.form-err:empty { display: none; }
.toast { position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; max-width: calc(100% - 32px); padding: 12px 18px; background: #1f1530; color: #fff; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast.bad { background: var(--bad-solid); }

/* meter fill widths in 5% steps (CSP blocks inline style attributes) */
.w0{width:0}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}.w30{width:30%}
.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}.w55{width:55%}.w60{width:60%}.w65{width:65%}
.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}.w90{width:90%}.w95{width:95%}.w100{width:100%}

/* ---------- printable check-in list ---------- */
body.print-page { padding: 16px; background: #fff; color: #000; font: 13px/1.35 system-ui, sans-serif; color-scheme: light; }
.print-page h1 { margin: 0 0 4px; font-size: 18px; }
.print-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.print-bar a { color: #2f1160; }
.print-table { width: 100%; border-collapse: collapse; }
.print-table th, .print-table td { padding: 6px 8px; border: 1px solid #999; text-align: left; vertical-align: top; }
.print-table ul { list-style: none; margin: 0; padding: 0; }
.print-table li { margin: 2px 0; }
.print-table .num { text-align: center; }
.box { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border: 1.5px solid #000; text-align: center; line-height: 12px; font-size: 12px; vertical-align: -2px; }
.owes { color: #b42318; }
@media print {
  .print-bar { display: none; }
  body.print-page { padding: 0; }
  .print-table tr { break-inside: avoid; }
}

/* the amount box keeps its own look inside forms */
.form label.money-in { flex-direction: row; align-items: center; gap: 0; }
.form label.money-in input:not([type=radio]) { min-height: 0; padding: 8px 6px; border: 0; background: none; font: 700 22px system-ui, sans-serif; }
.field-row .seg { flex: 0 1 250px; }
.seg span { white-space: nowrap; }
