/* Bill Split: neubrutalism (thick ink outlines, hard offset shadows, flat bold colour).
   Based on the Split Bill (Adis & Yuda) design. People get colours c0..c5 in list order;
   the Bill Split additions are at the bottom of this file. */

/* ------------------------------------------------------------ tokens */
:root {
  --paper: #fbf7ef;         /* app sheet */
  --surface: #ffffff;       /* cards, inputs */
  --sunk: #f3eee3;          /* inset areas */
  --text: #121212;
  --muted: #5f5b53;
  --ink: #121212;           /* outlines */
  --shadow: #121212;        /* hard shadows */
  --backdrop: #ffcf26;      /* page behind the sheet on wide screens */

  --yellow: #ffcf26;
  --pink: #ff5a87;
  --purple: #7b61ff;
  --green: #3fca45;
  --lime: #b5e93a;
  --peach: #ffdf96;
  --gray: #a3a19c;
  --red: #e5383b;
  --on-color: #121212;      /* text on any accent colour */

  --pink-soft: #ffe1ea;
  --purple-soft: #e6e0ff;
  --yellow-soft: #fff1bf;
  --green-soft: #dcf6dc;

  --bw: 2.5px;              /* border width */
  --r: 14px;                /* card radius */
  --r-sm: 10px;
  --sh: 4px 4px 0 var(--shadow);
  --sh-lg: 6px 6px 0 var(--shadow);
  --sh-sm: 2px 2px 0 var(--shadow);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* dark: same ink outlines on a deep violet-grey, accents stay bright */
:root[data-theme="dark"] {
  --paper: #23212b;
  --surface: #2f2c39;
  --sunk: #1b1a21;
  --text: #f5f0e6;
  --muted: #b3ada3;
  --ink: #0b0a0e;
  --shadow: #0b0a0e;
  --backdrop: #15141a;
  --pink-soft: #4a2a37;
  --purple-soft: #352d5c;
  --yellow-soft: #4a4126;
  --green-soft: #26442a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #23212b;
    --surface: #2f2c39;
    --sunk: #1b1a21;
    --text: #f5f0e6;
    --muted: #b3ada3;
    --ink: #0b0a0e;
    --shadow: #0b0a0e;
    --backdrop: #15141a;
    --pink-soft: #4a2a37;
    --purple-soft: #352d5c;
    --yellow-soft: #4a4126;
    --green-soft: #26442a;
  }
}

/* ------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 500 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
input, select, button, textarea { font: inherit; color: inherit; }
.num, .money { font-variant-numeric: tabular-nums; }

/* Normal website width on computers, full-width stack on phones. */
.app { max-width: 1240px; margin: 0 auto; padding: 14px 16px 48px; }
@media (min-width: 720px) { .app { padding: 22px 32px 64px; } }

