@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400..800&family=Poppins:wght@500;600;700;800&display=swap');

/* ── Design tokens: enhanced maroon + complementary colors ── */
:root {
  color-scheme: light;

  --font-sans: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  --font-display: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Poppins, Inter, sans-serif;

  /* Brand - Maroon Dominant */
  --primary: #3C0008; /* Changed from #7a1e2c */
  --primary-dark: #2d0006; /* Derived from #5e141d */
  --primary-light: #f8f5f5; /* Derived from #f9f1f3 */
  --primary-border: #e0d3d4; /* Derived from #e8c5cc */
  --primary-soft: #fefdfd; /* Derived from #fcf6f7 */
  --primary-soft-2: #f5f2f2; /* Derived from #f3e5e7 */
  --primary-ink: #1e0004; /* Derived from #4a0f19 */

  /* Accent Colors - Complementary to Maroon (No Gradients) */
  --accent-teal: #0d9488;
  --accent-teal-light: #e0f9f7;
  --accent-coral: #e85d3d;
  --accent-coral-light: #fef3f0;
  --accent-amber: #d97706;
  --accent-amber-light: #fef9f0;
  --accent-cyan: #06b6d4;
  --accent-cyan-light: #ecfdf5;
  --accent-emerald: #059669;
  --accent-emerald-light: #ecfdf5;

  /* Semantic */
  --danger: #dc2626;
  --info: var(--primary);
  --success: var(--accent-emerald);
  --warning: var(--accent-amber);

  /* Surfaces */
  --bg: #fcfcfd;
  --bg-soft: #f8f9fc;
  --bg-card: #ffffff;
  --bg-card-solid: #ffffff;

  /* Text */
  --text: #1a1c21;
  --text-muted: #6b7280;

  /* Borders + shadows */
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px rgba(122, 30, 44, 0.12);
  --shadow-xl: 0 20px 35px rgba(0, 0, 0, 0.12);
  --shadow-glow: none;

  /* Layout */
  --sidebar-w: 280px;
  --bottom-nav-h: 74px;
  --radius: 16px;
  --radius-sm: 12px;
  --glass-blur: 0px;
  --container-gap: 24px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Neutral accents */
  --surface-1: rgba(255, 255, 255, 0.92);
  --surface-2: rgba(255, 255, 255, 0.72);
  --surface-3: rgba(255, 255, 255, 0.55);
  --ring: rgba(122, 30, 44, 0.18);
}

/* Loan promotions (dashboard ad) */
.promo-offers-section{
  margin: 28px 0 32px;
}
.section-title-row{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.section-title-row h2{
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.section-title-row p{
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.promo-offer-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--container-gap);
}
.promo-offer-card{
  position: relative;
  border-radius: 14px;
  padding: 24px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  overflow:hidden;
  transition: all 0.3s var(--ease-out);
}
.promo-offer-card:hover{
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.promo-offer-section{
  position: relative;
  padding: 24px;
  border-left: 4px solid transparent;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 0 12px 12px 0;
  overflow: visible;
  transition: background 0.2s var(--ease-out);
}
.promo-offer-section:hover{
  background: rgba(255, 255, 255, 0.7);
}
.promo-offer-badge{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  border: none;
}
.promo-offer-title{
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.promo-offer-rate{
  margin-top: 8px;
  font-weight: 700;
  color: var(--accent-coral);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.promo-offer-term{
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.promo-offer-description{
  margin-top: 12px;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.6;
  opacity: 0.9;
}
.promo-offer-blue{
  border-left: 4px solid var(--accent-cyan);
}
.promo-offer-green{
  border-left: 4px solid var(--accent-emerald);
}
.promo-offer-gold{
  border-left: 4px solid var(--accent-amber);
}
@media (max-width: 980px){
  .promo-offer-grid{ grid-template-columns: 1fr; }
  .section-title-row{ align-items:flex-start; flex-direction:column; }
}

[data-theme='dark'] {
  color-scheme: dark;

  --bg: #0c0f14;
  --bg-soft: #0b0e13;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-solid: #0f141b;

  --text: rgba(255, 255, 255, 0.92);
  --text-muted: rgba(255, 255, 255, 0.62);

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.16);

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 18px 55px rgba(0, 0, 0, 0.35);
  --ring: rgba(255, 255, 255, 0.14);
}

[data-theme='dark'] body::before {
  background: var(--bg-soft);
}

[data-theme='dark'] thead th {
  background: rgba(255, 255, 255, 0.04);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme='dark'] tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.03);
}

[data-theme='dark'] tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme='dark'] .toast {
  background: var(--bg-card-solid);
}

[data-theme='dark'] .member-settings__menu {
  background: var(--bg-card-solid);
  border-color: var(--border);
}

[data-theme='dark'] .member-settings__item:hover {
  background: rgba(255, 255, 255, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 100%;
}

/* Prevent accidental horizontal overflow that can trigger mobile auto-scaling */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  font-family: var(--font-sans);
  background: var(--bg-soft);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, var(--bg), var(--bg-soft));
}

