:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --ink: #111318;
  --ink-2: #5d6370;
  --ink-3: #9a9fab;
  --line: #e6e7eb;
  --accent: #111318;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-soft: #e7f5ec;
  --wait: #a16207;
  --wait-soft: #fdf4e3;
  --bad: #b91c1c;
  --star: #d97706;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e11; --surface: #16181c; --surface-2: #1e2126; --ink: #f1f2f4; --ink-2: #a2a7b2; --ink-3: #6b717c;
    --line: #262930; --accent: #f1f2f4; --accent-ink: #0d0e11; --ok: #4ade80; --ok-soft: #11291b;
    --wait: #fbbf24; --wait-soft: #2c2410; --bad: #f87171; --star: #fbbf24; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e11; --surface: #16181c; --surface-2: #1e2126; --ink: #f1f2f4; --ink-2: #a2a7b2; --ink-3: #6b717c;
  --line: #262930; --accent: #f1f2f4; --accent-ink: #0d0e11; --ok: #4ade80; --ok-soft: #11291b;
  --wait: #fbbf24; --wait-soft: #2c2410; --bad: #f87171; --star: #fbbf24; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { letter-spacing: -0.015em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.star { color: var(--star); margin-right: 3px; }
.amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.bar-in {
  max-width: 1240px; margin: 0 auto; padding: 10px 16px 0;
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "ident right" "tabs tabs"; align-items: center; gap: 4px 12px;
}
.ident { grid-area: ident; display: flex; align-items: center; gap: 10px; min-width: 0; }
.ident-name { font-weight: 650; font-size: 16px; }
.ident-sub { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-right { grid-area: right; display: flex; align-items: center; gap: 10px; }
.tabs { grid-area: tabs; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
.tabs button {
  position: relative; padding: 12px 12px 13px; color: var(--ink-2); font-weight: 550; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.tabs button[aria-current="page"] { color: var(--ink); }
.tabs button[aria-current="page"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--kid, var(--ink)); border-radius: 2px; }
.badge { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.sync.on { background: var(--ok); }
.sync.off { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.page { max-width: 1240px; margin: 0 auto; padding: 20px 16px calc(48px + env(safe-area-inset-bottom)); }

/* ---------- monogram ---------- */
.mono {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--kid); color: #fff; font-weight: 650; font-size: 15px; letter-spacing: .02em;
}
.mono.sm { width: 32px; height: 32px; font-size: 13px; }
.mono.lg { width: 64px; height: 64px; font-size: 22px; }
.mono.xl { width: 80px; height: 80px; font-size: 28px; }
.parent-mono { background: var(--ink); color: var(--bg); }

/* ---------- picker ---------- */
.picker { min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 28px; padding: 32px 16px 48px; }
.picker-sync { position: fixed; top: 18px; right: 18px; }
.picker-title { text-align: center; }
.picker-title h1 { margin: 2px 0 0; font-size: 32px; font-weight: 700; }
.eyebrow { color: var(--ink-2); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 180px)); justify-content: center; gap: 14px; width: 100%; max-width: 860px; }
.pick {
  padding: 24px 12px 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  display: grid; justify-items: center; gap: 8px; transition: transform .12s, border-color .12s;
}
.pick:hover { border-color: var(--ink-3); }
.pick:active { transform: scale(.97); }
.pick-name { font-weight: 650; font-size: 17px; margin-top: 4px; }
.pick-sub { color: var(--ink-2); font-size: 13.5px; }
@media (max-width: 420px) { .pick-grid { grid-template-columns: 1fr 1fr; } .mono.xl { width: 64px; height: 64px; font-size: 22px; } }

/* ---------- kid hero ---------- */
.hero {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px;
}
.hero-mono { border-radius: 50%; }
.hero h1 { margin: 0; font-size: 24px; font-weight: 700; }
.hero-stat { text-align: right; }
.stat-num { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-num .amt { font-weight: 700; }
.stat-label { color: var(--ink-2); font-size: 12.5px; }
.progress { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--kid, var(--ok)); border-radius: inherit; transition: width .4s; }
.progress.thin { height: 4px; }
.progress.inline { margin-top: 8px; max-width: 220px; }
.footnote { color: var(--ink-2); font-size: 13.5px; margin: 14px 2px 0; }

.section { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 28px 2px 10px; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 2px 10px; }
.section-row .section { margin: 0; }
.page > .section:first-child, .page > .section-row:first-child { margin-top: 4px; }

/* ---------- list items ---------- */
.items { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.items.flush { border: 0; border-radius: 0; background: transparent; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); min-height: 64px; }
.item:first-child { border-top: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.item-action { display: flex; align-items: center; gap: 8px; flex: none; }
.chore-item { cursor: pointer; transition: background .15s; }
.chore-item:hover { background: var(--surface-2); }
.chore-item.is-done .item-title { color: var(--ink-2); }
.has-notes { font-size: 11px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; line-height: 18px; }
.sent-back { color: var(--bad); font-size: 13px; margin-top: 6px; font-weight: 550; }
.empty { color: var(--ink-3); text-align: center; padding: 28px 16px; }
.empty-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 16px; text-align: center; color: var(--ink-2); display: grid; gap: 14px; justify-items: center; }

.dots { display: flex; gap: 8px; margin-top: 10px; }
.dot-wrap { display: grid; justify-items: center; gap: 3px; }
.dot-wrap small { font-size: 10px; color: var(--ink-3); line-height: 1; min-height: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.dot.approved { background: var(--ok); border-color: var(--ok); }
.dot.pending { background: var(--wait); border-color: var(--wait); }
.dot.future { opacity: .4; }
.dot.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--kid, var(--ink)); }

