/* DIRA Gents — main stylesheet
 * Includes: base resets, login, m-pesa, stk push, admin/meetings/polls,
 * dashboard, photos, loans mini-cards, hamburger, responsive media queries.
 */

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
}

h1,
h2,
h3,
h4 {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  letter-spacing: -0.3px;
  margin: 0;
}

.mono, .money, .mpesa-num, .kpi {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

.app {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.container {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
}

/* ── Universal press feedback ────────────────────────────────────────── */
/* Every interactive surface gets a subtle scale-down on press. Cheap,
 * cumulative, and instantly makes the app feel "real". Using @media so
 * desktop hover states still feel right. */
button,
[role="button"],
.nav-item,
.member-card,
.list-item,
.month-tile,
.cal-cell,
.vault-action-card,
.vault-mpesa-card {
  -webkit-tap-highlight-color: transparent;
}

button:active,
[role="button"]:active {
  /* Skip if a more specific :active rule is already in effect for the
   * element — exclusion list keeps the bottom-tabs and modal interactive
   * elements from double-scaling. */
  transition: transform var(--motion-fast) var(--ease-out);
}

.btn:active,
.btn--ghost:active,
.btn--success:active,
.vault-stk-btn:active,
.vault-quickpay-btn:active,
.vault-quickpay-btn-sec:active,
.mpesa-copy-btn:active,
.toggle-btn:active,
.rsvp-btn:active,
.poll-opt-btn:active {
  transform: scale(0.97);
}

.member-card,
.list-item,
.vault-action-card,
.vault-mpesa-card {
  transition: transform var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-base) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.member-card:hover,
.list-item:hover,
.vault-action-card:hover,
.vault-mpesa-card:hover {
  transform: translateY(-2px);
}
.member-card:active,
.list-item:active,
.vault-action-card:active,
.vault-mpesa-card:active {
  transform: translateY(0) scale(0.99);
}

/* Smooth scroll anywhere we're navigating within the page. */
html { scroll-behavior: smooth; }

/* ---------- Component primitives ---------- */

.surface {
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.btn {
  border: 1px solid rgb(from var(--accent) r g b / 0.55);
  background: linear-gradient(180deg, rgb(from var(--accent) r g b / 0.92), rgb(from var(--accent) r g b / 0.72));
  color: var(--text);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-weight: 700;
  cursor: pointer;
  transition: transform 90ms ease, filter 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 14px 30px rgb(from var(--accent) r g b / 0.18);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }

.btn--ghost {
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-on-dark-hi);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-weight: 700;
  cursor: pointer;
}
body.theme-light .btn--ghost {
  background: var(--surface);
  color: var(--text);
}

.btn--success {
  border: none;
  background: linear-gradient(135deg, var(--stk-green) 0%, var(--stk-green-dark) 100%);
  color: #fff;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn--success:hover { opacity: 0.88; }
.btn--success:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--danger {
  border: 1px solid rgba(220,60,60,0.4);
  background: transparent;
  color: rgba(220,60,60,0.75);
  padding: var(--sp-1) var(--sp-3);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.btn--danger:hover {
  background: rgba(220,60,60,0.12);
  color: #ff6b6b;
}

.btn--sm {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
}

.input {
  width: 100%;
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder {
  color: var(--muted);
}
.input:focus {
  border-color: rgb(from var(--accent) r g b / 0.8);
  box-shadow: 0 0 0 4px rgb(from var(--accent) r g b / 0.15);
}

.select {
  padding: var(--sp-3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-on-dark-hi);
  font-weight: 700;
  outline: none;
  min-width: 220px;
}

/* ---------- Login screen ---------- */
.login {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 0 40px;
  overflow: hidden;
}

.login::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 1px 1px, rgb(from var(--accent) r g b / 0.22) 1px, rgba(0, 0, 0, 0) 1.6px)
      0 0 / 22px 22px,
    radial-gradient(1200px 700px at 20% 0%, rgb(from var(--accent) r g b / 0.12), rgba(0, 0, 0, 0) 60%),
    radial-gradient(900px 600px at 80% 90%, rgb(from var(--accent) r g b / 0.08), rgba(0, 0, 0, 0) 65%);
  pointer-events: none;
}

.login-grid {
  position: relative;
  width: min(460px, calc(100% - 40px));
  display: grid;
  gap: 14px;
  z-index: 1;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.login-card {
  padding: 26px 22px 22px;
}

.brand {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  margin-bottom: 18px;
}

.brand-logo {
  width: min(320px, 100%);
  display: grid;
  justify-items: center;
}

.brand-logo svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 35px rgba(0, 0, 0, 0.18));
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  border-color: rgb(from var(--accent) r g b / 0.8);
  box-shadow: 0 0 0 4px rgb(from var(--accent) r g b / 0.15);
}

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.btn {
  border: 1px solid rgb(from var(--accent) r g b / 0.55);
  background: linear-gradient(180deg, rgb(from var(--accent) r g b / 0.92), rgb(from var(--accent) r g b / 0.72));
  color: var(--text);
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 90ms ease, filter 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 14px 30px rgb(from var(--accent) r g b / 0.18);
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(1px);
}

.fineprint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.demo-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-hover);
}

.demo-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.demo-grid {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pill strong {
  font-weight: 700;
}

.pill code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--text-on-dark);
  background: rgb(from var(--accent) r g b / 0.12);
  border: 1px solid rgb(from var(--accent) r g b / 0.22);
  padding: 2px 7px;
  border-radius: 999px;
}

/* ---------- M-Pesa payment card ---------- */
.mpesa-wrap {
  border-color: var(--mpesa-border);
  background: linear-gradient(155deg, var(--mpesa-bg-soft) 0%, var(--card) 42%, var(--card) 100%);
  box-shadow: var(--shadow), 0 0 0 1px var(--mpesa-bg-soft) inset;
}

.mpesa-wrap.panel {
  height: auto;
  min-height: 0;
  overflow: visible;
}

.mpesa-wrap--inline {
  margin-top: 18px;
}

.mpesa-head-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mpesa-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--mpesa-bg);
  border: 1px solid var(--mpesa-border);
  color: var(--mpesa);
}

.mpesa-icon svg {
  display: block;
}

.mpesa-badge {
  border-color: var(--mpesa-border-hi);
  background: var(--mpesa-bg);
  color: rgba(187, 247, 208, 0.95);
  white-space: nowrap;
}

.mpesa-body {
  display: grid;
  gap: 14px;
}

.mpesa-pools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 640px) {
  .mpesa-pools {
    grid-template-columns: 1fr;
  }
}

.mpesa-pool {
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.mpesa-pool.fin {
  background: var(--mpesa-bg-soft);
  border: 1px solid var(--mpesa-border);
}

.mpesa-pool.msa {
  background: var(--accent-bg2);
  border: 1px solid var(--accent-bg);
}

body.theme-light .mpesa-pool.fin {
  background: var(--mpesa-bg-soft);
}

body.theme-light .mpesa-pool.msa {
  background: var(--accent-bg2);
}

.mpesa-pool-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.mpesa-dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.mpesa-dl-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 10px;
  align-items: center;
}

