/* Look and feel mirrors the Shofar WhatsApp Manager (its admin-theme.css plus the Tailwind slate
   palette its templates use), hand-written (by way of Tertius) so this app needs no Tailwind build or CDN.
   Dark mode is the .dark class on <html>, set by the inline script in base.html / login.html. */
:root {
  --brand: #ff571f; --brand-rgb: 255, 87, 31; --brand-hover: #e04815;
  --white: #ffffff;
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1; --slate-400: #94a3b8;
  --slate-400-rgb: 148, 163, 184;
  --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155; --slate-800: #1e293b; --slate-900: #0f172a;

  --bg: var(--slate-100); --surface: var(--white); --surface-alt: var(--slate-50);
  --text: var(--slate-900); --text-soft: var(--slate-700); --muted: var(--slate-500);
  --border: var(--slate-200); --border-soft: var(--slate-100); --input-border: var(--slate-300);
  --input-bg: var(--slate-50); --chip: var(--slate-100); --chip-hover: var(--slate-200); --row-hover: var(--slate-50);
  --brand-soft: rgba(var(--brand-rgb), 0.1); --brand-pill: var(--brand-hover);

  --ok: #047857; --ok-bg: #ecfdf5; --ok-border: #a7f3d0;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-border: #fcd34d;
  --error: #e11d48; --error-bg: #fff1f2; --error-border: #fecdd3;
  color-scheme: light;
}
html.dark {
  --bg: var(--slate-900); --surface: var(--slate-800); --surface-alt: rgba(15, 23, 42, 0.5);
  --text: var(--slate-100); --text-soft: var(--slate-300); --muted: var(--slate-400);
  --border: var(--slate-700); --border-soft: rgba(51, 65, 85, 0.6); --input-border: var(--slate-700);
  --input-bg: var(--slate-900); --chip: var(--slate-700); --chip-hover: var(--slate-600); --row-hover: var(--slate-900);
  --brand-soft: rgba(var(--brand-rgb), 0.18); --brand-pill: #ff7a4d;

  --ok: #6ee7b7; --ok-bg: rgba(6, 78, 59, 0.4); --ok-border: rgba(4, 120, 87, 0.6);
  --warn: #fcd34d; --warn-bg: rgba(120, 53, 15, 0.3); --warn-border: #b45309;
  --error: #fb7185; --error-bg: rgba(76, 5, 25, 0.4); --error-border: rgba(136, 19, 55, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
main { flex: 1; width: 100%; max-width: 80rem; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 16px; }
h2 { font-size: 1.125rem; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 6px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 9999px; }
html.dark ::-webkit-scrollbar-thumb { background: var(--slate-700); }

/* ---- Header ---- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.topbar-inner { max-width: 80rem; margin: 0 auto; padding: 0 16px; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.125rem; letter-spacing: -0.025em; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); opacity: 0.9; }
.brand img { width: 28px; height: 28px; }
.brand .brand-sub { font-weight: 400; color: var(--brand); }
.main-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; font-size: 0.875rem; font-weight: 500; color: var(--text-soft); white-space: nowrap; }
.nav-link:hover { color: var(--brand); }
html.dark .nav-link:hover { color: var(--white); }
.nav-link i { color: var(--brand); }
.nav-link.active { background: var(--brand-soft); }
.user-nav { display: flex; align-items: center; gap: 16px; }
.user-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 500; color: var(--text-soft); white-space: nowrap; }
.user-link:hover { color: var(--brand); }
html.dark .user-link:hover { color: var(--white); }
button.logout-link { display: inline-flex; align-items: center; gap: 4px; padding: 0; background: none; border: 0; box-shadow: none; font-size: 0.75rem; font-weight: 500; color: #e11d48; cursor: pointer; }
button.logout-link:hover { background: none; color: #be123c; }
button.icon-btn { padding: 8px; border-radius: 6px; background: none; box-shadow: none; color: var(--text-soft); font-size: 1rem; line-height: 1; }
button.icon-btn:hover { background: var(--chip); color: var(--text); }
html:not(.dark) .show-dark, html.dark .show-light { display: none; }
#mobile-menu-btn { display: none; font-size: 1.25rem; }
.mobile-menu { display: none; border-top: 1px solid var(--border); padding: 8px 16px 16px; }
.mobile-menu.open { display: block; }
.mobile-menu a, .mobile-menu button.mobile-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border-radius: 6px; font-size: 1rem; font-weight: 500; color: var(--text-soft); background: none; box-shadow: none; text-align: left; justify-content: flex-start; }
.mobile-menu a:hover, .mobile-menu button.mobile-item:hover { background: var(--chip); color: var(--text); }
.mobile-menu i { color: var(--brand); width: 1.1em; text-align: center; }
.mobile-menu .mobile-section { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.mobile-menu button.mobile-item.logout, .mobile-menu button.mobile-item.logout i { color: #e11d48; }
@media (max-width: 1023px) {
  .main-nav, .user-nav { display: none; }
  #mobile-menu-btn { display: inline-flex; }
}

/* ---- Page headings and cards ---- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-left: 4px solid var(--brand); border-bottom: 1px solid var(--border); padding: 0 0 20px 16px; margin-bottom: 24px; }
.page-header h1 { margin: 0; }
.page-header p { margin: 2px 0 0; font-size: 0.875rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-top: 2px solid var(--brand); border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
@media (min-width: 640px) { .card { padding: 28px 32px; } }
.card.narrow { max-width: 32rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-soft); }
.card-head h2 { margin: 0; }
.card-sub { font-size: 0.85rem; margin: 14px 12px 6px; }
.card-head p { margin: 0; font-size: 0.75rem; color: var(--muted); }
.card-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.8rem; margin: -8px 0 16px; }

/* ---- Forms ---- */
label { display: block; margin-bottom: 18px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
label .badge { text-transform: none; letter-spacing: 0; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 0.875rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text); }
.inline-check { display: inline-flex !important; margin: 0 0 0 10px; }
.hint label.check { font-size: 0.8rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px;
  font: inherit; font-size: 0.875rem; font-weight: 400; text-transform: none; letter-spacing: 0;
  background: var(--input-bg); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--slate-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.25); }