/* ── Auth pages (member) — match admin maroon background ── */
body.auth-maroon {
  background-color: var(--primary) !important;
  background-image: none !important;
}
body.auth-maroon::before {
  display: none !important;
}
body.auth-maroon .login-page::before {
  display: none !important;
}
body.auth-maroon .login-card,
body.auth-maroon .pre-app-card {
  background-color: #f4f4f2 !important;
  color: #333333;
  border: none;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
body.auth-maroon .login-title,
body.auth-maroon .login-logo .logo-text,
body.auth-maroon .pre-app-title,
body.auth-maroon .pre-app-headline {
  color: var(--primary) !important;
}
body.auth-maroon .login-sub,
body.auth-maroon .login-logo .logo-sub,
body.auth-maroon .text-muted,
body.auth-maroon .text-sm,
body.auth-maroon .form-label,
body.auth-maroon .pre-app-intro,
body.auth-maroon .pre-app-lead {
  color: #6b7280 !important;
}
body.auth-maroon .form-control {
  background: #ffffff !important;
  border: 1px solid #d1d5db !important;
  color: #333333 !important;
}
body.auth-maroon .form-control::placeholder {
  color: #9ca3af !important;
}
body.auth-maroon .btn-primary {
  background-color: var(--primary) !important;
  color: #ffffff !important;
}

h1,
h2,
h3,
.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

/* ── Theme toggle ── */
.theme-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s var(--ease-out), border-color 0.25s var(--ease-out);
}
.theme-toggle:hover {
  border-color: rgba(60, 0, 8, 0.35);
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary-light), var(--primary));
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.12);
  transition: transform 0.3s var(--ease-out), background 0.3s var(--ease-out);
}
[data-theme='dark'] .theme-toggle::after {
  transform: translateX(24px);
  background: linear-gradient(145deg, var(--primary-light), var(--primary));
}
.theme-toggle--floating {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
}

/* ── SIDEBAR (glass) ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 100;
  background: var(--primary);
  border-right: 1px solid var(--primary-dark);
  box-shadow: none;
}

.bottom-nav {
  display: none;
}

.sidebar-logo {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--primary-dark);
}
.sidebar-logo .logo-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.sidebar-logo .logo-sub {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-top: 6px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(60, 0, 8, 0.25) transparent;
}

.nav-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  padding: 14px 22px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  margin: 6px 16px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  position: relative;
  transform: translateX(4px);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: #fff;
  border-radius: 99px;
}
.nav-item .nav-icon {
  font-size: 1.12rem;
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 18px 22px;
  border-top: 1px solid var(--primary-dark);
  background: var(--primary-dark);
}
.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.12);
}
.user-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
}
.user-role {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
}

/* ── MAIN ── */
.main-content {
  margin-left: var(--sidebar-w);
  padding-top: 72px;
  min-height: 100vh;
  position: relative;
}

.topbar {
  background: var(--primary);
  padding: 0 32px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--primary-dark);
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  z-index: 900; /* High enough to stay above content, below modals */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: all 0.3s var(--ease-out);
  width: calc(100% - var(--sidebar-w));
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #fff;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── Member topbar widgets (datetime + calendar notification) ── */
.member-topbar-widgets {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}

.member-datetime {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  line-height: 1.2;
}
.member-datetime__main {
  font-weight: 800;
  letter-spacing: -0.01em;
  font-size: 0.86rem;
}
.member-datetime__sub {
  font-weight: 700;
  font-size: 0.78rem;
  opacity: 0.85;
  letter-spacing: 0.08em;
}

.member-calendar-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition);
}
.member-calendar-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.member-calendar-btn__icon {
  font-size: 1.1rem;
  line-height: 1;
}
.member-calendar-btn__dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
}
.member-calendar-btn__dot.dot-overdue {
  background: #ffedd5;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.35);
}

@keyframes memberShiver {
  0% { transform: translateX(0) rotate(0deg); }
  15% { transform: translateX(-1px) rotate(-1deg); }
  30% { transform: translateX(2px) rotate(1deg); }
  45% { transform: translateX(-2px) rotate(-1deg); }
  60% { transform: translateX(2px) rotate(1deg); }
  75% { transform: translateX(-1px) rotate(0deg); }
  100% { transform: translateX(0) rotate(0deg); }
}
.member-calendar-btn.is-overdue {
  border-color: rgba(255, 237, 213, 0.65);
}
@media (prefers-reduced-motion: no-preference) {
  .member-calendar-btn.is-overdue {
    animation: memberShiver 0.75s ease-in-out infinite;
  }
}

