:root {
  /* The Generis palette: teal 12837B, slate 41525A, light gray E3E9EB, mid gray A6B3BB, light teal A1CDCB, plum 510E35, amber D88D2B.
     The tints and darker shades below are derived from it so text stays readable. */
  --bg: #f1f4f5;
  --panel: #ffffff;
  --ink: #41525a;
  --muted: #667780;
  --line: #d5dde0;
  --accent: #12837b;
  --accent-ink: #ffffff;
  --head: #e3e9eb;
  --input-bg: #fcf1de;
  --good: #0e6b64;
  --bad: #510e35;
  --warn-bg: #f9ecd6;
  --warn-ink: #8a5614;
  --note-bg: #e1efee;
  --good-bg: #d9ecea;
  --bad-bg: #ebd9e3;
  --plum: #510e35;
  --tile: #f1f4f5;
  --band-spend: #d9ecea;
  --band-surplus: #e3e9eb;
  --band-holding: #f2e4eb;
  --shadow: 0 1px 2px rgba(65, 82, 90, .10);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b2429; --panel: #232d33; --ink: #e3e9eb; --muted: #a6b3bb; --line: #36444b;
    --accent: #4fb3a9; --accent-ink: #0f1d1c; --head: #2c3940; --input-bg: #3a3122;
    --good: #a1cdcb; --bad: #e0a6c4; --good-bg: #1d3a38; --bad-bg: #3a1f30; --warn-bg: #3d2f17; --warn-ink: #efc47f; --note-bg: #20383a;
    --plum: #d9a3c0;
    --tile: #2a353b;
    --band-spend: #1d3a38;
    --band-surplus: #2c3940;
    --band-holding: #3a1f30;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
header.top { display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top h1 { font-size: 17px; margin: 0; }
header.top .who { margin-left: auto; }
nav.sitenav { display: flex; gap: 4px; }
nav.sitenav a { padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
nav.sitenav a:hover { background: var(--bg, #f3f4f6); color: inherit; }
nav.sitenav a[aria-current="page"] { color: inherit; font-weight: 600; background: var(--bg, #f3f4f6); }
header.top h1 a { color: var(--plum); text-decoration: none; }
header.top .who { color: var(--muted); font-size: 13px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 60px; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p.sub, .muted { color: var(--muted); }
a { color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

button, .btn { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
input.entry { background: var(--input-bg); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.field { display: inline-block; vertical-align: top; margin-right: 14px; margin-bottom: 8px; }       /* tops line up even when one field has a hint under it */
.field input { width: 190px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.good { color: var(--good); border-color: var(--good); }
.badge.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: transparent; }

.banner { padding: 10px 14px; border-radius: 6px; margin: 12px 0; background: var(--note-bg); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.error { background: var(--warn-bg); color: var(--bad); }

nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 12px; flex-wrap: wrap; }
nav.tabs a { padding: 8px 16px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; }
nav.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.stat .note { font-size: 12px; color: var(--muted); }
.pos { color: var(--good); } .neg { color: var(--bad); }

.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table.sheet { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.sheet th, table.sheet td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.sheet th { position: sticky; top: 0; background: var(--head); font-size: 12px; z-index: 1; }
table.sheet td.l, table.sheet th.l { text-align: left; }
table.sheet tr.first td { background: var(--note-bg); font-weight: 600; }
table.sheet tr.yearstart td { border-top: 2px solid var(--line); }
table.sheet input.cell { width: 130px; text-align: right; }
table.sheet td.status { font-size: 12px; color: var(--muted); text-align: left; min-width: 70px; }

ol.steps { padding-left: 20px; margin: 6px 0; }
ol.steps li.done { color: var(--muted); text-decoration: line-through; }
ol.steps li.next { font-weight: 600; }

svg.chart { width: 100%; height: auto; max-height: 320px; }
svg.chart text { fill: var(--muted); font-size: 11px; }
svg.chart .grid { stroke: var(--line); }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); max-width: 520px; width: calc(100% - 40px); padding: 18px 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 6px; max-width: 360px; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.toast.error { background: var(--bad); color: #fff; }
.center { max-width: 460px; margin: 60px auto; }
.tag-edit { background: var(--warn-bg); color: var(--warn-ink); border-radius: 4px; padding: 0 6px; font-size: 12px; }
@media (max-width: 720px) { main { padding: 14px 12px 50px; } header.top { padding: 10px 12px; } .field input { width: 100%; } }

/* expense planner and status table */
.small { font-size: 12px; }
.strong { font-weight: 600; }
.field input[type="checkbox"] { width: auto; }
label.inline { display: inline-block; font-size: 14px; color: var(--ink); margin: 0 6px; }
.tablewrap.wide { max-height: 75vh; }
table.planner th, table.planner td { min-width: 118px; }
table.planner th.sticky, table.planner td.sticky { position: sticky; left: 0; min-width: 210px; max-width: 260px; white-space: normal; text-align: left; background: var(--panel); z-index: 2; }
table.planner th.sticky { background: var(--head); z-index: 3; }
table.planner tr.first td { background: var(--note-bg); }
table.planner tr.first td.sticky { background: var(--note-bg); }
table.planner tr.projectstart td { border-top: 2px solid var(--line); background: var(--panel); }
table.planner tr.sumstart td { border-top: 2px solid var(--line); }
table.planner input.cell { width: 104px; }
.who { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.who.church { color: var(--accent); border-color: var(--accent); }
.who.generis { color: var(--muted); }

.pctbox { display: inline-flex; align-items: center; gap: 4px; }
.pctbox input { width: 110px; text-align: right; }
.pctsign { color: var(--muted); font-size: 14px; }

table.sheet.grouped th.grp { text-align: center; }
table.sheet.grouped th.gs, table.sheet.grouped td.gs { border-left: 1px solid var(--line); }
table.sheet.grouped thead tr.groups th { top: 0; }
table.sheet.grouped thead tr.cols th { top: 29px; }
table.sheet.grouped td.proj { color: var(--muted); }
table.sheet.grouped td.month { position: sticky; left: 0; background: var(--panel); z-index: 1; }
table.sheet.grouped thead th.mh { left: 0; z-index: 3; }
table.sheet.grouped tr.first td.month { background: var(--note-bg); }
table.sheet.grouped input.cell { width: 104px; }
.recv { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.flag { display: inline-block; min-width: 40px; text-align: center; font-size: 11px; line-height: 1.5; padding: 0 6px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.flag.ok { background: var(--head); color: var(--muted); }
.flag.up { background: var(--good-bg); color: var(--good); }
.flag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.flag.bad { background: var(--bad-bg); color: var(--bad); }

.recv .flag { width: 58px; min-width: 0; box-sizing: border-box; flex: none; white-space: nowrap; }
.flag.slot { visibility: hidden; }

label.inline.block { display: block; margin: 6px 0 0 0; }

table.sheet tr.archived td { color: var(--muted); }
table.sheet tr.archived td a { color: var(--muted); }
button.quiet { color: var(--muted); }

table.sheet.dir { table-layout: fixed; }
table.sheet.dir th:nth-child(1) { width: 25%; } table.sheet.dir th:nth-child(2) { width: 23%; } table.sheet.dir th:nth-child(3) { width: 15%; }
table.sheet.dir th:nth-child(4) { width: 9%; } table.sheet.dir th:nth-child(5) { width: 8%; } table.sheet.dir th:nth-child(6) { width: 6%; } table.sheet.dir th:nth-child(7) { width: 14%; }
table.sheet.dir.withlead th:nth-child(1) { width: 14%; } table.sheet.dir.withlead th:nth-child(2) { width: 13%; } table.sheet.dir.withlead th:nth-child(3) { width: 11%; }
table.sheet.dir.withlead th:nth-child(4) { width: 14%; } table.sheet.dir.withlead th:nth-child(5) { width: 13%; } table.sheet.dir.withlead th:nth-child(6) { width: 7%; }
table.sheet.dir.withlead th:nth-child(7) { width: 8%; } table.sheet.dir.withlead th:nth-child(8) { width: 6%; } table.sheet.dir.withlead th:nth-child(9) { width: 200px; }
table.sheet.dir td.acts { white-space: nowrap; overflow: visible; text-align: right; }
h2 .church { font-size: 15px; font-weight: 400; }
table.sheet.dir td, table.sheet.dir th { overflow: hidden; text-overflow: ellipsis; }
table.sheet.dir td button { padding: 2px 10px; font-size: 13px; }

.two-up { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; margin-bottom: 16px; }
.two-up .card { margin: 0; }
svg.chart .grid.zero { stroke: var(--muted); stroke-width: 1.5; }
svg.chart .bar.planned { fill: var(--muted); opacity: .35; }
svg.chart .bar.actual { fill: var(--plum); }
svg.chart .line { stroke-width: 2.5; }
svg.chart .line.expected { stroke: var(--muted); stroke-dasharray: 6 4; stroke-width: 2; }
svg.chart .line.received { stroke: var(--good); }
svg.chart circle.received { fill: var(--good); stroke: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend .key { display: inline-flex; align-items: center; gap: 4px; }
.legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; }
.legend i.sw.planned { background: var(--muted); opacity: .35; }
.legend i.sw.actual { background: var(--plum); }
.legend i.sw.expected { height: 0; border-top: 2px dashed var(--muted); border-radius: 0; }
.legend i.sw.received { height: 0; border-top: 3px solid var(--good); border-radius: 0; }

table.sheet.people td .row { gap: 6px; flex-wrap: nowrap; }
table.sheet.people td button { padding: 2px 10px; font-size: 13px; }
table.sheet.people td { white-space: normal; }
input[type="search"] { min-width: 240px; }

/* expense planner: Planned and Actual sit indented under their project, and the summary rows are shaded in groups */
table.planner td.indent { padding-left: 28px; font-weight: 400; }
table.planner tr.projectstart td, table.planner tr.projectstart td.sticky { background: var(--tile); }
table.planner tr.band.spend { --band: var(--band-spend); }
table.planner tr.band.surplus { --band: var(--band-surplus); }
table.planner tr.band.holding { --band: var(--band-holding); }
table.planner tr.band td, table.planner tr.band td.sticky { background: var(--band); }
table.planner tr.bandstart td { border-top: 2px solid var(--muted); }

/* Givers */
table.givers th.sortable { cursor: pointer; user-select: none; }
table.givers th.sortable:hover { background: var(--note-bg); }
table.givers th, table.givers td { padding: 4px 6px; }
table.givers th { white-space: normal; vertical-align: bottom; line-height: 1.25; min-width: 64px; }
table.givers input.cell { width: 98px; text-align: right; padding: 4px 6px; }
table.givers input.cell.id { width: 66px; text-align: left; }
table.givers input.cell.wide { width: 178px; text-align: left; }
table.givers td.c { text-align: center; }
table.givers td.acts { text-align: right; }
table.givers td.acts button { padding: 2px 10px; font-size: 13px; }
table.givers tr.subrow td { background: var(--tile); color: var(--muted); font-size: 13px; }
table.givers tr.subrow td.subl { padding-left: 28px; }
table.givers tr.refreshonly td:first-child { border-left: 3px solid var(--accent); }
table.givers tfoot td { position: sticky; bottom: 0; background: var(--head); font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
dialog.wide { max-width: 860px; }
.tablewrap.short { max-height: 280px; }
table.sheet tr.errorrow td { background: var(--bad-bg); }

/* Fields in a grid keep their inputs on one line even when a label wraps or a help line is missing */
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px 22px; align-items: start; }
.fieldgrid .field { margin: 0; display: block; }
.fieldgrid .field label { min-height: 2.7em; display: flex; align-items: flex-end; }
.fieldgrid .field input:not([type=checkbox]) { width: 100%; max-width: 260px; }
.fieldgrid .pctbox input { width: 110px; }
/* Giver tiles and toolbar */
.cards.tiles { margin: 14px 0 18px; }
.row.toolbar { margin: 0 0 14px; }
.field label.inline { display: inline-flex; align-items: center; min-height: 2.3em; margin: 0; }      /* a checkbox row sits level with the other fields' inputs */