input[type=file] { padding: 8px; cursor: pointer; }
input[type=file]::file-selector-button { margin-right: 12px; padding: 6px 14px; border: 0; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; }
input[type=file]:hover::file-selector-button { background: rgba(var(--brand-rgb), 0.2); }
input.compact { display: inline-block; width: 160px; margin: 0 4px 0 0; padding: 6px 10px; }
textarea { resize: vertical; }
input[type=radio], input[type=checkbox] { accent-color: var(--brand); width: 1.05rem; height: 1.05rem; margin: 0; cursor: pointer; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset !important; -webkit-text-fill-color: var(--text) !important; caret-color: var(--text);
}
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px 6px; margin: 0 0 20px; }
legend { padding: 0 6px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
details { margin-bottom: 20px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px 0; }
summary { cursor: pointer; font-weight: 600; font-size: 0.875rem; margin-bottom: 12px; color: var(--text); }
summary::marker { color: var(--brand); }

/* ---- Buttons ---- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--brand); color: var(--white); border: 0; border-radius: 12px; padding: 10px 24px; font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); transition: background-color 0.15s, color 0.15s; }
button:hover, .button:hover { background: var(--brand-hover); color: var(--white); }
button:disabled { opacity: 0.6; cursor: wait; }
.button.cta { border-radius: 8px; padding: 10px 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; box-shadow: 0 10px 15px -3px rgba(var(--brand-rgb), 0.25); }
.button.small, button.small { padding: 6px 14px; font-size: 0.8rem; border-radius: 8px; }
.button.secondary, button.secondary { background: var(--chip); color: var(--text-soft); box-shadow: none; }
.button.secondary:hover, button.secondary:hover { background: var(--chip-hover); color: var(--text); }
button.link { background: none; color: var(--brand); padding: 0; font-size: 0.8rem; font-weight: 600; box-shadow: none; border-radius: 0; }
button.link:hover { background: none; color: var(--brand-hover); }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error-border); box-shadow: none; }
button.danger:hover { background: var(--error-bg); color: var(--error); }
form.inline { display: inline; }
.hidden { display: none !important; }

/* ---- Alerts (icons need Font Awesome, linked from the templates) ---- */
.flash { display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-size: 0.875rem; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.flash::before { font: var(--fa-font-solid); margin-top: 3px; flex: none; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.flash.ok::before { content: "\f058"; }
.flash.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.flash.warn::before { content: "\f071"; }
.flash.error { background: var(--error-bg); border-color: var(--error-border); color: var(--error); }
.flash.error::before { content: "\f06a"; }
.env-banner { padding: 6px 16px; text-align: center; font-size: 0.8125rem; font-weight: 600; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--warn-border); }

/* ---- Tables (sit inside a .card.table-card) ---- */
.card.table-card { padding: 12px 16px 8px; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.list th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--slate-600); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
html.dark table.list th { color: var(--slate-400); }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--row-hover); }
table.list td.strong, table.list td.strong a { font-weight: 600; color: var(--text); }
table.list td.strong a:hover { color: var(--brand); }
tr.inactive td { opacity: 0.6; }
.row-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline-flex; gap: 10px; align-items: center; }