/* Calendar modal module */
#memberCalendarModal {
  z-index: 10040;
}
#memberDateDetailsModal {
  z-index: 10050;
}
.member-calendar-modal {
  max-width: 720px;
}
.member-calendar {
  display: grid;
  gap: 14px;
}
.member-calendar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.member-calendar__month {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.member-calendar__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.member-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.member-calendar__cell {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  padding: 10px 10px 12px;
  min-height: 52px;
  cursor: default;
  text-align: left;
  transition: var(--transition);
  color: var(--text);
}
.member-calendar__cell.is-blank {
  background: transparent;
  border-color: transparent;
}
.member-calendar__cell.is-today {
  border-color: rgba(60, 0, 8, 0.45);
  box-shadow: 0 0 0 3px rgba(60, 0, 8, 0.12);
}
.member-calendar__day {
  font-weight: 800;
  font-family: var(--font-display);
}
.member-calendar__cell.has-disbursement {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(16, 185, 129, 0.35);
}
.member-calendar__cell.has-due {
  background: rgba(59, 130, 246, 0.09);
  border-color: rgba(59, 130, 246, 0.35);
}
.member-calendar__cell.has-overdue {
  background: rgba(234, 88, 12, 0.10);
  border-color: rgba(234, 88, 12, 0.45);
}
.member-calendar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.member-calendar__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.member-calendar__pill {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
  border: 1px solid transparent;
}
.member-calendar__pill.pill-disb { background: rgba(16,185,129,0.25); border-color: rgba(16,185,129,0.45); }
.member-calendar__pill.pill-due { background: rgba(59,130,246,0.22); border-color: rgba(59,130,246,0.40); }
.member-calendar__pill.pill-over { background: rgba(234,88,12,0.25); border-color: rgba(234,88,12,0.45); }

[data-theme='dark'] .member-calendar__cell {
  background: rgba(255, 255, 255, 0.04);
}
[data-theme='dark'] .member-calendar__cell.is-blank {
  background: transparent;
}

.page-body {
  padding: 32px 32px 48px;
  max-width: 1400px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

@media (min-width: 1200px) {
  .page-body {
    padding: 34px 40px 60px;
  }
}

/* ── Dashboard Layout & Headers ── */
.welcome-header { margin-bottom: 32px; }
.welcome-header h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.welcome-header p { color: var(--text-muted); font-size: 1rem; }

.modern-grid { display: grid; grid-template-columns: 7fr 3fr; gap: 32px; align-items: start; }
@media (max-width: 1024px) { .modern-grid { grid-template-columns: 1fr; } }

.secondary-panel .card { margin-bottom: 24px; }
.clickable-card { cursor: pointer; transition: transform 0.2s var(--ease-out); }
.clickable-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.maximize-icon { font-size: 0.8rem; }

/* ── Bento-style stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--container-gap);
  margin-bottom: 32px;
}

@media (max-width: 768px) {
  .promo-offer-grid, .stats-grid {
    display: flex !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 16px;
    padding: 10px 4px 20px;
    scrollbar-width: none;
  }
  .promo-offer-card, .stat-card {
    flex: 0 0 85%;
    scroll-snap-align: start;
  }
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--ease-out);
}
.stat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.stat-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* Icon Backgrounds with New Accent Colors */
.icon-teal, .stat-card.teal .stat-icon     { background: var(--accent-teal-light) !important; color: var(--accent-teal) !important; }
.icon-cyan, .stat-card.cyan .stat-icon     { background: var(--accent-cyan-light) !important; color: var(--accent-cyan) !important; }
.icon-coral, .stat-card.coral .stat-icon   { background: var(--accent-coral-light) !important; color: var(--accent-coral) !important; }
.icon-amber, .stat-card.amber .stat-icon   { background: var(--accent-amber-light) !important; color: var(--accent-amber) !important; }
.icon-emerald, .stat-card.emerald .stat-icon { background: var(--accent-emerald-light) !important; color: var(--accent-emerald) !important; }
.icon-maroon, .stat-card.maroon .stat-icon { background: var(--primary-light) !important; color: var(--primary) !important; }

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 600;
}
.stat-change {
  font-size: 0.82rem;
  margin-top: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-change a {
  color: inherit;
}

/* ── CARDS ── */
.card {
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 22px 52px rgba(17, 17, 17, 0.08);
  border: 1px solid rgba(122, 30, 44, 0.14);
  margin-bottom: 24px;
  transition: all 0.3s var(--ease-out);
  overflow: hidden;
  position: relative;
}
.card:hover {
  box-shadow: 0 26px 62px rgba(17, 17, 17, 0.12);
  border-color: rgba(122, 30, 44, 0.22);
}
.card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: var(--primary);
}
.card-header {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(122, 30, 44, 0.08);
  background: rgba(122, 30, 44, 0.05);
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-ink);
  letter-spacing: -0.01em;
}
.card-body {
  padding: 28px;
}

[data-theme='dark'] .card-header {
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}

/* ── TABLES ── */
.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid rgba(122, 30, 44, 0.10);
  background: #f5f1f2;
  box-shadow: 0 18px 40px rgba(17, 17, 17, 0.06);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #ffffff;
}
thead th {
  text-align: left;
  padding: 18px 20px;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  font-weight: 700;
  border-bottom: 2px solid var(--primary-dark);
  background-color: var(--primary);
}
tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:nth-child(even) {
  background-color: rgba(122, 30, 44, 0.02);
}

tbody tr:hover {
  background: rgba(122, 30, 44, 0.06);
  transition: background 0.2s var(--ease-out);
}

[data-theme='dark'] tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.03);
}

[data-theme='dark'] tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Theme loading overlay + loader (darkmode switch effect) */
.theme-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.theme-loading-overlay.open {
  display: flex;
}