/* ------------------------------------------------------------ icons */
.icon { display: inline-flex; width: 1.25em; height: 1.25em; flex: none; }
.icon svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------ top bar */
/* horizontal nav bar: brand left, page links + theme switch right */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.topbar nav { display: flex; gap: 10px; margin-left: auto; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.brand .tile { width: 46px; height: 46px; box-shadow: var(--sh-sm); }
.navlink { min-height: 50px; }
.navlink.active { background: var(--yellow); color: var(--on-color); }
@media (max-width: 719px) {
  .brand .word { display: none; }
  .navlink { width: 50px; padding: 0; }
  .navlink .lbl { display: none; }
}

/* square icon buttons (gear / folder / search in the reference) */
.sq {
  display: inline-grid; place-items: center;
  width: 50px; height: 50px; padding: 0;
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--ink); border-radius: 13px;
  box-shadow: var(--sh); cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.sq .icon { width: 24px; height: 24px; }
.sq.active { background: var(--yellow); color: var(--on-color); }
.sq.sm { width: 34px; height: 34px; border-radius: 9px; border-width: 2px; box-shadow: var(--sh-sm); }
.sq.sm .icon { width: 17px; height: 17px; }
.sq.xs { width: 28px; height: 28px; border-radius: 8px; border-width: 2px; box-shadow: none; }
.sq.xs .icon { width: 15px; height: 15px; }
.sq.danger { color: var(--red); }

/* ------------------------------------------------------------ type */
.hero {
  font-size: clamp(40px, 11.5vw, 64px); line-height: .98; font-weight: 800;
  letter-spacing: -.035em; margin: 0 0 22px;
}
.section {
  display: flex; align-items: center; gap: 8px;
  font-size: 21px; font-weight: 800; letter-spacing: -.01em; margin: 30px 0 14px;
}
.section .count { font-size: 14px; font-weight: 600; color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; margin: -6px 0 12px; }
.status { min-height: 1.3em; margin: 10px 2px 0; font-size: 15px; font-weight: 600; }
.status:empty { min-height: 0; margin: 0; }
.status a { font-weight: 700; }
.status.error, .error { color: var(--red); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px;
  background: var(--surface); color: var(--text);
  border: var(--bw) solid var(--ink); border-radius: 12px;
  box-shadow: var(--sh); font-weight: 700; cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.btn.sm { min-height: 36px; padding: 0 11px; font-size: 14px; border-width: 2px; border-radius: 9px; box-shadow: var(--sh-sm); }
.btn.big { min-height: 58px; font-size: 19px; font-weight: 800; padding: 0 22px; }
.btn.block { width: 100%; }
.btn.yellow { background: var(--yellow); color: var(--on-color); }
.btn.pink { background: var(--pink); color: var(--on-color); }
.btn.purple { background: var(--purple); color: var(--on-color); }
.btn.green { background: var(--green); color: var(--on-color); }
.btn.danger { color: var(--red); }
.btn .icon { width: 20px; height: 20px; }
.btn.sm .icon { width: 16px; height: 16px; }

@media (hover: hover) {
  .btn:hover, .sq:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
  .btn.sm:hover, .sq.sm:hover { box-shadow: 3px 3px 0 var(--shadow); }
  .sq.xs:hover { transform: none; box-shadow: none; background: var(--sunk); }
}
.btn:active, .sq:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.sq.xs:active { transform: translate(1px, 1px); }
.btn:disabled { opacity: .55; cursor: progress; }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }

/* ------------------------------------------------------------ cards */
.card {
  position: relative;
  background: var(--surface);
  border: var(--bw) solid var(--ink); border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: 16px;
}
.card + .card { margin-top: 18px; }

/* folder-tab card: a coloured tab peeking out above the top-left corner */
.folders { isolation: isolate; }
.folder { margin-top: 20px; }
.folder::before {
  content: ""; position: absolute; z-index: -1;
  left: 10px; top: -17px; width: 46%; height: 30px;
  background: var(--tab, var(--gray));
  border: var(--bw) solid var(--ink); border-radius: 9px 14px 0 0;
}
.tab-pink { --tab: var(--pink); }
.tab-purple { --tab: var(--purple); }
.tab-yellow { --tab: var(--yellow); }
.tab-green { --tab: var(--green); }
.tab-lime { --tab: var(--lime); }
.tab-peach { --tab: var(--peach); }
.tab-gray { --tab: var(--gray); }

/* coloured icon tile (like the folder / bolt / book squares) */
.tile {
  display: inline-grid; place-items: center; flex: none;
  width: 56px; height: 56px;
  background: var(--tile, var(--gray)); color: var(--on-color);
  border: var(--bw) solid var(--ink); border-radius: 11px;
}
.tile .icon { width: 28px; height: 28px; }
.tile.sm { width: 40px; height: 40px; border-radius: 9px; }
.tile.sm .icon { width: 21px; height: 21px; }
.tile.pink { --tile: var(--pink); }
.tile.purple { --tile: var(--purple); }
.tile.yellow { --tile: var(--yellow); }
.tile.green { --tile: var(--green); }
.tile.lime { --tile: var(--lime); }
.tile.peach { --tile: var(--peach); }
.tile.gray { --tile: var(--gray); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  background: var(--pink); color: #fff;
}
.badge.green { background: var(--green); color: var(--on-color); }
.badge.yellow { background: var(--yellow); color: var(--on-color); }

/* grid of folder cards (months, payers) */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.fcard { display: flex; flex-direction: column; gap: 14px; min-height: 150px; text-decoration: none; color: inherit; }
.fcard .top { display: flex; gap: 12px; align-items: flex-start; }
.fcard .meta { font-size: 14px; color: var(--muted); line-height: 1.5; padding-top: 4px; }
.fcard .name { margin-top: auto; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.fcard .sub { font-size: 13px; color: var(--muted); margin-top: -10px; }
@media (max-width: 380px) { .fcard .tile { width: 46px; height: 46px; } .fcard .name { font-size: 17px; } }

/* ------------------------------------------------------------ form controls */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.input, .field input, .field select, select.input {
  width: 100%; min-width: 0; height: 46px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 2px solid var(--ink); border-radius: var(--r-sm);
  font-size: 16px; font-weight: 600;
}
.input::placeholder { color: var(--muted); font-weight: 500; }
.input:focus, .field input:focus { outline: none; box-shadow: 3px 3px 0 var(--purple); }
input[type="date"], input[type="month"] { min-height: 46px; }
input[type="number"] { -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
:root[data-theme="dark"] input[type="date"], :root[data-theme="dark"] input[type="month"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input[type="date"], :root:not([data-theme="light"]) input[type="month"] { color-scheme: dark; }
}

.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.fields .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.fields label.field { min-width: 0; }

/* ------------------------------------------------------------ input page */
.scanbar { display: flex; gap: 14px; align-items: stretch; }
.scan-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px;
  min-height: 62px; padding: 0 16px;
  background: var(--surface); border: var(--bw) solid var(--ink); border-radius: 14px;
  box-shadow: var(--sh-lg); cursor: pointer; font-weight: 600; color: var(--muted);
  transition: transform .08s, box-shadow .08s;
}
.scan-field .lead { color: var(--text); width: 24px; height: 24px; }
.scan-field .trail { color: var(--text); margin-left: auto; width: 24px; height: 24px; }
.scan-field span.text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-field:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--shadow); }
.scan-field.busy { cursor: progress; background: var(--yellow-soft); color: var(--text); }
.scan-field.busy .trail { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sq.plus { width: 62px; height: 62px; border-radius: 14px; background: var(--yellow); color: var(--on-color); box-shadow: var(--sh-lg); }
.sq.plus .icon { width: 30px; height: 30px; }

/* who paid: two folder tiles acting as radio buttons */
.payer { cursor: pointer; min-height: 132px; }
.payer input { position: absolute; opacity: 0; pointer-events: none; }
.payer .check {
  position: absolute; right: 12px; top: 12px; width: 30px; height: 30px;
  display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%;
  background: var(--surface); color: transparent;
}
.payer .check .icon { width: 18px; height: 18px; }
/* no transform here: it would lift the folder tab above the card */
.payer:has(input:checked) { box-shadow: 3px 3px 0 var(--shadow); }
.payer.tab-pink:has(input:checked) { background: var(--pink-soft); }
.payer.tab-purple:has(input:checked) { background: var(--purple-soft); }
.payer:has(input:checked) .check { background: var(--green); color: var(--on-color); }
.payer:has(input:focus-visible) { outline: 3px solid var(--purple); outline-offset: 3px; }

.month-choice { display: flex; flex-wrap: wrap; gap: 8px; }
.month-choice:empty { display: none; }

/* item cards */
.item { padding: 14px; }
.item + .item, .charge-row + .charge-row { margin-top: 16px; }
.item.unassigned { box-shadow: 6px 6px 0 var(--pink); }
.item-top { display: flex; gap: 10px; align-items: center; }
/* phone: name + delete on row 1, qty × price on row 2 */
.item-body { display: grid; grid-template-columns: 64px auto minmax(0, 1fr) auto; gap: 10px 8px; align-items: center; }
.item-body .name { grid-column: 1 / 4; grid-row: 1; font-weight: 700; }
.item-body .del { grid-column: 4; grid-row: 1; }
.item-body .qty { grid-column: 1; grid-row: 2; text-align: center; }
.item-body .times { grid-column: 2; grid-row: 2; font-weight: 800; color: var(--muted); }
.item-body .price { grid-column: 3 / 5; grid-row: 2; }
.item-top .input { flex: 1; font-weight: 700; }
.item-nums { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.item-nums .qty { width: 64px; text-align: center; flex: none; }
.item-nums .price { flex: 1; }
.item-nums .times { font-weight: 800; color: var(--muted); }

.split { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; align-items: center; }
.split .chip { justify-content: center; padding: 0 6px; }
.split .ratio-inputs, .split .need-pick { grid-column: 1 / -1; }
@media (max-width: 400px) { .split .chip .icon { display: none; } }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 13px;
  background: var(--surface); color: var(--text);
  border: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--sh-sm);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.chip .icon { width: 17px; height: 17px; }
.chip.on { color: var(--on-color); transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.chip.adis.on { background: var(--pink); }
.chip.both.on { background: var(--yellow); }
.chip.yuda.on { background: var(--purple); }
.chip.ratio.on { background: var(--green); }
.ratio-inputs { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.ratio-inputs .input { width: 58px; height: 38px; text-align: center; padding: 0 4px; }
.ratio-inputs small { font-weight: 600; color: var(--muted); }
.need-pick { color: var(--pink); font-size: 13px; font-weight: 800; }

.shares { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; font-size: 13px; font-weight: 700; }
.shares:empty { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--sunk);
}
.pill.adis { background: var(--pink); color: var(--on-color); }
.pill.yuda { background: var(--purple); color: var(--on-color); }
.pill.total { background: var(--surface); }

.charge-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 64px auto; gap: 8px; align-items: center; padding: 12px; }
.charge-row select { padding: 0 6px; }
.charge-row .shares { grid-column: 1 / -1; margin-top: 2px; }
.editor .charge-row { grid-template-columns: minmax(0, 1fr) 84px 64px; }

.preview { background: var(--yellow); color: var(--on-color); margin-top: 28px; }
.preview .label { font-size: 14px; font-weight: 700; opacity: .75; }
.preview .total { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.preview .shares { margin-top: 10px; }
.preview .owe { margin-top: 12px; font-weight: 800; font-size: 17px; }
.preview.warn { background: var(--surface); color: var(--text); }
.preview.warn .msg { font-weight: 700; }
.preview.warn.bad .msg { color: var(--red); }

.save-bar { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.save-bar .grow { flex: 1 1 200px; }

/* ------------------------------------------------------------ recap page */
.month-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.month-head .hero { margin: 0; }
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  height: 46px; padding: 0 40px 0 14px; font-weight: 800;
  background: var(--surface); border: var(--bw) solid var(--ink); border-radius: 12px;
  box-shadow: var(--sh); cursor: pointer;
}
.select-wrap .icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }

.settle .who { display: flex; align-items: center; gap: 10px; }
.avatar {
  display: grid; place-items: center; width: 52px; height: 52px; flex: none;
  border: var(--bw) solid var(--ink); border-radius: 50%;
  font-size: 22px; font-weight: 800; color: var(--on-color);
}
.avatar.adis { background: var(--pink); }
.avatar.yuda { background: var(--purple); }
.settle .who .arrow { width: 34px; height: 34px; }
.settle .say { margin-top: 14px; font-size: 18px; font-weight: 700; }
.settle .amount { font-size: clamp(38px, 11vw, 60px); font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
.settle .paid-note { margin-top: 8px; font-size: 14px; font-weight: 700; }
.banner.is-paid { background: var(--green); }
.banner.is-paid .amount { text-decoration: line-through; text-decoration-thickness: 4px; }

/* paid toggle */
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative; width: 56px; height: 32px; flex: none;
  background: var(--surface); border: var(--bw) solid var(--ink); border-radius: 999px; box-shadow: var(--sh-sm);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  background: var(--ink); border-radius: 50%; transition: transform .15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(24px); }
.switch input:focus-visible + .track { outline: 3px solid var(--purple); outline-offset: 3px; }

/* payer header card */
.payer-head { display: flex; gap: 14px; align-items: center; }
.payer-head .title { font-size: 20px; font-weight: 800; }
.payer-head .meta { font-size: 14px; color: var(--muted); font-weight: 600; }
.payer-head .title, .payer-head .meta { white-space: nowrap; }

/* receipts */
.receipt { padding: 14px 14px 10px; }
.r-head { display: flex; gap: 12px; align-items: flex-start; }
.r-title { font-size: 18px; font-weight: 800; line-height: 1.2; }
.r-date { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.r-total { margin-left: auto; font-size: 18px; font-weight: 800; white-space: nowrap; }
.r-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; align-items: center; }
.r-actions .push { margin-left: auto; display: inline-flex; gap: 8px; }

.lines { margin-top: 6px; }
.line {
  display: grid; grid-template-columns: minmax(0, 1fr) 76px 68px 68px;
  gap: 4px; align-items: center; padding: 7px 0;
  border-top: 2px dashed color-mix(in srgb, var(--ink) 25%, transparent);
  font-size: 15px;
}
.line.head { border-top: 0; padding: 0 0 4px; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.line.head .a { color: var(--pink); }
.line.head .y { color: var(--purple); }
.line.charge { color: var(--muted); }
.line.total { border-top: var(--bw) solid var(--ink); font-weight: 800; padding-top: 9px; }
.line .n { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.line .n .pen { width: 14px; height: 14px; margin-left: 5px; vertical-align: -2px; color: var(--muted); opacity: .7; }
.line.tap { cursor: pointer; border-radius: 8px; }
@media (hover: hover) { .line.tap:hover { background: var(--sunk); } .line.tap:hover .pen { opacity: 1; color: var(--text); } }
.line.tap:active { background: var(--yellow-soft); }
.line.tap:focus-visible { outline-offset: 0; }
.tap-hint { font-size: 12px; color: var(--muted); font-weight: 600; margin: 4px 0 0; }
.line > .num { text-align: right; white-space: nowrap; }
.line .sub { display: block; width: 100%; font-size: 12px; color: var(--muted); font-weight: 600; }
@media (max-width: 420px) {
  .line { grid-template-columns: minmax(0, 1fr) 66px 58px 58px; font-size: 14px; }
}

.editor {
  margin: 8px -4px; padding: 12px;
  background: var(--sunk); border: 2px solid var(--ink); border-radius: 12px;
}
.editor .row { margin: 12px 0 0; }

.bayar .line { grid-template-columns: minmax(0, 1fr) auto; }
.bayar .line:first-child { border-top: 0; }

.empty { color: var(--muted); font-weight: 600; text-align: center; padding: 26px 10px; }

/* ------------------------------------------------------------ page layouts */

/* Yellow banner with the pink circle + purple shape from the reference, behind the content. */
.banner {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--yellow); color: var(--on-color);
  padding: 22px 20px; margin-bottom: 8px;
}
.banner::before {
  content: ""; position: absolute; z-index: -1;
  width: 150px; height: 150px; border-radius: 50%; border: var(--bw) solid var(--ink);
  background: var(--pink); right: -55px; top: -70px;
}
.banner::after {
  content: ""; position: absolute; z-index: -1;
  width: 210px; height: 110px; border: var(--bw) solid var(--ink);
  background: var(--purple); right: -80px; bottom: -75px; transform: rotate(-14deg);
}
.banner .hero { margin-bottom: 18px; }
.banner .btn, .banner .select-wrap select { color: var(--text); }
.banner .switch { color: var(--on-color); }
@media (min-width: 720px) {
  .banner { padding: 34px 36px; }
  .banner::before { width: 260px; height: 260px; right: -90px; top: -140px; }
  .banner::after { width: 400px; height: 170px; right: -150px; bottom: -120px; }
}

/* input page: form on the left, sticky summary on the right */
.input-banner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
@media (min-width: 980px) {
  .input-banner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 40px; }
  .input-banner .hero { margin: 0; }
}
.layout-input { display: grid; gap: 0 36px; }
@media (min-width: 980px) {
  .layout-input { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .layout-input .side { position: sticky; top: 20px; padding-top: 30px; }
  .layout-input .side .preview { margin-top: 0; }
  .who-receipt { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 0 28px; align-items: start; }
}
@media (min-width: 720px) {
  /* item card on one line: name | qty × price | delete, chips underneath */
  .item-body { grid-template-columns: minmax(0, 1fr) 70px auto 150px auto; }
  .item-body .name, .item-body .qty, .item-body .times, .item-body .price, .item-body .del { grid-row: 1; }
  .item-body .name { grid-column: 1; }
  .item-body .qty { grid-column: 2; }
  .item-body .times { grid-column: 3; }
  .item-body .price { grid-column: 4; }
  .item-body .del { grid-column: 5; }
  .split { display: flex; flex-wrap: wrap; }
  .split .chip { min-width: 92px; }
}
.side-title { display: none; }
@media (min-width: 980px) { .side-title { display: flex; margin-top: 0; } }

/* recap page */
.recap-banner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.recap-banner .month-head { margin: 0; }
.recap-banner .tools { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 18px; }
@media (min-width: 900px) {
  .recap-banner { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; gap: 32px; }
  .recap-banner .month-head { flex-direction: column; align-items: flex-start; }
}
.payer-cols { display: grid; gap: 0 32px; }
@media (min-width: 980px) { .payer-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.recap-bottom { display: grid; gap: 0 32px; }
@media (min-width: 980px) { .recap-bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; } }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 22px 16px; }

/* login page */
.login-wrap { display: grid; gap: 22px; max-width: 980px; margin: 0 auto; }
@media (min-width: 860px) { .login-wrap { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: stretch; margin-top: 4vh; } }
.login-banner { display: flex; flex-direction: column; justify-content: center; min-height: 220px; margin: 0; }
.login-banner .hero { margin: 0; }
.login-sub { margin: 14px 0 0; font-weight: 700; font-size: 18px; }
.login-card { display: grid; gap: 16px; align-content: center; padding: 24px; }
.pw { display: flex; gap: 8px; align-items: center; }
.pw .input { flex: 1; }
.login-card .btn { margin-top: 6px; }

/* ============================================================ Bill Split additions */

/* person colours, in list order (same order as the server's "color": n % 6) */
.c0 { --pc: var(--pink); }
.c1 { --pc: var(--purple); }
.c2 { --pc: var(--green); }
.c3 { --pc: var(--yellow); }
.c4 { --pc: var(--lime); }
.c5 { --pc: var(--peach); }
.avatar[class*=" c"] { background: var(--pc); }
.avatar.sm { width: 38px; height: 38px; font-size: 17px; border-width: 2px; }
.person-card { --tab: var(--pc); }

.grow { flex: 1 1 auto; min-width: 0; }
.hint.small { font-size: 13px; margin: 10px 0 0; }
.empty-sm { color: var(--muted); font-weight: 600; font-size: 14px; margin: 4px 0 8px; }
.field-error { color: var(--red); font-size: 13px; font-weight: 700; margin-top: 4px; }
.field-error:empty { display: none; }
.input.bad { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }

/* compact banner: less height on phones so the steps are visible right away */
.banner.compact { padding: 16px; }
.banner.compact .hero { font-size: clamp(32px, 9vw, 56px); margin-bottom: 14px; }
@media (min-width: 720px) { .banner.compact { padding: 26px 32px; } }

/* step tabs, sticky at the top while scrolling */
.steps {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
  margin: 18px -16px 0; padding: 12px 16px 10px;
  background: var(--paper);
}
@media (min-width: 720px) { .steps { margin: 22px 0 0; padding: 12px 0 10px; } }
.step {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 6px;
  background: var(--surface); color: var(--text);
  border: 2px solid var(--ink); border-radius: 11px; box-shadow: var(--sh-sm);
  font-weight: 800; font-size: 14px; cursor: pointer;
}
.step .no {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none;
  border: 2px solid var(--ink); border-radius: 50%; font-size: 12px; background: var(--sunk);
}
.step.active { background: var(--yellow); color: var(--on-color); transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow); }
.step.active .no { background: var(--surface); color: var(--text); }
.step .cnt {
  position: absolute; top: -9px; right: -6px; min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 11px;
}
.step .cnt:empty { display: none; }
.step .cnt.warn { background: var(--pink); color: var(--on-color); }
@media (max-width: 400px) { .step .no { display: none; } .step { font-size: 13px; } }

