:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #5d6676; --line: #dfe3ea;
  --accent: #1f5f9e; --accent-soft: #e8f0f9; --warn: #8a5a00; --warn-soft: #fff4dc;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.topbar { background: var(--accent); color: #fff; }
.topbar .inner { max-width: 1200px; margin: 0 auto; padding: .6rem 1rem; display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.topbar a { color: #fff; }
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar form.search { display: flex; }
.topbar input[type=search] { border: 0; border-radius: var(--radius); padding: .4rem .7rem; width: 16rem; max-width: 50vw; }
.topbar .user { font-size: .9rem; opacity: .9; display: flex; gap: .75rem; align-items: center; }
.topbar .user button { background: none; border: 0; color: #fff; cursor: pointer; font: inherit; padding: 0; }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.subtitle { color: var(--muted); margin: 0 0 1.25rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--muted); }
.notice { background: var(--warn-soft); color: var(--warn); padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; }

dl.fields { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
tr.ended td { color: var(--muted); }
.table-wrap { overflow-x: auto; }

form.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
input, select, button { font: inherit; }
form.filters input, form.filters select { padding: .35rem .5rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: var(--radius); padding: .4rem .9rem; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--line); }

.btn.danger { background: #b3261e; }
.btn.small { padding: .15rem .55rem; font-size: .85rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.row-actions { white-space: nowrap; text-align: right; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem 1.25rem; }
.form-row { display: flex; flex-direction: column; gap: .2rem; }
.form-row.wide, .form-row:has(textarea) { grid-column: 1 / -1; }
.form-row label { font-size: .85rem; color: var(--muted); }
.form-row.check label { color: var(--text); font-size: .95rem; display: flex; gap: .5rem; align-items: center; }
.form-row input:not([type=checkbox]), .form-row select, .form-row textarea {
  padding: .4rem .5rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; width: 100%; }
.form-row.has-error input, .form-row.has-error select { border-color: #b3261e; }
.form-actions { display: flex; gap: .5rem; margin-top: 1.25rem; align-items: center; }

.lookup { position: relative; }
.lookup-results { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0,0,0,.08); max-height: 18rem; overflow-y: auto; }
.lookup-results li { padding: .4rem .6rem; cursor: pointer; }
.lookup-results li small { color: var(--muted); }
.lookup-results li:hover, .lookup-results li.active { background: var(--accent-soft); }

.report-item { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.report-item:last-child { border-bottom: 0; }
.report-filters { display: flex; flex-wrap: wrap; gap: .9rem 1.25rem; align-items: flex-start; }
.report-filters .form-row { min-width: 180px; }
.report-filters .form-actions { flex-basis: 100%; margin-top: .25rem; }
.report-filters select[multiple] { min-width: 260px; }
.report-section { margin-bottom: 1.5rem; }
.report-section h2 { margin: 1rem 0 .1rem; }
.report-section > p.muted { margin: 0 0 .4rem; }
.report-table { background: var(--panel); font-size: .9rem; }
.report-table td.num, .report-table th.num { text-align: right; white-space: nowrap; }
.report-table tfoot td { font-weight: 600; border-top: 2px solid var(--text); }
.print-only { display: none; }

/* Year charts (year_chart.js) */
.year-chart { position: relative; margin: .25rem 0 1rem; }
.chart-svg { display: block; font: 12px system-ui, "Segoe UI", sans-serif; outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.chart-svg .grid { stroke: #e1e0d9; stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .axis { stroke: #c3c2b7; stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .tick { fill: #52514e; font-variant-numeric: tabular-nums; }
.chart-svg .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .series-dot { stroke: #fff; stroke-width: 2; }
.chart-svg .series-line.s1 { stroke: #2a78d6; }   /* series slot 1: salary */
.chart-svg .series-dot.s1 { fill: #2a78d6; }
.chart-svg .series-line.s2 { stroke: #eb6834; }   /* series slot 2: total compensation */
.chart-svg .series-dot.s2 { fill: #eb6834; }
.chart-svg .end-label { fill: #0b0b0b; font-weight: 600; }
.chart-svg .crosshair { stroke: #898781; stroke-width: 1; }
.chart-legend { display: flex; gap: 1.25rem; font-size: .85rem; color: #52514e; margin-bottom: .35rem; }
.chart-legend span, .tip-row { display: inline-flex; align-items: center; gap: .4rem; }
.key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.key.s1 { background: #2a78d6; }
.key.s2 { background: #eb6834; }
.chart-tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid rgba(11,11,11,.12);
  border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.08); padding: .35rem .6rem; white-space: nowrap; font-size: .85rem; }
.chart-tip .tip-head { color: #52514e; margin-bottom: .15rem; }
.chart-tip .tip-row { display: flex; }
.chart-tip strong { color: #0b0b0b; font-variant-numeric: tabular-nums; min-width: 5.5em; }
.chart-tip span { color: #52514e; }

.dq-summary { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.dq-summary a { white-space: nowrap; }

.last-change { margin: -.9rem 0 1.25rem; font-size: .85rem; }
.history ul.changes { margin: 0; padding-left: 1rem; }
.history td { vertical-align: top; }

/* Home page */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-tile { display: flex; flex-direction: column; gap: .2rem; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.1rem; color: var(--text); }
.stat-tile:hover { text-decoration: none; border-color: var(--accent); }
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-value { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.home-row { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.home-row:last-child { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.link-list { margin: 0; padding-left: 1.1rem; }
.link-list li { margin: .2rem 0; }

/* Printable clergy profile */
.profile-toolbar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.profile-toolbar form.filters { margin: 0; }
.profile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem; font-size: .92rem; }
.profile-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--text); padding-bottom: .5rem; margin-bottom: .75rem; }
.profile-head h1 { font-size: 1.45rem; }
.profile-sub { margin: .1rem 0 0; color: var(--muted); }
.profile-meta { text-align: right; font-size: .8rem; white-space: nowrap; }
.profile-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
.profile section { margin-top: .9rem; }
.profile h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .3rem;
  border-bottom: 1px solid var(--line); padding-bottom: .15rem; }
.profile p { margin: .2rem 0; }
.profile-table { width: 100%; border-collapse: collapse; }
.profile-table th { font-size: .72rem; padding: .1rem .35rem; }
.profile-table td { padding: .12rem .35rem; border-bottom: 1px solid #efeee9; }
.profile-table .w-label { width: 34%; }
.profile-table .w-date { width: 4.5rem; white-space: nowrap; }
ul.compact { margin: 0; padding-left: 1rem; }
.profile-foot { margin-top: 1rem; font-size: .8rem; }

.messages { margin-bottom: 1rem; display: grid; gap: .4rem; }
.message { background: var(--accent-soft); color: var(--accent); border-radius: var(--radius); padding: .55rem .9rem; }
.message.success { background: #e6f4e6; color: #1d5e1d; }
.message.warning, .message.error { background: var(--warn-soft); color: var(--warn); }

tr.needs-fix td { background: var(--warn-soft); }

.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
details.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; }
details.section > summary { padding: .75rem 1.25rem; cursor: pointer; font-weight: 600; }
details.section > div { padding: 0 1.25rem 1rem; }

.login { max-width: 360px; margin: 4rem auto; }
.login label { display: block; margin: .75rem 0 .25rem; }
.login input { width: 100%; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius); }
.errorlist { color: #a12; padding-left: 1rem; }
.btn.google { width: 100%; padding: .6rem; font-size: 1rem; }
.password-login { margin-top: 1.25rem; }
.password-login summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

@media print {
  .topbar, form.filters, .pager, .no-print { display: none !important; }
  .print-only { display: block; }
  main { max-width: none; padding: 0; }
  .report-table { font-size: 8.5pt; }
  .report-table th, .report-table td { padding: .15rem .3rem; }
  .report-section { break-inside: auto; }
  .report-section h2 { break-after: avoid; }
  tr { break-inside: avoid; }
  .profile { border: 0; padding: 0; margin: 0; font-size: 9.5pt; }
  .profile + .profile { break-before: page; }
  .profile h2 { break-after: avoid; }
  .profile section { break-inside: auto; }
  a { color: inherit; }
  body { background: #fff; }
  .panel, details.section { border: 0; padding: 0; }
  details.section > div { display: block; }
}
