/* ChurchLedger — styles.
   Design tokens follow the validated reference palette (light + dark). */

:root {
  --surface-1: #fcfcfb;
  --surface-2: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-income: #2a78d6;
  --series-expense: #e34948;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #4a3aa7;
  --series-6: #e87ba4;
  --series-7: #008300;
  --series-8: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --accent: #5b21b6;
  --accent-ink: #ffffff;
  --gold: #f0a800;
  --sidebar-bg: #2a1060;
  --sidebar-ink: #ece5fb;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 14px rgba(0, 0, 0, .06);
  --radius: 10px;
}

:root[data-theme="dark"] {
  --surface-1: #1a1a19;
  --surface-2: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-income: #3987e5;
  --series-expense: #e66767;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #9085e9;
  --series-6: #d55181;
  --series-7: #008300;
  --series-8: #d95926;
  --good: #0ca30c;
  --good-text: #0ca30c;
  --accent: #a78bfa;
  --gold: #ffb703;
  --sidebar-bg: #150a2b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.45;
}
.hidden { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; }
small { color: var(--text-muted); }

/* ------------------------------- Login ------------------------------ */
.login-screen {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: linear-gradient(160deg, #1e0b4a 0%, #3b1487 55%, #5b21b6 100%);
  padding: 16px;
}
.login-card {
  background: var(--surface-1); border-radius: 14px; box-shadow: var(--shadow);
  padding: 36px 32px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { height: 76px; width: auto; max-width: 160px; object-fit: contain; }
.login-card h1 { font-size: 24px; margin: 4px 0 2px; }
.login-sub { color: var(--text-muted); margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; text-align: left; margin-bottom: 14px; font-weight: 550; font-size: 13px; }
.login-card input {
  width: 100%; margin-top: 5px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--baseline); background: var(--surface-2); color: var(--text-primary);
  font-size: 15px;
}
.login-error {
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  color: var(--critical); border-radius: 8px; padding: 9px 12px; margin-bottom: 14px; font-size: 13px;
}

/* ------------------------------ Layout ------------------------------ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-head {
  display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { height: 36px; width: auto; max-width: 64px; object-fit: contain; flex-shrink: 0; }
.sidebar-head strong { display: block; font-size: 15px; }
.sidebar-head small { color: rgba(229,233,240,.55); font-size: 11px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 6px; scrollbar-width: thin; }
.nav-section { margin: 10px 8px 3px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: rgba(229,233,240,.45); }
.nav-section:first-child { margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  border-radius: 8px; color: var(--sidebar-ink); text-decoration: none; font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot .btn { color: var(--sidebar-ink); width: 100%; justify-content: flex-start; }
.app-version-footer {
  font-size: 10.5px; color: rgba(229,233,240,.45); text-align: center; margin: 0;
  line-height: 1.5;
}
.sidebar-foot .app-version-footer { margin-top: 10px; padding: 0 4px; }
.login-screen .app-version-footer { max-width: 420px; color: rgba(255,255,255,.5); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 17px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.menu-btn { display: none; }
.help-btn {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  font-size: 14px; font-weight: 700; cursor: pointer; line-height: 1; padding: 0;
}
.help-btn:hover { color: var(--accent); border-color: var(--accent); }
.chat-btn { position: relative; cursor: pointer; font-size: 18px; padding: 4px; }
.chat-online-count {
  position: absolute; top: -2px; right: -6px; background: var(--good); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px;
}
.chat-unread-dot {
  position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--critical); border: 1.5px solid var(--surface-1);
}
.alert-bell { position: relative; cursor: pointer; font-size: 18px; padding: 4px; }
.alert-count {
  position: absolute; top: -2px; right: -6px; background: var(--critical); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px;
}
.user-chip { font-size: 13px; color: var(--text-secondary); }
.user-chip b { color: var(--text-primary); }
.view { padding: 22px; max-width: 1280px; width: 100%; margin: 0 auto; }

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 40; left: -240px; transition: left .2s ease; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-flex; }
  .view { padding: 14px; }
}

/* ------------------------------ Cards ------------------------------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface-1); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 16px 18px; min-width: 0;
}
.card h3 { font-size: 13px; color: var(--text-secondary); font-weight: 600; margin-bottom: 10px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-row h3 { margin: 0; }

/* Plain block by default (label/value/sub stacked) — only the tiles that
   actually carry a .stat-icon (dashboard KPIs) switch to an icon+body row,
   so older simple stat-tiles elsewhere in the app aren't squeezed sideways. */
.stat-tile:has(.stat-icon) { display: flex; gap: 12px; align-items: flex-start; }
a.stat-tile {
  display: block; text-decoration: none; color: inherit; cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease;
}
a.stat-tile:has(.stat-icon) { display: flex; }
a.stat-tile:hover { box-shadow: 0 3px 14px rgba(0,0,0,.12); transform: translateY(-1px); }
.stat-tile .stat-value { color: var(--text-primary); }
.stat-tile .stat-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 9px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.stat-tile .stat-body { min-width: 0; flex: 1; }
.stat-tile h3 { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.stat-tile .stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.stat-tile.stat-tile-hero .stat-value { font-size: 22px; }
.stat-tile .stat-value {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.stat-tile .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.stat-tile .up { color: var(--good-text); }
.stat-tile .down { color: var(--critical); }
.stat-delta {
  display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 700;
  padding: 1px 7px 1px 6px; border-radius: 999px; white-space: nowrap;
}
.stat-delta.up { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-text); }
.stat-delta.down { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.stat-delta.flat { background: color-mix(in srgb, var(--text-muted) 15%, transparent); color: var(--text-muted); }

/* ---------------------------- Alert banner --------------------------- */
.alert-banner { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert-banner-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 9px;
  background: color-mix(in srgb, var(--warning) 14%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
  font-size: 13.5px;
}
:root[data-theme="dark"] .alert-banner-row { background: color-mix(in srgb, var(--warning) 10%, var(--surface-1)); }
.alert-banner-row .alert-icon { flex-shrink: 0; font-size: 15px; }
.alert-banner-row .alert-text { flex: 1; color: var(--text-primary); }
.alert-banner-row .alert-action { flex-shrink: 0; }

/* ---------------------------- Verse banner ---------------------------- */
.verse-banner {
  display: flex; align-items: baseline; gap: 8px; padding: 9px 14px; margin-bottom: 16px;
  border-radius: 9px; font-size: 13px; font-style: italic; color: var(--text-secondary);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.verse-banner .verse-icon { font-style: normal; flex-shrink: 0; }
.verse-banner .verse-ref { font-style: normal; font-weight: 700; color: var(--text-primary); white-space: nowrap; }

.dq-clean {
  font-size: 13.5px; color: var(--good-text); padding: 8px 2px 0;
}

/* -------------------- Rotating dashboard notice banner ---------------- */
.notice-banner { margin-bottom: 16px; }
.notice-controls {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 7px;
}
.notice-nav {
  border: none; background: transparent; cursor: pointer; font-size: 20px; line-height: 1;
  color: var(--text-secondary); padding: 0 2px;
}
.notice-nav:hover { color: var(--text-primary); }
.notice-counter { font-size: 12px; color: var(--text-muted); min-width: 42px; text-align: center; }
.notice-dots { display: flex; gap: 5px; align-items: center; }
.notice-dot {
  width: 7px; height: 7px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: color-mix(in srgb, var(--warning) 30%, transparent);
}
.notice-dot.active { background: var(--warning); }
.dq-clean-pill {
  font-size: 13px; color: var(--good-text); margin-bottom: 16px; padding: 9px 14px; border-radius: 9px;
  background: color-mix(in srgb, var(--good) 9%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--good) 25%, transparent);
}

/* ------------------------------- Help --------------------------------- */
.help-doc .help-intro { font-size: 13px; color: var(--text-secondary); margin: 0 0 8px; }
.help-doc .more-options-toggle { font-size: 14px; font-weight: 600; }
.help-doc .help-body { font-size: 13.5px; color: var(--text-secondary); padding: 2px 4px 8px 22px; }
.help-doc .help-body p { margin: 6px 0; }
.help-doc .help-body ul { margin: 6px 0; padding-left: 18px; }
.help-doc .help-body li { margin: 4px 0; }

/* ------------------------------- Chat --------------------------------- */
.chat-online { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 10px; }
.chat-online .chat-dot { color: var(--good); font-size: 9px; vertical-align: middle; margin-right: 3px; }
.chat-online b { color: var(--text-primary); font-weight: 600; }
.chat-messages {
  height: 46vh; min-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg .chat-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.chat-msg .chat-bubble {
  padding: 7px 11px; border-radius: 12px; font-size: 13.5px; line-height: 1.35; white-space: pre-wrap;
  word-break: break-word; background: var(--surface-1); border: 1px solid var(--border); color: var(--text-primary);
}
.chat-msg.mine .chat-bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chat-empty { color: var(--text-muted); text-align: center; margin: auto; font-size: 13px; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-input-row textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); font: inherit; font-size: 13.5px;
}

/* ------------------------------ Bar list ------------------------------ */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-list-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 10px; }
.bar-list-label {
  font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.bar-list-track {
  position: relative; height: 10px; border-radius: 5px;
  background: color-mix(in srgb, var(--text-muted) 16%, transparent);
  overflow: hidden;
}
.bar-list-fill { position: absolute; inset: 0 auto 0 0; height: 100%; border-radius: 5px; min-width: 3px; }
.bar-list-value {
  font-size: 12.5px; font-weight: 700; color: var(--text-primary); text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bar-list-empty { font-size: 12.5px; color: var(--text-muted); padding: 6px 0; }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }

/* ------------------------------ Tables ------------------------------ */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--grid);
  white-space: nowrap;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data tbody tr:nth-child(even) td { background: var(--surface-2); }
table.data tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.date-col, table.data th.date-col { white-space: nowrap; }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--baseline); }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text-primary); }
table.data .sort-indicator { display: inline-block; width: 10px; color: var(--accent); }
table.data tbody tr.group-footer-row td {
  background: var(--surface-2);
}
table.data tr.group-header-row td {
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-1));
  border-top: 2px solid var(--grid); border-bottom: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