/* ---- Pills ---- */
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; text-transform: capitalize; white-space: nowrap; background: rgba(var(--slate-400-rgb), 0.2); color: var(--muted); }
.status.completed, .status.active { background: var(--ok-bg); color: var(--ok); }
.status.completed.warn { background: var(--warn-bg); color: var(--warn); }
.status.failed { background: var(--error-bg); color: var(--error); }
.status.transcribing, .status.cleaning, .status.queued, .status.superadmin { background: rgba(var(--brand-rgb), 0.15); color: var(--brand-pill); }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.shared { background: rgba(var(--brand-rgb), 0.15); color: var(--brand-pill); }
.badge.off { background: var(--chip); color: var(--muted); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; }
button.tab { background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 8px 18px; box-shadow: none; }
button.tab:hover { background: var(--chip); color: var(--text); }
button.tab.active { position: relative; margin-bottom: -1px; background: var(--surface); color: var(--brand); border-color: var(--border); border-top: 2px solid var(--brand); }
.tab-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 0 16px 16px 16px; padding: 20px; margin-bottom: 24px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.actions { display: flex; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.working { display: flex; align-items: center; margin: 0 0 4px; font-weight: 500; }
.working::before { content: ""; flex: none; width: 14px; height: 14px; margin-right: 12px; border: 2px solid var(--brand); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.danger-zone { margin-top: 32px; }

/* ---- Login ---- */
body.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-wrap { width: 100%; max-width: 28rem; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand img { display: block; margin: 0 auto; height: 13rem; width: auto; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05)); }
.login-brand h1 { margin: 12px 0 0; line-height: 2rem; }
.login-brand p { margin: 12px 0 0; font-size: 0.75rem; line-height: 1rem; color: var(--muted); }
.login-wrap .card { border-radius: 12px; }
@media (min-width: 640px) { .login-wrap .card { padding: 32px; } }
.login-wrap .flash { padding: 12px; font-size: 0.75rem; line-height: 1rem; }
.login-wrap label { margin-bottom: 20px; line-height: 1rem; }
.login-wrap input[type=text], .login-wrap input[type=password] { line-height: 1.25rem; }
.login-title { display: flex; align-items: center; gap: 8px; margin: 0 0 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); font-size: 1.125rem; line-height: 1.75rem; font-weight: 700; }
.login-title i { color: var(--brand); }
.login-wrap button[type=submit] { width: 100%; padding: 12px 16px; border-radius: 12px; font-size: 1rem; line-height: 1.5rem; }
.login-theme { position: fixed; top: 12px; right: 12px; }
.login-support { margin: 28px 0 0; text-align: center; font-size: 0.75rem; line-height: 1rem; color: var(--muted); }
.login-support a { font-weight: 500; }
.login-powered { margin-top: 24px; text-align: center; font-size: 0.75rem; line-height: 1rem; color: var(--muted); }
.login-powered strong { color: var(--text); font-weight: 600; }

/* Show/Hide toggle inside password and API key fields (added by app.js). */
.password-field { position: relative; display: block; margin-top: 6px; }
.password-field input { margin-top: 0; padding-right: 60px; }
.password-field.compact { display: inline-block; width: 180px; margin: 0 4px 0 0; }
.password-field.compact input { width: 100%; padding-right: 50px; }
button.password-toggle { position: absolute; top: 0; bottom: 0; right: 0; display: flex; align-items: center; padding: 0 12px;
  background: none; border: 0; box-shadow: none; color: var(--slate-500); font-size: 0.75rem; font-weight: 500; text-transform: none; letter-spacing: 0; cursor: pointer; }
button.password-toggle:hover { background: none; color: var(--text-soft); }

/* ---- Range links, tiles, pagination ---- */
.range-links { display: flex; gap: 8px; }
.range-link { padding: 6px 14px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; border: 1px solid var(--input-border); color: var(--text-soft); background: var(--surface); }
.range-link:hover { color: var(--text); border-color: var(--brand); }
.range-link.active, .range-link.active:hover { background: var(--brand); border-color: var(--brand); color: var(--white); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.tile-title { font-size: 0.75rem; color: var(--muted); }
.tile-value { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-top: 2px; }
.tile-sub { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.progress.credit-meter { height: 22px; margin: 12px 0 14px; }
.card .card-intro { margin: -16px 0 16px; font-size: 0.8rem; color: var(--muted); }
.card.table-card .card-head { margin: 8px 0 8px; padding: 0 0 12px; }
td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 0.7rem; color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-top: 1px solid var(--border); font-size: 0.75rem; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination span.page { padding: 4px 10px; border-radius: 8px; font-weight: 600; border: 1px solid var(--input-border); color: var(--text-soft); }
.pagination a:hover { border-color: var(--brand); color: var(--text); }
.pagination span.page.current { background: var(--brand); border-color: var(--brand); color: var(--white); }
.pagination span.page.disabled { opacity: 0.4; }
.usage-range { margin: -8px 0 16px; }
.usage-subhead { margin: 24px 0 4px; }
.table-scroll { overflow-x: auto; }
.usage-empty { margin-top: 16px; }

/* ======================================================================
   Numbers: dashboards, comparisons and the data grid
   ====================================================================== */
input[type=date], input[type=search], input[type=email] {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px;
  font: inherit; font-size: 0.875rem; background: var(--input-bg); color: var(--text);
}
html.dark input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1); }
.brand .brand-icon { width: 28px; height: 28px; }
.status.up, .verdict.up { background: var(--ok-bg); color: var(--ok); }
.status.down, .verdict.down { background: var(--error-bg); color: var(--error); }
.status.flat, .verdict.flat { background: var(--warn-bg); color: var(--warn); }
.status.na, .verdict.na { background: var(--chip); color: var(--muted); }
.status.apostolic, .status.regional, .status.pastor { background: var(--chip); color: var(--text-soft); }