/* HTML: <div class="loader"></div> */
.loader {
  width: 40px;
  aspect-ratio: 1;
  position: relative;
}
.loader:before,
.loader:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  margin: -8px 0 0 -8px;
  width: 16px;
  aspect-ratio: 1;
  background: #3FB8AF;
  animation:
    l1-1 2s  infinite,
    l1-2 .5s infinite;
}
.loader:after {
  background:#FF3D7F;
  animation-delay: -1s,0s;
}
@keyframes l1-1 {
  0%   {top:0   ;left:0}
  25%  {top:100%;left:0}
  50%  {top:100%;left:100%}
  75%  {top:0   ;left:100%}
  100% {top:0   ;left:0}
}
@keyframes l1-2 {
   80%,100% {transform: rotate(0.5turn)}
}

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: capitalize;
}
.badge-green { background: var(--accent-emerald-light); color: var(--accent-emerald); }
.badge-gold  { background: var(--accent-amber-light); color: var(--accent-amber); }
.badge-red   { background: rgba(220, 38, 38, 0.1); color: #dc2626; }
.badge-blue  { background: var(--accent-cyan-light); color: var(--accent-cyan); }
.badge-gray  { background: #f3f4f6; color: #6b7280; }
.badge-teal  { background: var(--accent-teal-light); color: var(--accent-teal); }
.badge-coral { background: var(--accent-coral-light); color: var(--accent-coral); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  font-family: var(--font-sans);
  text-decoration: none;
}
.btn:active {
  transform: scale(0.97);
}

/* Primary Button - Maroon Dominant */
.btn-primary {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 3px 10px rgba(122, 30, 44, 0.2) !important;
}
.btn-primary:hover {
  background-color: var(--primary-dark) !important;
  box-shadow: 0 6px 16px rgba(122, 30, 44, 0.25) !important;
}

/* Accent Button - Emerald Green */
.btn-accent {
  background-color: var(--accent-emerald) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.2) !important;
}
.btn-accent:hover {
  background-color: #047857 !important;
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.3) !important;
}

/* Secondary Button - Teal */
.btn-secondary {
  background-color: var(--accent-teal) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 3px 10px rgba(13, 148, 136, 0.2) !important;
}
.btn-secondary:hover {
  background-color: #0d7e7a !important;
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.3) !important;
}

/* Danger Button - Red */
.btn-danger {
  background-color: #dc2626 !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.2) !important;
}
.btn-danger:hover {
  background-color: #b91c1c !important;
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.3) !important;
}

/* Outline Button - Maroon */
.btn-outline {
  background-color: #ffffff !important;
  color: var(--primary) !important;
  border: 2px solid var(--primary) !important;
  box-shadow: none !important;
}
.btn-outline:hover {
  background-color: var(--primary-light) !important;
  border-color: var(--primary-dark) !important;
  box-shadow: 0 3px 10px rgba(122, 30, 44, 0.15) !important;
}
.btn-outline.active {
  background-color: var(--primary) !important;
  color: #ffffff !important;
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none !important;
}
.btn-ghost:hover {
  background: rgba(60, 0, 8, 0.08);
  color: var(--text);
  box-shadow: none !important;
}

/* Size variants */
.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
  padding: 12px;
}