.pill { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag { font-size: 12px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.wait { background: var(--wait-soft); color: var(--wait); }

.delta { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.delta.pos { color: var(--ok); }
.delta.neg { color: var(--bad); }

/* ---------- parents overview ---------- */
.columns { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.column { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.column-head { display: flex; align-items: center; gap: 12px; padding: 16px; }
.column-name { font-weight: 650; font-size: 16px; }
.column .progress { margin: 0 16px 8px; }
.column .item { padding: 12px 16px; }

/* ---------- rewards / chips ---------- */
.balance-line { font-size: 15px; color: var(--ink-2); margin: 0 2px 12px; }
.balance-line .amt { color: var(--ink); font-size: 17px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 16px; scrollbar-width: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 999px; flex: none;
  background: var(--surface); border: 1px solid var(--line); font-weight: 550; color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kid, var(--ink-3)); display: inline-block; flex: none; }
.rota { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.rota span { display: inline-flex; align-items: center; gap: 6px; }
.rota b { color: var(--ink); font-weight: 600; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  height: 42px; padding: 0 16px; border-radius: 10px; font-weight: 600;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); transition: background .12s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 85%, var(--bg)); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-text { border-color: transparent; background: transparent; color: var(--bad); padding: 0 8px; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn:disabled { opacity: .4; }

label.field, div.field { display: grid; gap: 8px; font-weight: 600; font-size: 13.5px; }
.hint { font-weight: 450; color: var(--ink-3); }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 400;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 550; }
.check input { width: 18px; height: 18px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); font-weight: 550; font-size: 14px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.stepper { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; width: fit-content; }
.stepper button { min-width: 38px; height: 36px; padding: 0 8px; border-radius: 8px; font-size: 16px; font-weight: 600; color: var(--ink-2); }
.stepper button:hover { background: var(--surface-2); color: var(--ink); }
.stepper output { min-width: 56px; padding: 0 6px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; background: var(--c); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.order { display: flex; flex-wrap: wrap; gap: 6px; }
.order button {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 6px; border-radius: 999px;
  border: 1px solid var(--line); font-weight: 550; font-size: 14px; color: var(--ink-2);
}
.order .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 1.5px dashed var(--ink-3); }
.order button.on { color: var(--ink); border-color: var(--kid); }
.order button.on .n { background: var(--kid); border: 0; color: #fff; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.form { display: grid; gap: 18px; }

/* ---------- modal ---------- */
dialog {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 24px 64px rgb(0 0 0 / .22);
}
dialog.narrow { width: min(360px, calc(100vw - 24px)); }
dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
dialog::backdrop { background: rgb(10 10 12 / .45); }
.m-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 16px 0 20px; flex: none; }
.m-head > div { flex: 1; min-width: 0; }
.m-head h3 { margin: 0; font-size: 18px; font-weight: 650; }
.m-sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.m-body { padding: 16px 20px 20px; display: grid; gap: 20px; overflow-y: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }
.m-body p { margin: 0; }
.m-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px 16px; flex: none; border-top: 1px solid var(--line); }
.label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 8px; }
.notes { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; line-height: 1.55; }
.slot-list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.slot-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); min-height: 56px; flex-wrap: wrap; }
.slot-row:first-child { border-top: 0; }
.slot-label { font-weight: 600; }
.slot-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 280px; justify-self: center; }
.pinpad button { height: 60px; border-radius: 12px; background: var(--surface-2); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pinpad button:hover { background: color-mix(in srgb, var(--surface-2) 70%, var(--line)); }
.pinpad button:active { transform: scale(.96); }
.pinpad button[data-v="del"] { font-size: 14px; color: var(--ink-2); }
.pinpad button.ok { background: var(--accent); color: var(--accent-ink); font-size: 15px; }
.pindots { display: flex; justify-content: center; gap: 14px; padding: 6px 0 4px; }
.pindots i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink-3); }
.pindots i.f { background: var(--ink); border-color: var(--ink); }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: min(400px, 100%); padding: 28px; display: grid; gap: 16px; }
.auth h1 { margin: 0; font-size: 24px; }
.auth p { margin: 0; }
.err { color: var(--bad); font-weight: 550; min-height: 1.2em; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px; font-weight: 550; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  .page { padding-top: 16px; }
  .hero { grid-template-columns: auto 1fr; padding: 16px; }
  .hero-stat { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 8px; }
  .columns { grid-template-columns: 1fr; }
  .item { flex-wrap: wrap; }
  .item-action.two { width: 100%; justify-content: flex-end; }
  .chore-item .item-action { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