:root[data-theme="dark"] table.data tr.group-header-row td {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-1));
}
table.data tr.group-footer-row td { font-weight: 700; border-top: 1px solid var(--grid); }
table.data tr.group-header-row:hover td {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-1));
}
table.data tr.group-footer-row:hover td { background: var(--surface-2); }
table.data tr.group-header-row.group-color-critical td {
  color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, var(--surface-1));
  border-bottom: 1px solid color-mix(in srgb, var(--critical) 25%, transparent);
}
:root[data-theme="dark"] table.data tr.group-header-row.group-color-critical td {
  background: color-mix(in srgb, var(--critical) 16%, var(--surface-1));
}
table.data tr.group-header-row.group-color-critical:hover td {
  background: color-mix(in srgb, var(--critical) 18%, var(--surface-1));
}
.amount-in { color: var(--good-text); font-weight: 600; }
.amount-out { color: var(--critical); font-weight: 600; }
.amount-deduction { color: var(--critical); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px;
  border-radius: 999px; text-transform: capitalize;
}
.badge.approved { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-text); }
.badge.pending { background: color-mix(in srgb, var(--warning) 20%, transparent); color: #8a6100; }
:root[data-theme="dark"] .badge.pending { color: var(--warning); }
.badge.rejected, .badge.void { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical); }
.badge.restricted { background: color-mix(in srgb, var(--series-5) 15%, transparent); color: var(--series-5); }
.badge.unrestricted { background: color-mix(in srgb, var(--series-3) 15%, transparent); color: var(--series-3); }