/* Page header with the scope and month pickers */
.page-header .crumbs { font-size: 0.75rem; color: var(--muted); margin: 0 0 4px; }
.page-header .crumbs a { color: var(--muted); }
.page-header .crumbs a:hover { color: var(--brand); }
.page-header .crumbs span + span::before { content: "/"; margin: 0 6px; color: var(--slate-400); }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.verdict { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar label { margin: 0; min-width: 12rem; }
.toolbar label.narrow { min-width: 9rem; }
.toolbar select, .toolbar input { margin-top: 4px; padding: 8px 10px; }
.toolbar .button, .toolbar button { padding: 9px 16px; }
/* Collapsible scope picker (app.js swaps it in for the "Showing" select) */
.scope-picker { position: relative; min-width: 12rem; }
.scope-field[hidden], .scope-picker[hidden], .scope-panel[hidden], .scope-node[hidden], .scope-empty[hidden] { display: none; }
.scope-picker-label { display: block; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
.toolbar .scope-button, .toolbar .scope-button:hover { display: flex; justify-content: space-between; gap: 10px; width: 100%; max-width: 22rem; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--input-border); border-radius: 8px; background: var(--input-bg); color: var(--text); font-size: 0.875rem; font-weight: 400; text-align: left; box-shadow: none; }
.toolbar .scope-button[aria-expanded="true"], .toolbar .scope-button:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.25); }
.scope-button-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-button i { font-size: 0.7rem; color: var(--muted); }
.scope-panel { position: absolute; right: 0; top: 100%; z-index: 40; width: min(24rem, calc(100vw - 52px)); max-height: min(70vh, 34rem); overflow: auto; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15); }
@media (max-width: 1023px) { .scope-panel { right: auto; left: 0; } }
.scope-panel input.scope-search { position: sticky; top: 0; z-index: 1; margin: 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; padding: 10px 14px; background: var(--surface); box-shadow: none; }
.scope-tree, .scope-tree ul { list-style: none; margin: 0; padding: 0; }
.scope-tree { padding: 6px 0; }
.scope-tree ul { padding-left: 18px; display: none; }
.scope-node.expanded > ul, .scope-tree.searching .scope-node.search-open > ul { display: block; }
.scope-row { display: flex; align-items: center; gap: 2px; padding: 0 8px; }
.scope-row:hover { background: var(--row-hover); }
.toolbar .scope-twisty, .toolbar .scope-twisty:hover { flex: none; width: 24px; height: 28px; padding: 0; border-radius: 6px; background: none; box-shadow: none; color: var(--muted); font-size: 0.65rem; }
.toolbar button.scope-twisty:hover { color: var(--brand); background: var(--chip); }
.scope-twisty i { transition: transform 0.15s; }
.scope-node.expanded > .scope-row .scope-twisty i, .scope-tree.searching .scope-node.search-open > .scope-row .scope-twisty i { transform: rotate(90deg); }
.toolbar .scope-option, .toolbar .scope-option:hover { flex: 1; justify-content: flex-start; min-width: 0; padding: 6px 6px; border-radius: 6px; background: none; box-shadow: none;
  color: var(--text); font-size: 0.85rem; font-weight: 400; text-align: left; }
.toolbar .scope-option:hover, .toolbar .scope-option:focus-visible { color: var(--brand); outline: none; }
.toolbar .scope-option:focus-visible { background: var(--brand-soft); }
.has-children > .scope-row .scope-option { font-weight: 600; }
.scope-tree > .scope-node > .scope-row .scope-option { font-weight: 700; }
.toolbar .scope-group { color: var(--text-soft); }
.scope-node.current > .scope-row { background: var(--brand-soft); }
.scope-node.current > .scope-row .scope-option { color: var(--brand); }
.scope-tree.searching .scope-node.match > .scope-row .scope-option { color: var(--brand); }
.scope-count { flex: none; font-size: 0.7rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.scope-empty { padding: 10px 14px 14px; font-size: 0.85rem; color: var(--muted); }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; margin: -12px 0 20px; font-size: 0.8rem; }
.quick-links a { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-soft); background: var(--surface); }
.quick-links a:hover { border-color: var(--brand); color: var(--brand); }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--text);
  font: inherit; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
