/* ==========================================================================
   ChurchPlus application shell and components
   ========================================================================== */

/* ---------- Shell ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--cp-sidebar-w);
  display: flex; flex-direction: column;
  background: var(--cp-side-bg); color: var(--cp-side-text);
  border-right: 1px solid rgba(255,255,255,.06);
  transition: width .25s var(--cp-ease), transform .28s var(--cp-ease);
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 12px 20px; min-height: var(--cp-topbar-h); }
.sidebar-head .brand { color: #fff; min-width: 0; }
.sidebar-head .brand-name { color: #fff; }
.sidebar-close { margin-left: auto; display: none; }
.church-chip {
  display: flex; align-items: center; gap: 10px; margin: 4px 14px 10px; padding: 10px 12px;
  border-radius: var(--cp-radius-md); background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
  min-width: 0;
}
.church-chip .avatar { width: 32px; height: 32px; font-size: 12px; }
.church-chip-text { min-width: 0; }
.church-chip-name { color: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.church-chip-sub { color: var(--cp-side-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-filter { position: relative; margin: 0 14px 6px; }
.nav-filter .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--cp-side-muted); }
.nav-filter input {
  width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: var(--cp-radius-sm);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); color: #fff; font: inherit; font-size: 14px;
}
.nav-filter input::placeholder { color: var(--cp-side-muted); }
.nav-filter input:focus { outline: none; border-color: rgba(201,162,39,.6); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-section { margin-top: 12px; }
.nav-section-title { padding: 6px 12px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--cp-side-muted); }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; margin: 1px 0;
  border-radius: var(--cp-radius-sm); color: var(--cp-side-text); font-size: 14px; font-weight: 500;
  transition: background .15s var(--cp-ease), color .15s var(--cp-ease);
}
.nav-link:hover { background: var(--cp-side-hover); color: #fff; text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--cp-side-active); color: var(--cp-side-active-text); }
.nav-link[aria-current="page"] .icon { color: var(--cp-gold-500); }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-empty { padding: 10px 12px; color: var(--cp-side-muted); font-size: 13px; }

.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-collapse {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 8px 12px;
  border: 0; border-radius: var(--cp-radius-sm); background: transparent; color: var(--cp-side-muted);
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.sidebar-collapse:hover { background: var(--cp-side-hover); color: #fff; }
.sidebar-collapse .icon-open { display: none; }

/* Collapsed sidebar (desktop) */
html.sidebar-collapsed .sidebar { width: var(--cp-sidebar-w-collapsed); }
html.sidebar-collapsed .sidebar .brand-name,
html.sidebar-collapsed .sidebar .nav-label,
html.sidebar-collapsed .sidebar .nav-section-title,
html.sidebar-collapsed .sidebar .church-chip-text,
html.sidebar-collapsed .sidebar .nav-filter,
html.sidebar-collapsed .sidebar .collapse-label { display: none; }
html.sidebar-collapsed .sidebar .nav-link,
html.sidebar-collapsed .sidebar .sidebar-collapse { justify-content: center; padding: 8px; }
html.sidebar-collapsed .sidebar .church-chip { justify-content: center; padding: 8px; margin: 4px 12px 10px; }
html.sidebar-collapsed .sidebar-head { justify-content: center; padding: 18px 8px 12px; }
html.sidebar-collapsed .sidebar-collapse .icon-open { display: inline; }
html.sidebar-collapsed .sidebar-collapse .icon-close { display: none; }
html.sidebar-collapsed .nav-section { margin-top: 8px; border-top: 1px solid rgba(255,255,255,.05); padding-top: 6px; }

.app-body { margin-left: var(--cp-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .25s var(--cp-ease); }
html.sidebar-collapsed .app-body { margin-left: var(--cp-sidebar-w-collapsed); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  min-height: var(--cp-topbar-h); padding: 10px 24px;
  background: var(--cp-surface); border-bottom: 1px solid var(--cp-border);
  -webkit-backdrop-filter: saturate(170%) blur(20px); backdrop-filter: saturate(170%) blur(20px);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; list-style: none; margin: 0 0 2px; padding: 0; font-size: 12.5px; color: var(--cp-text-subtle); }
.breadcrumb a { color: var(--cp-text-muted); }
.breadcrumb li + li::before { content: "/"; margin-right: 4px; color: var(--cp-border-strong); }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.global-search { position: relative; width: clamp(180px, 24vw, 320px); }
.global-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--cp-text-subtle); pointer-events: none; }
.global-search input {
  width: 100%; height: 40px; padding: 0 44px 0 38px; border-radius: var(--cp-radius-pill);
  background: var(--cp-surface-sunken); border: 1px solid transparent; color: var(--cp-text); font: inherit; font-size: 14px;
}
.global-search input:focus { outline: none; background: var(--cp-surface-solid); border-color: var(--cp-accent); box-shadow: 0 0 0 4px var(--cp-focus); }
.global-search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 600 11px var(--cp-font); color: var(--cp-text-subtle); background: var(--cp-surface-solid);
  border: 1px solid var(--cp-border); border-radius: 6px; padding: 2px 6px;
}