/* back / next, fixed at the bottom (thumb reach) */
.editor-app { max-width: 860px; padding-bottom: 110px; }
.stepnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 10px; max-width: 860px; margin: 0 auto;
  padding: 14px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 72%, transparent);
}
@media (min-width: 720px) { .stepnav { padding-left: 32px; padding-right: 32px; } }
.stepnav .btn { min-height: 54px; }
.stepnav .grow { flex: 1; font-size: 17px; }

.share-app { max-width: 860px; }

/* people */
.add-row { display: flex; gap: 10px; margin-top: 16px; }
.add-row .input { flex: 1; height: 50px; }
.add-row .btn { min-height: 50px; }
.people-list { margin-top: 8px; }
.person-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px; box-shadow: var(--sh); }
.person-row + .person-row { margin-top: 12px; }
.person-row .avatar { margin-top: 4px; }
.person-row .input { font-weight: 700; }

/* items */
.item-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.line-total { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.line-total:not(:empty), .item-foot .field-error:not(:empty) { margin-top: 8px; }
.items-total { margin-left: auto; font-weight: 800; }

/* assign */
.assign-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 17px; }
.assign-head .aname { min-width: 0; overflow-wrap: anywhere; }
.assign-head .num { white-space: nowrap; }
.pchips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pchips .chip { height: 40px; }
.chip.pchip.on { background: var(--pc); }
.chip.everyone.on { background: var(--ink); color: var(--paper); }
.assign-foot { margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--muted); }
.assign-foot.need-pick { color: var(--pink); }