button.kpi { background: var(--surface); color: var(--text); border-radius: 14px; padding: 16px 18px 14px; align-items: stretch; justify-content: flex-start; font-weight: 400; }
button.kpi:hover { background: var(--surface); color: var(--text); border-color: var(--slate-400); }
.kpi.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.18); }
.kpi-head { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
.kpi-head i { color: var(--brand); }
.kpi-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi-basis { font-size: 0.72rem; color: var(--muted); line-height: 1.35; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--error); }
.delta.flat, .delta.na { color: var(--muted); font-weight: 600; }
.spark { flex: none; overflow: visible; }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }

/* Charts */
.metric-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.metric-tabs button { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  font-size: 0.8rem; font-weight: 600; box-shadow: none; }
.metric-tabs button:hover { background: var(--surface); color: var(--text); border-color: var(--slate-400); }
.metric-tabs button.active { background: var(--brand); color: var(--white); border-color: var(--brand); }
.metric-tabs.compact { margin-bottom: 8px; }
.metric-tabs.compact button { padding: 3px 10px; font-size: 0.72rem; }
/* The service picker under the measure tabs, on a church's adults and children. */
.service-pick { margin: -4px 0 14px; }
.service-pick-row { display: flex; align-items: baseline; gap: 10px; }
.service-pick-label { font-size: 0.72rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.service-pick .metric-tabs { margin-bottom: 6px; }
.service-pick button[hidden] { display: none; }
.service-pick .hint { margin: 0; }
/* An option on one chart, such as the months its average runs over. */
.chart-option { display: flex; align-items: baseline; gap: 10px; }
.chart-option .metric-tabs { margin-bottom: 6px; }
.service-summary { font-size: 0.85rem; margin: 0 0 4px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 24px; }
@media (max-width: 640px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card[hidden] { display: none; }
.chart-card h3 { margin: 0; font-size: 0.9rem; }
.chart-card .chart-sub { margin: 2px 0 10px; font-size: 0.75rem; color: var(--muted); }
.chart-box { position: relative; height: 260px; }
.chart-card.wide .chart-box { height: 300px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.75rem; color: var(--text-soft); margin: 0 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.chart-legend i.swatch.box { height: 10px; width: 10px; border-radius: 3px; }
.chart-legend i.swatch.dash, .chart-legend i.swatch.dot { width: 18px; height: 0; border-radius: 0; background: none; border-top: 3px dashed; }
.chart-legend i.swatch.dot { border-top-style: dotted; }
.chart-legend .legend-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; margin: -2px -6px; border: 0; border-radius: 4px; background: none; font: inherit; color: inherit; cursor: pointer; }
.chart-legend .legend-toggle:hover { background: var(--border); }
.chart-legend .legend-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.chart-legend .legend-toggle[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }
/* Two-thumb month slider: two range inputs laid over one track, only
   their thumbs taking the pointer; the fill between them is drawn by JS. */
.month-range { margin: 0 0 10px; font-size: 0.75rem; color: var(--text-soft); --thumb: 16px; }
.month-range-head { display: flex; justify-content: space-between; margin-bottom: 2px; }
.month-range-head output { font-weight: 600; color: var(--text); }
.month-range-track { position: relative; height: 22px; }
.month-range-track::before, .month-range-fill { content: ""; position: absolute; top: 9px; height: 4px; border-radius: 2px; }
.month-range-track::before { left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); background: var(--border); }
.month-range-fill { background: var(--brand); }
.month-range-track input { position: absolute; inset: 0; width: 100%; height: 22px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.month-range-track input:focus { outline: none; }
.month-range-track input::-webkit-slider-runnable-track { background: none; }
.month-range-track input::-moz-range-track { background: none; }
.month-range-track input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: var(--thumb); height: var(--thumb); border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--brand); cursor: pointer; }
.month-range-track input::-moz-range-thumb { pointer-events: auto; width: var(--thumb); height: var(--thumb); border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--brand); cursor: pointer; box-sizing: border-box; }
.month-range-track input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--brand); }
.month-range-track input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--brand); }
.month-range-ticks { display: flex; justify-content: space-between; padding: 0 calc(var(--thumb) / 2 - 3px); color: var(--muted); font-size: 0.7rem; }
.month-range-ticks span { width: 6px; text-align: center; }
.chart-table { margin-top: 10px; font-size: 0.8rem; }
.chart-table summary { font-size: 0.75rem; color: var(--muted); font-weight: 600; margin: 0; }
.chart-table details, details.chart-table { border: 0; padding: 0; margin: 0; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 0.85rem; }

