/* ============================================================
   MEMBERSHIP PORTAL — FULL STYLESHEET
   Light theme, large readable text for 50–75 age group
   ============================================================ */

/* --- Google Font already loaded in header.php --- */

/* ===================== CSS VARIABLES ===================== */
:root {
  --font-body: 'Inter', 'Segoe UI', Arial, sans-serif;
  --base-font-size: 18px;

  /* Surfaces */
  --bg: #f5f4f0;
  --shell-bg: #f4f7fe;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-off: #f1f5f9;
  --divider: #e2e8f0;
  --border: #e2e8f0;

  /* Text */
  --text: #1e1c18;
  --text-muted: #56534e;
  --text-faint: #9c9a96;
  --text-inv: #ffffff;

  /* Brand / Accent */
  --primary: #01696f;
  --primary-h: #004f54;
  --primary-a: #003538;
  --primary-hl: #cce4e5;

  /* Semantic */
  --success: #2f6b10;
  --success-bg: #edf5e8;
  --warning: #8c4a00;
  --warning-bg: #fef3e2;
  --error: #a01c1c;
  --error-bg: #fdeaea;
  --info-bg: #e8f2ff;
  --info: #1254a0;

  /* Radii */
  --r-sm: 0.375rem;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;
  --r-full: 9999px;

  /* Shadows */
  --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --sh-md: 0 4px 14px rgba(0, 0, 0, 0.10);
  --sh-lg: 0 8px 28px rgba(0, 0, 0, 0.13);

  /* App chrome */
  --topbar-h: 62px;
  --topbar-bg: #2d2b52;
  --nav-bg: #ffffff;

  /* Transitions */
  --tr: 160ms ease;
}

/* ===================== RESET + BASE ===================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--base-font-size);
  /* adjustable reading size */
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  scroll-margin-top: calc(var(--topbar-h) + 60px);
}

body {
  font-family: var(--font-body);
  background: var(--shell-bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100dvh;
}

body.mobile-nav-open {
  overflow: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* ===================== APP SHELL (top-nav layout) ===================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Top Navigation Bar ── */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  background: var(--topbar-bg);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.18);
}

/* Brand / Logo */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  margin-right: 0.75rem;
}

.topbar-brand:hover {
  text-decoration: none;
  color: #fff;
  opacity: 0.9;
}

.topbar-logo-mark {
  flex-shrink: 0;
  line-height: 0;
}

.topbar-brand-text {
  white-space: nowrap;
}

/* Allow manual line break only on mobile */
.topbar-brand-text br { display: none; }

/* Desktop nav links */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.topbar-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--r-md);
  font-size: 0.93rem;
  font-weight: 500;
  color: rgb(255, 255, 255);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--tr), color var(--tr);
}

.topbar-nav-link svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.topbar-nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.topbar-nav-link.active {
  background: rgba(99, 102, 241, 0.4);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 #a5b4fc;
}

/* Right side actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  margin-right: 0.25rem;
}

/* Buttons inside topbar */
.app-topbar .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}

.app-topbar .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid rgba(252, 165, 165, 0.4);
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: #fca5a5;
  transition: background var(--tr), border-color var(--tr);
  text-decoration: none;
  background: transparent;
}

.btn-logout:hover {
  background: rgba(252, 165, 165, 0.12);
  border-color: #fca5a5;
  text-decoration: none;
}

/* Mobile hamburger */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: var(--r-md);
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  flex-shrink: 0;
}

.mobile-menu-toggle span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: var(--tr);
}

.mobile-menu-toggle.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.is-open span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Mobile Nav Drawer (drops from topbar) ── */
.mobile-nav {
  display: none;
  flex-direction: column;
  background: var(--topbar-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0.75rem 0.75rem;
  gap: 0.15rem;
  z-index: 190;
}

.mobile-nav.is-open {
  display: flex;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--r-md);
  font-size: 0.97rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  transition: background var(--tr), color var(--tr);
}

.mobile-nav-link svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.mobile-nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.mobile-nav-link.active {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
  font-weight: 600;
}

.mobile-nav-link--logout {
  color: #fca5a5;
}

.mobile-nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.35rem 0;
}

/* ── Main area ── */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--shell-bg);
}

