:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #e6effb;
  --danger: #c0392b;
  --ok: #1f7a3a;
  --carry: #7d6b9e; --spent: #2563c9; --funds: #b7791f;
  --warn: #9a6400;
  --grid: #ecebe6;
  --axis: #c9c8c2;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c;
    --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #5598e7; --accent-ink: #0b0b0b; --accent-soft: #1d2a3b;
    --danger: #e66767; --ok: #4cc06d; --warn: #e0a42a; --carry: #a99bc6; --spent: #6ea4f0; --funds: #e0a42a; --carry: #a99bc6; --spent: #6ea4f0; --funds: #e0a42a;
    --grid: #262624; --axis: #3d3d39;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2f2f2c;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #5598e7; --accent-ink: #0b0b0b; --accent-soft: #1d2a3b;
  --danger: #e66767; --ok: #4cc06d; --warn: #e0a42a;
  --grid: #262624; --axis: #3d3d39;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; color: var(--text-2); }
.muted { color: var(--muted); }
.pad { padding: 24px; }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout */
#app { display: flex; min-height: 100vh; }
#nav {
  width: 220px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px;
}
#nav[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 8px 16px; }
.brand-logo { position: relative; flex: none; width: 30px; height: 30px; border-radius: 50%; overflow: hidden; background: #0b0b0b;
  box-shadow: 0 0 0 1px var(--border, rgba(127,127,127,.35)); }
.brand-logo img { position: absolute; width: 45.7px; height: 45.7px; left: -7.8px; top: -6.4px; max-width: none; }
.auth .brand-logo { width: 40px; height: 40px; }
.auth .brand-logo img { width: 61px; height: 61px; left: -10.4px; top: -8.5px; }
#nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav-bottom { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; border-top: 1px solid var(--border); }
#nav-links a, #nav-bottom a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
#nav-links a svg, #nav-bottom a svg { width: 18px; height: 18px; flex: none; }
#nav-links a:hover, #nav-bottom a:hover { background: var(--surface-2); }
#nav-links a.active, #nav-bottom a.active { background: var(--accent-soft); color: var(--accent); }
.nav-foot { font-size: .85rem; color: var(--muted); padding: 8px; border-top: 1px solid var(--border); }
main { flex: 1; min-width: 0; padding: 24px 28px 48px; max-width: 1200px; }

@media (max-width: 860px) {
  #app { display: block; }
  #nav {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; width: auto; z-index: 20;
    flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
  }
  .brand, .nav-foot { display: none; }
  #nav-links { flex-direction: row; justify-content: space-around; gap: 0; }
  #nav-bottom { flex-direction: row; flex: none; padding: 0; border-top: 0; gap: 0; }
  #nav-links a, #nav-bottom a { flex-direction: column; gap: 2px; font-size: .7rem; padding: 6px 4px; flex: 1; justify-content: center; text-align: center; }
  #nav-links a svg, #nav-bottom a svg { width: 22px; height: 22px; }
  #nav-links a.desktop-only, #nav-bottom a.desktop-only { display: none; }
  main { padding: 16px 16px 96px; }
}

/* ---------- pieces */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.tight { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi .value { font-size: 1.4rem; } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--text-2); font-size: .82rem; }
.kpi .value { font-size: 1.7rem; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: .8rem; }
.change.up { color: var(--ok); } .change.down { color: var(--danger); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

button, .btn {
  font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; justify-content: center;
}
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; font-weight: 500; }
button:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