.mpesa-dl-row dt {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.mpesa-dl-row dd {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.mpesa-num {
  font-size: 17px;
  font-weight: 800;
  font-family: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text);
}

.mpesa-pool.fin .mpesa-num {
  color: var(--mpesa);
}

.mpesa-pool.msa .mpesa-num {
  color: var(--accent);
}

.mpesa-clip {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 120ms, border-color 120ms, background 120ms;
}

.mpesa-clip:hover {
  color: var(--text);
  border-color: var(--border-text-hi);
}

.mpesa-clip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--mpesa-ring);
  border-color: var(--mpesa-border-hi);
}

body.theme-light .mpesa-clip {
  background: rgba(255, 255, 255, 0.7);
}

.mpesa-pool-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.mpesa-copy-btn {
  flex: 1;
  border: 1px solid var(--mpesa-border-hi);
  background: var(--mpesa-bg);
  color: var(--mpesa-text);
  font-size: 11px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms, filter 120ms;
}

.mpesa-pool.msa .mpesa-copy-btn {
  border-color: var(--accent-bg);
  background: var(--accent-bg);
  color: rgba(147, 180, 255, 0.98);
}

body.theme-light .mpesa-pool.msa .mpesa-copy-btn {
  color: #1e40af;
}

.mpesa-copy-btn:active {
  filter: brightness(1.08);
}

.mpesa-copy-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--mpesa-ring);
}

.mpesa-pool.msa .mpesa-copy-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.mpesa-dial-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, border-color 120ms;
  white-space: nowrap;
}

.mpesa-dial-btn:hover {
  color: var(--text);
  border-color: var(--border-text-hi);
}

.mpesa-dial-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(from var(--accent) r g b / 0.2);
}

.mpesa-steps {
  list-style: none;
  margin: 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 12px;
  counter-reset: mpesa-step;
}

.mpesa-steps li {
  counter-increment: mpesa-step;
  position: relative;
  padding: 0 0 0 26px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

.mpesa-steps li::before {
  content: counter(mpesa-step);
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  background: var(--mpesa-bg-strong);
  border: 1px solid var(--mpesa-border);
  color: var(--mpesa);
}

.mpesa-steps strong {
  color: var(--text);
  font-weight: 700;
}

.mpesa-footnote {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- STK Push button ---------- */
.mpesa-stk-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 14px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--stk-green) 0%, var(--stk-green-dark) 100%);
  color: #fff;
  transition: opacity 0.15s, transform 0.1s;
}
.mpesa-stk-btn:hover { opacity: 0.88; }
.mpesa-stk-btn:active { transform: scale(0.97); }
.mpesa-pool.msa .mpesa-stk-btn {
  background: linear-gradient(135deg, var(--stk-blue) 0%, var(--stk-blue-dark) 100%);
}

/* ---------- STK Push modal ---------- */
.stk-modal-card { width: min(460px, 100%); }

.stk-modal-head-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.stk-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--stk-green-bg);
  color: var(--stk-green);
  flex-shrink: 0;
}
.stk-pool-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--stk-green-bg);
  color: var(--stk-green);
  letter-spacing: 0.03em;
}
.stk-pool-badge.msa {
  background: var(--stk-blue-bg);
  color: var(--stk-blue);
}
.stk-hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.stk-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.stk-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stk-field input,
.stk-field select {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: inherit;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.stk-field input:focus,
.stk-field select:focus { border-color: var(--stk-green); }
.stk-field-hint {
  font-size: 11px;
  color: var(--muted);
}
.stk-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stk-paybill-preview {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  line-height: 1.6;
  display: none;
}
.stk-paybill-preview.visible { display: block; }
.stk-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--stk-green) 0%, var(--stk-green-dark) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s;
}
.stk-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.stk-submit-btn:not(:disabled):hover { opacity: 0.88; }

/* pending / success / error shared */
.stk-state-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 8px 8px;
  text-align: center;
}
.stk-state-area.hidden { display: none; }
.stk-state-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}
.stk-state-sub, .stk-timer-msg {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
/* spinner */
.stk-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--stk-green-ring);
  border-top-color: var(--stk-green);
  animation: stk-spin 0.8s linear infinite;
}
@keyframes stk-spin { to { transform: rotate(360deg); } }
/* success */
.stk-success-icon { color: var(--stk-green); }
/* error */
.stk-error-icon { color: var(--danger); }
.stk-cancel-poll-btn,
.stk-done-btn,
.stk-retry-btn {
  margin-top: 6px;
  padding: 8px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.stk-retry-btn { border-color: var(--danger); color: var(--danger); }

/* ---------- Phase 2: admin, meetings, polls ---------- */
.app-toast {
  position: fixed;
  /* Desktop default: top-right slide-in */
  top: 24px;
  right: 24px;
  bottom: auto;
  left: auto;
  transform: translateX(20px);
  color: #fff;
  font-size: var(--text-md);
  font-weight: 600;
  padding: 12px 18px 12px 16px;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35),
              0 0 0 1px var(--glass-stroke);
  background: var(--brand-grad);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-base) var(--ease-out),
              transform var(--motion-base) var(--ease-spring);
  z-index: 10000;
  max-width: min(92vw, 420px);
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-toast::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  flex-shrink: 0;
}

.app-toast--show {
  opacity: 1;
  transform: translateX(0);
}

.app-toast--ok {
  /* Pull from --green-grad so the success toast follows the theme
   * (deeper green on light backgrounds, mid-green on dark). */
  background: var(--green-grad);
}
.app-toast--err {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}

/* Mobile: slide up from the bottom centre, above the bottom-tab bar */
@media (max-width: 767px) {
  .app-toast {
    top: auto;
    right: auto;
    left: 50%;
    bottom: calc(86px + env(safe-area-inset-bottom));
    transform: translate(-50%, 14px);
  }
  .app-toast--show {
    transform: translate(-50%, 0);
  }
}

.form-stack {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.form-stack label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.form-stack .input,
.form-stack .select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-on-dark-hi);
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
}

.meeting-live-card {
  padding: 16px 16px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 12px;
}

.meeting-live-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
}