/* ── FORMS ── */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.form-control {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  transition: all 0.2s var(--ease-out);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(122, 30, 44, 0.1);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}
.form-row.three {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ── SEARCH ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.85)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b9d91' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E")
    12px center no-repeat;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.search-input:focus {
  border-color: rgba(122, 30, 44, 0.45);
  box-shadow: 0 0 0 3px rgba(122, 30, 44, 0.12);
}
.filter-select {
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  outline: none;
  cursor: pointer;
}

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 540px;
  border: 1px solid rgba(60, 0, 8, 0.16);
  box-shadow: 0 32px 80px rgba(17, 17, 17, 0.12);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.35s var(--ease-out);
}
@keyframes modalIn {
  from {
    transform: translateY(28px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 22px;
  color: var(--primary-dark);
  letter-spacing: -0.03em;
}
.modal .form-label {
  color: #333333;
}
.modal .form-control {
  background: #ffffff;
  border-color: rgba(122, 30, 44, 0.18);
}
.modal .btn-outline {
  color: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
.modal .btn-outline:hover {
  background-color: rgba(60, 0, 8, 0.08) !important;
  border-color: rgba(60, 0, 8, 0.22) !important;
  box-shadow: 0 3px 10px rgba(60, 0, 8, 0.15) !important;
}
.modal .section-title {
  color: var(--primary);
  border-color: rgba(60, 0, 8, 0.12);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--primary-light);
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--primary);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
}
.modal-close:hover {
  background: var(--primary-soft-2);
  color: var(--primary-dark);
  transform: rotate(90deg);
}
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}
.tab-btn {
  padding: 10px 20px;
  background-color: transparent;
  color: var(--text-muted);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-size: 0.87rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  font-family: var(--font-sans);
}
.tab-btn:hover {
  color: var(--text);
  border-bottom-color: rgba(60, 0, 8, 0.2);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  padding: 16px 16px;
  border-radius: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.45s var(--ease-out), opacity 0.45s var(--ease-out);
  z-index: 99999;
  border-left: 4px solid var(--primary);
  max-width: min(420px, calc(100vw - 48px));
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: start;
  gap: 12px;
}
.toast__icon{
  width: 32px; height: 32px;
  border-radius: 10px;
  display:grid; place-items:center;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  font-size: 1rem;
}
.toast__content{
  padding-top: 4px;
  line-height: 1.4;
}
.toast__close{
  width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: all 0.2s var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast__close:hover{
  color: var(--text);
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.toast[data-type="success"]{ border-left-color: var(--accent-emerald); }
.toast[data-type="success"] .toast__icon { color: var(--accent-emerald); background: var(--accent-emerald-light); border-color: rgba(5, 150, 105, 0.2); }
.toast[data-type="warning"]{ border-left-color: var(--accent-amber); }
.toast[data-type="warning"] .toast__icon { color: var(--accent-amber); background: var(--accent-amber-light); border-color: rgba(217, 119, 6, 0.2); }
.toast[data-type="error"]{ border-left-color: #dc2626; }
.toast[data-type="error"] .toast__icon { color: #dc2626; background: rgba(220, 38, 38, 0.1); border-color: rgba(220, 38, 38, 0.2); }
.toast.show {
  transform: none;
  opacity: 1;
}

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  position: relative;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 90% 70% at 20% 20%, rgba(122, 30, 44, 0.16), transparent 50%),
    radial-gradient(ellipse 70% 50% at 85% 80%, rgba(122, 30, 44, 0.08), transparent 45%),
    linear-gradient(165deg, #ffffff 0%, #f5f5f5 100%);
}
.login-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("logo.png") center 22% / min(360px, 62vw) no-repeat;
  opacity: 0.18;
  pointer-events: none;
  z-index: -1;
}
.login-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: cardRise 0.7s var(--ease-out) both;
}
@keyframes cardRise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 36px;
}
.login-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.login-logo-content {
  text-align: left;
}
.login-logo .logo-text {
  font-size: clamp(1.6rem, 4vw, 2rem);
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1;
}
.login-logo .logo-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 8px;
  font-weight: 600;
}
.login-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.04em;
}
.login-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}
.login-footer {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.login-footer a {
  font-size: 0.83rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.login-footer a:hover {
  color: var(--neon-green);
}
.login-footer .link-accent {
  color: var(--neon-green);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  margin-bottom: 18px;
  border-left: 3px solid;
}
.alert-error {
  color: var(--primary-ink);
  background: rgba(60, 0, 8, 0.06);
  border-color: rgba(60, 0, 8, 0.30);
}
.alert-success {
  background: rgba(60, 0, 8, 0.04);
  color: var(--primary);
  border-color: rgba(60, 0, 8, 0.25);
}
.alert-info {
  background: rgba(59, 130, 246, 0.08);
  color: #1e3a8a;
  border-color: rgba(59, 130, 246, 0.35);
}

/* ── DASHBOARD HERO ── */
.dashboard-hero {
  position: relative;
  border-radius: var(--radius);
  padding: 40px 48px;
  margin-bottom: 32px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 20px 40px rgba(122, 30, 44, 0.2);
}

.dashboard-hero::before {
  content: '🌾';
  position: absolute;
  right: -20px;
  top: -10px;
  font-size: 10rem;
  opacity: 0.07;
  transform: rotate(-15deg);
  pointer-events: none;
}

.dashboard-hero h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dashboard-hero p {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 24px;
}

.dashboard-hero .actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dashboard-hero .btn-accent {
  background: #fff !important;
  color: var(--primary) !important;
  font-weight: 700;
}

.dashboard-hero .btn-outline {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
  backdrop-filter: blur(4px);
}

/* ── PREMIUM STAT CARDS ── */
.stat-card {
  border: 1px solid var(--border-strong);
  background: #fff;
  padding: 24px;
  border-radius: 20px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
  transition: all 0.3s var(--ease-out);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.08);
}

.stat-card.cyan    { border-bottom: 4px solid var(--accent-cyan); }
.stat-card.emerald { border-bottom: 4px solid var(--accent-emerald); }
.stat-card.teal    { border-bottom: 4px solid var(--accent-teal); }
.stat-card.amber   { border-bottom: 4px solid var(--accent-amber); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin-bottom: 16px;
  position: static; /* Move from absolute to top-left for cleaner layout */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.profile-header {
  display: flex;
  gap: 18px;
  align-items: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--primary-light);
  display: grid;
  place-items: center;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.1rem;
  border: 3px solid rgba(122,30,44,0.06);
}

.profile-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text);
}

.profile-sub {
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 20px;
}