label { display: block; font-size: .85rem; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); min-height: 38px;
}
input[type=checkbox] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin: 0; }
.hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
td.n, th.n { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tr.click { cursor: pointer; }
tr.total td { font-weight: 700; }
.table-wrap { overflow: auto; max-height: 70vh; }
.wrap-cell { white-space: normal; min-width: 200px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.pill.held { background: rgba(31,122,58,.12); color: var(--ok); }
.pill.canceled { background: rgba(192,57,43,.1); color: var(--danger); }
.pill.not_reported { background: rgba(154,100,0,.12); color: var(--warn); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--text-2); padding: 10px 12px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 999px; padding: 4px 12px; min-height: 32px; font-weight: 500; font-size: .85rem; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
details.picker { position: relative; }
details.picker > summary { list-style: none; cursor: pointer; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); min-height: 38px; }
details.picker > summary::-webkit-details-marker { display: none; }
details.picker .menu { position: absolute; z-index: 10; margin-top: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; max-height: 320px; overflow: auto; min-width: 240px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
details.picker .menu label { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); padding: 4px; margin: 0; }

/* ---------- record screen */
.big-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.big-item { display: block; text-align: left; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; min-height: 72px; }
.big-item:hover { border-color: var(--accent); }
.big-item strong { display: block; font-size: 1.05rem; }
.stepper { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stepper:last-child { border-bottom: 0; }
.stepper .ctrl { display: flex; align-items: center; gap: 6px; }
.stepper .ctrl button { width: 48px; height: 48px; font-size: 1.4rem; padding: 0; border-radius: 10px; }
.stepper .ctrl input { width: 84px; height: 48px; text-align: center; font-size: 1.25rem; font-weight: 700; }
.stepper .name { font-weight: 600; }
.total-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
@media (max-width: 520px) { .total-bar .seg { width: 100%; } .total-bar .seg button { flex: 1; padding: 8px 4px; } }
.total-bar .big { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.save-bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 8px; z-index: 5; }
.save-bar button { flex: 1; min-height: 50px; font-size: 1.05rem; }
@media (max-width: 860px) { .save-bar { bottom: 64px; } }
.person-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 4px; border-bottom: 1px solid var(--border); min-height: 54px; }
.person-row .tick { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 1.2rem; }
.person-row.in .tick { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- charts */
.chart { position: relative; }
.chart-plot { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; font-size: .85rem; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend i, .chart-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 160px; z-index: 3; }
.chart-tip div { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.chart-tip b { margin-left: auto; padding-left: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip .tip-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.chart-empty { padding: 40px 0; text-align: center; }

/* ---------- auth */
.auth { max-width: 400px; margin: 10vh auto; }
.auth .brand { justify-content: center; font-size: 1.3rem; }
.error { color: var(--danger); font-size: .9rem; margin: 8px 0; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
@media (max-width: 860px) { #toast { bottom: 84px; } }
.log { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; background: var(--surface-2); border-radius: 8px; padding: 10px; max-height: 220px; overflow: auto; white-space: pre-wrap; }

@media print {
  #nav, .no-print, .save-bar { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
}

.seg.todate button { min-width: 56px; }

.source-note { font-size: .85rem; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 8px 0 0; }

.ministry-card { display: flex; flex-direction: column; gap: 4px; }
.mini-stats { display: flex; gap: 18px; margin: 8px 0 4px; flex-wrap: wrap; }
.mini-stats div { display: flex; flex-direction: column; }
.mini-stats b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: .75rem; color: var(--muted); }

.show-filter { gap: 16px; margin: -8px 0 14px; }

.seg.todate { flex-wrap: nowrap; white-space: nowrap; }
@media (max-width: 520px) { .fields > div[style*='span 2'] { grid-column: auto !important; } }

table.sundays tr.qhead td { background: var(--surface-2); font-weight: 700; color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.sundays tr.total td { color: var(--text-2); font-size: .9rem; }

.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { padding: 9px 14px; color: var(--text-2); text-decoration: none; font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.subtabs a:hover { color: var(--text); }
.subtabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.plan-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.plan-team { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.card.plan.upcoming { border-style: dashed; }
.sv { display: inline-block; min-width: 26px; text-align: center; border-radius: 999px; padding: 1px 7px; margin-left: 4px; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sv.c { background: rgba(31,122,58,.15); color: var(--ok); }
.sv.u { background: rgba(154,100,0,.15); color: var(--warn); }
.sv.d { background: rgba(192,57,43,.12); color: var(--danger); }
.sv.n { background: var(--surface-2); color: var(--text-2); }
table.roles { margin-top: 8px; font-size: .85rem; }
table.roles td { padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: normal; }
table.roles tr.st-declined td:nth-child(2) { text-decoration: line-through; color: var(--muted); }
table.roles tr.st-needed td { color: var(--muted); font-style: italic; }
table.roles tr.st-confirmed td:last-child { color: var(--ok); }
table.roles tr.st-unconfirmed td:last-child { color: var(--warn); }
table.roles tr.st-declined td:last-child { color: var(--danger); }
.legend-row { margin: -4px 0 12px; }

.card.prayer .prayer-text { white-space: pre-wrap; margin: 10px 0 0; line-height: 1.55; }
.card.prayer .prayer-notes { margin-top: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: 8px; font-size: .9rem; white-space: pre-wrap; }

.catbar { height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.catbar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.catbar.over span { background: var(--danger); }
.fin-carry { color: var(--carry); } .fin-spent { color: var(--spent); }
.fin-funds { color: var(--funds); }
.fg-chips { flex-wrap: wrap; gap: 6px 14px; margin: 6px 0; }
.fg-controls { margin: 8px 0 6px; }
.hpill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.hpill b { font-weight: 800; }
.h-healthy { background: rgba(31,122,58,.14); color: var(--ok); }
.h-watch { background: rgba(154,100,0,.14); color: var(--warn); }
.h-over { background: rgba(192,57,43,.14); color: var(--danger); }
.h-none, .h-future { background: var(--surface-2); color: var(--text-2); }
.hcell { display: inline-block; min-width: 44px; padding: 3px 4px; border-radius: 6px; font-size: .75rem; font-weight: 600; text-align: center; }
.hcal td, .hcal th { padding-left: 4px; padding-right: 4px; }
.catbar .pace { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .6; }
.insights { margin: 12px 0 4px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); }
.insights p { margin: 6px 0; }
.ins { display: inline-block; width: 1.2em; text-align: center; }
.ins-up, .ins-down, .ins-info { color: var(--text-2); }
.trend { color: var(--text-2); font-weight: 600; font-size: .85em; white-space: nowrap; }

/* "CITIZEN CHURCH" wordmark, cut from the logo file (white artwork: shown black on the light theme) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.brand-word { position: relative; flex: none; display: inline-block; width: 128px; height: 16px; overflow: hidden; }
.brand-word img { position: absolute; width: 216px; height: 216px; left: -43.2px; top: -183.2px; max-width: none; filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-word img { filter: none; } }
:root[data-theme="dark"] .brand-word img { filter: none; }
.auth .brand-word { width: 160px; height: 20px; }
.auth .brand-word img { width: 270px; height: 270px; left: -54px; top: -229px; }
.glance { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 10px; }
.glance > div { display: flex; flex-direction: column; gap: 4px; }
.glance b { font-size: 1.5rem; }
@media (max-width: 520px) { .glance { grid-template-columns: 1fr; } }