.app-main { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px 24px 40px; }

/* Phone drawer + tab bar (hidden on larger screens) */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 35; background: rgba(7, 14, 34, .48);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--cp-ease);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.tabbar { display: none; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-header h2 { font-size: 1.45rem; margin: 0 0 2px; }
.page-header p { margin: 0; color: var(--cp-text-muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-main-side > .card { align-self: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mb-4 { margin-bottom: 16px; } .mt-4 { margin-top: 16px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main-side { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Cards ---------- */
.card {
  background: var(--cp-surface); border: 1px solid var(--cp-border); border-radius: var(--cp-radius-lg);
  box-shadow: var(--cp-shadow); -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
  min-width: 0;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px 0; }
.card-header h3 { margin: 0; font-size: 1rem; }
.card-header p { margin: 2px 0 0; font-size: 13px; color: var(--cp-text-muted); }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 12px 0 0; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--cp-border); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.stat-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 13px; font-weight: 500; color: var(--cp-text-muted); }
.stat-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--cp-accent-soft); color: var(--cp-accent); }
.stat-icon.tone-gold { background: var(--cp-gold-100); color: var(--cp-gold-600); }
.stat-icon.tone-success { background: var(--cp-success-bg); color: var(--cp-success); }
.stat-icon.tone-danger { background: var(--cp-danger-bg); color: var(--cp-danger); }
.stat-icon.tone-info { background: var(--cp-info-bg); color: var(--cp-info); }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--cp-text-muted); flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta.up { color: var(--cp-success); } .delta.down { color: var(--cp-danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--cp-radius-pill);
  border: 1px solid var(--cp-border-strong); background: var(--cp-surface-solid); color: var(--cp-text);
  font: 600 14px var(--cp-font); cursor: pointer; white-space: nowrap;
  transition: background .15s var(--cp-ease), border-color .15s var(--cp-ease), transform .1s var(--cp-ease), box-shadow .15s;
}
.btn:hover { text-decoration: none; border-color: var(--cp-accent); }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary, .btn-primary:visited { background: var(--cp-accent); border-color: var(--cp-accent); color: var(--cp-on-accent); box-shadow: 0 4px 14px rgba(91, 63, 209, .25); }
.btn-primary:hover { background: var(--cp-accent-hover); border-color: var(--cp-accent-hover); }
.btn-gold { background: var(--cp-gold-500); border-color: var(--cp-gold-500); color: #2a1f00; }
.btn-gold:hover { background: #d6b13b; border-color: #d6b13b; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--cp-text-muted); }
.btn-ghost:hover { background: var(--cp-surface-hover); border-color: transparent; color: var(--cp-text); }
.btn-danger { background: var(--cp-danger); border-color: var(--cp-danger); color: #fff; }
.btn-danger:hover { background: #ad2c2c; border-color: #ad2c2c; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; position: relative; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .badge-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--cp-danger); border: 2px solid var(--cp-surface-solid); }
.sidebar .btn-icon { color: var(--cp-side-text); background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.08); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--cp-radius-pill); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--cp-surface-sunken); color: var(--cp-text-muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge-success { background: var(--cp-success-bg); color: var(--cp-success); }
.badge-warning { background: var(--cp-warning-bg); color: var(--cp-warning); }
.badge-danger { background: var(--cp-danger-bg); color: var(--cp-danger); }
.badge-info { background: var(--cp-info-bg); color: var(--cp-info); }
.badge-accent { background: var(--cp-accent-soft); color: var(--cp-accent); }
.badge-gold { background: var(--cp-gold-100); color: var(--cp-gold-600); }

/* ---------- Avatars and profile cards ---------- */
.avatar { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--cp-purple-500), var(--cp-navy-700)); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.profile-card { display: flex; gap: 14px; align-items: center; padding: 16px; }
.profile-card .who { min-width: 0; }
.profile-card .name { font-weight: 650; }
.profile-card .meta { font-size: 13px; color: var(--cp-text-muted); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 12.5px; color: var(--cp-text-muted); }

/* ---------- 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 { text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--cp-text-subtle); padding: 10px 16px; border-bottom: 1px solid var(--cp-border); white-space: nowrap; background: transparent; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--cp-border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--cp-surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.table .num, .table .col-num { text-align: right; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]::after { content: " ↕"; opacity: .35; }
.table th[aria-sort="ascending"]::after { content: " ↑"; opacity: .9; }
.table th[aria-sort="descending"]::after { content: " ↓"; opacity: .9; }
.table td.wrap { white-space: normal; min-width: 120px; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--cp-border); }
.filter-bar .search-input { flex: 1 1 220px; }
.filter-bar .select { flex: 0 1 180px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: var(--cp-radius-pill); border: 1px solid var(--cp-border-strong); background: var(--cp-surface-solid); color: var(--cp-text-muted); font: 500 13px var(--cp-font); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--cp-accent-soft); border-color: transparent; color: var(--cp-accent); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13.5px; font-weight: 600; color: var(--cp-text); }
.label .req { color: var(--cp-danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--cp-radius-sm);
  border: 1px solid var(--cp-border-strong); background: var(--cp-surface-solid); color: var(--cp-text);
  font: 16px/1.4 var(--cp-font); transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--cp-text-subtle); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--cp-accent); box-shadow: 0 0 0 4px var(--cp-focus); }
.textarea { min-height: 110px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none; padding-right: 38px;
  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='%237d8399' 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 12px center; }
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { min-height: 44px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--cp-text-subtle); pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.help { font-size: 12.5px; color: var(--cp-text-muted); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--cp-danger); }
.field-error { font-size: 12.5px; color: var(--cp-danger); font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--cp-accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--cp-border-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--cp-ease); }
.switch input:checked { background: var(--cp-accent); }
.switch input:checked::after { transform: translateX(18px); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.upload-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px; border: 1.5px dashed var(--cp-border-strong); border-radius: var(--cp-radius-md); background: var(--cp-surface-sunken); text-align: center; color: var(--cp-text-muted); font-size: 13.5px; }
.upload-drop input { max-width: 100%; font-size: 14px; }

/* ---------- Alerts and toasts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--cp-radius-md); font-size: 14px; border: 1px solid transparent; }
.alert-info { background: var(--cp-info-bg); color: var(--cp-info); }
.alert-success { background: var(--cp-success-bg); color: var(--cp-success); }
.alert-warning { background: var(--cp-warning-bg); color: var(--cp-warning); }
.alert-danger { background: var(--cp-danger-bg); color: var(--cp-danger); }
.alert .alert-body { color: var(--cp-text); }
.alert strong { display: block; color: inherit; }
.toast-stack { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--cp-radius-md); background: var(--cp-surface-solid); border: 1px solid var(--cp-border); box-shadow: var(--cp-shadow-lg); font-size: 14px; animation: toast-in .3s var(--cp-ease); }
.toast .toast-icon { color: var(--cp-info); }
.toast.toast-success .toast-icon { color: var(--cp-success); }
.toast.toast-danger .toast-icon, .toast.toast-error .toast-icon { color: var(--cp-danger); }
.toast.toast-warning .toast-icon { color: var(--cp-warning); }
.toast .toast-msg { flex: 1; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .25s var(--cp-ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 220px; max-width: min(360px, calc(100vw - 24px));
  padding: 6px; border-radius: var(--cp-radius-md); background: var(--cp-surface-solid);
  border: 1px solid var(--cp-border); box-shadow: var(--cp-shadow-lg);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity .15s var(--cp-ease), transform .15s var(--cp-ease);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
/* Boxes around an open menu are lifted above the cards that follow them (set by app.js). */
.menu-host { z-index: 60; }
.menu-host-static { position: relative; z-index: 60; }
.dropdown.open { z-index: 61; }
.dropdown-menu.align-left { left: 0; right: auto; transform-origin: top left; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 8px 10px; border: 0; border-radius: var(--cp-radius-sm); background: none; color: var(--cp-text); font: 500 14px var(--cp-font); text-align: left; cursor: pointer; }
.dropdown-item:hover { background: var(--cp-surface-hover); text-decoration: none; }
.dropdown-item.danger { color: var(--cp-danger); }
.dropdown-divider { height: 1px; margin: 6px 4px; background: var(--cp-border); }
.dropdown-header { padding: 10px 10px 8px; }
.notif-menu { width: 340px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--cp-border); font-weight: 650; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; color: var(--cp-text-muted); font-size: 13.5px; text-align: center; }

/* ---------- Modals (native <dialog>) ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); padding: 0; border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-xl); background: var(--cp-surface-solid); color: var(--cp-text); box-shadow: var(--cp-shadow-lg);
}
dialog.modal[open] { animation: modal-in .22s var(--cp-ease); }
dialog.modal::backdrop { background: rgba(7, 14, 34, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 0; }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 14px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 6px 22px 20px; }
.modal-sm { width: min(420px, calc(100vw - 24px)); }
.confirm-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--cp-danger-bg); color: var(--cp-danger); margin-bottom: 10px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--cp-border); font-size: 13.5px; color: var(--cp-text-muted); }
.pager { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a, .pager span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--cp-radius-sm); color: var(--cp-text); font-weight: 500; font-variant-numeric: tabular-nums; }
.pager a:hover { background: var(--cp-surface-hover); text-decoration: none; }
.pager .current { background: var(--cp-accent); color: var(--cp-on-accent); }
.pager .disabled { color: var(--cp-text-subtle); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: var(--cp-radius-pill); background: var(--cp-surface-sunken); width: max-content; max-width: 100%; overflow-x: auto; }
.tab { min-height: 34px; padding: 0 14px; border: 0; border-radius: var(--cp-radius-pill); background: none; color: var(--cp-text-muted); font: 600 13.5px var(--cp-font); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--cp-surface-solid); color: var(--cp-text); box-shadow: var(--cp-shadow-sm); }

/* ---------- Lists, feeds, quick actions ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--cp-border); }
.feed li:first-child { border-top: 0; }
.feed-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--cp-surface-sunken); color: var(--cp-text-muted); flex: none; }
.feed-text { font-size: 14px; min-width: 0; }
.feed-time { font-size: 12.5px; color: var(--cp-text-subtle); }
.quick-actions { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.quick-action { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; border-radius: var(--cp-radius-md); background: var(--cp-surface-sunken); color: var(--cp-text); font-weight: 600; font-size: 13.5px; border: 1px solid transparent; transition: border-color .15s, background .15s; }
.quick-action:hover { text-decoration: none; border-color: var(--cp-accent); background: var(--cp-surface-solid); }
.quick-action .icon { color: var(--cp-accent); }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 20px; color: var(--cp-text-muted); }
.empty-state .empty-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--cp-accent-soft); color: var(--cp-accent); margin-bottom: 4px; }
.empty-state h3 { color: var(--cp-text); margin: 0; }
.empty-state p { max-width: 42ch; margin: 0 0 8px; }
.progress { height: 8px; border-radius: 999px; background: var(--cp-surface-sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cp-purple-500), var(--cp-gold-500)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--cp-text-muted); } .kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--cp-text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Sign-in pages: neumorphism + spatial ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-shell { width: min(440px, 100%); }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.auth-card {
  padding: 32px; border-radius: 28px; background: var(--cp-bg);
  box-shadow: 12px 12px 28px rgba(18, 32, 74, .12), -10px -10px 26px rgba(255, 255, 255, .9), inset 0 0 0 1px rgba(255,255,255,.6);
}
.auth-card h1 { font-size: 1.45rem; }
.auth-card .input { background: var(--cp-bg); border-color: transparent; box-shadow: inset 4px 4px 10px rgba(18, 32, 74, .09), inset -4px -4px 10px rgba(255, 255, 255, .9); }
.auth-card .input:focus { border-color: var(--cp-accent); box-shadow: inset 4px 4px 10px rgba(18, 32, 74, .09), inset -4px -4px 10px rgba(255,255,255,.9), 0 0 0 4px var(--cp-focus); }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--cp-text-muted); }

/* Small utilities (no inline styles: CSP blocks them) */
.btn-account { padding: 0 6px; }
.mt-1 { margin-top: 6px; }
.modal-body-top { padding-top: 22px; }
progress.progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--cp-surface-sunken); overflow: hidden; display: block; }
progress.progress::-webkit-progress-bar { background: var(--cp-surface-sunken); border-radius: 999px; }
progress.progress::-webkit-progress-value { background: linear-gradient(90deg, var(--cp-purple-500), var(--cp-gold-500)); border-radius: 999px; }
progress.progress::-moz-progress-bar { background: linear-gradient(90deg, var(--cp-purple-500), var(--cp-gold-500)); border-radius: 999px; }
.legend i.c0 { background: #5b3fd1; } .legend i.c1 { background: #c9a227; } .legend i.c2 { background: #1a8a5c; } .legend i.c3 { background: #2367c9; }
.min-w-0 { min-width: 0; }
/* Shell-only buttons: hidden on larger screens (beats .btn display). */
.btn.sidebar-close, .btn.menu-btn, .btn.app-back { display: none; }
.split { justify-content: space-between; }
.auth-shell.wide { width: min(720px, 100%); }
.radio-group { display: grid; gap: 10px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--cp-radius-md); border: 1px solid var(--cp-border-strong); cursor: pointer; font-size: 14px; }
.radio-card input { margin-top: 3px; accent-color: var(--cp-accent); width: 18px; height: 18px; flex: none; }
.radio-card:has(input:checked) { border-color: var(--cp-accent); background: var(--cp-accent-soft); }
.form-section-title { grid-column: 1 / -1; margin: 8px 0 -4px; font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--cp-text-subtle); }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--cp-border); font-size: 14px; }
.checklist li:first-child { border-top: 0; }
.checklist .tick { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--cp-border-strong); color: transparent; flex: none; }
.checklist .done .tick { background: var(--cp-success); border-color: var(--cp-success); color: #fff; }
.checklist .done .item-label { color: var(--cp-text-muted); text-decoration: line-through; }
.checklist a { margin-left: auto; font-size: 13px; font-weight: 600; }
.logo-preview { width: 96px; height: 96px; border-radius: 22px; object-fit: contain; background: var(--cp-surface-sunken); border: 1px solid var(--cp-border); padding: 8px; }
.logo-placeholder { display: inline-grid; place-items: center; width: 96px; height: 96px; border-radius: 22px; font-size: 28px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--cp-purple-500), var(--cp-navy-700)); }
.church-list { display: grid; gap: 10px; }
.church-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border-radius: var(--cp-radius-md); border: 1px solid var(--cp-border-strong); background: var(--cp-surface-solid); color: var(--cp-text); font: inherit; text-align: left; cursor: pointer; }
.church-option:hover { border-color: var(--cp-accent); }
.church-option[disabled] { opacity: .6; cursor: not-allowed; }
.church-option .chev { margin-left: auto; color: var(--cp-text-subtle); }
.church-chip .avatar img, .church-logo-img { width: 100%; height: 100%; object-fit: cover; }
.fieldset-plain { border: 0; padding: 0; margin: 0; min-width: 0; } .fieldset-plain legend { padding: 0; margin-bottom: 6px; }
a.stat-card { color: inherit; }
a.stat-card:hover { text-decoration: none; border-color: var(--cp-accent); }
.auth-card .select { background-color: var(--cp-bg); border-color: transparent; box-shadow: inset 4px 4px 10px rgba(18, 32, 74, .09), inset -4px -4px 10px rgba(255, 255, 255, .9); }
[data-theme="dark"] .auth-card .select { background-color: #0c1228; box-shadow: inset 4px 4px 10px rgba(0, 0, 0, .45), inset -3px -3px 8px rgba(60, 76, 130, .12); }
.role-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.radio-card.is-disabled { opacity: .55; cursor: not-allowed; }
.perm-matrix td, .perm-matrix th { padding: 8px 10px; }
.col-center { text-align: center !important; }
.perm-box { width: 20px; height: 20px; accent-color: var(--cp-accent); cursor: pointer; }
.perm-box:disabled { cursor: not-allowed; }
.qr-box { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: var(--cp-radius-md); width: max-content; max-width: 100%; margin: 0 auto; }
.qr-box svg { width: 220px; height: 220px; max-width: 100%; }
.secret-key { font: 600 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; word-break: break-all; text-align: center; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; margin: 16px 0 20px; padding-left: 22px; font: 600 16px ui-monospace, SFMono-Regular, Menlo, monospace; }
.input-static { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--cp-surface-sunken); border-color: transparent; }
.date-input { flex: 0 1 170px; }
@media (max-width: 760px) { .date-input { flex: 1 1 140px; } }