.profile-field {
  background: var(--bg-soft);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.field-label { color: var(--text-muted); font-size: 0.82rem; font-weight:700; }
.field-value { font-weight:800; color: var(--text); margin-top:8px; }

/* Metric value color variants to add more accents */
.metric-value.capital { color: var(--accent-emerald); }
.metric-value.status { color: var(--accent-cyan); }
.metric-value.date { color: var(--text); }

/* Profile metric card visuals */
.profile-metric {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #ffffff);
  box-shadow: 0 8px 20px rgba(17,17,17,0.03);
}
.metric-label { color: var(--text-muted); font-size: 0.82rem; font-weight:700; }
.metric-value { font-weight:800; margin-top:8px; }

/* Metadata items: make them look like chips/cards */
.metadata-item {
  background: linear-gradient(180deg, #fff, #fff);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(17,17,17,0.03);
  border: 1px solid var(--border);
}
.metadata-item span { color: var(--text-muted); font-size: 0.82rem; display:block; }
.metadata-item strong { display:block; margin-top:8px; font-size:1rem; color:var(--text); }

/* ── QR / progress ── */
.qr-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 28px;
  text-align: center;
  margin: 18px 0;
  background: rgba(0, 0, 0, 0.15);
}
.qr-placeholder {
  width: 120px;
  height: 120px;
  margin: 0 auto 14px;
  background: repeating-conic-gradient(var(--border) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px;
  border-radius: 8px;
}
.progress-bar {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.55s var(--ease-out);
}

/* ── Scroll reveal (class added by app.js) ── */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  pointer-events: none;
  visibility: hidden;
  will-change: opacity, transform;
}

.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .stat-card:hover,
  .btn:active {
    transform: none;
  }
  .login-card {
    animation: none;
  }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -100%; /* Hide off-screen by default on mobile */
    top: 0;
    bottom: 0;
    z-index: 2000;
    transition: left 0.3s var(--ease-out);
    box-shadow: 20px 0 50px rgba(0,0,0,0.2);
  }

  .sidebar.open {
    left: 0; /* Slide in when toggled */
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
  }

  .sidebar-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    padding: 10px;
    transition: background 0.2s;
  }

  .sidebar-toggle__bar {
    display: block;
    width: 100%;
    height: 2px;
    background-color: #fff;
    border-radius: 1px;
  }

  .main-content {
    margin-left: 0;
    padding-top: 68px;
  }
  .member-datetime,
  .member-settings,
  .topbar img {
    display: none !important;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-row.three {
    grid-template-columns: 1fr;
  }
  .page-body {
    padding: 20px 16px calc(20px + var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 0 16px;
    min-height: 68px;
    left: 0;
    width: 100%;
  }

  .bottom-nav {
    display: flex;
    gap: 6px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    height: var(--bottom-nav-h);
    z-index: 1000;
    padding: 10px 10px;
    border-radius: 22px;
    background: rgba(122, 30, 44, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 -5px 25px rgba(0,0,0,0.1), 0 18px 40px rgba(17, 24, 39, 0.22);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(12px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.3s var(--ease-out);
  }

  .bottom-nav__item {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.78);
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 8px 6px;
    border-radius: 16px;
    transition: transform 0.2s var(--ease-out), background 0.2s var(--ease-out), color 0.2s var(--ease-out);
    flex: 0 0 72px;
    min-width: 72px;
  }

  .bottom-nav__item:active {
    transform: scale(0.98);
  }

  .bottom-nav__icon {
    font-size: 1.2rem;
    line-height: 1;
  }

  .bottom-nav__label {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1;
  }

  .bottom-nav__item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
  }
  
  .bottom-nav__item.active .bottom-nav__icon {
    transform: translateY(-2px);
  }

  .bottom-nav__item--primary {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
  }

  /* Mobile density + table usability */
  .member-welcome-banner {
    padding: 20px 18px;
  }

  .stats-grid {
    gap: 14px;
    padding: 6px 6px 16px;
  }
  .stat-card {
    flex: 0 0 75%; /* Slightly smaller for stats to see more items */
    padding: 20px 18px;
  }

  .card-header {
    padding: 18px 18px 12px;
  }
  .card-body {
    padding: 18px;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }
  .table-wrap table {
    min-width: 560px; /* horizontal scroll inside card, not page */
  }
  thead th {
    padding: 14px 16px;
  }
  tbody td {
    padding: 16px 16px;
  }
}

@media (max-width: 480px) {
  html {
    font-size: 15px;
  }
  .welcome-header h1 { font-size: 1.8rem; }
  .welcome-hero { padding: 24px 20px; }
  .pre-app-card { padding: 24px 16px; }
  .step-nav { flex-direction: column-reverse; gap: 8px; }
  .step-nav .btn { width: 100%; }
}

/* Make dashboard tables properly responsive without breaking structure */
@media (max-width: 900px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table {
    min-width: 560px;
    width: 100%;
    table-layout: auto;
  }
  thead th,
  tbody td {
    white-space: nowrap;
  }
  thead th {
    padding: 12px 14px;
  }
  tbody td {
    padding: 12px 14px;
  }
}

@media (max-width: 600px) {
  .card {
    border-radius: 14px;
  }
  .card-header {
    padding: 16px 16px 10px;
  }
  .card-body {
    padding: 16px;
  }
  .table-wrap table {
    min-width: 500px;
  }
  .table-wrap thead th {
    padding: 10px 12px;
    font-size: 0.72rem;
  }
  .table-wrap tbody td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }
}