.task-list { display: flex; flex-direction: column; margin-top: 8px; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--grid); }
.task-row:last-child { border-bottom: none; }
.task-row input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.task-title { font-size: 13.5px; }
.task-row.done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-meta { font-size: 11.5px; color: var(--text-muted); }
.task-meta.overdue { color: var(--critical); font-weight: 600; }
.task-description { font-size: 12.5px; color: var(--text-secondary); margin: 3px 0 0; white-space: pre-wrap; }
.task-actions { display: flex; gap: 2px; flex-shrink: 0; }

.checkbox-list {
  display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); max-height: 140px; overflow-y: auto;
}
.checkbox-list-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checkbox-list-item input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }

/* ----------------------------- Buttons ------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; font-size: 13.5px;
  font-weight: 600; background: transparent; color: var(--text-primary); font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-outline { border-color: var(--baseline); }
.btn-outline:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: color-mix(in srgb, var(--text-primary) 7%, transparent); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ------------------------------ Forms ------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.field-hint { display: block; font-weight: 400; font-style: italic; color: var(--text-muted); margin-top: 1px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--baseline);
  background: var(--surface-2); color: var(--text-primary); font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }

.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px;
  background: var(--surface-1); border: 1px solid var(--baseline); border-radius: 8px;
  max-height: 220px; overflow-y: auto; box-shadow: var(--shadow);
}
.autocomplete-list.hidden { display: none; }
.autocomplete-item { padding: 7px 10px; font-size: 13.5px; cursor: pointer; }
.autocomplete-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.autocomplete-item.autocomplete-add { color: var(--accent); font-weight: 600; }

.more-options-toggle {
  background: none; border: none; cursor: pointer; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; padding: 4px 0 8px; font-family: inherit; display: block;
}
.more-options-toggle:hover { color: var(--accent); }
.more-options-toggle .chevron { display: inline-block; width: 14px; }
.more-options-body { padding-top: 10px; border-top: 1px solid var(--grid); gap: 12px 16px; }
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px;
}
.filters .field { min-width: 130px; }
.filters .field input, .filters .field select { padding: 6px 9px; font-size: 13px; }

/* ------------------------------- Reports ----------------------------- */
.reports-now-showing { font-size: 13px; color: var(--text-secondary); margin: 0; }
.report-quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.report-quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 14px 10px; border-radius: 10px; border: 1px solid var(--baseline);
  background: var(--surface-2); color: var(--text-primary); cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
}
.report-quick-btn:hover { background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.report-quick-btn.active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  border-color: var(--accent); color: var(--accent);
}
.report-quick-icon { font-size: 22px; }
.advanced-reports-toggle {
  background: none; border: none; cursor: pointer; color: var(--text-secondary);
  font-size: 13px; font-weight: 600; padding: 6px 0; font-family: inherit;
}
.advanced-reports-toggle:hover { color: var(--accent); }
.advanced-reports-toggle .chevron { display: inline-block; width: 14px; }
.advanced-reports-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }

/* ------------------------------ Modal ------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  background: var(--surface-1); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 620px; padding: 22px 24px;
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ------------------------------ Toast ------------------------------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text-primary); color: var(--surface-1); padding: 10px 16px;
  border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; max-width: 340px;
  animation: toast-in .18s ease;
}
.toast.error { background: var(--critical); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------ Misc -------------------------------- */
.empty { text-align: center; color: var(--text-muted); padding: 34px 10px; }
.alert-list .alert-item {
  display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--grid); font-size: 13.5px;
}
.alert-list .alert-item:last-child { border-bottom: 0; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; justify-content: space-between; align-items: center; }
.page-actions .left, .page-actions .right { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mono { font-variant-numeric: tabular-nums; }
.secret-box {
  font-family: ui-monospace, monospace; background: var(--surface-2); border: 1px dashed var(--baseline);
  padding: 10px 14px; border-radius: 8px; word-break: break-all; margin: 10px 0; font-size: 15px; letter-spacing: .06em;
}
.progress { height: 8px; background: var(--grid); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; }

.faith-budget-row { margin-bottom: 18px; }
.faith-budget-row:last-child { margin-bottom: 0; }
.faith-budget-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 6px; flex-wrap: wrap;
}
.faith-budget-head strong { font-size: 13.5px; }
.faith-budget-head span { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.faith-budget-track { height: 14px; background: var(--grid); border-radius: 999px; overflow: hidden; }
.faith-budget-fill {
  height: 100%; border-radius: 999px; background: var(--accent);
  min-width: 3px; transition: width .3s ease;
}
.faith-budget-fill.over { background: var(--gold); }
.faith-budget-pct { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ------------------------------ Print ------------------------------- */
@media print {
  .sidebar, .topbar, .page-actions, .filters, .btn, #toast-root, .reports-picker { display: none !important; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; }
  body { background: #fff; color: #000; font-size: 12px; }
  table.data th, table.data td { padding: 4px 6px; }
  .print-header { display: flex !important; align-items: center; justify-content: center; gap: 12px; margin-bottom: 14px; }
  .print-signature-block { display: flex !important; }
}
.print-header { display: none; }
.print-logo { height: 51px; width: auto; max-width: 90px; object-fit: contain; flex-shrink: 0; margin: 0; }
.print-header-text h2 { margin: 0; }
.print-header-text p { margin: 2px 0 0; }

.print-signature-block {
  display: none; gap: 36px; margin-top: 64px; page-break-inside: avoid;
}
.print-signature-block .sig-col { flex: 1; text-align: center; }
.print-signature-block .sig-line { border-top: 1px solid #000; height: 40px; }
.print-signature-block .sig-label { font-weight: 600; font-size: 12px; margin-top: 4px; }
.print-signature-block .sig-date { font-size: 11px; margin-top: 16px; color: #333; }

/* ------------------------------ Payroll ------------------------------ */
.btn.active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  border-color: var(--accent); color: var(--accent);
}
.payroll-preview {
  font-size: 12.5px; color: var(--text-muted); margin: 0; padding: 8px 10px;
  background: var(--surface-2); border-radius: 8px;
}
.payroll-preview strong.up { color: var(--good-text); }
.payroll-print-batch { display: none; }
@media print {
  body.printing-batch .view > *:not(.payroll-print-batch) { display: none !important; }
  body.printing-batch .payroll-print-batch { display: block !important; }
}
/* Payslip document — matches the church's own payslip template */
.payslip-doc { font-size: 13px; color: #1a1a19; }
.payslip-doc .payslip-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.payslip-doc .payslip-brand {
  background: #2b3a2f; color: #fff; padding: 10px 20px; border-radius: 4px;
  font-weight: 800; font-size: 19px; letter-spacing: .01em;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.payslip-doc .payslip-brand .accent { color: #d7de5a; font-style: italic; font-weight: 600; }
.payslip-doc .payslip-title { font-size: 26px; font-weight: 800; letter-spacing: .05em; color: #2b3a2f; }
.payslip-doc .payslip-infobar {
  background: #e3ecd9; border-radius: 6px; padding: 10px 16px;
  display: flex; justify-content: space-between; gap: 16px; margin-bottom: 16px; color: #2b3a2f;
}
.payslip-doc .payslip-infobar > div:last-child { text-align: right; }
.payslip-doc .payslip-infobar strong { font-size: 14px; }
.payslip-doc table.data { margin-bottom: 14px; }
.payslip-doc table.data th:first-child { color: var(--text-primary); font-style: italic; font-size: 13px; }
.payslip-doc tr.payslip-total-row td {
  font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--grid);
}
.payslip-doc tr.payslip-net-row td {
  font-weight: 800; font-size: 15px; background: #e3ecd9; color: #2b3a2f;
}
.payslip-signatures { display: flex; gap: 40px; margin: 30px 0 16px; }
.payslip-signatures .sig-line {
  border-top: 1px solid var(--baseline); margin-top: 34px; padding-top: 5px;
  font-weight: 700; font-style: italic; font-size: 12.5px;
}
.payslip-footer-note { text-align: center; font-size: 12px; color: var(--text-secondary); }
.payslip-footer-note strong { display: block; margin-bottom: 3px; }
@media print {
  .payslip-doc .payslip-infobar, .payslip-doc tr.payslip-net-row td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* ----------------------------- Branding ----------------------------- */
/* Two-tone wordmark, matching the brand art: "Church" in gold, "Ledger"
   inheriting the surrounding text color. */
.brand-gold { color: var(--gold); }

/* -------------------------- Toggle switches -------------------------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 26px;
  background: var(--baseline); transition: background .18s;
}
.switch-slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .18s;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------- Setup Wizard --------------------------- */
.setup-wizard { max-width: 720px; margin: 0 auto; }
.setup-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 17px; margin-bottom: 18px;
}
.setup-steps {
  display: flex; justify-content: space-between; margin-bottom: 20px; gap: 4px;
}
.setup-step {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; opacity: .55;
}
.setup-step.active, .setup-step.done { opacity: 1; }
.setup-step-dot {
  width: 26px; height: 26px; border-radius: 50%; background: var(--baseline);
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700;
}
.setup-step.active .setup-step-dot { background: var(--accent); color: var(--accent-ink); }
.setup-step.done .setup-step-dot { background: var(--good); color: #fff; }
.setup-step-label { font-size: 11.5px; color: var(--text-muted); }
.setup-step.active .setup-step-label { color: var(--text-primary); font-weight: 600; }
.setup-card { padding: 28px; }
.setup-lede { color: var(--text-muted); font-size: 13px; margin: -6px 0 18px; }

/* ----------------------------- Demo banner ---------------------------- */
.demo-banner {
  position: sticky; top: 0; z-index: 60;
  background: var(--gold); color: #2a1a00;
  text-align: center; font-size: 13px; font-weight: 600;
  padding: 7px 12px;
}

.logo-settings-preview {
  width: 84px; height: 84px; object-fit: contain; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); padding: 8px;
}