/* ---------- Members ---------- */
.member-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 20px; }
.member-photo { width: 104px; height: 128px; border-radius: 18px; object-fit: cover; background: var(--cp-surface-sunken); border: 1px solid var(--cp-border); flex: none; }
.member-photo-placeholder { display: grid; place-items: center; width: 104px; height: 128px; border-radius: 18px; font-size: 30px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--cp-purple-500), var(--cp-navy-700)); flex: none; }
.member-hero h2 { margin: 0 0 4px; font-size: 1.4rem; }
.member-hero .meta { color: var(--cp-text-muted); font-size: 14px; }
.member-hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.tab-panels > [role=tabpanel] { margin-top: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--cp-border); margin-left: 6px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--cp-accent); border: 2px solid var(--cp-surface-solid); }
.timeline li:last-child { padding-bottom: 0; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--cp-border); }
.doc-list li:first-child { border-top: 0; }
.doc-list .grow { flex: 1; min-width: 0; }
.import-errors { max-height: 320px; overflow-y: auto; }
.list-photo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }

/* Membership ID card (CR80 proportions) */
.id-card { width: 340px; max-width: 100%; aspect-ratio: 85.6 / 54; border-radius: 16px; overflow: hidden; display: grid; grid-template-rows: auto 1fr; background: #fff; color: #14182b; border: 1px solid #d9dbe6; box-shadow: var(--cp-shadow); }
.id-card-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: linear-gradient(135deg, #12204a, #5b3fd1); color: #fff; font-weight: 700; font-size: 12px; }
.id-card-head .brand-mark { width: 22px; height: 22px; border-radius: 7px; }
.id-card-body { display: grid; grid-template-columns: 74px 1fr 84px; gap: 10px; padding: 10px 12px; align-items: center; }
.id-card-body img, .id-card-body .member-photo-placeholder { width: 74px; height: 92px; border-radius: 10px; object-fit: cover; font-size: 22px; }
.id-card-body .who { min-width: 0; font-size: 11px; line-height: 1.35; }
.id-card-body .who strong { display: block; font-size: 13px; }
.id-card-body .num { font: 700 12px ui-monospace, Menlo, monospace; color: #5b3fd1; }
.id-card-qr svg { width: 84px; height: 84px; display: block; }
@media print {
  .id-card { box-shadow: none !important; border: 1px solid #999 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .id-card-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-header, .card-footer, .breadcrumb { display: none !important; }
}
.grow { flex: 1; min-width: 0; }
.scan-video { width: 100%; max-width: 360px; aspect-ratio: 1; object-fit: cover; border-radius: var(--cp-radius-md); background: #000; }
.register-table td { padding-top: 8px; padding-bottom: 8px; }
.rows-table td { padding: 6px 8px; }
.rows-table .input { min-height: 40px; }
.rows-table input[type="time"] { min-width: 110px; }
a.tab { display: inline-flex; align-items: center; text-decoration: none; }
details > summary { list-style: none; cursor: pointer; width: max-content; }
details > summary::-webkit-details-marker { display: none; }
.dept-name { font-size: 1.15rem; }

/* ---------- Finance ---------- */
.num-input { font-variant-numeric: tabular-nums; text-align: right; }
.text-danger { color: var(--cp-danger) !important; }
.progress-cell { min-width: 120px; }
.progress-cell .help { margin-left: 6px; }
.table tfoot td { border-top: 2px solid var(--cp-border-strong); font-weight: 650; padding: 10px 16px; }
.total-row td { font-weight: 650; border-top: 1px solid var(--cp-border-strong); }
.grand-row td { font-weight: 750; font-size: 1.02rem; border-top: 3px double var(--cp-border-strong) !important; }
.section-row th { background: var(--cp-surface-sunken); color: var(--cp-text); text-transform: none; letter-spacing: 0; font-size: 13.5px; }
.statement .num { min-width: 140px; }
.code { color: var(--cp-text-subtle); font-variant-numeric: tabular-nums; margin-right: 6px; font-size: 12.5px; }
.report-title { text-align: center; }
.report-title h2 { margin: 2px 0; }
.report-church { font-weight: 650; color: var(--cp-text-muted); }
.receipt-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 2px solid var(--cp-border); }
.receipt-church { font-size: 1.2rem; font-weight: 700; }
.receipt-no { text-align: right; display: flex; flex-direction: column; }
.receipt-no strong { font: 700 1.1rem ui-monospace, Menlo, monospace; color: var(--cp-accent); }
.receipt-kv { margin-bottom: 16px; }
.receipt-amount { font-size: 1.3rem; font-weight: 750; }
.print-only { display: none; }
.signature-lines { display: none; }
@media print {
  .print-only, .signature-lines { display: flex !important; }
  .signature-lines { justify-content: space-between; gap: 24px; margin-top: 48px; }
  .signature-lines span { flex: 1; border-top: 1px solid #000; padding-top: 4px; font-size: 12px; }
  .filter-bar { display: none !important; }
  .report { border: 0 !important; }
}

/* ---------- Calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head { padding: 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--cp-text-subtle); border-bottom: 1px solid var(--cp-border); }
.cal-day { min-height: 104px; padding: 6px; border-right: 1px solid var(--cp-border); border-bottom: 1px solid var(--cp-border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: var(--cp-surface-sunken); color: var(--cp-text-subtle); }
.cal-num { font-size: 12.5px; font-weight: 600; }
.cal-day.today .cal-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--cp-accent); color: var(--cp-on-accent); }
.cal-event { display: block; padding: 2px 6px; border-radius: 6px; background: var(--cp-accent-soft); color: var(--cp-accent); font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.cancelled { text-decoration: line-through; opacity: .6; }
@media (max-width: 760px) {
  .cal-day { min-height: 64px; padding: 3px; }
  .cal-event { font-size: 0; padding: 0; height: 6px; border-radius: 3px; background: var(--cp-accent); }
  .cal-head { padding: 6px 2px; text-align: center; font-size: 10.5px; }
}

/* ---- Stage 7: ministry ---- */
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.prose { line-height: 1.65; max-width: 72ch; }
.textarea.textarea-lg { min-height: 260px; }
.media-player { display: block; width: 100%; max-width: 420px; margin-top: 8px; height: 36px; }
.pickup-code { font: 700 40px/1 var(--cp-font-mono, ui-monospace, monospace); letter-spacing: .18em; color: var(--cp-accent); }
.label-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.child-label { border: 2px dashed var(--cp-border-strong); border-radius: 18px; padding: 16px; text-align: center; }
.child-label .name { font-weight: 700; font-size: 18px; }
.child-label .warn { color: var(--cp-danger); font-weight: 600; margin-top: 6px; }
.lock-note { display: flex; gap: 8px; align-items: center; color: var(--cp-text-muted); font-size: 13px; }
.restriction { color: var(--cp-danger); font-weight: 600; }
@media print { .child-label { break-inside: avoid; } .menu-btn, .tabbar, .topbar-tools { display: none !important; } }
@media (max-width: 760px) { .label-sheet { grid-template-columns: 1fr; } }
.grid > *, .stack > * { min-width: 0; }

/* ---- Stage 8: communication, portal, website ---- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: var(--cp-radius-pill); background: var(--cp-surface-sunken); border: 1px solid var(--cp-border); }
.segment { position: relative; }
.segment input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segment span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--cp-radius-pill); font-weight: 600; font-size: 14px; color: var(--cp-text-muted); }
.segment input:checked + span { background: var(--cp-surface-solid); color: var(--cp-accent); box-shadow: var(--cp-shadow-sm); }
.segment input:focus-visible + span { outline: 3px solid var(--cp-focus); }
.message-bubble { background: var(--cp-accent-soft); color: var(--cp-text); border-radius: 18px 18px 18px 6px; padding: 12px 14px; max-width: 46ch; overflow-wrap: anywhere; }
code { font-size: 12.5px; background: var(--cp-surface-sunken); border-radius: 6px; padding: 1px 5px; }
.divider { height: 1px; background: var(--cp-border); margin: 16px 0; }
.input.input-narrow { width: 90px; }

/* ---- Public church website ---- */
.site-page { background: var(--cp-bg); }
.site-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 12px max(20px, env(safe-area-inset-left)); margin: 12px auto 0; max-width: 1120px; background: var(--cp-surface); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--cp-border); border-radius: 20px; box-shadow: var(--cp-shadow); }
.site-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--cp-text); text-decoration: none; min-width: 0; }
.site-brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-mark { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(135deg, var(--cp-purple-600), #2a1d78); color: #f3d77d; font-weight: 700; font-size: 14px; flex: none; }
.site-logo { width: 36px; height: 36px; border-radius: 12px; object-fit: cover; }
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a { padding: 8px 12px; border-radius: var(--cp-radius-pill); color: var(--cp-text-muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.site-nav a:hover, .site-nav a[aria-current] { background: var(--cp-accent-soft); color: var(--cp-accent); }
.site-main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 40px; }
.site-hero { padding: 48px 28px; border-radius: 24px; background: linear-gradient(135deg, #12204a, #2a1d78 60%, #5b3fd1); color: #fff; margin-bottom: 20px; box-shadow: var(--cp-shadow-lg); }
.site-hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 8px; letter-spacing: -0.02em; }
.site-tagline { font-size: 18px; opacity: .9; margin: 0 0 20px; max-width: 60ch; }
.site-hero .btn:not(.btn-primary) { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.site-title { font-size: clamp(24px, 4vw, 34px); margin: 8px 0 4px; letter-spacing: -0.02em; }
.site-sub { color: var(--cp-text-muted); margin: 0 0 20px; }
.site-form { max-width: 560px; padding: 24px; }
.site-footer { max-width: 1120px; margin: 0 auto; padding: 24px 20px calc(32px + env(safe-area-inset-bottom)); color: var(--cp-text-muted); font-size: 14px; display: grid; gap: 6px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.break-all { overflow-wrap: anywhere; }
.site-page .site-drawer { display: none; }
@media (max-width: 760px) {
  .site-page .site-drawer { display: flex; }
  .site-nav { display: none; }
  .site-header { margin: 8px 8px 0; padding: 8px 12px; gap: 8px; }
  .site-header .theme-toggle { margin-left: auto; }
  .site-hero { padding: 32px 20px; }
  .site-main { padding: 16px 12px 32px; }
}
.section-title { font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--cp-text-subtle); margin: 8px 0 10px; }
.report-card { display: flex; gap: 12px; align-items: flex-start; padding: 18px; text-decoration: none; color: var(--cp-text); transition: transform .15s var(--cp-ease), box-shadow .15s var(--cp-ease); }
.report-card:hover { transform: translateY(-2px); box-shadow: var(--cp-shadow-lg); }
.report-head { margin-bottom: 12px; }
.plan-price { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.invoice-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.text-right { text-align: right; }
.billing-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.report-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; }
.report-filters .select, .report-filters .input { width: auto; flex: 0 1 210px; min-width: 150px; }
.report-dates { display: contents; }
.report-dates[hidden] { display: none; }
@media (max-width: 760px) { .report-filters .select, .report-filters .input { flex: 1 1 140px; } }

/* Calendar month list: phones only (the grid shows each event as a coloured bar there). */
.cal-agenda { display: none; }
@media (max-width: 760px) {
  .cal-agenda { display: block; margin-top: 16px; padding: 14px 6px 6px; }
  .cal-agenda-title { font-size: 15px; font-weight: 700; margin: 0 10px 8px; }
  .cal-agenda-list { list-style: none; margin: 0; padding: 0; }
  .cal-agenda-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 10px; border-radius: 12px; color: var(--cp-text); text-decoration: none; }
  .cal-agenda-item:hover, .cal-agenda-item:focus-visible { background: var(--cp-surface-sunken); }
  .cal-agenda-date { display: grid; place-items: center; flex: 0 0 44px; height: 44px; border-radius: 12px; background: var(--cp-accent-soft); color: var(--cp-accent); line-height: 1.05; }
  .cal-agenda-date strong { font-size: 16px; }
  .cal-agenda-date small { font-size: 10.5px; font-weight: 600; text-transform: uppercase; }
  .cal-agenda-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .cal-agenda-name { font-weight: 600; overflow-wrap: anywhere; }
  .cal-agenda-text small { color: var(--cp-text-subtle); font-size: 13px; }
  .cal-agenda-item.cancelled .cal-agenda-name { text-decoration: line-through; opacity: .7; }
  .cal-agenda-item .icon { color: var(--cp-text-subtle); flex: none; }
  .cal-agenda-empty { margin: 4px 10px 10px; color: var(--cp-text-subtle); }
}
@media print { .cal-agenda { display: none !important; } }

/* ---------- Camera: passport photos of members and leaders ---------- */
dialog.camera-modal { width: min(460px, calc(100vw - 24px)); display: none; flex-direction: column; overflow: hidden; }
dialog.camera-modal[open] { display: flex; }
.camera-modal .modal-head h3 { min-width: 0; overflow-wrap: anywhere; }
.camera-stage {
  position: relative; margin: 14px 22px 0; aspect-ratio: 4 / 5; max-height: min(60dvh, 520px); align-self: center; width: auto;
  height: min(60dvh, 520px); max-width: calc(100% - 44px); border-radius: 20px; overflow: hidden; background: #0b1020; flex: none;
}
@supports not (aspect-ratio: 4 / 5) { .camera-stage { height: 420px; width: 336px; } }
.camera-video, .camera-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-video.is-mirrored { transform: scaleX(-1); }
.camera-video[hidden], .camera-still[hidden] { display: none; }
.camera-guide { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.camera-guide[hidden] { display: none; }
.camera-oval {
  width: 62%; height: 64%; margin-top: -6%; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 999px rgba(4, 8, 22, .38);
}
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.is-on { animation: camera-flash .35s ease-out; }
@keyframes camera-flash { from { opacity: .85; } to { opacity: 0; } }
.camera-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: #e8ecf8; font-size: 15px; line-height: 1.45; }
.camera-message[hidden] { display: none; }
.camera-message.is-loading .icon { animation: camera-pulse 1.2s ease-in-out infinite; }
@keyframes camera-pulse { 50% { opacity: .35; } }
.camera-message p { margin: 0; max-width: 30ch; }
.camera-tip { margin: 10px 22px 0; min-height: 2.6em; font-size: 14px; color: var(--cp-text-muted); text-align: center; line-height: 1.35; }
.camera-tip.is-warning { color: var(--cp-warning); font-weight: 600; }
.camera-bar { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 22px 20px; flex-wrap: wrap; }
.camera-bar[hidden], .camera-review[hidden], .camera-done[hidden] { display: none; }
.camera-bar .camera-side { flex: 1 1 0; min-width: 0; max-width: 140px; justify-content: center; }
.camera-side.is-unavailable { visibility: hidden; }
.camera-side input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.camera-side:focus-within { outline: 2px solid var(--cp-accent); outline-offset: 2px; }
.camera-shutter {
  flex: none; width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--cp-accent); background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.camera-shutter span { width: 54px; height: 54px; border-radius: 50%; background: var(--cp-accent); transition: transform .12s var(--cp-ease); }
.camera-shutter:active span { transform: scale(.88); }
.camera-shutter:disabled { opacity: .4; cursor: default; }
.camera-shutter:focus-visible { outline: 3px solid var(--cp-accent); outline-offset: 3px; }
.camera-review { padding-top: 4px; }
.camera-consent { display: flex; align-items: flex-start; margin: 4px 22px 0; padding: 12px 14px; border-radius: 14px; background: var(--cp-accent-soft); line-height: 1.4; }
.camera-consent input { flex: none; margin-top: 1px; }
.camera-done-text { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 6px 22px 0; color: var(--cp-success); font-weight: 600; text-align: center; }
.btn.is-busy { opacity: .7; pointer-events: none; }
@media (max-width: 760px) {
  dialog.camera-modal { max-height: calc(100dvh - 16px); }
  .camera-stage { height: min(52dvh, 460px); max-height: min(52dvh, 460px); margin-top: 10px; }
  .camera-tip { margin-top: 8px; font-size: 13.5px; }
  .camera-bar { padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); gap: 10px; }
}
@media (max-height: 560px) { .camera-stage { height: 46dvh; max-height: 46dvh; } }
@media (prefers-reduced-motion: reduce) { .camera-flash.is-on, .camera-message.is-loading .icon { animation: none; } }
@media print { dialog.camera-modal { display: none !important; } }

/* Profile photo with its camera button */
.photo-slot { position: relative; flex: none; }
.photo-slot .photo-slot-btn { position: absolute; right: -6px; bottom: -6px; border-radius: 50%; box-shadow: var(--cp-shadow); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Photo day */
.photo-progress { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
progress.photo-progress-bar { flex: 1 1 200px; width: auto; height: 10px; }
.photo-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; }
.photo-person { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 12px 14px; text-align: center; border-radius: 18px; }
.photo-person .member-photo, .photo-person .member-photo-placeholder { width: 96px; height: 120px; font-size: 26px; }
.photo-person-name { font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.photo-person-meta { font-size: 13px; color: var(--cp-text-muted); overflow-wrap: anywhere; }
.photo-person-roles { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.photo-person .btn { margin-top: auto; width: 100%; justify-content: center; }
.photo-person[data-photo-done] { outline: 2px solid var(--cp-success); outline-offset: -2px; }
.photo-person[data-photo-done] .photo-person-name::after { content: " ✓"; color: var(--cp-success); }
@media (max-width: 420px) {
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photo-person { padding: 12px 8px; }
  .photo-person .member-photo, .photo-person .member-photo-placeholder { width: 80px; height: 100px; font-size: 22px; }
}

/* Toasts that carry a link (e.g. an invitation link to pass on when email isn't working) */
.toast-msg { overflow-wrap: anywhere; }
.toast-link { color: inherit; text-decoration: underline; font-weight: 600; }
.toast-copy { display: flex; margin-top: 8px; }
