/* SplitBill consumer app — mobile-first, self-contained (no external assets).
   Shares the brand palette with the merchant surfaces but is a separate file:
   consumer styling can change without touching the POS demo. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #17272e;
  --ink-2: #51626b;
  --ink-3: #8a979e;
  --line: #e5e2d9;
  --line-2: #efece4;
  --brand: #14833b;
  --brand-dark: #0e5931;
  --brand-soft: #e9f5ec;
  --brand-bright: #70cf2a;
  --accent: #ff791a;
  --accent-dark: #c85a08;
  --accent-soft: #ffeede;
  --good: #1c7c4d;
  --good-soft: #e6f3ec;
  --warn: #935d0c;
  --warn-soft: #f9efdd;
  --bad: #b3261e;
  --bad-soft: #f9e9e8;
  --info: #34539c;
  --info-soft: #e9eef8;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(23, 39, 46, 0.05), 0 8px 24px rgba(23, 39, 46, 0.06);
  --tap: 44px; /* minimum touch target */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { line-height: 1.22; margin: 0 0 .35em; letter-spacing: -0.01em; }
h1 { font-size: 25px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }
a { color: var(--brand); }
small, .muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.amount { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.noscript { padding: 24px; text-align: center; }

/* App shell: phone-width column on larger screens */
.app-shell { display: flex; justify-content: center; min-height: 100dvh; }
.view {
  width: 100%; max-width: 480px; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg); outline: none;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
@media (min-width: 560px) {
  .view { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.screen { display: flex; flex-direction: column; flex: 1; padding: 16px 16px 28px; gap: 12px; }
.screen-scroll { flex: 1; }

/* Top bar */
.cbar { display: flex; align-items: center; gap: 10px; padding: 4px 0 6px; min-height: 44px; }
.cbar .spacer { flex: 1; }
.cbar .title { font-weight: 750; font-size: 17px; letter-spacing: -0.01em; }
.logo-row { display: flex; align-items: center; gap: 9px; }
.logo-row img { width: 34px; height: 34px; }
.wordmark { font-weight: 800; font-size: 20px; color: var(--brand-dark); letter-spacing: -0.015em; }
.wordmark .wm-bill { color: var(--accent); }

/* Buttons — generous tap targets */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  border-radius: var(--radius-s); padding: 10px 16px;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-danger { color: var(--bad); border-color: #ecc7c4; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-lg { min-height: 54px; font-size: 17px; border-radius: 13px; width: 100%; }
.btn-sm { min-height: 36px; padding: 5px 12px; font-size: 14px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--line-2); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.card-tight { padding: 12px 14px; }

/* Forms */
input[type='text'], input[type='number'], input[type='date'], input[type='search'], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 11px 12px; width: 100%; min-height: var(--tap);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.field { display: block; font-size: 13.5px; font-weight: 650; color: var(--ink-2); margin: 8px 0 4px; }
.input-uncertain { border-color: var(--warn); background: var(--warn-soft); }

/* Keyboard focus ring. Declared after the form rules so it wins for every
   control type — a keyboard user always gets the strong high-contrast ring. */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--info); outline-offset: 2px; border-radius: 6px;
}

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 650; letter-spacing: .015em;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.pill-good { color: var(--good); background: var(--good-soft); }
.pill-warn { color: var(--warn); background: var(--warn-soft); }
.pill-bad { color: var(--bad); background: var(--bad-soft); }
.pill-info { color: var(--info); background: var(--info-soft); }
.pill-neutral { color: var(--ink-2); background: var(--line-2); }
.pill-accent { color: var(--accent-dark); background: var(--accent-soft); }

/* Home hero */
.hero { text-align: center; padding: 40px 8px 8px; }
.hero .tagline { font-size: 16.5px; color: var(--ink-2); margin: 6px 0 0; }
.hero-art { display: block; width: 128px; height: 128px; margin: 0 auto 12px; }

/* Room code entry */
.code-input {
  text-transform: uppercase; text-align: center; letter-spacing: .35em;
  font-family: ui-monospace, Menlo, monospace; font-size: 22px; font-weight: 700;
}
.code-big {
  font-family: ui-monospace, Menlo, monospace; font-size: 34px; font-weight: 800;
  letter-spacing: .28em; text-align: center; color: var(--brand-dark); padding-left: .28em;
}

/* Avatars */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: #fff; background: var(--brand);
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.avatar-sm { width: 26px; height: 26px; font-size: 13px; border-width: 1.5px; }
.avatar-btn { border: 2px solid var(--line); background: var(--surface); cursor: pointer; width: var(--tap); height: var(--tap); border-radius: 50%; font-size: 22px; }
.avatar-btn[aria-pressed='true'] { border-color: var(--brand); background: var(--brand-soft); }

/* Participants strip */
.people { display: flex; gap: 12px; overflow-x: auto; padding: 6px 2px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; position: relative; }
.person .name { font-size: 12px; font-weight: 650; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .share { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.person .done-check {
  position: absolute; top: -3px; right: 6px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--good); color: #fff; font-size: 11px; line-height: 17px; text-align: center;
  border: 2px solid var(--bg);
}
.person button { all: unset; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.person.acting .avatar { outline: 3px solid var(--accent); }

/* Bill lines */
.bill-lines { display: flex; flex-direction: column; }
.bline {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 12px; border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.bline:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.bline:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.bline:only-child { border-radius: var(--radius); }
.bline-top { display: flex; align-items: baseline; gap: 8px; }
.bline-desc { font-weight: 650; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bline-state { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 24px; }
.bline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bline.mine { box-shadow: inset 3px 0 0 var(--brand); }
.bline.taken { background: var(--surface-2); }
.bline.is-shared { box-shadow: inset 3px 0 0 var(--info); }

/* Qty stepper */
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.stepper button {
  width: var(--tap); height: 40px; border: 0; background: var(--surface);
  font-size: 20px; font-weight: 700; cursor: pointer; color: var(--brand-dark);
}
.stepper button:disabled { color: var(--ink-3); cursor: not-allowed; }
.stepper .qty { min-width: 44px; text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Share chips */
.chips { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 650;
  background: var(--line-2); border-radius: 999px; padding: 3px 9px 3px 4px;
}

/* Sticky footer bar */
.footbar {
  position: sticky; bottom: 0; margin-top: auto;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.footbar .rowline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.foot-total { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Banners */
.banner { border-radius: var(--radius-s); padding: 10px 14px; font-weight: 650; display: flex; gap: 8px; align-items: center; font-size: 14.5px; }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-good { background: var(--good-soft); color: var(--good); }
.banner-info { background: var(--info-soft); color: var(--info); }
.banner-bad { background: var(--bad-soft); color: var(--bad); }

/* Bottom sheets */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(23, 39, 46, 0.42);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(23, 39, 46, 0.18);
}
.sheet .grab { width: 42px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { display: flex; align-items: center; gap: 8px; }

/* Tip presets */
.tip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tip-grid .btn[aria-pressed='true'] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }

/* Review editor */
.editor-line { display: grid; grid-template-columns: 1fr 84px; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.editor-line .full { grid-column: 1 / -1; }
.editor-row2 { display: flex; gap: 8px; align-items: center; }
.editor-row2 select { width: auto; flex: 1; }
.editor-row2 input.qty-in { width: 74px; text-align: center; }
.editor-row2 input.money-in { width: 108px; text-align: right; font-variant-numeric: tabular-nums; }
.totals-panel .rowline { display: flex; justify-content: space-between; padding: 3px 0; }
.totals-panel .grand { font-size: 18px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }

/* Receipt photo preview */
.photo-preview { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); max-height: 46dvh; object-fit: contain; background: #222; }
.photo-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* QR block */
.qr-box { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); padding: 14px; display: flex; justify-content: center; }
.qr-box img { width: min(64vw, 300px); height: auto; }

/* Summary */
.summary-lines { display: flex; flex-direction: column; }
.summary-lines .rowline { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.summary-lines .rowline:last-child { border-bottom: 0; }
.summary-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 21px; font-weight: 800; padding-top: 10px; border-top: 2px solid var(--ink); margin-top: 6px; }

/* Sponsor card — clearly labelled, below the bill, never obscuring it */
.sponsor-card { border: 1px dashed var(--line); background: var(--surface-2); }
.sponsor-tag { font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.sponsor-row { display: flex; gap: 12px; align-items: center; }
.sponsor-logo { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--line-2); flex: none; }

/* Toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 420px); }
.toast {
  background: var(--ink); color: #fff; border-radius: 12px; padding: 11px 16px;
  font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow); text-align: center;
  animation: toast-in .18s ease-out;
}
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Skeletons & spinners (no fake percentages) */
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, var(--line-2), var(--surface-2), var(--line-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.rowflex { display: flex; align-items: center; gap: 10px; }
.rowflex .spacer { flex: 1; }

/* Celebration */
.celebrate { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.92); opacity: .4; } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }

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