/* ── UTILS ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 {
  gap: 8px;
}
.gap-3 {
  gap: 12px;
}
.mt-1 {
  margin-top: 4px;
}
.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 12px;
}
.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.text-sm {
  font-size: 0.82rem;
}
.fw-600 {
  font-weight: 600;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 22px;
}

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

/* ── Pre-application (membership form) ── */
.pre-app-inner {
  width: 100%;
  max-width: 1120px;
  padding: 20px;
}
.pre-app-card {
  background-color: #ffffff !important;
  border-radius: 20px;
  padding: 40px;
  border: 1px solid var(--primary-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  animation: cardRise 0.65s var(--ease-out) both;
  position: relative;
  overflow: hidden;
}

/* Wider “rectangle” form layout */
.pre-app-form-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
}
.pre-app-form-col {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}
.pre-app-section-card {
  border: 1px solid rgba(122, 30, 44, 0.18);
  border-radius: 16px;
  padding: 18px 18px 6px;
  background: #fff7f9;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 28px rgba(122, 30, 44, 0.1);
}
.pre-app-section-card > .section-title,
.pre-app-section-card > .form-group,
.pre-app-section-card > .form-row,
.pre-app-section-card > .step-nav,
.pre-app-section-card > .pre-app-actions {
  width: 100%;
}
body.auth-maroon .pre-app-section-card {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
}
.pre-app-section-card .section-title {
  margin-top: 6px;
  text-align: center;
}
.pre-app-actions {
  margin-top: 18px;
}
.pre-app-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
}

@media (max-width: 980px) {
  .pre-app-form-grid {
    grid-template-columns: 1fr;
  }
}

/* Spouse conditional visibility */
.is-hidden {
  display: none !important;
}
.pre-app-card--success {
  text-align: center;
  padding: 48px 40px;
}
.pre-app-emoji {
  font-size: 4rem;
  margin-bottom: 20px;
  line-height: 1;
}
.pre-app-headline {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}
.pre-app-lead {
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.65;
}
.pre-app-verify {
  background: rgba(122, 30, 44, 0.06);
  border: 1px solid rgba(122, 30, 44, 0.22);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 24px;
  color: var(--primary);
  font-size: 0.88rem;
}
.pre-app-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}
.pre-app-intro {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 0.92rem;
}

.pre-app-title,
.pre-app-intro,
.pre-app-headline,
.pre-app-lead,
.pre-app-verify {
  text-align: center;
}

.pre-app-card .form-label {
  text-align: center;
}
.pre-app-notice {
  background: rgba(15, 23, 42, 0.03);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.84rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.required-mark {
  color: var(--danger);
}

/* ── Password Visibility Toggle ── */
.password-toggle-wrapper {
  position: relative;
  width: 100%;
}
.password-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
}

/* Member Specific Styles */
.member-welcome-banner {
  background: var(--primary) !important;
  border-radius:var(--radius);
  padding:28px 32px;
  margin-bottom:24px;
  color:#fff;
  position:relative;
  overflow:hidden;
}
.member-welcome-banner::before {
  content:'🌾';
  position:absolute;
  right:-20px;
  top:-20px;
  font-size:6rem;
  opacity:0.08;
}
.member-welcome-banner .btn {
  background:rgba(255,255,255,0.15);
  color:#fff;
}
.member-welcome-banner .btn-accent {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ── Member settings (top right) ── */
.member-settings {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.member-settings__btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}
.member-settings__btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.member-settings__label {
  font-weight: 700;
}
.member-settings__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 120;
}
.member-settings__menu.open {
  display: block;
}
.member-settings__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
}
.member-settings__item:hover {
  background: rgba(122, 30, 44, 0.06);
}
.member-settings__item--danger {
  color: #b91c1c;
}

.loan-info-box {
  background:var(--bg);
  border-radius:10px;
  padding:16px;
  margin-bottom:16px;
}

.section-title {
  font-family:var(--font-display);
  font-size:1.2rem;
  font-weight:700;
  color:var(--primary);
  margin-bottom:16px;
  margin-top:24px;
  border-bottom:1px solid var(--border);
  padding-bottom:8px;
}

