:root {
  --bg: #eef1ec; --surface: #f9faf8; --paper: #ffffff; --ink: #22262a; --muted: #6e757b; --grid: #d5dad3;
  --accent: #de4e1c; --primary: #0f7193; --primary-ink: #fff; --good: #5c9122; --bad: #de4e1c; --chart: #0b7ea6;
  --shadow: 0 2px 0 rgba(34, 38, 42, 0.12), 0 8px 24px rgba(34, 38, 42, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191c; --surface: #1e2126; --paper: #262a30; --ink: #f4f6f2; --muted: #9aa1a6; --grid: #40464d;
    --accent: #f0653a; --primary: #1c9cc4; --primary-ink: #10171b; --good: #7db83a; --bad: #f0653a; --chart: #1c9cc4;
    --shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0 auto; max-width: 980px; padding: 0 16px 80px; background: var(--bg); color: var(--ink); font: 16px/1.45 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; }
.top { padding: 14px 0 6px; }
.brand { display: flex; align-items: center; gap: 8px; }
h1 { font-size: 1.35rem; margin: 0; }
.logo { display: inline-flex; color: var(--ink); }
.logo svg { display: block; height: 24px; width: auto; }
.summary { margin: 6px 0 0; color: var(--muted); }
.summary b { color: var(--ink); }
.summary .warn { color: var(--bad); font-weight: 700; }

.tabs { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0 0; padding: 4px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.tabs button { font: inherit; font-size: 0.85rem; font-weight: 700; min-height: 44px; padding: 2px; border: 0; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.hint { margin: 12px 2px; color: var(--muted); }

.btn { font: inherit; font-weight: 700; font-size: 0.9rem; min-height: 40px; padding: 6px 12px; border: 0; border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.4; cursor: default; }
svg.thumb { display: block; background: var(--paper); border-radius: 12px; }
svg.thumb path { fill: var(--good); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; list-style: none; margin: 0; padding: 0; }
.cards li { display: grid; gap: 8px; padding: 12px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.cards svg.thumb { width: 100%; aspect-ratio: 1; }
.cards .name { font-weight: 800; }
.cards .meta, .days .meta { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.cards .actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }

.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.days li { display: grid; grid-template-columns: 64px 1fr; grid-template-areas: "thumb what" "thumb actions"; gap: 4px 12px; align-items: center; padding: 10px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.days svg.thumb { grid-area: thumb; width: 64px; height: 64px; }
.days .what { grid-area: what; min-width: 0; }
.days .when { font-weight: 800; }
.days .tag { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: 0.75rem; font-weight: 700; }
.days .actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.days .actions .btn { min-height: 36px; padding: 4px 10px; }
.days input[type="date"] { font: inherit; font-size: 0.9rem; min-height: 36px; padding: 2px 8px; border-radius: 12px; border: 2px solid var(--grid); background: var(--paper); color: var(--ink); }
.days li.locked { opacity: 0.6; }
.past { margin-bottom: 12px; }
.past summary { cursor: pointer; font-weight: 700; padding: 8px 2px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 32px); margin: 0; padding: 10px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }

.brand .btn { margin-left: auto; text-decoration: none; display: grid; place-items: center; }
.link { font: inherit; font-weight: 700; padding: 0; border: 0; background: none; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tabs { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 720px) { .tabs { grid-template-columns: repeat(6, 1fr); } }
a.btn { display: grid; place-items: center; text-decoration: none; }
/* Google's sign-in button as people know it, to Google's branding guidelines: white with a grey
   outline (near-black in the dark theme), the "G" in its own colours, a medium-weight label. */
a.btn.google { display: flex; justify-content: center; align-items: center; gap: 10px; border: 1px solid #747775; background: #ffffff; color: #1f1f1f; box-shadow: none; font-family: Roboto, system-ui, sans-serif; font-weight: 500; }
a.btn.google svg { flex: none; width: 20px; height: 20px; }
@media (prefers-color-scheme: dark) {
  a.btn.google { border-color: #8e918f; background: #131314; color: #e3e3e3; }
}
.sign-in, .add-member { display: grid; gap: 12px; max-width: 420px; margin: 24px auto; padding: 20px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.add-member { max-width: none; margin: 0 0 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.sign-in h2, .add-member h2 { margin: 0; font-size: 1.2rem; grid-column: 1 / -1; }
.sign-in .hint { margin: 0; }
label { display: grid; gap: 4px; font-weight: 700; font-size: 0.9rem; }
input, select { font: inherit; min-height: 44px; padding: 4px 10px; border-radius: 12px; border: 2px solid var(--grid); background: var(--paper); color: var(--ink); min-width: 0; }
.cards .badge { justify-self: start; padding: 1px 10px; border-radius: 999px; background: var(--grid); font-size: 0.75rem; font-weight: 700; }
.cards .badge.approved, .cards .badge.paid { background: var(--good); color: #fff; }
.cards .badge.rejected { background: var(--bad); color: #fff; }
.cards .badge.admin { background: var(--primary); color: var(--primary-ink); }
.cards .badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cards .actions.stack { grid-auto-flow: row; }
.cards.members { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
h1, .brand .btn { white-space: nowrap; }
.brand { flex-wrap: wrap; }

.tabs { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 720px) { .tabs { grid-template-columns: repeat(8, 1fr); } }
label.check { display: flex; gap: 8px; align-items: center; min-height: 44px; }
label.check input { min-height: 0; width: 20px; height: 20px; }
.offer-status { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.offer-status b { color: var(--ink); }
.invitees { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.85rem; }
.invitees li { display: block; padding: 6px 8px; border-radius: 10px; background: var(--paper); box-shadow: none; }
.invitees .ok { color: var(--good); font-weight: 700; }
.invitees .wait { color: var(--muted); }
.cards .progress { font-weight: 800; }

/* The Stats tab (admin/stats.js): headline figures, then charts of one measure each. */
@media (min-width: 720px) { .tabs { grid-template-columns: repeat(5, 1fr); } }
.stats { display: grid; gap: 14px; }
.tiles, .facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tiles li, .chart, .facts { padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.tiles .label { font-weight: 700; font-size: 0.85rem; color: var(--muted); }
.tiles .value { font-weight: 800; font-size: 2rem; line-height: 1.2; overflow-wrap: anywhere; }
.tiles .meta { color: var(--muted); font-size: 0.85rem; }
.range { display: flex; gap: 4px; justify-self: start; padding: 4px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.range button { font: inherit; font-size: 0.85rem; font-weight: 700; min-height: 36px; padding: 2px 12px; white-space: nowrap; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.range button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
@media (max-width: 420px) { .range { justify-self: stretch; } .range button { flex: 1; padding: 2px 4px; } }
.charts { display: grid; gap: 12px; min-width: 0; }
.chart { margin: 0; min-width: 0; }
.chart figcaption { display: grid; margin-bottom: 6px; }
.chart figcaption span { color: var(--muted); font-size: 0.85rem; }
.chart .plot { position: relative; }
.chart svg { display: block; max-width: 100%; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; opacity: 0.6; }
.chart .base { stroke: var(--grid); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--chart); }
.chart .bar.on { fill: var(--ink); }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .wash { fill: var(--chart); opacity: 0.1; }
.chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .tip { position: absolute; z-index: 1; transform: translate(-50%, -100%); padding: 6px 10px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 0.85rem; white-space: nowrap; pointer-events: none; }
.chart .tip span { display: block; opacity: 0.8; font-size: 0.75rem; }
.facts { gap: 8px; font-size: 0.95rem; color: var(--muted); }
.facts b { color: var(--ink); }
.stats .scroll { overflow-x: auto; }
.stats table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
.stats thead th { color: var(--muted); font-size: 0.8rem; }
.stats th:first-child { text-align: left; }

/* The Suspects tab's report: kept rounds that would be flagged as copies, at a few thresholds. */
.suspect-table { grid-column: 1 / -1; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.suspect-table th, .suspect-table td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--grid); }
.suspect-table th:first-child, .suspect-table td:first-child { text-align: left; }
