/* Allowance — mobile-first, one-handed, offline. */

:root {
  --bg: #0f1720;
  --surface: #17212b;
  --surface-2: #1e2b38;
  --line: #2b3a49;
  --text: #eef4f9;
  --muted: #93a5b6;
  --green: #35c07f;
  --green-dim: #1d6b48;
  --red: #f2695f;
  --amber: #e5a83c;
  --blue: #5aa9e6;
  --radius: 14px;
  --tap: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, #16222e 0%, #131d27 100%);
  border-bottom: 1px solid var(--line);
}

.balance { flex: 1; min-width: 0; }
.balance-label { font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.balance-amount { font-size: 40px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.balance-amount.neg { color: var(--red); }
.balance-amount.pos { color: var(--green); }
.balance-sub { font-size: 13px; color: var(--muted); }

.icon-btn {
  width: var(--tap); min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 22px;
}

/* ---------- layout ---------- */
main { padding: 6px 14px 20px; max-width: 640px; margin: 0 auto; }
.view.hidden { display: none; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 22px 0 10px;
}
.section-head h2 { font-size: 16px; margin: 0; letter-spacing: .02em; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint.center { text-align: center; margin-top: 26px; }
.pill {
  font-size: 13px; color: var(--green);
  background: rgba(53,192,127,.12);
  border: 1px solid var(--green-dim);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}

.list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.empty { color: var(--muted); font-size: 14px; padding: 14px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- job row (the checklist) ---------- */
.jobrow {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  min-height: 64px; padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text); font: inherit;
}
.jobrow:active { background: var(--surface-2); }
.jobrow.done { border-color: var(--green-dim); background: rgba(53,192,127,.09); }

.check {
  flex: 0 0 30px; height: 30px; border-radius: 9px;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  font-size: 18px; color: transparent;
}
.jobrow.done .check { border-color: var(--green); background: var(--green); color: #06120c; }

.jobrow .body { flex: 1; min-width: 0; display: block; }
.jobrow .name { display: block; font-weight: 600; }
.jobrow .meta { display: block; font-size: 13px; color: var(--muted); }
.jobrow .amt { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.jobrow.done .amt { color: var(--green); }
/* Once-a-week job whose slot was already used earlier in the week. Dimmed rather
   than hidden so the row can explain itself; still tappable for the toast. */
/* Log day card — tappable, jumps to that day's checklist. */
.logday { cursor: pointer; }
.logday:active { background: var(--surface-2); }
.logday:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.go-chevron { color: var(--muted); font-size: 20px; line-height: 1; margin-left: 6px; }

.jobrow.spent { opacity: .5; }
.jobrow.spent .amt { color: var(--muted); text-decoration: line-through; }
.count-badge {
  background: var(--green); color: #06120c; font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px; margin-left: 6px;
}

/* ---------- bill / manage rows ---------- */
.billrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.billrow.off { opacity: .55; }
.billrow .body { flex: 1; min-width: 0; display: block; }
.billrow .name { display: block; font-weight: 600; }
.billrow .meta { display: block; font-size: 13px; color: var(--muted); }

.switch { flex: 0 0 auto; min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; }
.switch.on { background: rgba(53,192,127,.16); border-color: var(--green-dim); color: var(--green); }

.link-btn { background: none; border: none; color: var(--blue); font: inherit; font-size: 14px;
  padding: 8px 6px; min-height: 40px; }
.link-btn.danger { color: var(--red); }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap); padding: 0 18px;
  background: var(--green); color: #06120c;
  border: none; border-radius: var(--radius);
  font: inherit; font-weight: 700;
}
.btn:disabled { opacity: .4; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--red); color: #22060a; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }

/* ---------- fields ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; min-height: var(--tap);
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 12px; font: inherit;
}

/* ---------- alerts ---------- */
.alert { border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; font-size: 15px;
  border: 1px solid; }
.alert b { display: block; margin-bottom: 2px; }
.alert.bad { background: rgba(242,105,95,.12); border-color: rgba(242,105,95,.5); }
.alert.warn { background: rgba(229,168,60,.12); border-color: rgba(229,168,60,.5); }
.alert.good { background: rgba(53,192,127,.10); border-color: var(--green-dim); }

.daynav { display: flex; gap: 10px; margin-top: 24px; }
.daynav .btn { flex: 1; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: #131d27; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; min-height: 62px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; color: var(--muted);
  font: inherit; font-size: 11px;
}
.tab span { font-size: 19px; line-height: 1; }
.tab.active { color: var(--green); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(4,9,14,.72);
  display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-box {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.modal-box h3 { margin: 0 0 14px; }
.modal-actions { margin-top: 6px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; z-index: 60;
}
.toast.hidden { display: none; }

.mono { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.btn.wide { width: 100%; margin-top: 10px; }

/* miles entry on a mileage bill */
.miles-input {
  flex: 0 0 78px; width: 78px; min-height: 44px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 8px; font: inherit; text-align: right;
  font-variant-numeric: tabular-nums;
}
.unit { font-size: 13px; color: var(--muted); margin: 0 2px 0 4px; }

/* ---------- generic visibility ----------
   Only .view/.modal/.toast had their own hidden rule; profiles hide tabs, the gear
   and the review actions too, so the class needs to mean the same thing anywhere. */
.hidden { display: none !important; }

/* ---------- profile switch ---------- */
.profilebar {
  position: sticky; top: 0; z-index: 19;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.plabel { font-size: 13px; color: var(--muted); }
.pswitch { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.pbtn {
  min-height: 44px; padding: 6px 18px;
  border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600;
}
.pbtn.on { background: var(--blue); color: #06121c; }

/* ---------- bills rendered as job rows ----------
   Same row, same tap target, same check mark as a job — but a charged bill is money
   leaving, so it reads red where a done job reads green. */
.jobrow.billjob.done { border-color: rgba(242,105,95,.42); background: rgba(242,105,95,.09); }
.jobrow.billjob.done .check { border-color: var(--red); background: var(--red); color: #2a0b08; }
.jobrow.billjob.done .amt { color: var(--red); }

/* ---------- waiting for a parent's review ----------
   Dashed amber: visibly not settled yet, on either profile. */
.jobrow.waiting, .billrow.waiting { border-style: dashed; border-color: var(--amber); }
.jobrow.waiting .meta, .billrow.waiting .meta { color: var(--amber); }
/* The tick glyph stays transparent unless the row is actually checked. Colouring it
   amber on every waiting row made a proposed SKIP look like a proposed charge. */
.jobrow.waiting .check { border-color: var(--amber); background: transparent; color: transparent; }
.jobrow.waiting.done .check { background: var(--amber); color: #241800; }

/* ---------- review queue ---------- */
.tab { position: relative; }
.tabbadge {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--amber); color: #241800;
  font-size: 11px; font-weight: 700; font-style: normal; line-height: 18px; text-align: center;
}
.reviewrow .switch { min-width: 46px; padding: 8px 10px; font-size: 17px; }
.switch.reject { color: var(--red); border-color: rgba(242,105,95,.4); }
#reviewActions { margin-top: 14px; }

/* ---------- Login gate ---------- */
.login {
  position: fixed; inset: 0; z-index: 80; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px calc(16px + env(safe-area-inset-left)) calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.login.hidden { display: none; }
.login-box { width: 100%; max-width: 420px; }
.login-title { font-size: 24px; margin: 0 0 20px; text-align: center; }
.login-role { margin-bottom: 10px; }
.login-who { color: var(--muted); margin: 0 0 14px; }
.login-hint {
  margin-top: 22px; padding: 12px 14px;
  border: 1px dashed var(--amber); border-radius: var(--radius);
  color: var(--muted); font-size: 14px; line-height: 1.5;
}
.login-hint b { color: var(--amber); }
.login-hint .pin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); }

/* ---------- family account ---------- */

/* A checkbox that is a real 52px tap target, because the one it gates decides
   whether a teenager's existing balance comes with him into the account. */
.checkline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 4px 2px;
  color: var(--muted);
  font-size: 15px;
}
.checkline input { width: 22px; height: 22px; accent-color: var(--green); flex: none; }

.errline {
  margin: 8px 0 0;
  color: var(--red);
  font-size: 15px;
}

/* Sync trouble is a money problem, so it gets a bar across the top of every tab
   rather than a quiet icon. Tapping it goes to the thing that fixes it. */
.syncbanner {
  display: block;
  width: 100%;
  min-height: var(--tap);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: left;
  padding: 12px 16px;
}
.syncbanner.warn { background: #3a2a10; color: #f4d9a4; }
.syncbanner.bad { background: #3a1614; color: #ffd2cd; }

.acct-line { margin: 0 0 6px; }
.acct-line .muted { color: var(--muted); }

/* The join code is read off one phone and typed into another, so it is set in a
   monospace face at a size that survives a kitchen table. */
.joincode {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px;
  letter-spacing: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 4px 0 10px;
}

/* The sticky bar holds either the device-only profile toggle or the signed-in
   identity + sign out. Both lay out the same way so the bar never jumps height. */
.pbwrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%;
}
.pbwrap .plabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Smaller than a primary action on purpose — signing out is not something a kid
   should hit while reaching for a job — but still a 44px target, not a link. */
.btn.tiny {
  min-height: 44px; padding: 6px 16px;
  font-size: 14px; flex: none;
}

/* One row per person who can open the family's money. Name and role read first;
   the reset button is deliberately quiet, since it signs someone out everywhere. */
.memberrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.memberrow:last-of-type { border-bottom: 0; }
.memberwho { min-width: 0; }
.memberwho .muted { color: var(--muted); font-size: 14px; }