/* charges */
.charge-card { padding: 12px; box-shadow: var(--sh); }
.charge-card + .charge-card { margin-top: 14px; }
.charge-card.is-discount { background: var(--green-soft); }
.cc-top { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.cc-top select { padding: 0 6px; }
.cc-move { display: flex; gap: 4px; }
.cc-move .sq:disabled { opacity: .3; cursor: default; }
.cc-bottom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.cc-bottom .cval { width: 110px; flex: none; }
.cc-bottom .base { width: auto; flex: 1 1 140px; padding: 0 8px; }
.cc-bottom .camt { margin-left: auto; font-weight: 800; }
.cc-bottom .camt:empty { display: none; }
@media (max-width: 400px) {
  .cc-top { grid-template-columns: 96px minmax(0, 1fr) auto; }
  .cc-move { grid-column: 1; grid-row: 2; }
}
.presets { margin-top: 14px; }

/* segmented control (% / Rp, link duration) */
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 11px; overflow: hidden; box-shadow: var(--sh-sm); }
.seg button {
  min-height: 44px; padding: 0 14px; border: 0; border-left: 2px solid var(--ink);
  background: var(--surface); color: var(--text); font-weight: 800; cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--yellow); color: var(--on-color); }
.seg.sm button { min-height: 42px; padding: 0 12px; }
.share-card .seg { display: flex; margin: 8px 0 16px; }
.share-card .seg button { flex: 1; }
.field-lbl { font-size: 13px; font-weight: 700; color: var(--muted); }