.meeting-live-title {
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.meeting-live-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.rsvp-counts {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.rsvp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rsvp-btn {
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.rsvp-btn:hover {
  border-color: rgb(from var(--accent) r g b / 0.45);
}

.rsvp-btn.is-on {
  border-color: var(--rsvp-yes);
  background: var(--rsvp-yes-bg);
  color: var(--rsvp-yes-text);
}

.rsvp-btn.rsvp-no.is-on {
  border-color: var(--rsvp-no);
  background: var(--rsvp-no-bg);
  color: var(--rsvp-no-text);
}

.rsvp-btn.rsvp-maybe.is-on {
  border-color: var(--rsvp-maybe);
  background: var(--rsvp-maybe-bg);
  color: var(--rsvp-maybe-text);
}

.yes-names {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.yes-names b {
  color: var(--text);
}

.poll-card {
  padding: 16px 16px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 12px;
}

.poll-q {
  font-weight: 900;
  font-size: 15px;
  line-height: 1.35;
}

.poll-status {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.poll-options-stack {
  display: grid;
  gap: 8px;
}

.poll-opt-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.poll-opt-btn:hover {
  border-color: rgb(from var(--accent) r g b / 0.45);
}

.poll-result-row {
  display: grid;
  gap: 4px;
}

.poll-result-bar-wrap {
  height: 10px;
  border-radius: 999px;
  background: rgb(from var(--accent) r g b / 0.1);
  overflow: hidden;
  border: 1px solid var(--border);
}

.poll-result-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(from var(--accent) r g b / 0.85), rgb(from var(--accent) r g b / 0.45));
  transition: width 400ms ease;
}

.poll-result-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.admin-stack {
  display: grid;
  gap: 14px;
}

.admin-stack .collapse {
  margin-top: 0;
}


/* ---------- Dashboard ---------- */
.dashboard {
  /* The sidebar width lives in a CSS variable so the grid + the sidebar
   * itself can animate together. Toggling .sidebar-expanded just changes
   * the variable and everything else follows. */
  --sidebar-w: 72px;
  --sidebar-pad-x: 10px;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  transition: grid-template-columns var(--motion-base) var(--ease-out);
}
.dashboard.sidebar-expanded {
  --sidebar-w: 232px;
  --sidebar-pad-x: 14px;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 18px var(--sidebar-pad-x);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  width: var(--sidebar-w);
  flex-shrink: 0;
  transition: width var(--motion-base) var(--ease-out),
              padding var(--motion-base) var(--ease-out);
}

/* ── Brand mark — icon + wordmark that fades in when expanded ───────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--sp-5);
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--accent-bg);
  border: 1px solid var(--accent-bg);
  align-self: center;
  width: auto;
  transition: width var(--motion-base) var(--ease-out),
              padding var(--motion-base) var(--ease-out);
}
.sidebar-brand-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.sidebar-brand-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-6px);
  width: 0;
  overflow: hidden;
  transition: opacity var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out),
              width var(--motion-base) var(--ease-out);
}
.dashboard.sidebar-expanded .sidebar-brand {
  align-self: stretch;
  padding: 8px 12px;
}
.dashboard.sidebar-expanded .sidebar-brand-name {
  opacity: 1;
  transform: translateX(0);
  width: auto;
  transition-delay: 80ms;
}

.sidebar-nav {
  display: grid;
  gap: var(--sp-1);
  flex: 1;
  align-content: start;
  width: 100%;
  justify-items: center;
}
.dashboard.sidebar-expanded .sidebar-nav {
  justify-items: stretch;
}

/* ── Nav items: pill row when expanded, centred icon when collapsed ── */
/* Force the sidebar's nav-icons to use flexbox so the label can collapse
 * to zero width without offsetting the icon. (Higher specificity than
 * the base .vault-nav-icon rule in vault.css.) */
.sidebar .vault-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.sidebar-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.sidebar-label {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  max-width: 0;
  transform: translateX(-6px);
  transition: opacity var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out),
              max-width var(--motion-base) var(--ease-out);
}
.dashboard.sidebar-expanded .sidebar-label {
  opacity: 1;
  transform: translateX(0);
  max-width: 160px;
  transition-delay: 80ms;
}

/* Expanded: icon + label sits on the left of a full-width pill. */
.dashboard.sidebar-expanded .sidebar .vault-nav-icon {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  justify-content: flex-start;
  padding: 0 12px;
  gap: 12px;
}
/* The little dot badge moves to the right edge in expanded mode. */
.dashboard.sidebar-expanded .vault-nav-dot {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

/* ── Footer: toggle, sign-out, avatar ────────────────────────────────── */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-soft);
  width: 100%;
}
/* When expanded, the footer becomes a horizontal row */
.dashboard.sidebar-expanded .sidebar-footer {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

/* Collapse / expand toggle (chevron) */
.sidebar-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out),
              transform var(--motion-base) var(--ease-out);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-bg2);
}
.sidebar-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.dashboard.sidebar-expanded .sidebar-toggle {
  transform: rotate(180deg);
}
/* Hide the toggle below the desktop breakpoint — sidebar collapses on its own */
@media (max-width: 980px) {
  .sidebar-toggle { display: none; }
}

.sidebar-signout {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              width var(--motion-base) var(--ease-out),
              padding var(--motion-base) var(--ease-out),
              gap var(--motion-base) var(--ease-out);
}
.sidebar-signout:hover {
  color: var(--text);
  border-color: var(--accent);
}
.sidebar-signout:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg);
}
/* Expanded: sign-out becomes a wide pill with icon + label */
.dashboard.sidebar-expanded .sidebar-signout {
  width: auto;
  flex: 1;
  height: 38px;
  padding: 0 14px;
  gap: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
  border: 2px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,102,255,0.25);
}

.nav-dot-accent { background: var(--accent-hi); display: none; }
/* Voting nav dot — orange so it lines up with the orange "this matters /
 * cast a vote" role used elsewhere in the dashboard. */
.nav-dot-orange { background: var(--orange-500); }

.login-error {
  color: var(--danger);
  font-size: var(--text-base);
  text-align: center;
  min-height: 18px;
}

.vault-hero-label {
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.vault-hero-kpi {
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--text-xl);
  font-weight: 500;
  margin-top: 3px;
  letter-spacing: -0.3px;
}

.vault-hero-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
}

.side-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgb(from var(--accent) r g b / 0.12);
  border: 1px solid rgb(from var(--accent) r g b / 0.28);
}

.side-logo svg {
  width: 34px;
  height: 34px;
  display: block;
}

.side-meta {
  display: grid;
  gap: 1px;
}

.side-meta .name {
  font-weight: 800;
  font-size: 13px;
}
.side-meta .sub {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  flex: 1;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  padding-right: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: var(--text-on-dark);
  background: transparent;
  cursor: pointer;
}

.nav-item.active {
  background: rgb(from var(--accent) r g b / 0.12);
  border-color: rgb(from var(--accent) r g b / 0.32);
}

.nav-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgb(from var(--accent) r g b / 0.18);
  border-color: rgb(from var(--accent) r g b / 0.38);
}

.badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-hi);
}

.side-footer {
  margin-top: auto;
  padding-top: 14px;
}

.ghost-btn {
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-on-dark-hi);
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: rgb(from var(--accent) r g b / 0.38);
}

.content {
  padding: 22px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 16px;
}

.greeting {
  display: grid;
  gap: 4px;
}

.greeting h2 {
  font-size: 22px;
}

.greeting p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-on-dark-hi);
  font-size: 12px;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-on-dark-hi);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: rgb(from var(--accent) r g b / 0.38);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  padding: 16px 16px;
  border-radius: var(--radius-lg);
  background: rgb(from var(--accent) r g b / 0.06);
  border: 1px solid var(--border);
}

.stat-card.emphasis {
  background: rgb(from var(--accent) r g b / 0.1);
  border-color: rgb(from var(--accent) r g b / 0.28);
}

.stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.stat-title {
  color: var(--text-on-dark);
  font-weight: 800;
  font-size: 13px;
}

