/* 教會收支報表:帳冊風格 — 留白、等寬數字、細線表格。圖表顏色:收入 = 藍、支出 = 橘(色盲可分辨的一組)。 */
:root {
  --bg: #f6f6f3; --panel: #fcfcfb; --fg: #17181a; --muted: #5c5d5a; --line: #dcdcd6; --line-soft: #ebebe6;
  --accent: #1d5fb4; --neg: #b3261e; --warn-bg: #fff4e0; --warn-fg: #7a4b00;
  --series-1: #2a78d6; --series-2: #eb6834;
  --font: system-ui, "Microsoft JhengHei", "Noto Sans TC", "PingFang TC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --panel: #1a1a19; --fg: #f0efec; --muted: #b5b4ab; --line: #3a3a37; --line-soft: #2a2a28;
    --accent: #7fb2f0; --neg: #f28b82; --warn-bg: #3a2c10; --warn-fg: #f5d08a;
    --series-1: #3987e5; --series-2: #d95926;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.6 var(--font); }
.wrap { max-width: 1080px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding-block: 10px; }
.brand { font-size: 17px; font-weight: 700; color: var(--fg); text-decoration: none; margin-right: auto; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.nav a { text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--fg); font-weight: 600; }
.who { color: var(--muted); font-size: 13px; }
button.link { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--accent); cursor: pointer; }
button.link.danger { color: var(--neg); }

main.wrap { padding-block: 20px 32px; display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 22px; line-height: 1.3; margin: 4px 0 0; text-wrap: balance; }
h2 { font-size: 16px; margin: 14px 0 0; }
p { margin: 0; max-width: 70ch; }
.lead { font-size: 16px; }
.soft { color: var(--muted); font-size: 13px; }
.neg { color: var(--neg); }
.warn { background: var(--warn-bg); color: var(--warn-fg); padding: 8px 12px; border-radius: 6px; }
.foot { color: var(--muted); font-size: 12px; padding-block: 0 28px; }

.tabs, .pager { display: flex; flex-wrap: wrap; gap: 6px; }
.pager { justify-content: space-between; }
.tabs a, .pager a { text-decoration: none; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--fg); font-variant-numeric: tabular-nums; }
.tabs a[aria-current="page"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card.narrow { max-width: 460px; margin: 24px auto; width: 100%; }
.card h1, .card h2 { margin: 0; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); text-decoration: none; text-align: center; font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); font-weight: 600; }
.btn[disabled] { opacity: .6; cursor: default; }
.upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.upload input { min-width: 0; max-width: 100%; font: inherit; }
#upload-result ul { margin: 6px 0 0; padding-left: 20px; }
#upload-result .ok { color: var(--fg); background: var(--line-soft); padding: 8px 12px; border-radius: 6px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; min-width: 0; }
.tile span { color: var(--muted); font-size: 13px; }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
thead th { font-weight: 600; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); background: var(--panel); }
tbody th { font-weight: 400; }
td.num, th.num { text-align: right; }
tr.total > * { font-weight: 700; border-top: 1px solid var(--line); }
tr.alert > * { color: var(--neg); font-weight: 700; }
tbody tr:last-child > *, tfoot tr:last-child > * { border-bottom: 0; }
.grid-table th[scope="row"] { position: sticky; left: 0; background: var(--panel); }
.report th.sect { vertical-align: top; font-weight: 700; border-right: 1px solid var(--line-soft); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.cols section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cols h2 { margin: 0; }
.kv th { font-weight: 400; }

.chart { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); padding-bottom: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.sw.s1, rect.s1 { background: var(--series-1); fill: var(--series-1); }
.sw.s2, rect.s2 { background: var(--series-2); fill: var(--series-2); }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 13px; font-family: var(--font); font-variant-numeric: tabular-nums; }

@media print {
  .top .nav, .tabs, .pager, .foot, .chart { display: none; }
  body { background: #fff; }
  .scroll, .cols section { border-color: #999; }
}