/* Breakdown and comparison tables */
table.list th.sortable { cursor: pointer; user-select: none; }
table.list th.sortable:hover { color: var(--brand); }
table.list th a.sort-link { color: inherit; }
table.list th.sorted-asc::after { content: " \2191"; }
table.list th.sorted-desc::after { content: " \2193"; }
/* Right-aligned headings carry the arrow in front, so the label still lines up with the figures */
table.list th.num.sorted-asc::after, table.list th.num.sorted-desc::after { content: none; }
table.list th.num.sorted-asc::before { content: "\2191 "; }
table.list th.num.sorted-desc::before { content: "\2193 "; }
table.list td.delta-cell { font-weight: 600; font-variant-numeric: tabular-nums; }
td.up, span.up { color: var(--ok); }
td.down, span.down { color: var(--error); }
td.muted-cell { color: var(--muted); }
table.list.dense td, table.list.dense th { padding: 7px 9px; }
table.list .group-row td { background: var(--surface-alt); font-weight: 700; color: var(--text); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.list tbody tr:hover .sticky-col { background: var(--row-hover); }
table.list th.span-head { text-align: center; border-bottom: 1px solid var(--border); }
.tag { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--chip); color: var(--muted); vertical-align: 1px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.03em; }

/* Source dots in the data grid */
.src { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: 1px; flex: none; }
.src.manual { background: var(--brand); }
.src.pco { background: #2a78d6; }
.src.sheet { background: var(--slate-400); }
.src.blank { background: transparent; border: 1.5px solid var(--error); }
.legend-row { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.75rem; color: var(--muted); margin: 0 0 12px; align-items: center; }
.legend-row .src { margin: 0 4px 0 0; }
.cell { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
/* Every figure in a grid is followed by a fixed-width slot (source dot, plus the revert button when editing),
   even when there is no dot, so the figures form one right edge. Headings are padded to end on that edge. */
.cell-tail { flex: none; display: inline-flex; align-items: center; gap: 2px; width: 14px; }
#data-grid .cell-tail { width: 38px; }
table.list.has-src th.num { padding-right: calc(9px + 2px + 14px); }
#data-grid table.list.has-src th.num { padding-right: calc(9px + 2px + 38px + 9px); }
#data-grid td.muted-cell .cell { padding-right: 9px; }
input.cell-input { display: inline-block; width: 7rem; margin: 0; padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums; border-radius: 6px; }
input.cell-input.changed { border-color: var(--brand); background: var(--brand-soft); }
input.cell-input.blanked { text-decoration: line-through; color: var(--error); }
button.cell-revert { background: none; box-shadow: none; padding: 2px 4px; color: var(--muted); font-size: 0.75rem; border-radius: 4px; }
button.cell-revert:hover { background: var(--chip); color: var(--brand); }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--brand); border-radius: 12px; padding: 12px 16px; margin-top: 16px; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08); }
.save-bar input[type=text] { margin: 0; max-width: 28rem; }

/* Watch list */
.heat { display: inline-block; min-width: 4.2rem; text-align: right; padding: 2px 8px; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.heat.down { background: var(--error-bg); color: var(--error); }
.heat.up { background: var(--ok-bg); color: var(--ok); }
.heat.na { color: var(--muted); }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 1.6rem; border-radius: 8px; font-weight: 700; background: var(--chip); color: var(--text-soft); }
.score.s-high { background: var(--error-bg); color: var(--error); }
.score.s-mid { background: var(--warn-bg); color: var(--warn); }

/* Admin sub navigation */
.sub-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: -8px 0 20px; border-bottom: 1px solid var(--border); }
.sub-nav a { padding: 8px 14px; font-size: 0.85rem; font-weight: 600; color: var(--text-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-nav a:hover { color: var(--brand); }
.sub-nav a.active { color: var(--brand); border-bottom-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 18px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; max-height: 18rem; overflow: auto;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); margin: 6px 0 18px; }
.check-grid label.check { margin: 0; font-size: 0.82rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form select, .inline-form input { display: inline-block; width: auto; margin: 0; padding: 5px 8px; font-size: 0.8rem; }
.inline-form input.wide { min-width: 14rem; }
pre.log { white-space: pre-wrap; margin: 0; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-soft); }
.stat-pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 0 0 8px; }
.notes-box { background: var(--surface-alt); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 14px; font-size: 0.85rem; color: var(--text-soft); margin-bottom: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.section-title h2 { margin: 0; }
details.collapsible { border: 0; border-radius: 0; padding: 0; margin: 0; }
details.collapsible > summary { list-style: none; margin: 8px 0 12px; font-size: inherit; font-weight: inherit; user-select: none; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary h2 { display: flex; align-items: center; gap: 8px; }
details.collapsible > summary .toggle { font-size: 0.8em; color: var(--brand); transition: transform 0.15s; }
details.collapsible:not([open]) > summary .toggle { transform: rotate(-90deg); }
details.collapsible > summary .count { font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0 24px; }
@media print {
  .topbar, .toolbar, .metric-tabs, .quick-links, .save-bar { display: none !important; }
  .kpi, .chart-card, .card { box-shadow: none; break-inside: avoid; }
}
.kpi-value { white-space: nowrap; }
.kpi-row .spark { min-width: 0; flex-shrink: 1; }
table.list td.num, table.list th.num { white-space: nowrap; }
table.list td.nowrap { white-space: nowrap; }
.chip { display: inline-block; margin: 1px 4px 1px 0; padding: 2px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.chip.down { background: var(--error-bg); color: var(--error); }
.chip.up { background: var(--ok-bg); color: var(--ok); }

/* Rankings */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 640px) { .rank-grid { grid-template-columns: 1fr; } }
.rank-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rank-col > h2 { margin: 4px 0 0; display: flex; align-items: center; gap: 8px; }
.rank-col > h2 i { color: var(--brand); }
.chart-card .missing { margin: 8px 0 0; font-size: 0.72rem; color: var(--muted); }
.login-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 0.75rem; color: var(--muted); }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border-soft); }
.login-wrap .login-sso { width: 100%; padding: 12px 16px; font-size: 1rem; line-height: 1.5rem; }
.status.pending { background: var(--warn-bg); color: var(--warn); }
.sso-choice { margin-bottom: 16px; }
.sso-choice p { font-size: 0.875rem; }
.sso-choice form button[type=submit]:not(.link) { width: 100%; }
.sso-choice-or { margin-top: 20px; }
.sso-choice-cancel { text-align: center; margin-top: 8px; }
.login-wrap button.link { width: auto; padding: 0; font-size: 0.8rem; border-radius: 0; }