/* Responsive */
@media (max-width: 860px) {
  .topbar-nav {
    display: none;
  }

  .topbar-user {
    display: none;
  }

  .topbar-actions .nav-pw-link {
    display: none;
  }

  .topbar-actions .nav-backup-link {
    display: none;
  }

  .topbar-actions .btn-logout {
    display: none;
  }

  .mobile-menu-toggle {
    display: flex;
  }
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.5rem 1.35rem 2.5rem;
}

@media (max-width: 640px) {
  .main-content {
    padding: 1rem 0.85rem 2rem;
  }
}

/* ===================== PAGE TITLE ===================== */
.page-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  line-height: 1.2;
}

/* ===================== FOOTER ===================== */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--divider);
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  color: var(--text-faint);
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.footer-sep {
  color: var(--divider);
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--tr), border-color var(--tr), color var(--tr), box-shadow var(--tr);
  min-height: 44px;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inv);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
}

.btn-primary:active {
  background: var(--primary-a);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-off);
  border-color: var(--text-faint);
}

.btn-success {
  background: var(--success);
  color: var(--text-inv);
  border-color: var(--success);
}

.btn-success:hover {
  background: #235108;
}

.btn-lg {
  padding: 0.6rem 1.4rem;
  font-size: 1rem;
  min-height: 48px;
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.88rem;
  min-height: 36px;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ===================== CARD ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  box-shadow: var(--sh-sm);
}

.divider {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 1.25rem 0;
}

/* ===================== ALERTS ===================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  border: 1.5px solid transparent;
}

.alert-error {
  background: var(--error-bg);
  color: var(--error);
  border-color: #f5c0c0;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: #b8dfaa;
}

.alert-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: #b3d1f7;
}

/* ===================== FORMS ===================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.form-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  gap: 0.2rem;
}

.required {
  color: var(--error);
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--tr), box-shadow var(--tr);
  min-height: 44px;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 105, 111, 0.12);
  outline: none;
}

.form-control::placeholder {
  color: var(--text-faint);
}

.form-control:disabled {
  background: var(--surface-off);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-control.is-invalid {
  border-color: var(--error);
  background: var(--error-bg);
}

.form-error {
  font-size: 0.85rem;
  color: var(--error);
  display: none;
}

.is-invalid+.form-error,
.form-control.is-invalid~.form-error {
  display: block;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2356534e' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.25rem;
}

/* ===================== RADIO GROUP ===================== */
.radio-group {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}

.radio-label input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ===================== FILTER BAR ===================== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 1rem;
}

/* .filter-bar.sticky {
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: 5;
  box-shadow: var(--sh-sm);
} */
.filter-bar.sticky {
  position: sticky;
  top: calc(var(--topbar-h) + 8px);
  z-index: 5;
  box-shadow: var(--sh-sm);
}

.filter-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ===================== TABLE ===================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  background: var(--surface);
  scroll-margin-top: calc(var(--topbar-h) + 60px);
}

/* Membership list: always show H-scrollbar + big chevron cues (no paragraph to read) */
.member-table-frame {
  position: relative;
}

#memberTableWrap {
  overflow-x: scroll;
  scrollbar-width: auto;
  scrollbar-color: #94a3b8 #eef2f7;
}

#memberTableWrap::-webkit-scrollbar {
  height: 14px;
}

#memberTableWrap::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 7px;
}

#memberTableWrap::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 7px;
  border: 3px solid #eef2f7;
}

#memberTableWrap::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.member-table-scroll-cue {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 64px;
  margin-top: -8px;
  pointer-events: none;
  color: var(--primary);
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--r-lg);
  box-sizing: border-box;
}

.member-table-scroll-cue--end {
  right: 10px;
}

.member-table-scroll-cue--start {
  left: 10px;
}

.member-table-scroll-cue[hidden] {
  display: none !important;
}

.member-table-scroll-cue--end .member-table-scroll-cue__svg {
  animation: memberScrollCueNudgeRight 1.15s ease-in-out infinite;
}

.member-table-scroll-cue--start .member-table-scroll-cue__svg {
  animation: memberScrollCueNudgeLeft 1.15s ease-in-out infinite;
}

@keyframes memberScrollCueNudgeRight {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(5px);
  }
}