.dependent-card,
.beneficiary-card {
  background: #fff7f9;
  border: 1px solid rgba(122, 30, 44, 0.2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 18px rgba(122, 30, 44, 0.08);
}

/* ── Member pre-application page ── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

body.auth-maroon {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

body.auth-maroon .pre-app-wrapper {
  width: min(100%, 920px);
  margin: auto;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 30px 50px rgba(17, 24, 39, 0.12);
  overflow: hidden;
  animation: slideUp 0.45s var(--ease-out);
}

body.auth-maroon .pre-app-header {
  padding: 38px 36px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f2f2 100%);
  border-bottom: 1px solid rgba(60, 0, 8, 0.06);
}

body.auth-maroon .pre-app-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
}

body.auth-maroon .pre-app-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

body.auth-maroon .pre-app-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), #a8324c);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.35rem;
}

body.auth-maroon .pre-app-header-title h1 {
  font-size: 1.65rem;
  margin-bottom: 6px;
}

body.auth-maroon .pre-app-header-title p {
  font-size: 0.95rem;
}

body.auth-maroon .pre-app-clear-btn {
  padding: 12px 18px;
  border: 1.5px solid rgba(60, 0, 8, 0.10);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-muted);
  border-radius: 12px;
  transition: all 0.2s ease;
}

body.auth-maroon .pre-app-clear-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(250, 250, 250, 0.95);
}

body.auth-maroon .pre-app-content {
  padding: 32px 36px 40px;
  max-width: 860px;
  margin: 0 auto;
}

body.auth-maroon .step-card { display: none; }
body.auth-maroon .step-card.active { display: block; animation: fadeIn 0.3s ease-in; }

body.auth-maroon .step-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
  padding-top: 22px;
  border-top: 1px solid rgba(60, 0, 8, 0.06);
}

body.auth-maroon .step-nav .btn { min-width: 110px; }

body.auth-maroon .section-header-meta {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
  display: block;
}

body.auth-maroon .pre-app-progress-bar {
  height: 10px;
  background: rgba(60, 0, 8, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 30px;
}

body.auth-maroon .pre-app-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #c96d84);
  width: 0%;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

body.auth-maroon .form-control {
  padding: 12px 15px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: #ffffff;
  border-radius: 12px;
}

body.auth-maroon .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60, 0, 8, 0.12);
}

body.auth-maroon .form-label {
  font-weight: 700;
  margin-bottom: 8px;
}

body.auth-maroon .form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

body.auth-maroon .form-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.auth-maroon .form-group { margin-bottom: 0; }

body.auth-maroon .checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
body.auth-maroon .checkbox-item { padding: 10px 14px; background: #fff; border: 1px solid rgba(122, 30, 44, 0.08); border-radius: 12px; }

body.auth-maroon .alert { border-left-width: 4px; }

body.auth-maroon .card { background: #ffffff; border: 1px solid rgba(148, 163, 184, 0.18); }

body.auth-maroon .pre-app-section-card { margin-bottom: 0; }

body.auth-maroon .pre-app-form-grid { display: grid; gap: 0; }

body.auth-maroon .btn-primary {
  background: linear-gradient(135deg, var(--primary), #a8324c);
  color: #ffffff;
}

body.auth-maroon .btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(60, 0, 8, 0.25);
}

body.auth-maroon .beneficiary-card,
body.auth-maroon .dependent-card {
  background: #fff7f9;
  border: 1px solid rgba(122, 30, 44, 0.14);
  box-shadow: 0 8px 18px rgba(122, 30, 44, 0.06);
}

body.auth-maroon .input-help { color: var(--text-muted); }

body.auth-maroon .pre-app-emoji { color: var(--success); }

body.auth-maroon .pre-app-headline { font-size: 1.9rem; }

body.auth-maroon .pre-app-lead { color: var(--text-muted); }

body.auth-maroon .pre-app-verify { border-color: #86efac; }

body.auth-maroon .pre-app-actions { flex-wrap: wrap; gap: 10px; }

body.auth-maroon .progress-card { background: rgba(122, 30, 44, 0.04); border-color: rgba(122, 30, 44, 0.1); }

body.auth-maroon .progress-card-label { color: var(--primary-dark); }

body.auth-maroon .progress-card-percent { color: var(--primary); }

body.auth-maroon .email-verify-container,
body.auth-maroon .success-container { max-width: 680px; margin: 0 auto; }

@media (max-width: 900px) {
  body.auth-maroon .pre-app-wrapper { width: calc(100% - 32px); margin: auto; }
  body.auth-maroon .pre-app-header, body.auth-maroon .pre-app-content { padding-left: 24px; padding-right: 24px; }
  body.auth-maroon .pre-app-header-content { flex-direction: column; align-items: stretch; text-align: center; }
  body.auth-maroon .pre-app-header-left { justify-content: center; }
  body.auth-maroon .form-row, body.auth-maroon .form-row.three { grid-template-columns: 1fr; }
}

/* ── Email Verification Screen ── */
.email-verify-container { text-align: center; padding: 10px 0; max-width: 480px; margin: 0 auto; }
.email-verify-header { margin-bottom: 32px; }
.email-verify-title { 
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--font-display); font-size: 1.65rem; font-weight: 800; color: var(--primary);
  margin-bottom: 8px;
}
.email-verify-subtitle { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

/* ── Progress Card Details ── */
.progress-card {
  background: #ffffff; border: 1px solid rgba(122, 30, 44, 0.12); border-radius: 16px;
  padding: 22px; margin-bottom: 32px; box-shadow: 0 8px 24px rgba(122, 30, 44, 0.04);
}
.progress-card-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.progress-card-label { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: var(--text); }
.progress-card-percent { font-weight: 800; font-size: 0.88rem; color: var(--primary); background: var(--primary-light); padding: 4px 10px; border-radius: 8px; }

/* ── Dynamic Form Elements ── */
.btn-remove-beneficiary, .btn-remove-dependent { 
  transition: all 0.2s var(--ease-out); border-radius: 8px !important;
}
.btn-remove-beneficiary:hover, .btn-remove-dependent:hover {
  background: var(--danger) !important; transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

/* ── Help Center Specific Styles ── */
.help-header {
  background: var(--primary);
  color: #fff;
  padding: 60px 24px;
  text-align: center;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--primary-dark);
}

.help-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.tabs-wrapper {
  overflow-x: auto;
  margin-bottom: 32px;
  scrollbar-width: none; /* Firefox */
}
.tabs-wrapper::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.help-container .tabs {
  border-bottom: 1px solid var(--border-strong);
  justify-content: center;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  border: 1px solid var(--primary-border);
}

.guide-step {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
  position: relative;
}

.step-number {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(122, 30, 44, 0.2);
}

.step-content h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.help-center-card-footer {
  padding: 24px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  text-align: center;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