/* ---- Steward ------------------------------------------------------------ */
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--error); }
.pos { color: var(--ok); }
.strong-num { font-weight: 600; color: var(--text); }
.warn-text { color: var(--warn); }
.plain-list { padding-left: 18px; margin: 8px 0; }
.plain-list li { margin-bottom: 6px; }
p.crumbs { font-size: 0.8rem; margin: -8px 0 16px; }
p.crumbs a { color: var(--muted); }
.nav-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 0.65rem; font-weight: 700; line-height: 18px; text-align: center; }
.status.admin, .status.member { background: rgba(var(--brand-rgb), 0.15); color: var(--brand-pill); }
.status.viewer { background: var(--chip); color: var(--text-soft); }
.status.kind { margin-right: 6px; }
.status.kind.income { background: var(--ok-bg); color: var(--ok); }
.status.kind.expense { background: rgba(var(--brand-rgb), 0.15); color: var(--brand-pill); }
.status.kind.transfer { background: var(--chip); color: var(--text-soft); }
.badge.todo { background: var(--warn-bg); color: var(--warn); }
.badge.auto { background: var(--chip); color: var(--text-soft); }
.badge:first-child { margin-left: 0; }

/* Budget meter: the bar never carries meaning alone; the percentage and an icon sit beside it. */
.meter { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 0.75rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.meter-track { position: relative; width: 84px; height: 6px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--slate-400); }
.meter.ok .meter-fill { background: var(--ok); }
.meter.warn .meter-fill { background: #f59e0b; }
.meter.over .meter-fill { background: var(--error); }
.meter.warn .meter-label i { color: var(--warn); }
.meter.over .meter-label i { color: var(--error); }
.kpi .meter { margin: 8px 0 6px; }
.kpi .meter-track { width: 140px; }
.kpi-value.neg { color: var(--error); }
.legend-chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 999px; font-size: 0.72rem; }
.legend-chip.ok { background: var(--ok-bg); color: var(--ok); }
.legend-chip.warn { background: var(--warn-bg); color: var(--warn); }
.legend-chip.over { background: var(--error-bg); color: var(--error); }

/* Statement tables: sections, groups and lines, foldable. */
table.statement td.line-name { white-space: nowrap; }
table.statement tr.depth-0 td { background: var(--surface-alt); font-weight: 700; color: var(--text); }
table.statement tr.depth-0 td.line-name a { color: var(--text); }
table.statement tr.depth-1.group td { font-weight: 600; }
table.statement tr.depth-1 td.line-name { padding-left: 30px; }
table.statement tr.depth-2 td.line-name { padding-left: 52px; }
table.statement tr.leaf td.line-name a { color: var(--text-soft); }
table.statement td.line-name a:hover { color: var(--brand); }
table.statement tr.total-row td { font-weight: 700; color: var(--text); border-top: 2px solid var(--border); background: var(--surface-alt); }
table.statement tr.net-row td { background: var(--brand-soft); }
table.statement tbody + tbody { border-top: 8px solid transparent; }
table.statement th.future, table.statement tr.future td { opacity: 0.55; }
table.list tr.future td { opacity: 0.55; }
button.twisty { background: none; box-shadow: none; padding: 0 4px 0 0; margin: 0 2px 0 -18px; width: 18px; color: var(--muted); font-size: 0.65rem; }
button.twisty:hover { background: none; color: var(--brand); }
button.twisty i { transition: transform 0.15s; }
tr.folded button.twisty i { transform: rotate(-90deg); }
table.statement.monthly td, table.statement.monthly th { padding: 8px 8px; }