@keyframes memberScrollCueNudgeLeft {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(-5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .member-table-scroll-cue--end .member-table-scroll-cue__svg,
  .member-table-scroll-cue--start .member-table-scroll-cue__svg {
    animation: none;
  }
}

.data-table {
  width: 100%;
}

.data-table thead tr {
  background: var(--surface-off);
  border-bottom: 2px solid var(--divider);
  position: static;
  z-index: 2;
}

.data-table th {
  padding: 0.85rem 0.95rem;
  font-size: 0.97rem;
  font-weight: 700;
  text-align: left;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.data-table td {
  padding: 0.8rem 0.95rem;
  font-size: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:nth-child(even) {
  background: #fcfbf9;
}

.data-table tbody tr:hover {
  background: #f1f4f4;
}

.data-table .sl-col {
  color: var(--text-faint);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  width: 54px;
}

.empty-row td {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-faint);
  font-size: 0.97rem;
}

#memberCount,
.member-count {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.lazy-sentinel {
  height: 1px;
}

.loading-more {
  text-align: center;
  padding: 1rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  display: none;
}

/* ===================== KPI ROW ===================== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--sh-sm);
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* SaaS-style KPI strip (dashboard) */
.dashboard-page .kpi-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .dashboard-page .kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .dashboard-page .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-page .kpi-card .kpi-value {
    font-size: 1.45rem;
  }

  .dashboard-page .kpi-card .kpi-label {
    font-size: 0.78rem;
  }
}

.dashboard-page .kpi-card {
  border: none;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(45, 43, 82, 0.12);
  color: #fff;
}

.dashboard-page .kpi-card .kpi-label {
  color: rgba(255, 255, 255, 0.88);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.86rem;
  font-weight: 600;
}

.dashboard-page .kpi-card .kpi-value {
  color: #fff;
  font-size: 1.75rem;
}

.kpi-card--indigo {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.kpi-card--rose {
  background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
}

.kpi-card--emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.kpi-card--amber {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.kpi-card--sky {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

/* Dashboard root — avoid grid/flex overflow on narrow viewports */
.dashboard-page {
  min-width: 0;
  width: 100%;
}

.dashboard-page .kpi-row,
.dashboard-page .dashboard-grid,
.dashboard-page .dashboard-panels-grid {
  min-width: 0;
}

.dashboard-page .chart-card,
.dashboard-page .panel-card {
  min-width: 0;
  max-width: 100%;
}

/* Dashboard panels, badges, recent list */
.dashboard-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.35rem;
}

.dashboard-page-header .page-title {
  margin-bottom: 0;
}

.dashboard-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
  width: 100%;
  margin-top: -0.5rem;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem 1.25rem 1.2rem;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  margin-bottom: 1.25rem;
}

.panel-card--flush {
  padding: 0;
  overflow: hidden;
}

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 1rem;
  padding: 0 0.25rem;
}

.panel-card--flush .panel-title {
  padding: 1rem 1.15rem 0.65rem;
  margin-bottom: 0;
}

.dashboard-panels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard-panels-grid {
    grid-template-columns: 1fr;
  }
}

.data-table tfoot tr {
  background: var(--surface-off);
  font-weight: 700;
}

.data-table tfoot td {
  border-top: 2px solid var(--divider);
  border-bottom: none;
  padding: 0.85rem 0.95rem;
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: var(--r-full);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.ui-badge--blue {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.ui-badge--violet {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}

.ui-badge--green {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.ui-badge--orange {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.ui-badge--red {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.ui-badge--slate {
  background: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 700;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-variant-numeric: tabular-nums;
}

.stat-pill svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0 0;
}

.recent-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid var(--divider);
}

.recent-list li:last-child {
  border-bottom: none;
  padding-bottom: 0.25rem;
}

.recent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.recent-body {
  min-width: 0;
  flex: 1;
}

.recent-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
  line-height: 1.35;
}

.recent-meta {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.col-actions {
  width: 48px;
}

/* ===================== DASHBOARD CHARTS ===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
}

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

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
}

.chart-box {
  height: 300px;
  position: relative;
}

.chart-box--taluk {
  height: 320px;
}

/* --- Dashboard (mobile-friendly) --- */
.dashboard-heading {
  font-size: 1.45rem;
  margin-bottom: 1rem;
}

.dashboard-page .dashboard-grid {
  align-items: stretch;
}

.chart-box--compact {
  height: 260px;
}

@media (max-width: 767px) {
  .dashboard-page .dashboard-grid {
    gap: 1rem;
  }

  .dashboard-page .chart-card {
    padding: 1rem 0.85rem 0.85rem;
    border-radius: var(--r-md);
  }

  .dashboard-page .chart-title {
    font-size: 0.95rem;
    margin-bottom: 0.7rem;
    line-height: 1.35;
  }

  .chart-box--taluk {
    height: min(380px, 65vh);
    min-height: 260px;
  }

  .chart-box--compact {
    height: 220px;
    min-height: 180px;
  }

  .dashboard-page .table-wrap {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .dashboard-page .panel-card--flush .panel-title {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .dashboard-page .ui-badge {
    white-space: normal;
    text-align: left;
    line-height: 1.35;
  }

  /* More room for taluk + category tables without horizontal scroll */
  .dashboard-page .data-table .sl-col,
  .dashboard-page .data-table .col-actions {
    display: none;
  }
}

@media (max-width: 480px) {
  .chart-box--taluk {
    height: min(320px, 60vh);
    min-height: 240px;
  }

  .chart-box--compact {
    height: 180px;
    min-height: 160px;
  }

  .dashboard-heading {
    font-size: 1.2rem;
  }

  .dashboard-page-header {
    margin-bottom: 0.85rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.6rem 0.65rem;
    font-size: 0.88rem;
  }

  .panel-card {
    padding: 0.85rem 0.9rem 1rem;
  }

  .recent-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.78rem;
  }

  .recent-name {
    font-size: 0.92rem;
  }

  .recent-meta {
    font-size: 0.78rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .dashboard-page .panel-card--flush .panel-title {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
    font-size: 0.95rem;
  }
}

/* Very narrow phones: single-column KPI strip reads more clearly */
@media (max-width: 380px) {
  .dashboard-page .kpi-row {
    grid-template-columns: 1fr;
  }

  .dashboard-page .kpi-row .kpi-card:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .dashboard-page .kpi-card {
    padding: 0.7rem 0.8rem;
  }
}

/* ===================== MEMBERSHIP TOOLBAR ===================== */
.mem-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* ===================== ADD MEMBER PAGE ===================== */
.add-container {
  width: 100%;
  max-width: 100%;
}

/* Add member: multi-column rows + tighter spacing on desktop (fit without scroll) */
.add-member-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.add-member-page .add-member-title {
  margin: 0;
  flex: 1;
  min-width: min(100%, 11rem);
}

.add-member-reg-strip {
  margin-bottom: 0.35rem;
}

.add-member-reg-strip .kpi-label {
  display: block;
  margin-bottom: 0.2rem;
}

.form-row--cols-3 {
  grid-template-columns: 1fr;
}

.form-row--taluk-status {
  grid-template-columns: 1fr;
}

@media (min-width: 641px) and (max-width: 900px) {
  .form-row--cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-row--cols-3 .form-group:last-child:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 901px) {
  .form-row--cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-row--taluk-status {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 200px);
    align-items: end;
  }

  .add-member-page .add-member-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
  }

  .add-member-page .add-member-title {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
  }

  .add-member-page .add-member-card {
    padding: 0.85rem 1.1rem 1rem;
  }

  .add-member-page .add-member-reg-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0;
  }

  .add-member-page .add-member-reg-strip .kpi-label {
    display: inline;
    margin: 0;
  }

  .add-member-page .add-member-divider {
    margin: 0.5rem 0;
  }

  .add-member-page .add-member-form .form-group {
    margin-bottom: 0.4rem;
    gap: 0.2rem;
  }

  .add-member-page .add-member-form .form-row {
    gap: 0.65rem;
    margin-bottom: 0.15rem;
  }

  .add-member-page .add-member-form .form-label {
    font-size: 0.86rem;
  }

  .add-member-page .add-member-form .form-control {
    min-height: 38px;
    padding: 0.35rem 0.65rem;
    font-size: 0.95rem;
  }

  .add-member-page .add-member-form select.form-control {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .add-member-page .add-member-actions {
    margin-top: 0.15rem;
    flex-wrap: nowrap;
  }

  .add-member-page .add-member-submit {
    min-height: 42px;
    padding: 0.45rem 1.15rem;
    font-size: 0.95rem;
  }

  .add-member-page .add-member-status-input {
    max-width: none;
    width: 100%;
    background: var(--success-bg);
    color: var(--success);
    font-weight: 600;
    text-align: center;
  }
}

.reg-badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: var(--primary-hl);
  color: var(--primary);
  border-radius: var(--r-full);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}

.import-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid #b3d1f7;
  border-radius: var(--r-md);
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

/* ===================== REPORTS PAGE ===================== */
.report-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.report-opt {
  padding: 0.75rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  min-width: 180px;
  transition: border-color var(--tr), background var(--tr);
  background: var(--surface);
}

.report-opt:hover {
  border-color: var(--primary);
  background: var(--surface-2);
}

.report-opt.selected {
  border-color: var(--primary);
  background: var(--primary-hl);
}

.report-opt .rtitle {
  font-weight: 700;
  font-size: 0.97rem;
  color: var(--text);
}

.report-opt .rdesc {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.export-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ===================== ADDRESS PRINT PAGE ===================== */
.addr-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

/* Screen preview of print pages (label sheet: top 1.2cm, left 0.7cm, cells 6.4×3.4cm, col gap 0.35cm) */
.print-page {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.2cm 0.7cm;
  margin-bottom: 1.5rem;
  box-shadow: var(--sh-md);
}

.address-grid {
  display: grid;
  grid-template-columns: repeat(3, 6.4cm);
  grid-auto-rows: 3.4cm;
  column-gap: 0.35cm;
  row-gap: 0;
}

.address-cell {
  display: flex;
  flex-direction: column;
  gap: 0;
  box-sizing: border-box;
  padding: 4mm 5mm;
  border: 0.5px solid #ccc;
  width: 6.4cm;
  height: 3.4cm;
  min-height: 3.4cm;
  overflow: hidden;
  border-radius: var(--r-sm);
}

.addr-name {
  font-weight: 700;
  font-size: 9.5pt;
  color: #111;
  line-height: 1.35;
}

.addr-phone {
  font-size: 8.5pt;
  color: #333;
  line-height: 1.3;
}

.addr-line {
  font-size: 8pt;
  color: #444;
  line-height: 1.3;
}

/* ===================== LOGIN PAGE ===================== */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eaf4f4 0%, #f5f4f0 60%, #fdf9f4 100%);
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--sh-lg);
  text-align: center;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.login-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-card .form-group {
  text-align: left;
}

.login-foot {
  font-size: 0.84rem;
  color: var(--text-faint);
  margin-top: 1.1rem;
}

/* ===================== TEXT SIZE CONTROLS ===================== */
.text-size-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.text-size-btn {
  min-height: 34px;
  min-width: 34px;
  padding: 0 0.45rem;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-weight: 700;
  border: 1px solid transparent;
}

.text-size-btn:hover {
  background: var(--surface-off);
  color: var(--text);
  text-decoration: none;
}

.text-size-btn.active {
  background: var(--primary-hl);
  color: var(--primary);
  border-color: #9cc7ca;
}

@media (max-width: 900px) {
  .text-size-controls {
    display: none;
  }
}

/* ===================== RESPONSIVE TUNING ===================== */
@media (max-width: 900px) {
  .main-content {
    padding: 1.1rem 0.85rem 2.2rem;
  }

  .card {
    padding: 1rem;
  }

  .page-title {
    font-size: 1.35rem;
    margin-bottom: 0.95rem;
  }

  .btn-group {
    width: 100%;
  }

  .mem-toolbar,
  .addr-toolbar,
  .export-bar {
    align-items: stretch;
  }

  .mem-toolbar .btn-group,
  .filter-search,
  .export-bar {
    width: 100%;
  }

  .filter-bar {
    gap: 0.75rem;
    padding: 0.7rem 0.8rem;
  }

  .radio-group {
    width: 100%;
    gap: 0.8rem;
  }

  .filter-search .form-control,
  .filter-search select,
  .addr-toolbar .form-control {
    width: 100%;
    max-width: none !important;
  }

  .filter-search .btn,
  .export-bar .btn,
  .addr-toolbar .btn,
  .mem-toolbar .btn {
    flex: 1 1 180px;
    justify-content: center;
  }

  .table-wrap {
    border-radius: var(--r-md);
  }

  .data-table th,
  .data-table td {
    padding: 0.65rem 0.7rem;
    font-size: 0.93rem;
  }

  .chart-box:not(.chart-box--taluk) {
    height: 250px;
  }
}

@media (max-width: 640px) {
  /* Prevent topbar title from forcing overflow on mobile */
  .topbar-brand {
    min-width: 0;
  }

  .topbar-brand-text {
    max-width: 56vw;
    overflow: hidden;
    white-space: normal;
    font-size: 0.95rem;
    line-height: 1.15;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .topbar-brand-text br { display: inline; }

  .topbar-nav {
    min-width: 0;
  }

  .topbar-actions {
    gap: 0.35rem;
  }

  .app-topbar {
    padding-left: 0.5rem;
    padding-right: 0.65rem;
  }

  .site-footer {
    padding: 0.85rem 0.8rem;
  }

  .footer-inner {
    gap: 0.35rem;
    font-size: 0.88rem;
  }

  .footer-sep {
    display: none;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  .kpi-row .kpi-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .kpi-card {
    padding: 0.75rem 0.85rem;
    min-width: 0;
  }

  .kpi-label {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    line-height: 1.25;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .dashboard-page .kpi-card .kpi-value {
    font-size: 1.35rem;
  }

  .report-opt {
    min-width: 100%;
  }

  .login-wrap {
    padding: 0.9rem;
  }

  .login-card {
    padding: 1.4rem 1rem;
    border-radius: var(--r-lg);
  }

  .print-page {
    overflow-x: auto;
    padding: 0.65rem;
  }

  .address-grid {
    min-width: 20cm;
  }

  .address-cell {
    border-radius: 0;
  }
}

@media (max-width: 420px) {
  .topbar-brand-text { max-width: 52vw; font-size: 0.9rem; }
  .page-title { font-size: 1.2rem; }

  .main-content {
    padding-inline: 0.55rem;
  }

  .dashboard-heading {
    font-size: 1.28rem;
    margin-bottom: 0.85rem;
  }

  .btn {
    width: 100%;
  }

  .btn-sm,
  .btn-lg {
    width: 100%;
  }

  .form-control {
    font-size: 16px;
  }

  .chart-box--compact {
    height: 210px;
  }

  .chart-box--taluk {
    min-height: 288px;
    height: min(360px, 62vh);
  }
}

/* ===================== PRINT STYLES ===================== */
@media print {

  .no-print,
  .app-sidebar,
  .app-topbar,
  .sidebar-backdrop,
  .site-footer {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .app-main {
    display: block;
  }

  body {
    background: white;
    font-size: 9pt;
  }

  .main-content {
    padding: 0;
    max-width: 100%;
  }

  .print-page {
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    page-break-after: always;
    margin: 0;
    width: 100%;
    min-height: calc(297mm - 2.4cm);
    box-sizing: border-box;
  }

  .print-page:last-child {
    page-break-after: avoid;
  }

  .address-grid {
    display: grid;
    grid-template-columns: repeat(3, 6.4cm);
    grid-auto-rows: 3.4cm;
    column-gap: 0.35cm;
    row-gap: 0;
    min-height: calc(297mm - 2.4cm);
    box-sizing: border-box;
  }

  .address-cell {
    box-sizing: border-box;
    width: 6.4cm;
    height: 3.4cm;
    min-height: 3.4cm;
    border: 0.4pt solid #bbb;
    padding: 3mm 4mm;
    overflow: hidden;
    page-break-inside: avoid;
    border-radius: var(--r-sm);
  }

  .addr-name {
    font-size: 9pt;
    font-weight: 700;
  }

  .addr-phone {
    font-size: 8pt;
  }

  .addr-line {
    font-size: 7.5pt;
  }

  /* Label sheet: top/bottom 1.2cm, left/right 0.7cm; cells 6.4×3.4cm; col gap 0.35cm; row gap 0 */
  @page {
    size: A4;
    margin: 1.2cm 0.7cm;
  }
}

.btn-backup {
    background: #10b981;
    color: #fff;
    border: 1px solid #10b981;
}

.btn-backup:hover {
    background: #059669;
    border-color: #059669;
    color: #fff;
}