.stat-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.kpi {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.stat-card.emphasis .kpi {
  font-size: 26px;
}

.delta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.delta b {
  color: var(--text-on-dark-hi);
}

.accent-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgb(from var(--accent) r g b / 0.92);
  box-shadow: 0 0 0 5px rgb(from var(--accent) r g b / 0.18);
  margin-top: 3px;
}

.span-2 {
  grid-column: span 2;
}

.attendance-strip {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.check {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  flex: 0 0 auto;
}

.check.present {
  background: rgb(from var(--accent) r g b / 0.22);
  border-color: rgb(from var(--accent) r g b / 0.45);
}

.check.apology {
  background: var(--attend-apology);
  border-color: var(--attend-apology-border);
}

.check.missed {
  background: var(--attend-missed);
  border-color: var(--attend-missed-border);
  opacity: 0.85;
}

.legend {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}

.legend .item {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.legend .swatch.present {
  background: rgb(from var(--accent) r g b / 0.22);
  border-color: rgb(from var(--accent) r g b / 0.45);
}
.legend .swatch.apology {
  background: var(--attend-apology);
  border-color: var(--attend-apology-border);
}
.legend .swatch.missed {
  background: var(--attend-missed);
  border-color: var(--attend-missed-border);
}

.main-grid {
  grid-template-columns: 1.35fr 0.85fr;
  align-items: start;
}

.tabs {
  display: grid;
  gap: 14px;
}

.tab-panel.hidden {
  display: none !important;
}

.two-col {
  grid-template-columns: 1.2fr 0.8fr;
  align-items: start;
}

.dash {
  display: grid;
  /* No gap: each .dash-page provides its own vertical padding so the
   * dashboard reads as a sequence of distinct "page" sections. The legacy
   * .dash-row.row-N classes (used outside the new markup) still get their
   * own spacing via the rules below. */
  gap: 0;
}

.dash-row {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.dash-row > .card {
  height: 100%;
  overflow: hidden;
  position: relative;
}

.dash-row.row-1 {
  grid-template-columns: 1.6fr 1fr;
  grid-auto-rows: minmax(210px, auto);
}

.dash-row.row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(200px, auto);
}

.dash-row.row-3 {
  grid-template-columns: 1.35fr 0.85fr;
  grid-auto-rows: minmax(320px, auto);
}

.dash-row.row-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(240px, auto);
}

.dash-row.row-5 {
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(190px, auto);
}

.dash-row.row-loans {
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(150px, auto);
}

.dash-row.row-mpesa {
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
}

.dash-row.row-mpesa > .card {
  height: auto;
  min-height: 0;
  overflow: visible;
}

/* ─── Dashboard page-style sections ─────────────────────────────────────
 * Each major dashboard section is wrapped in a .dash-page so it reads
 * like its own focused "page" while you scroll. Generous vertical padding
 * + a hairline divider create breathing room; opacity/translate transition
 * gives a subtle fade-up as each page enters the viewport (driven by an
 * IntersectionObserver in dashboard.js).
 */
.dash-page {
  /* Vertical rhythm: clamp() makes desktop feel airy (96px on huge
   * monitors) while keeping mobile compact (48px). 7vw = "scales with
   * how wide the viewport is, but never goes outside the clamp range." */
  padding: clamp(48px, 7vw, 96px) 0;
  border-top: 1px solid var(--border-soft);
  position: relative;
  /* Initial state for the scroll-fade. JS adds .in-view to flip it. */
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms var(--ease-out),
              transform 600ms var(--ease-out);
}
.dash-page.in-view {
  opacity: 1;
  transform: none;
}
/* The first page sits flush at the top of the panel — no leading
 * padding/border, since there's nothing above it to separate from. */
.dash-page:first-child {
  padding-top: 0;
  border-top: 0;
}

/* ── Page header: eyebrow / title / subtitle ───────────────────────── */
.dash-page-header {
  margin-bottom: clamp(20px, 3vw, 32px);
}
.dash-page-eyebrow {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent-hi);
  font-weight: 700;
}
/* 24px gradient tick before each eyebrow — tiny but premium. */
.dash-page-eyebrow::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--brand-grad);
  border-radius: 999px;
  margin-right: 10px;
  vertical-align: middle;
}
.dash-page-title {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.15;
  margin: 8px 0 4px;
}
.dash-page-subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
}

/* ── Two-column rows used inside specific .dash-pages ──────────────── */
/* "Coming up" page: Next Meeting + Upcoming Events side-by-side. */
.dash-row-upcoming {
  display: grid;
  gap: 14px;
  align-items: stretch;
  grid-template-columns: 1fr 1fr;
}
.dash-row-upcoming > .card {
  height: 100%;
  overflow: hidden;
  position: relative;
}
/* "Daily inspiration" page: Daily Quote + Photo Memories side-by-side. */
.dash-row-inspiration {
  display: grid;
  gap: 14px;
  align-items: stretch;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(240px, auto);
}
.dash-row-inspiration > .card {
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* On tablets and below, the side-by-side rows stack vertically so each
 * card has full width to breathe. */
@media (max-width: 920px) {
  .dash-row-upcoming,
  .dash-row-inspiration {
    grid-template-columns: 1fr;
  }
}

/* Shrink the section padding slightly on phones — keeps the rhythm
 * but stops sections from feeling like a marketing landing page. */
@media (max-width: 520px) {
  .dash-page {
    padding: 40px 0;
  }
  .dash-page-header {
    margin-bottom: 18px;
  }
}

/* Respect users who've asked the OS to reduce motion — fade only,
 * no translate. The .in-view class still flips opacity to 1. */
@media (prefers-reduced-motion: reduce) {
  .dash-page {
    transform: none;
    transition: opacity 300ms linear;
  }
}

/* ─── Dashboard page-indicator rail ─────────────────────────────────────
 * A small column of dots fixed on the right edge of the viewport. Each
 * dot represents one .dash-page; the active dot fills with the brand
 * gradient. Click a dot to smooth-scroll to that page.
 *
 * Hidden below 1100px viewport width — at narrower sizes the dashboard
 * sidebar+content layout already takes the right edge, and dots feel
 * cramped on tablets/phones.
 */
.dash-rail {
  /* Built dynamically by JS and appended inside the dashboard panel,
   * so it disappears automatically when the user is on a different tab
   * (.tab-panel.hidden { display: none } cascades to children). */
  position: fixed;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
  padding: 10px 8px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-stroke);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
@media (min-width: 1100px) {
  .dash-rail {
    display: flex;
  }
}

.dash-rail-dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgb(from var(--accent) r g b / 0.18);
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: background var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
}
.dash-rail-dot:hover {
  background: rgb(from var(--accent) r g b / 0.4);
  transform: scale(1.15);
}
.dash-rail-dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.dash-rail-dot.is-active {
  background: var(--brand-grad);
  transform: scale(1.3);
  box-shadow: 0 0 12px rgb(from var(--accent) r g b / 0.5);
}

/* Tooltip beside each dot (the page title), shown on hover/focus. */
.dash-rail-dot::after {
  content: attr(data-label);
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out);
}
.dash-rail-dot:hover::after,
.dash-rail-dot:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-body {
  flex: 1;
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.quote-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgb(from var(--accent) r g b / 0.12), var(--surface-hi));
}