/* Budget grid */
.budget-scroll { max-height: 75vh; overflow: auto; }
table.budget-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); }
table.budget-grid .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 15rem; }
table.budget-grid thead .sticky-col { z-index: 3; }
table.budget-grid tr.depth-0 .sticky-col, table.budget-grid tr.total-row .sticky-col { background: var(--surface-alt); }
table.budget-grid td { padding: 4px 6px; }
table.budget-grid input.cell-input { width: 6.5rem; text-align: right; padding: 5px 6px; font-variant-numeric: tabular-nums; }
table.budget-grid input.year-input { font-weight: 600; }
table.budget-grid tfoot td { font-weight: 700; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); }

/* Transactions */
.filter-bar { margin-bottom: 4px; }
.tile-link { display: block; color: inherit; }
.tile-link:hover { border-color: var(--brand); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: 12px; }
.bulk-bar select { width: auto; max-width: 16rem; margin: 0; padding: 6px 8px; }
.bulk-bar label.check { margin: 0; }
.bulk-bar .similar-toggle { margin-left: auto; font-size: 0.8rem; }
table.transactions td.desc { min-width: 16rem; color: var(--text); }
table.transactions td.desc .sub { display: block; }
table.transactions select { margin: 0; padding: 5px 6px; font-size: 0.8rem; width: 15rem; }
table.transactions td.project-cell select { width: 10rem; }
table.transactions tr.todo td { background: var(--warn-bg); }
table.transactions tr.excluded td { opacity: 0.6; }
table.transactions tr.saving { opacity: 0.5; }
button.link.suggestion { display: block; font-size: 0.72rem; margin-top: 4px; text-align: left; }
td .sub, .sub { font-size: 0.72rem; color: var(--muted); }
tr.duplicate td { opacity: 0.5; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 26rem; padding: 10px 16px; border-radius: 10px; font-size: 0.85rem; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2); background: var(--surface); border: 1px solid var(--ok-border); color: var(--ok); }
.toast.error { border-color: var(--error-border); color: var(--error); }

/* Uploads */
.save-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px 16px; }
.save-bar label { margin: 0; min-width: 14rem; }
.save-bar .hint { flex-basis: 100%; margin: 0; }
table.raw-preview select { margin: 0; padding: 4px 6px; font-size: 0.75rem; min-width: 8rem; }
table.raw-preview tr.header-row td { font-weight: 700; background: var(--brand-soft); }
table.raw-preview td { white-space: nowrap; max-width: 20rem; overflow: hidden; text-overflow: ellipsis; }

/* Categories */
table.category-table td.category-row { padding: 4px 8px; }
.category-form { display: grid; grid-template-columns: minmax(16rem, 2fr) minmax(12rem, 2fr) 4.5rem minmax(10rem, 1.2fr) 3.5rem 6rem 5.5rem; gap: 8px; align-items: center; }
.category-head { font-size: inherit; }
table.category-table th.category-row { padding: 10px 8px; }
.category-form input[type=text], .category-form select, .category-form input[type=number] { margin: 0; padding: 5px 8px; font-size: 0.82rem; }
.category-form .cat-name { display: flex; align-items: center; gap: 4px; }
table.category-table tr.depth-0 td { background: var(--surface-alt); }
table.category-table tr.depth-0 .cat-name input { font-weight: 700; }
table.category-table tr.group .cat-name input { font-weight: 600; }
.cat-actions { display: flex; gap: 4px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form select { width: auto; margin: 0; padding: 4px 8px; }

/* Home and admin */
.congregation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
a.card.congregation-card { display: block; color: inherit; margin: 0; }
a.card.congregation-card:hover { border-color: var(--brand); }
dl.figures { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 8px 0 0; font-size: 0.9rem; }
dl.figures dt { color: var(--muted); }
dl.figures dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-foot { margin: 12px 0 0; font-size: 0.8rem; }
.access-fieldset { margin: 12px 0; }
.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 6px 16px; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-weight: 500; }
.access-row select { width: 9rem; margin: 0; padding: 5px 8px; }
.access-row.inactive { opacity: 0.6; }
details.inline-details summary { cursor: pointer; color: var(--brand); font-size: 0.85rem; }
details.inline-details form { margin-top: 8px; min-width: 18rem; }
.audit-detail { font-size: 0.75rem; word-break: break-word; }
button.logout-link { white-space: nowrap; }
table.transactions td.row-actions { display: flex; gap: 6px; align-items: center; border-bottom: 0; }
table.transactions td.row-actions .button, table.transactions td.row-actions button { margin: 0; }
.tile.tile-warn { border-color: var(--warn-border); background: var(--warn-bg); }
tr.possible td { background: var(--warn-bg); }