/* result */
.result .card + .card { margin-top: 18px; }
.preview.grand { margin-top: 0; }
.rlines { margin-top: 12px; }
.rl {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 0; border-top: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent);
  font-size: 15px;
}
.rl:first-child { border-top: 0; }
.rl .n { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.rl .sub { display: block; font-size: 12px; font-weight: 600; opacity: .7; }
.rl .num { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.rl.charge, .rl.subtotal { color: var(--muted); }
.rl.total { border-top: var(--bw) solid var(--ink); font-weight: 800; padding-top: 9px; font-size: 16px; }
.rl.total .n { font-weight: 800; }

.glance { padding: 8px 16px; }
.glance-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; text-decoration: none;
  border-top: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent);
}
.glance-row:first-child { border-top: 0; }
.glance-row .gname { flex: 1; min-width: 0; font-weight: 800; font-size: 17px; overflow-wrap: anywhere; }
.glance-row .gtotal { font-weight: 800; font-size: 18px; white-space: nowrap; }
.check-sum {
  display: flex; align-items: center; gap: 6px; padding: 10px 0 6px; font-size: 13px; font-weight: 800;
  color: var(--muted); border-top: var(--bw) solid var(--ink);
}
.check-sum .icon { width: 16px; height: 16px; color: var(--green); }
.check-sum.error, .check-sum.error .icon { color: var(--red); }