.quote-mark {
  position: absolute;
  right: 14px;
  top: 8px;
  font-family: "Space Grotesk", "Inter", system-ui;
  font-weight: 900;
  font-size: 92px;
  line-height: 1;
  color: rgb(from var(--accent) r g b / 0.18);
  pointer-events: none;
}

.quote-text {
  font-family: "Space Grotesk", "Inter", system-ui;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 18px;
  line-height: 1.35;
  margin: 0;
}

.quote-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.quote-fade {
  transition: opacity 350ms ease, transform 350ms ease;
  will-change: opacity, transform;
}

.quote-fade.out {
  opacity: 0;
  transform: translateY(4px);
}

.events-grid {
  display: grid;
  gap: 10px;
}

.events-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.event {
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
}

.empty {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.ok {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--mpesa-border-hi);
  background: var(--mpesa-bg);
  color: var(--text-on-dark-hi);
}

.ok svg {
  width: 22px;
  height: 22px;
  display: block;
}

@media (max-width: 980px) {
  .dash-row.row-1,
  .dash-row.row-2,
  .dash-row.row-3,
  .dash-row.row-4 {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  .events-row {
    grid-template-columns: 1fr;
  }
}

.date-badge {
  border-radius: 16px;
  border: 1px solid rgb(from var(--accent) r g b / 0.32);
  background: rgb(from var(--accent) r g b / 0.12);
  padding: 10px 8px;
  text-align: center;
  display: grid;
  gap: 2px;
}

.date-badge .d {
  font-family: "Space Grotesk", "Inter", system-ui;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.date-badge .m {
  font-size: 11px;
  color: var(--text-on-dark-85);
}

.event .title {
  font-weight: 900;
  font-size: 13px;
}

.event .desc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.memories {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 20% 0%, rgb(from var(--accent) r g b / 0.14), rgba(0, 0, 0, 0) 62%),
    radial-gradient(820px 520px at 85% 90%, rgb(from var(--accent) r g b / 0.1), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, var(--surface-hi), var(--surface));
  height: 100%;
}

.slides {
  position: absolute;
  inset: 0;
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 700ms ease;
  background:
    radial-gradient(900px 460px at 20% 0%, rgb(from var(--accent) r g b / 0.18), rgba(0, 0, 0, 0) 60%),
    radial-gradient(800px 480px at 85% 90%, rgb(from var(--accent) r g b / 0.12), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, var(--surface-hi), var(--surface));
}

.slide:nth-child(2) {
  background:
    radial-gradient(900px 460px at 80% 15%, rgb(from var(--accent) r g b / 0.18), rgba(0, 0, 0, 0) 60%),
    radial-gradient(800px 480px at 15% 90%, rgb(from var(--accent) r g b / 0.12), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, var(--surface-hi), var(--surface));
}

.slide:nth-child(3) {
  background:
    radial-gradient(1000px 520px at 50% 0%, rgb(from var(--accent) r g b / 0.18), rgba(0, 0, 0, 0) 62%),
    radial-gradient(820px 520px at 50% 100%, rgb(from var(--accent) r g b / 0.1), rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, var(--surface-hi), var(--surface));
}

/* Photo slides loaded from Supabase Storage */
.slide.photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.slide.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7,9,26,0.25) 0%, rgba(7,9,26,0.55) 100%);
}

.slide-caption {
  position: absolute;
  bottom: 48px;
  left: 16px;
  right: 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  z-index: 2;
  pointer-events: none;
}

.slide.active {
  opacity: 1;
}

.memories-overlay {
  position: absolute;
  inset: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.memories-center {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  padding: 8px 0;
}

.mem-emoji {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.25));
  opacity: 0.95;
}

.mem-center-title {
  font-family: "Space Grotesk", "Inter", system-ui;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 16px;
}

.mem-center-sub {
  color: var(--muted);
  font-size: 12px;
}

.memories-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.camera {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgb(from var(--accent) r g b / 0.14);
  border: 1px solid rgb(from var(--accent) r g b / 0.28);
  color: var(--text-on-dark-hi);
}

.memories-copy {
  display: grid;
  gap: 2px;
}

.memories-copy .h {
  font-weight: 900;
  font-size: 13px;
}

.memories-copy .p {
  color: var(--muted);
  font-size: 12px;
}

.dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  pointer-events: auto;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--text-on-dark-lo);
  cursor: pointer;
}

.dot.active {
  background: rgb(from var(--accent) r g b / 0.65);
  border-color: rgb(from var(--accent) r g b / 0.6);
}

.pool-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--card-hi);
}

.pool-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 120ms ease;
}

.pool-tab.active {
  background: var(--accent-bg);
  border-color: var(--accent-bg);
  color: var(--text);
}

@media (max-width: 980px) {
  .memories {
    min-height: 240px;
  }
}

.stack {
  display: grid;
  gap: 14px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.list-item .left {
  display: grid;
  gap: 2px;
  /* Without min-width:0, grid items don't shrink past their intrinsic
   * content size — a long member name like "#1 Some-Long-Member-Name"
   * would force the row wider than the viewport on phones. */
  min-width: 0;
}
.list-item .left .title {
  /* Long titles wrap to a second line and ellipsis on the third — keeps
   * leaderboard rows compact on phones without chopping names mid-word. */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.list-item .title {
  font-weight: 900;
  font-size: 13px;
}

.list-item .sub {
  font-size: 12px;
  color: var(--muted);
}

.list-item .right {
  text-align: right;
  display: grid;
  gap: 2px;
  flex: 0 0 auto;
}

.money {
  font-weight: 900;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.rules {
  display: grid;
  gap: 10px;
}

.rule {
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgb(from var(--accent) r g b / 0.06);
  display: grid;
  gap: 4px;
}

.rule .k {
  color: var(--muted);
  font-size: 12px;
}

.rule .v {
  font-weight: 900;
  font-size: 13px;
}

.table-scroll {
  overflow: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 10px;
}

.select {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-on-dark-hi);
  font-weight: 700;
  outline: none;
  min-width: 220px;
}

.toggle-btn {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgb(from var(--accent) r g b / 0.45);
  background: rgb(from var(--accent) r g b / 0.12);
  color: var(--text-on-dark-hi);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.summary {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.summary-header,
.summary-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.8fr 0.8fr 1.1fr;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
}

.summary-header {
  background: var(--surface-hi);
  font-size: 12px;
  color: var(--text-on-dark);
  position: sticky;
  top: 0;
  z-index: 1;
}

.summary-row .name {
  font-weight: 900;
}

.summary-row .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.progress-mini {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-hover);
}

.progress-mini .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgb(from var(--accent) r g b / 0.9), rgb(from var(--accent) r g b / 0.45));
}

.finance-table {
  min-width: 1160px;
}

.table-row.finance {
  grid-template-columns: 220px repeat(12, 92px) 110px;
  align-items: center;
}

.finance-table.msa {
  min-width: 920px;
}

.table-row.msa {
  grid-template-columns: 220px repeat(8, 92px) 110px;
  align-items: center;
}

.table-row.finance.header,
.table-row.msa.header {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-row.finance > :first-child,
.table-row.msa > :first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
}

