/* ChurchBright staff-app design system — "refined & premium". Tokens first; components reference tokens only.
   Type: Instrument Sans (loaded by the layouts). Depth: hairlines + soft layered shadows. Motion: 150ms/220ms, no bounce. */
:root {
  color-scheme: light;
  --primary: #4f46e5; --primary-hover: #4338ca; --primary-soft: #eef0ff; --primary-ink: #3730a3;
  --brand: #f59e0b; --brand-2: #f97316;
  --ink: #0b1224; --ink-2: #28324a; --muted: #5b6480; --faint: #8a93ad;
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f9fafc; --surface-3: #f2f4f9;
  --border: rgba(11,18,36,.08); --border-strong: rgba(11,18,36,.14);
  --sidebar: #0b1224; --sidebar-2: #0e1530; --sidebar-ink: #c7cde0; --sidebar-muted: #7f8aa6; --sidebar-active: rgba(255,255,255,.08);
  --sidebar-line: rgba(255,255,255,.07); --sidebar-card: rgba(255,255,255,.04);
  --success: #15803d; --success-soft: #e7f7ec; --warning: #b45309; --warning-soft: #fff4dc;
  --danger: #dc2626; --danger-hover: #b91c1c; --danger-soft: #feecec; --info: #1d4ed8; --info-soft: #e6efff;
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(11,18,36,.04);
  --shadow: 0 1px 2px rgba(11,18,36,.04), 0 6px 20px -12px rgba(11,18,36,.12);
  --shadow-lg: 0 12px 40px -12px rgba(11,18,36,.25), 0 0 0 1px rgba(11,18,36,.06);
  --shadow-btn: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(11,18,36,.15);
  --ring: 0 0 0 3px rgba(79,70,229,.25);
  --row-hover: rgba(79,70,229,.04);
  --ease: cubic-bezier(.2,.8,.2,1); --t-fast: 150ms; --t-panel: 220ms;
  --font: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 260px; --topbar-h: 60px;
  /* Chart tokens (validated categorical palette) */
  --viz-surface: #ffffff; --viz-grid: #e8e7e1; --viz-axis: #c3c2b7; --viz-ink: #52514e; --viz-muted: #898781;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.55 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-variant-numeric: tabular-nums; }
img, svg { vertical-align: middle; }
a { color: var(--primary); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; color: var(--ink); letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 600; } h3 { font-size: 16px; font-weight: 600; } h4 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, kbd, .mono { font-family: var(--mono); font-size: 12.5px; }
kbd { display: inline-flex; align-items: center; min-height: 20px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface); color: var(--muted); font: 500 11px/1 var(--font); letter-spacing: .02em; }
.icon { flex-shrink: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible, .input:focus-visible, .sb-link:focus-visible, .sb-church-btn:focus-visible, .sb-meter:focus-visible, .tab:focus-visible, .dropdown-item:focus-visible,
.search-item:focus-visible, .picker-item:focus-visible, .settings-nav a:focus-visible, .avatar-btn:focus-visible, .chip:focus-visible, .stat:focus-visible { outline: none; box-shadow: var(--ring); }
[hidden] { display: none !important; }
::selection { background: rgba(79,70,229,.18); }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%); color: var(--sidebar-ink); display: flex; flex-direction: column; z-index: 40; }
.sb-head { padding: 14px 12px 8px; }
.sb-church { width: 100%; }
.sb-church-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border: 1px solid var(--sidebar-line); border-radius: 12px; background: var(--sidebar-card); color: #fff; cursor: pointer; text-align: left; font: inherit; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.sb-church-btn:hover { background: var(--sidebar-active); border-color: rgba(255,255,255,.1); text-decoration: none; }
.sb-church-btn > .icon { color: var(--sidebar-muted); }
.sb-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; background: #fff; flex-shrink: 0; }
.sb-logo-fallback { display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: 12.5px; letter-spacing: .01em; }
.sb-church-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.sb-church-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.sb-church-sub { font-size: 12px; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-church .dropdown-menu { left: 0; right: 0; min-width: 0; }
.sb-nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; scrollbar-width: thin; scrollbar-color: #243152 transparent; }
.sb-section { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 18px 10px 6px; font-weight: 600; }
.sb-link { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px; color: var(--sidebar-ink); font-size: 13.5px; font-weight: 500; margin: 1px 0; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.sb-link:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.sb-link.active { background: var(--sidebar-active); color: #fff; }
.sb-link .icon { color: var(--sidebar-muted); stroke-width: 1.75; transition: color var(--t-fast) var(--ease); }
.sb-link.active .icon, .sb-link:hover .icon { color: #fff; }
.sb-badge { margin-left: auto; background: var(--brand); color: #1a1200; font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 6px; border-radius: 999px; }
.sb-foot { padding: 10px 12px 14px; border-top: 1px solid var(--sidebar-line); }
.sb-meter { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--sidebar-card); border: 1px solid var(--sidebar-line); color: var(--sidebar-ink); font-size: 12.5px; transition: background var(--t-fast) var(--ease); }
.sb-meter:hover { text-decoration: none; background: var(--sidebar-active); }
.sb-meter-label { display: inline-flex; align-items: center; gap: 6px; color: var(--sidebar-muted); }
.sb-meter-value { font-weight: 600; color: #fff; }
.sb-scrim { position: fixed; inset: 0; background: rgba(11,18,36,.45); z-index: 35; backdrop-filter: blur(2px); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 28px; background: rgba(255,255,255,.72); -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2); border-bottom: 1px solid var(--border); }
.topbar-menu { display: none; }
.topbar-title { font-size: 13.5px; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 8px; }
.topbar-title .icon { color: var(--primary); }
.topbar-search { position: relative; flex: 1; min-width: 0; max-width: 520px; display: flex; align-items: center; gap: 8px; background: rgba(11,18,36,.045); border: 1px solid transparent; border-radius: var(--r); padding: 0 8px 0 12px; height: 38px; color: var(--muted); transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.topbar-search:hover { background: rgba(11,18,36,.065); }
.topbar-search:focus-within { background: #fff; border-color: var(--primary); box-shadow: var(--ring); }
.topbar-search > .icon { color: var(--faint); }
.topbar-search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--ink); outline: none; min-width: 0; }
.topbar-search input::placeholder { color: var(--faint); }
.topbar-search kbd { background: #fff; }
.search-results { position: absolute; top: 46px; left: 0; right: 0; background: #fff; border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; padding: 6px; animation: menu-in var(--t-panel) var(--ease); }
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.search-item:hover, .search-item.active { background: var(--surface-3); text-decoration: none; }
.search-item small { color: var(--muted); display: block; font-size: 12px; }
.search-item .tag { margin-left: auto; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.branch-filter { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); border-radius: var(--r); padding: 0 8px 0 10px; height: 36px; color: var(--muted); background: #fff; box-shadow: var(--shadow-sm); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.branch-filter:hover { border-color: rgba(11,18,36,.22); }
.branch-filter:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.branch-filter select { border: 0; background: transparent; font: inherit; font-weight: 500; color: var(--ink); max-width: 180px; outline: none; }
.avatar-btn { border: 0; background: transparent; padding: 2px; border-radius: 999px; cursor: pointer; transition: box-shadow var(--t-fast) var(--ease); }
.avatar-btn:hover { box-shadow: 0 0 0 3px var(--surface-3); }
.notif { position: relative; }
.notif .dot { position: absolute; top: 4px; right: 4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; box-shadow: 0 0 0 2px #fff; }
.notif-menu { width: 360px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.notif-list { max-height: 360px; overflow: auto; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--ink); font-size: 13.5px; transition: background var(--t-fast) var(--ease); }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.unread { background: #fbfbff; }
.notif-item.unread > div:first-child { font-weight: 600; }
.notif-item small { color: var(--muted); }
.notif-all { display: block; text-align: center; padding: 10px; font-size: 13px; font-weight: 500; }
.banner { display: flex; align-items: center; gap: 8px; padding: 9px 28px; font-size: 13px; border-bottom: 1px solid var(--border); }
.banner-warn { background: var(--warning-soft); color: #7c3d0a; }
.banner-info { background: var(--info-soft); color: #1e3a8a; }
.content { padding: 28px 32px 48px; max-width: 1400px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head-text { min-width: 0; }
.page-title { font-size: 24px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; max-width: 72ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.crumbs { display: flex; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumbs span { color: var(--faint); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--border-strong); background: #fff; color: var(--ink); font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; box-shadow: var(--shadow-sm); transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.btn:hover { background: var(--surface-2); border-color: rgba(11,18,36,.22); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn .icon { color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-btn); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary .icon, .btn-danger .icon, .btn-success .icon { color: rgba(255,255,255,.85); }
.btn-secondary { background: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: var(--shadow-btn); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; box-shadow: var(--shadow-btn); }
.btn-success:hover { background: #166534; border-color: #166534; }
.btn-link { background: transparent; border-color: transparent; color: var(--primary); padding: 0 4px; box-shadow: none; }
.btn-link:hover { background: transparent; border-color: transparent; color: var(--primary-hover); }
.btn-link .icon { color: inherit; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-lg.btn-icon { width: 44px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Cards, grids ──────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); margin-bottom: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head-text { min-width: 0; }
.card-title { font-weight: 600; font-size: 15px; line-height: 1.3; letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.card-body { padding: 20px; }
.card-body + .card-body { border-top: 1px solid var(--border); }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card > .table-wrap:first-child .table thead th:first-child { border-top-left-radius: var(--r-lg); }
.card > .table-wrap:first-child .table thead th:last-child { border-top-right-radius: var(--r-lg); }
.card > .table-wrap:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-side { grid-template-columns: 300px minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

/* ── Stats ─────────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px 16px; box-shadow: var(--shadow); color: var(--ink); display: block; overflow: hidden; min-width: 0; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
a.stat:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: 0 1px 2px rgba(11,18,36,.04), 0 10px 28px -12px rgba(11,18,36,.18); }
.stat-top { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 30px; }
.stat-label { font-size: 11.5px; font-weight: 600; line-height: 1.25; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stat-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); flex-shrink: 0; }
.stat-icon .icon { stroke-width: 1.75; }
.stat-icon-success { background: var(--success-soft); color: var(--success); }
.stat-value { font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; margin-top: 14px; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-height: 20px; margin-top: 8px; }
.stat-delta { display: inline-flex; align-items: center; gap: 2px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-delta.good { background: var(--success-soft); color: var(--success); }
.stat-delta.bad { background: var(--danger-soft); color: var(--danger); }
.stat-delta.flat { background: var(--surface-3); color: var(--muted); }
.stat .sparkline { position: absolute; right: 18px; bottom: 18px; width: 88px; height: 28px; opacity: .9; }
.stat:has(> .sparkline) .stat-foot { padding-right: 100px; }
.stat-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sparkline path { fill: none; stroke: var(--faint); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sparkline circle { fill: var(--primary); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; height: 44px; padding: 0 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table tbody th { position: static; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); background: transparent; height: 48px; }
.table td { height: 48px; padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.table tbody tr:hover td, .table tbody tr:hover th { background: var(--row-hover); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table .check-col { width: 36px; }
.table-sm td, .table-sm th { height: 38px; padding: 6px 12px; }
.table tr[data-href] { cursor: pointer; }
.table a.row-title { font-weight: 600; color: var(--ink); }
.table a.row-title:hover { color: var(--primary); text-decoration: none; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.pager-links { display: flex; gap: 6px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; background: var(--primary-soft); color: var(--primary-ink); border-bottom: 1px solid var(--border); font-size: 13px; }

/* ── Filters ───────────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters .input { height: 36px; width: auto; min-width: 140px; }
.filters .search { flex: 1; min-width: 200px; }
.filters .field { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: #fff; color: var(--ink-2); font-size: 12.5px; font-weight: 500; border: 1px solid var(--border-strong); transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.chip.active { background: var(--primary-soft); color: var(--primary-ink); border-color: rgba(79,70,229,.25); }
a.chip:hover { text-decoration: none; border-color: rgba(11,18,36,.24); background: var(--surface-2); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2, .form-grid-3 .span-3 { grid-column: 1 / -1; }
.field { margin-bottom: 16px; min-width: 0; }
.field > label, .field .label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field > label.check, .field > label.switch { display: inline-flex; font-weight: 400; font-size: 14px; color: var(--ink); margin-bottom: 0; }
.req { color: var(--danger); }
.input { display: block; width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: #fff; color: var(--ink); font: 14px/1.4 var(--font); box-shadow: var(--shadow-sm); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.input::placeholder { color: var(--faint); }
.input:hover:not(:focus):not(:disabled):not([readonly]) { border-color: rgba(11,18,36,.22); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 88px; line-height: 1.5; }
select.input { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6480' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select.input[multiple] { height: auto; min-height: 100px; background-image: none; padding: 6px; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input[readonly] { background: var(--surface-2); box-shadow: none; }
.input:disabled { background: var(--surface-3); color: var(--muted); box-shadow: none; }
input[type="file"].input { height: auto; padding: 8px; font-size: 13px; }
input[type="color"].input { width: 64px; padding: 3px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.45; }
.error { color: var(--danger); font-size: 12.5px; margin-top: 6px; font-weight: 500; }
.has-error .input { border-color: var(--danger); }
.has-error .input:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.2); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; flex: 1; min-width: 0; }
.input-group > :first-child { border-top-left-radius: var(--r-sm); border-bottom-left-radius: var(--r-sm); }
.input-group > :last-child { border-top-right-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm); }
.input-group > * + * { margin-left: -1px; }
.input-group .input:focus { position: relative; z-index: 1; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--muted); font-size: 14px; white-space: nowrap; }
.input-group .btn { border-radius: 0; height: 40px; box-shadow: none; }
.field-check { margin-bottom: 12px; }
.check, .switch { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 14px; color: var(--ink); font-weight: 400; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 36px; height: 20px; border-radius: 999px; background: #d3d8e5; position: relative; flex-shrink: 0; transition: background var(--t-fast) var(--ease); margin-top: 1px; box-shadow: inset 0 1px 2px rgba(11,18,36,.08); }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(11,18,36,.2); transition: transform var(--t-fast) var(--ease); }
.switch input:checked + .switch-ui { background: var(--primary); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { box-shadow: var(--ring); }
.radio-group { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 8px; flex-wrap: wrap; }
.form-section { padding-bottom: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; margin-bottom: 0; }
.form-section-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; letter-spacing: -.01em; }
.form-section-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.copy-field label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.person-picker { position: relative; }
.picker-results { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 280px; overflow: auto; padding: 4px; animation: menu-in var(--t-panel) var(--ease); }
.picker-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.picker-item:hover, .picker-item.active { background: var(--surface-3); }
.picker-item small { color: var(--muted); }

/* ── Badges, alerts, misc ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap; letter-spacing: .005em; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; flex-shrink: 0; }
.badge-gray { background: var(--surface-3); color: var(--ink-2); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-purple { background: #eee9fd; color: #5b21b6; }
.badge-teal { background: #daf5f0; color: #115e59; }
.badge-pink { background: #fbe7f1; color: #9d174d; }
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r); margin-bottom: 16px; font-size: 14px; border: 1px solid transparent; line-height: 1.45; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert > .icon { margin-top: 1px; }
.alert-success { background: var(--success-soft); color: #14532d; border-color: rgba(21,128,61,.18); }
.alert-success > .icon { color: var(--success); }
.alert-error { background: var(--danger-soft); color: #7f1d1d; border-color: rgba(220,38,38,.18); }
.alert-error > .icon { color: var(--danger); }
.alert-info { background: var(--info-soft); color: #1e3a8a; border-color: rgba(29,78,216,.18); }
.alert-info > .icon { color: var(--info); }
.alert-warning { background: var(--warning-soft); color: #78350f; border-color: rgba(180,83,9,.2); }
.alert-warning > .icon { color: var(--warning); }
.alert > span { flex: 1; }
.alert-close { background: none; border: 0; color: inherit; opacity: .55; cursor: pointer; padding: 0; margin-left: auto; display: inline-grid; place-items: center; transition: opacity var(--t-fast) var(--ease); }
.alert-close:hover { opacity: 1; }
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty-icon .icon { stroke-width: 1.5; }
.empty-title { font-weight: 600; font-size: 16px; margin-bottom: 4px; letter-spacing: -.01em; }
.empty-text { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--ink-2); object-fit: cover; flex-shrink: 0; background: var(--surface-3); box-shadow: inset 0 0 0 1px rgba(11,18,36,.06); letter-spacing: .01em; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }
.avatar-xl { width: 96px; height: 96px; font-size: 30px; }
.av-0 { background: #e0e4ff; color: #3730a3; } .av-1 { background: #d6f3f9; color: #155e75; } .av-2 { background: #d5f3e6; color: #065f46; } .av-3 { background: #fdeccb; color: #92400e; }
.av-4 { background: #fde3e3; color: #991b1b; } .av-5 { background: #ebe5fd; color: #5b21b6; } .av-6 { background: #fbe3ee; color: #9d174d; } .av-7 { background: #dbe8fd; color: #1e40af; }
.av-8 { background: #d3f2ec; color: #115e59; } .av-9 { background: #f1e6fd; color: #6b21a8; } .av-10 { background: #fde8d5; color: #9a3412; } .av-11 { background: #e4e8f1; color: #334155; }
.person-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); min-width: 0; }
a.person-chip:hover { text-decoration: none; }
a.person-chip:hover .chip-name { color: var(--primary); }
.chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.chip-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color var(--t-fast) var(--ease); }
.chip-sub { color: var(--muted); font-size: 12px; }
.progress { height: 6px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .4s var(--ease); }
.progress-green { background: var(--success-soft); } .progress-green > span { background: var(--success); }
.progress-amber { background: var(--warning-soft); } .progress-amber > span { background: var(--brand); }
.progress-red { background: var(--danger-soft); } .progress-red > span { background: var(--danger); }
.progress-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 4px; bottom: 4px; width: 2px; background: var(--surface-3); }
.timeline li { position: relative; padding: 0 0 18px 36px; }
.timeline .tl-dot { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 1px solid var(--border-strong); display: grid; place-items: center; color: var(--muted); box-shadow: var(--shadow-sm); }
.timeline .tl-time { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12.5px; } .strong { font-weight: 600; }
.nowrap { white-space: nowrap; } .text-right { text-align: right; } .text-center { text-align: center; }
.pad { padding: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tip { color: var(--faint); cursor: help; position: relative; display: inline-flex; }
.tip:hover::after, .tip:focus::after { content: attr(data-tip); position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; width: max-content; max-width: 260px; z-index: 50; font-weight: 400; line-height: 1.4; box-shadow: var(--shadow-lg); }
.code-block { background: var(--ink); color: #dfe4f2; border-radius: var(--r); padding: 14px 16px; font: 12.5px/1.6 var(--mono); overflow-x: auto; white-space: pre; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.callout .icon { color: var(--primary); margin-top: 2px; }
.qr-box { display: inline-block; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, #fbfbfd 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; color: transparent; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; padding: 10px 12px; color: var(--muted); font-weight: 500; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; border-radius: 8px 8px 0 0; transition: color var(--t-fast) var(--ease); }
.tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--border-strong); transform: scaleX(0); transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab:hover::after { transform: scaleX(1); }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after { transform: scaleX(1); background: var(--primary); }
.tab .count { background: var(--surface-3); color: var(--muted); font-size: 11.5px; line-height: 18px; padding: 0 7px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tab.active .count { background: var(--primary-soft); color: var(--primary-ink); }

/* ── Dropdowns & dialogs ───────────────────────────────────────────────── */
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.985); } }
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; color: var(--ink); transform-origin: top; }
.dropdown-menu.right { left: auto; right: 0; transform-origin: top right; }
.dropdown.open > .dropdown-menu { display: block; animation: menu-in var(--t-panel) var(--ease); }
.dropdown-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--ink); background: none; border: 0; font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; transition: background var(--t-fast) var(--ease); }
.dropdown-item:hover, .dropdown-item.active { background: var(--surface-3); text-decoration: none; }
.dropdown-item .icon { color: var(--muted); }
.dropdown-item.danger { color: var(--danger); } .dropdown-item.danger .icon { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }
.dropdown-menu form { margin: 0; }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-label { padding: 6px 10px; font-size: 12px; color: var(--muted); font-weight: 600; line-height: 1.4; }
dialog.modal { border: 0; border-radius: var(--r-xl); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-lg); color: var(--ink); background: #fff; }
dialog.modal[open] { animation: menu-in var(--t-panel) var(--ease); }
dialog.modal.wide { width: min(820px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(11,18,36,.45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 24px; overflow-y: auto; max-height: calc(100vh - 200px); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; max-width: 360px; animation: toast-in var(--t-panel) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Settings layout ───────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 0 10px; border-radius: 8px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.settings-nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.settings-nav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.settings-nav .icon { color: var(--faint); stroke-width: 1.75; }
.settings-nav a:hover .icon { color: var(--muted); }
.settings-nav a.active .icon { color: var(--primary); }

/* ── Platform admin (same kit, related header colour) ──────────────────── */
body.admin .sidebar { background: linear-gradient(180deg, #111433 0%, #0b1224 100%); }
body.admin .sb-church-btn { text-decoration: none; }
body.admin .topbar { background: rgba(250,250,255,.78); }

/* ── Auth pages ────────────────────────────────────────────────────────── */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; background: radial-gradient(900px 420px at 50% -8%, rgba(79,70,229,.09) 0%, transparent 65%), radial-gradient(600px 320px at 100% 100%, rgba(245,158,11,.07) 0%, transparent 60%), var(--bg); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); margin-bottom: 24px; letter-spacing: -.02em; }
.auth-brand:hover { text-decoration: none; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: 0 1px 2px rgba(11,18,36,.04), 0 24px 60px -24px rgba(11,18,36,.2); padding: 32px; }
.auth-card.wide { max-width: 640px; }
.auth-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; line-height: 1.5; }
.auth-card .alert { margin-bottom: 20px; }
.auth-foot { margin-top: 20px; color: var(--muted); font-size: 13.5px; text-align: center; }
.auth-foot a { font-weight: 500; }
.auth-legal { margin-top: 28px; color: var(--faint); font-size: 12px; text-align: center; }
.auth-legal a { color: var(--faint); }
.auth-body > .alert { max-width: 420px; width: 100%; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; box-shadow: 0 1px 2px rgba(11,18,36,.12), 0 6px 16px -8px rgba(249,115,22,.5); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-side { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 24px; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--t-panel) var(--ease); box-shadow: 0 0 0 1px rgba(255,255,255,.04), 24px 0 60px -20px rgba(11,18,36,.5); }
  body.sidebar-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar-menu { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .banner { padding-left: 16px; padding-right: 16px; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; scrollbar-width: none; }
  .settings-nav a { white-space: nowrap; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .branch-filter select { max-width: 110px; }
}
@media (max-width: 640px) {
  .content { padding: 16px 16px 40px; }
  .grid-2, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .page-title { font-size: 22px; }
  .page-head { align-items: stretch; margin-bottom: 20px; }
  .hide-sm { display: none !important; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; margin-top: 10px; }
  .stat .sparkline { display: none; }
  .stat:has(> .sparkline) .stat-foot { padding-right: 0; }
  .topbar-search { height: 40px; padding-left: 10px; }
  .topbar-search kbd { display: none; }
  .stat-label { font-size: 11px; letter-spacing: .04em; overflow-wrap: anywhere; }
  .branch-filter { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .auth-body { padding: 24px 16px; }
  .auth-card { padding: 24px 20px; }
  .notif-menu { width: calc(100vw - 24px); }
  .table { font-size: 13.5px; }
  .table td { padding-left: 14px; padding-right: 14px; }
  .table th { padding-left: 14px; padding-right: 14px; }
  .card-head, .card-body { padding: 16px; }
  .card-foot, .pager { padding-left: 16px; padding-right: 16px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  /* Touch targets ≥ 44px */
  .btn:not(.btn-sm) { height: 44px; }
  .btn-icon:not(.btn-sm) { width: 44px; }
  .btn-sm { height: 36px; }
  .btn-sm.btn-icon { width: 36px; }
  .input, .filters .input, .input-group .btn { height: 44px; }
  textarea.input, select.input[multiple], input[type="file"].input { height: auto; }
  .sb-link { height: 44px; }
  .tab { min-height: 44px; }
  .dropdown-item, .settings-nav a, .search-item { min-height: 44px; }
  .check input { width: 18px; height: 18px; }
}
@media print {
  .sidebar, .topbar, .page-actions, .no-print, .banner, .toast-host, .settings-nav, .filters, .pager { display: none !important; }
  .main { margin: 0; } .content { padding: 0; max-width: none; } body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  .settings-grid { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Charts (.viz) ─────────────────────────────────────────────────────── */
.viz { position: relative; color: var(--viz-ink); }
.viz-plot { position: relative; overflow-x: auto; }
.viz-svg { width: 100%; min-width: 480px; height: auto; display: block; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-grid.viz-base { stroke: var(--viz-axis); }
.viz-tick { fill: var(--viz-muted); font-size: 11.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.viz-endlabel { fill: var(--ink-2); font-size: 12px; font-weight: 600; font-family: var(--font); }
.viz-bar { transition: opacity .12s; }
.viz-bar.viz-muted { opacity: .55; }
.viz-hit:hover .viz-bar, .viz-hit:focus .viz-bar { opacity: .82; }
.viz-hitbox { fill: transparent; }
.viz-hit { outline: none; }
.viz-bar.s1, .viz-seg.s1, .viz-swatch.s1 { fill: var(--series-1); background: var(--series-1); }
.viz-bar.s2, .viz-seg.s2, .viz-swatch.s2 { fill: var(--series-2); background: var(--series-2); }
.viz-bar.s3, .viz-seg.s3, .viz-swatch.s3 { fill: var(--series-3); background: var(--series-3); }
.viz-seg.s4, .viz-swatch.s4 { fill: var(--series-4); background: var(--series-4); }
.viz-seg.s5, .viz-swatch.s5 { fill: var(--series-5); background: var(--series-5); }
.viz-seg.s6, .viz-swatch.s6 { fill: var(--series-6); background: var(--series-6); }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-line.s1 { stroke: var(--series-1); } .viz-line.s2 { stroke: var(--series-2); } .viz-line.s3 { stroke: var(--series-3); }
.viz-area.s1 { fill: var(--series-1); opacity: .1; }
.viz-dot { stroke: var(--viz-surface); stroke-width: 2; }
.viz-dot.s1 { fill: var(--series-1); } .viz-dot.s2 { fill: var(--series-2); } .viz-dot.s3 { fill: var(--series-3); }
.viz-ring.s1 { fill: none; stroke: var(--series-1); }
.viz-seg { stroke: var(--viz-surface); stroke-width: 2; }
.viz-hit:hover .viz-seg, .viz-hit:focus .viz-seg { opacity: .85; }
.viz-cross { stroke: var(--viz-axis); stroke-width: 1; }
.viz-band { fill: transparent; }
.viz-center { font: 700 18px var(--font); fill: var(--ink); }
.viz-center-sub { font: 12px var(--font); fill: var(--viz-muted); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-2); }
.viz-key { display: inline-flex; align-items: center; gap: 6px; }
.viz-swatch { display: inline-block; flex-shrink: 0; }
.viz-swatch.viz-rect { width: 10px; height: 10px; border-radius: 3px; }
.viz-swatch.viz-line { width: 14px; height: 2px; border-radius: 2px; }
.viz-tip { position: absolute; z-index: 20; pointer-events: none; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--ink); min-width: 120px; white-space: nowrap; }
.viz-tip .tip-title { color: var(--muted); margin-bottom: 4px; }
.viz-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.viz-tip .tip-row strong { font-variant-numeric: tabular-nums; }
.viz-tip .tip-key { width: 12px; height: 2px; border-radius: 2px; }
.viz-empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); font-size: 13px; background: repeating-linear-gradient(45deg, transparent, transparent 8px, var(--surface-2) 8px, var(--surface-2) 9px); border-radius: var(--r); }
.viz-table { margin-top: 8px; font-size: 12.5px; }
.viz-table summary { cursor: pointer; color: var(--muted); display: inline-block; }
.viz-table .table-wrap { margin-top: 8px; max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.viz-hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; outline: none; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hbar-label a { color: var(--ink-2); }
.hbar-track { height: 10px; background: transparent; border-radius: 0 4px 4px 0; }
.hbar-fill { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbar:hover .hbar-fill, .hbar:focus .hbar-fill { opacity: .82; }
.hbar-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); min-width: 60px; text-align: right; }
.viz-donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.viz-donut .viz-plot { overflow: visible; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; font-size: 13px; }
.donut-legend li { display: grid; grid-template-columns: 12px 1fr auto 40px; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--surface-3); }
.donut-legend li:last-child { border-bottom: 0; }
.dl-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.dl-pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ── Phone frame (phone_frame()) ──────────────────────────────────────────────
   An iPhone-style handset: titanium band, black bezel, glass with a Dynamic Island, status bar and home indicator, plus
   the action, volume and power buttons standing just proud of the frame. Every measure is a share of the phone's width
   (cqw), so the one frame is right at any size; the screen inside keeps its own font sizes. */
.cb-phone { position: relative; width: 100%; max-width: 300px; margin: 0 auto; container-type: inline-size; color: #0b1224; }
.cb-phone-dark { color: #fff; }
.cb-phone-btn { position: absolute; width: 1.4cqw; background: linear-gradient(180deg, #5b5e64, #2a2b2f 50%, #4d5055); }
.cb-phone-btn-action, .cb-phone-btn-up, .cb-phone-btn-down { left: -.9cqw; border-radius: .9cqw 0 0 .9cqw; }
.cb-phone-btn-action { top: 42cqw; height: 10.5cqw; }
.cb-phone-btn-up { top: 60.5cqw; height: 19.3cqw; }
.cb-phone-btn-down { top: 84cqw; height: 19.3cqw; }
.cb-phone-btn-power { right: -.9cqw; top: 66cqw; height: 30cqw; border-radius: 0 .9cqw .9cqw 0; }
.cb-phone-band { position: relative; padding: 1.3cqw; border-radius: 19.3cqw; background: linear-gradient(140deg, #9a9da3 0%, #44464b 18%, #202125 46%, #2c2d31 64%, #6e7176 86%, #b4b7bc 100%); box-shadow: 0 46px 70px -28px rgba(0, 0, 0, .55), 0 18px 28px -18px rgba(0, 0, 0, .45); }
.cb-phone-bezel { padding: 2.6cqw; border-radius: 18cqw; background: #000; }
.cb-phone-glass { position: relative; display: flex; flex-direction: column; aspect-ratio: 9 / 19.5; overflow: hidden; border-radius: 15.4cqw; background: #f5f6fb; }
.cb-phone-light .cb-phone-glass { background: #fff; }
.cb-phone-dark .cb-phone-glass { background: #0b0c0f; }
.cb-phone-island { position: absolute; top: 3.9cqw; left: 50%; width: 31.6cqw; height: 9.6cqw; transform: translateX(-50%); border-radius: 999px; background: #000; z-index: 3; }
.cb-phone-status { display: flex; flex: none; align-items: center; justify-content: space-between; height: 17.4cqw; padding: 0 8cqw 0 9.5cqw; font-size: 4.4cqw; font-weight: 600; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.cb-phone-status span:last-child { display: inline-flex; align-items: center; gap: 1.8cqw; }
.cb-phone-status svg { display: block; width: auto; height: 3.7cqw; }
.cb-phone-screen { position: relative; z-index: 1; display: flex; flex: 1; flex-direction: column; min-height: 0; padding: 0 4.6cqw 9cqw; font-size: 12px; }
.cb-phone-home { position: absolute; left: 50%; bottom: 2.8cqw; z-index: 3; width: 36.8cqw; height: 1.6cqw; transform: translateX(-50%); border-radius: 999px; background: currentColor; opacity: .85; }
.cb-phone-glare { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(115deg, rgba(255, 255, 255, .16) 0%, transparent 30%); }