.people-cards { margin-top: 6px; }
.person-card { margin-top: 34px; scroll-margin-top: 80px; }
.pc-head { display: flex; align-items: center; gap: 12px; }
.pc-name { flex: 1; min-width: 0; font-size: 20px; font-weight: 800; overflow-wrap: anywhere; }
.pc-total { font-size: 24px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }

/* share */
.link-box { margin-top: 12px; padding: 12px; background: var(--sunk); border: 2px solid var(--ink); border-radius: 12px; }
.link-input { font-size: 14px; }
.link-box .row { margin-bottom: 0; }
.share-row { display: flex; align-items: center; gap: 8px; padding: 12px; box-shadow: var(--sh); }
.share-row + .share-row { margin-top: 12px; }
.sr-title { font-weight: 800; overflow-wrap: anywhere; }
.sr-meta { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 4px; }
.sr-meta .icon { width: 14px; height: 14px; }

/* read-only share page */
.share-app { max-width: 760px; }
.share-banner { margin-bottom: 24px; }
.share-banner .hero { margin-bottom: 10px; overflow-wrap: anywhere; }
.share-sub { margin: 0; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.share-sub .icon { width: 18px; height: 18px; }
.banner.is-expired { background: var(--peach); }
.expired-card { display: flex; gap: 14px; align-items: center; }
.ex-title { font-weight: 800; font-size: 18px; }
.ex-text { color: var(--muted); font-weight: 600; margin-top: 2px; }
.read-only-note { text-align: center; margin-top: 24px; }

/* charge card: who pays (by items / equally) */
.cc-split { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.cc-split .seg button { min-width: 92px; }