.badge.good {
  color: var(--text-on-dark-hi);
  border-color: var(--mpesa-border-hi);
  background: var(--mpesa-bg);
}

.meet-table {
  min-width: 980px;
}

.table-row.meet {
  grid-template-columns: 220px repeat(7, 64px) 90px 90px 110px;
  align-items: center;
}

.table-row.meet.header {
  position: sticky;
  top: 0;
  z-index: 1;
}

.mark {
  font-weight: 900;
  display: inline-flex;
  justify-content: center;
  width: 100%;
}

.mark.ok {
  color: var(--mpesa);
}

.mark.no {
  color: var(--text-on-dark-lo);
}

.loan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.collapse {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  overflow: hidden;
}

.collapse .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--surface-hi);
  border-bottom: 1px solid var(--border);
}

.collapse .chev {
  font-weight: 900;
  color: var(--muted);
}

.collapse .body {
  padding: 14px;
}

.loan-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 920px) {
  .loan-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Vault-style KPI mini-card (used in Loans summary) */
.vault-kpi-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--card-hi);
  border: 1px solid var(--border-soft);
}
.vault-kpi-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 6px;
}
.vault-kpi-value {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}
.vault-kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 920px) {
  .lib-grid {
    grid-template-columns: 1fr;
  }
}

.lib-card {
  padding: 14px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 6px;
  text-decoration: none;
}

.lib-card .t {
  font-weight: 900;
  font-size: 13px;
}

.lib-card .d {
  color: var(--muted);
  font-size: 12px;
}

.lib-card:hover {
  border-color: rgb(from var(--accent) r g b / 0.38);
}

.lib-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 0 14px 0;
}

.lib-pill {
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.lib-pill:hover {
  border-color: rgb(from var(--accent) r g b / 0.4);
  color: var(--text);
}

.lib-pill.active {
  background: rgb(from var(--accent) r g b / 0.15);
  border-color: rgb(from var(--accent) r g b / 0.5);
  color: var(--text);
}

.lib-card-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(from var(--accent) r g b / 0.7);
  margin-bottom: 2px;
}

.lib-card-del {
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid rgba(220,60,60,0.4);
  background: transparent;
  color: rgba(220,60,60,0.75);
  font-size: 11px;
  cursor: pointer;
  display: none;
}

.lib-card-del:hover {
  background: rgba(220,60,60,0.12);
  color: #ff6b6b;
}

body.is-admin .lib-card-del {
  display: inline-block;
}

.calendar {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-hi);
}

.cal-title {
  font-weight: 900;
  font-family: "Space Grotesk", "Inter", system-ui;
  letter-spacing: -0.02em;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-dow {
  padding: 10px 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.cal-cell {
  min-height: 74px;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.cal-cell:nth-child(7n) {
  border-right: 0;
}

.cal-day {
  font-weight: 900;
  font-size: 12px;
  color: var(--text-on-dark);
}

.cal-cell.muted .cal-day {
  color: var(--muted);
}

.cal-pill {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgb(from var(--accent) r g b / 0.35);
  background: rgb(from var(--accent) r g b / 0.12);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.cal-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgb(from var(--accent) r g b / 0.9);
  border: 0;
}

.cal-pill.meeting {
  border-color: rgb(from var(--accent) r g b / 0.35);
  background: rgb(from var(--accent) r g b / 0.12);
}

.cal-pill.bday {
  border-color: var(--cal-bday-border);
  background: var(--cal-bday-bg);
}

.cal-pill.bday .dot {
  background: var(--cal-bday-dot);
}

.cal-pill.grad {
  border-color: var(--cal-grad-border);
  background: var(--cal-grad-bg);
}

.cal-pill.grad .dot {
  background: var(--cal-grad-dot);
}

.popover {
  position: absolute;
  z-index: 50;
  min-width: 240px;
  max-width: 320px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 12px 12px;
}

body.theme-light .popover {
  background: rgba(255, 255, 255, 0.98);
}

.popover .t {
  font-weight: 900;
  font-size: 13px;
}

.popover .m {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.popover .x {
  margin-left: auto;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  border-radius: 12px;
  padding: 6px 8px;
  cursor: pointer;
}

.popover .top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.accordion {
  display: grid;
  gap: 12px;
}

.acc-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  overflow: hidden;
}

.acc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--surface-hi);
}

.acc-head .title {
  font-weight: 900;
}

.acc-body {
  padding: 14px;
  color: var(--text-on-dark);
  line-height: 1.5;
  font-size: 13px;
}

.acc-body.hidden {
  display: none;
}

.member-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 980px) {
  .member-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .member-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Member cards (premium redesign) ───────────────────────────────────
 * Each card is a glass-y tile with:
 *   • a subtle blue accent strip at the top (gold for top-1, brand for leads)
 *   • a luminous avatar with inner rim + soft drop shadow
 *   • Space-Grotesk numerics, all-caps labels for that fintech feel
 *   • glass-tinted KPI tiles with hover lift
 * Click + keyboard behaviour are unchanged — purely cosmetic.
 */
.member-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-hi) 100%);
  padding: 16px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  overflow: hidden;
  isolation: isolate;
}

/* Top accent strip — brightens on hover. ::before is decorative only,
 * so it doesn't need to be tab-stopable. */
.member-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-grad);
  opacity: 0.55;
  transition: opacity var(--motion-fast) var(--ease-out),
              height var(--motion-fast) var(--ease-out);
}
.member-card:hover::before {
  opacity: 1;
}

/* Leadership cards swap the brand-grad strip for the orange-grad — same
 * pattern, different colour — so a leader's card visually pops away
 * from the "regular member" cards (which keep brand-grad). Rank-1 still
 * wins the gold medal strip via the rule below. */
.member-card[data-role="leadership"]::before {
  background: var(--orange-grad);
  opacity: 1;
}

/* Top contributor (rank #1) gets a gold accent strip. */
.member-card[data-rank="1"]::before {
  background: linear-gradient(90deg, var(--gold), #fbbf24);
  opacity: 1;
  height: 4px;
}

.member-card:hover {
  border-color: rgb(from var(--accent) r g b / 0.45);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgb(from var(--accent) r g b / 0.18);
}

.member-top {
  display: flex;
  gap: 12px;
  /* Wrap when the name + role-badge can't fit on one line — the role
   * badge then drops onto its own row instead of clipping the name. */
  flex-wrap: wrap;
  row-gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.member-top-id {
  display: flex;
  gap: 12px;
  align-items: center;
  /* min-width: 0 lets the flex item shrink below its intrinsic content
   * width so the inner name/meta lines can ellipsis or wrap correctly. */
  min-width: 0;
  /* flex: 1 1 auto = "grow if there's space, shrink if there isn't" */
  flex: 1 1 auto;
}

.member-name-block {
  min-width: 0;
  flex: 1 1 auto;
}

/* ── Avatar: gradient background + inner rim + soft shadow ── */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: #fff;
  flex: 0 0 auto;
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition: transform var(--motion-base) var(--ease-spring);
}
/* Light theme — softer rim against light backgrounds */
body.theme-light .avatar {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.member-card:hover .avatar {
  transform: scale(1.04);
}

.member-name {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.2px;
  color: var(--text);
  line-height: 1.25;
  /* Allow up to 2 lines, then ellipsis. -webkit-line-clamp is the
   * widely-supported way to do this; the standard `line-clamp` works
   * in modern Chrome/Safari/Firefox too. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.member-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* ── Role badge: neutral by default, brand-tinted for leadership ── */
.role-badge {
  font-size: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-hi);
  /* Keep the badge on a single line — it's short enough that wrapping
   * looks bad ("Head of\nCommunications"). flex-wrap on the parent
   * lets it drop onto its own row when the line is too tight. */
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  flex-shrink: 0;
  /* Cap the badge width on absurdly long roles so the row can wrap
   * predictably; the badge then fades into ellipsis. */
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Leadership badge — orange so leaders read as "warmth / recognition"
 * and are visually distinct from the blue-branded "regular member"
 * badge above. Rank-1 still uses the gold medal strip on the card. */
.role-badge.role-lead {
  background: var(--orange-bg);
  border-color: rgba(255, 107, 53, 0.34);
  color: var(--orange-500);
}

/* ── KPI tiles: glass-style, hover lifts the border to brand ── */
.member-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mini {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-stroke);
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.member-card:hover .mini {
  background: var(--glass-hi);
  border-color: rgb(from var(--accent) r g b / 0.25);
}

.mini .k {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.mini .v {
  margin-top: 5px;
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-weight: 700;
  /* Scales between 12px (narrow tile) → 13px (normal) so "KES 100,000"
   * still fits when the 3-col grid is squeezed on tablets. */
  font-size: clamp(12px, 1.6vw, 13px);
  letter-spacing: -0.2px;
  color: var(--text);
  /* Don't truncate the value — if the column is too narrow on a tiny
   * phone, let it wrap rather than hiding part of the number. */
  word-break: break-word;
  line-height: 1.2;
}

/* Top-3 rank highlight — gold / silver / bronze for the rank value. */
.mini.rank-1 .v { color: var(--gold); }
.mini.rank-2 .v { color: #c0c4cc; }
.mini.rank-3 .v { color: #cd7f32; }

/* ── Optional bottom row: birthday / graduation ──
 * Replaces the old emoji-prefixed tiles with cleaner icon-led rows. */
.member-extra {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 12px;
  margin-top: 2px;
  border-top: 1px dashed var(--border-soft);
}
/* If only one of birthday/graduation is shown, let it span the row. */
.member-extra:has(.member-extra-line:only-child) {
  grid-template-columns: 1fr;
}

.member-extra-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
}

.member-extra-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--accent-hi);
}

.member-extra-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.member-extra-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.7;
}
.member-extra-value {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.3;
}
.member-extra-line.is-grad .member-extra-value {
  white-space: normal;
}

/* On narrow phones, KPI grid drops to 2 columns — Attendance wraps below
 * to keep numbers readable. */
@media (max-width: 380px) {
  .member-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .member-kpis .mini:nth-child(3) {
    grid-column: 1 / -1;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  background: rgba(5, 7, 26, 0.55);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  padding: 20px;
}
body.theme-light .modal {
  background: rgba(244, 246, 251, 0.65);
}

.modal.open {
  display: grid;
  animation: dira-fade-in var(--motion-base) var(--ease-out) both;
}

.modal-card {
  width: min(720px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 16px;
  animation: dira-scale-in var(--motion-base) var(--ease-spring) both;
}

body.theme-light .modal-card {
  background: rgba(255, 255, 255, 0.98);
}

/* Mobile: full-width bottom-sheet with drag handle */
@media (max-width: 767px) {
  .modal { align-items: end; padding: 0; }
  .modal-card {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 18px 18px max(24px, env(safe-area-inset-bottom));
    animation: dira-sheet-up var(--motion-base) var(--ease-spring) both;
    position: relative;
  }
  .modal-card::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    margin: -2px auto 12px;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-title {
  font-weight: 900;
  font-size: 14px;
}

.modal-close {
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}

.cal-today {
  outline: 2px solid rgb(from var(--accent) r g b / 0.45);
  outline-offset: -2px;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

@media (max-width: 920px) {
  .year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.month-tile {
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.month-tile:hover {
  border-color: rgb(from var(--accent) r g b / 0.38);
}

.month-tile .m {
  font-weight: 900;
}

.month-tile .s {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.cell {
  font-size: 12px;
  color: var(--text-on-dark);
}

.cell.muted {
  color: var(--muted);
}

.cell.total {
  font-weight: 900;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  color: var(--text-on-dark);
  font-size: 12px;
  white-space: nowrap;
}

.panel {
  padding: 18px 16px;
  border-radius: var(--radius-xl);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-title {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.panel-subtitle {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 3px;
}

.table {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.9fr;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.table-row.header {
  background: var(--surface-hi);
  color: var(--text-on-dark);
  font-size: 12px;
}

.table-row .muted {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.amount {
  font-weight: 800;
}

.right-col {
  display: grid;
  gap: 14px;
}

.meeting-card {
  display: grid;
  gap: 12px;
}

.meeting-meta {
  display: grid;
  gap: 10px;
}

.kv {
  display: grid;
  gap: 4px;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.kv .k {
  color: var(--muted);
  font-size: 12px;
}

.kv .v {
  font-weight: 800;
  font-size: 13px;
}

.present {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.present .status {
  font-size: 12px;
  color: var(--muted);
}

.small-btn {
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 800;
  border: 1px solid rgb(from var(--accent) r g b / 0.45);
  background: rgb(from var(--accent) r g b / 0.14);
  color: var(--text-on-dark-hi);
  cursor: pointer;
}

.small-btn:hover {
  background: rgb(from var(--accent) r g b / 0.2);
}

.small-btn.done {
  border-color: rgba(28, 38, 84, 1);
  background: var(--surface);
  color: var(--text-on-dark-85);
  cursor: default;
}

.loans {
  display: grid;
  gap: 10px;
}

.loan-item {
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  gap: 8px;
}

.loan-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.loan-name {
  font-weight: 900;
  font-size: 13px;
}
.loan-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.progress {
  height: 10px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgb(from var(--accent) r g b / 0.92), rgb(from var(--accent) r g b / 0.5));
  border-right: 1px solid var(--border-text);
}

.loan-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Hamburger button (hidden on desktop) ---------- */
.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.menu-btn:hover {
  background: rgb(from var(--accent) r g b / 0.1);
  border-color: rgb(from var(--accent) r g b / 0.4);
}
.menu-btn svg { display: block; }

/* Backdrop that dims content when sidebar is open on mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 900;
  cursor: pointer;
}
.sidebar-backdrop.open { display: block; }

/* ---------- Responsive ---------- */
/* Tablet + mobile: ≤ 980px — sidebar becomes a slide-in overlay
 * triggered by the hamburger button. We use the same pattern across
 * phones AND tablets so there's only one mobile-style nav variant to
 * reason about. (Previously tablets used a vertical top-strip that
 * stacked all 9 nav icons, eating ~500px of vertical space — bad on
 * portrait iPad. The slide-in is cleaner and matches modern fintech
 * apps.)
 */
@media (max-width: 980px) {
  /* Hamburger appears at this breakpoint and below. */
  .menu-btn {
    display: flex;
  }

  /* Force a single-column dashboard and neutralise --sidebar-w so the
   * desktop collapse/expand grid logic can't leak in. */
  .dashboard,
  .dashboard.sidebar-expanded {
    --sidebar-w: auto;
    grid-template-columns: 1fr;
  }

  /* Sidebar slides in from the left as a fixed overlay. Width is fixed
   * at 260px (looks roomy on phones, doesn't get absurdly wide on
   * tablet portrait). */
  .sidebar {
    position: fixed;
    top: 0;
    left: -290px;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    padding: 22px 18px;
    overflow-y: auto;
    transition: left 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .content {
    padding-top: 14px;
  }

  /* The desktop sidebar-toggle (chevron) doesn't make sense on
   * mobile/tablet — the slide-in is opened/closed via .menu-btn. */
  .sidebar-toggle { display: none; }

  /* ── Force the slide-in nav to ALWAYS render in "expanded pill" mode
   * regardless of the .sidebar-expanded toggle state. Without this,
   * users opening the slide-in would see icon-only buttons (because the
   * default desktop state is collapsed) — confusing on mobile where
   * labels are essential.
   */
  .sidebar .sidebar-label,
  .sidebar .sidebar-brand-name {
    opacity: 1;
    max-width: 160px;
    width: auto;
    transform: translateX(0);
  }
  .sidebar .vault-nav-icon {
    width: 100%;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 12px;
    gap: 12px;
  }
  .sidebar .vault-nav-dot {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
  }
  .sidebar-brand {
    align-self: stretch;
    padding: 8px 12px;
  }
  .sidebar-nav {
    justify-items: stretch;
  }
  /* Footer becomes a horizontal row (sign-out pill + avatar) since the
   * collapse-toggle is hidden at this size. */
  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
  }
  .sidebar-signout {
    width: auto;
    padding: 0 var(--sp-3);
    gap: var(--sp-2);
    flex: 1 1 auto;
    justify-content: flex-start;
  }
  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .side-footer {
    padding-top: 10px;
  }
}

/* Phone-only: ≤ 767px — bottom-tab bar takes over primary nav. */
@media (max-width: 767px) {
  .nav {
    grid-template-columns: 1fr;
  }
  .side-footer {
    padding-top: 0;
  }
}

/* Tight phones: ≤ 480px — hide the topbar duplicate chips
 * (Member # / Finance) since the same numbers live in the hero card
 * directly below. Saves ~140px of horizontal space and lets the
 * greeting + hamburger sit comfortably side by side on iPhone SE
 * widths. */
@media (max-width: 480px) {
  .top-actions .vault-chip {
    display: none;
  }
}

@media (max-width: 920px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .span-2 {
    grid-column: span 2;
  }
  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .container {
    width: min(1100px, calc(100% - 28px));
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
  }
  .top-actions {
    justify-content: space-between;
    gap: var(--sp-2);
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
  .nav {
    grid-template-columns: 1fr;
  }
  .table-row {
    grid-template-columns: 1fr;
  }
  .cal-cell {
    min-height: 56px;
    font-size: var(--text-sm);
  }
  /* Quick-action grid → 2×2 on phones. Default uses
   * `repeat(auto-fit, minmax(150px, 1fr))` which collapses to a single
   * column on a 360px screen, turning the four "quick" actions into a
   * tall list. Forcing 2×2 keeps every action reachable in one
   * thumb-scroll. */
  .vault-quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* Snapshot section sits flush against the topbar on phones — give it
   * a small breathing top-padding so it doesn't feel jammed. */
  .dash-page:first-child {
    padding-top: 8px;
  }
}

/* ── Mobile bottom tab bar ───────────────────────────────────────────── */
.mobile-tabs {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 800;
  padding: 8px;
  border-radius: 22px;
  background: var(--glass-hi);
  border: 1px solid var(--glass-stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
}
body.theme-light .mobile-tabs {
  background: rgba(255, 255, 255, 0.85);
}

.mobile-tabs {
  /* 5-column grid for the tab buttons; the indicator sits behind them. */
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  position: fixed;
}

.mobile-tabs-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  height: calc(100% - 16px);
  width: calc((100% - 16px) / 5);
  border-radius: 16px;
  background: var(--brand-grad);
  box-shadow: var(--brand-glow);
  transition: transform var(--motion-base) var(--ease-spring);
  pointer-events: none;
}

.mobile-tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-out);
}
.mobile-tab svg { transition: transform var(--motion-fast) var(--ease-out); }
.mobile-tab:active { transform: scale(0.94); }
.mobile-tab.active {
  color: #fff;
}
body.theme-light .mobile-tab.active { color: #fff; }
.mobile-tab.active svg { transform: translateY(-1px); }

@media (max-width: 767px) {
  .mobile-tabs { display: grid; }
  /* Reserve space at bottom of content so the floating bar doesn't cover it. */
  main.content { padding-bottom: 84px; }
}

/* ── Tab panel transitions ───────────────────────────────────────────── */
.tab-panel {
  animation: dira-fade-in var(--motion-base) var(--ease-out) both;
}

/* ── Sheet / modal overlay (used by dMotion.openSheet) ────────────────── */
.dira-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(5, 7, 26, 0.55);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  display: grid;
  place-items: center;
  animation: dira-fade-in var(--motion-base) var(--ease-out) both;
}
body.theme-light .dira-sheet-overlay {
  background: rgba(244, 246, 251, 0.65);
}
.dira-sheet-overlay.dira-sheet-closing {
  animation: dira-fade-in var(--motion-base) var(--ease-out) reverse both;
}

.dira-sheet-card {
  width: min(440px, calc(100% - 32px));
  max-height: 84vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
  box-shadow: var(--shadow);
  animation: dira-scale-in var(--motion-base) var(--ease-spring) both;
}
.dira-sheet-overlay.dira-sheet-closing .dira-sheet-card {
  animation: dira-scale-in var(--motion-fast) var(--ease-out) reverse both;
}

.dira-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto var(--sp-4);
  display: none;
}

.dira-sheet-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 0 0 var(--sp-3);
  color: var(--text);
}

.dira-sheet-body {
  color: var(--text-dim);
  font-size: var(--text-md);
  line-height: 1.5;
}

.dira-sheet-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}
.dira-sheet-actions .btn,
.dira-sheet-actions .btn--ghost {
  flex: 1;
}

/* On phones: slide up from the bottom and pin to the bottom edge. */
@media (max-width: 767px) {
  .dira-sheet-overlay {
    align-items: end;
  }
  .dira-sheet-card {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: max(var(--sp-6), env(safe-area-inset-bottom));
    animation: dira-sheet-up var(--motion-base) var(--ease-spring) both;
  }
  .dira-sheet-overlay.dira-sheet-closing .dira-sheet-card {
    animation: dira-sheet-up var(--motion-fast) var(--ease-out) reverse both;
  }
  .dira-sheet-handle { display: block; }
}
