/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --navy:    #1a3a5c;
  --gold:    #c9a227;
  --gold-lt: #e8c55c;
  --green:   #2e7d32;
  --red:     #c62828;
  --orange:  #e65100;
  --bg:      #f0f4f8;
  --card:    #ffffff;
  --border:  #dde3ea;
  --text:    #1e2d3e;
  --muted:   #6b7b8d;
  --sidebar-w: 240px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Auth Page ─────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--navy) 0%, #0d2540 60%, #122b48 100%);
}

.auth-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px;
  color: #fff;
  text-align: center;
}

.auth-brand .logo-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 24px;
  box-shadow: 0 4px 24px rgba(201,162,39,0.4);
}

.auth-brand h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.auth-brand h2 { font-size: 16px; font-weight: 400; opacity: 0.75; max-width: 320px; }

.auth-brand .tagline {
  margin-top: 40px;
  padding: 16px 24px;
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 13px;
  opacity: 0.85;
  max-width: 340px;
}

.auth-panel {
  width: 440px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 40px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 32px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.auth-tab.active { color: var(--navy); border-bottom-color: var(--gold); }
.auth-tab:hover  { color: var(--navy); }

.auth-form { display: none; }
.auth-form.active { display: block; }

.auth-form h3 { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.auth-form p  { font-size: 13px; color: var(--muted); margin-bottom: 24px; }

/* ── Form Elements ─────────────────────────────────────────────── */
.form-row { display: flex; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; flex: 1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.form-group input,
.form-group select,
.form-group textarea {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #fafbfc;
  transition: border-color .15s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  width: 100%;
  padding: 12px;
  font-size: 15px;
}
.btn-primary:hover { background: #0d2540; }

.btn-gold {
  background: var(--gold);
  color: var(--navy);
}
.btn-gold:hover { background: var(--gold-lt); }

.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: #fff;
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-pdf {
  border: 1.5px solid var(--navy);
  color: var(--navy);
  background: #fff;
  gap: 5px;
}
.btn-pdf:hover { background: var(--navy); color: #fff; }

.error-msg {
  color: var(--red);
  font-size: 12px;
  padding: 10px 12px;
  background: #fde8e8;
  border-radius: 6px;
  margin-bottom: 16px;
  display: none;
}

/* ── App Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .logo-sm {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--navy);
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text { line-height: 1.3; }
.sidebar-brand .brand-text strong { font-size: 13px; display: block; }
.sidebar-brand .brand-text span   { font-size: 11px; opacity: .6; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section { padding: 16px 20px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: .45; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13.5px;
  color: rgba(255,255,255,0.75);
  border-left: 3px solid transparent;
  transition: all .15s;
}

.nav-item:hover   { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active  { background: rgba(201,162,39,0.15); color: #fff; border-left-color: var(--gold); }
.nav-item .icon   { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--navy);
  font-size: 13px;
  flex-shrink: 0;
}

.user-info .user-name  { font-size: 13px; font-weight: 600; }
.user-info .user-email { font-size: 11px; opacity: .55; }

.btn-logout {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 600;
  transition: all .15s;
  text-align: center;
}
.btn-logout:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h2 { font-size: 16px; font-weight: 700; color: var(--navy); }
.topbar .topbar-right { display: flex; align-items: center; gap: 12px; }

.page { display: none; padding: 28px; }
.page.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.card-body  { padding: 20px; }

/* ── KPI Grid ──────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card .kpi-icon  { font-size: 24px; margin-bottom: 4px; }
.kpi-card .kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.kpi-card .kpi-value { font-size: 26px; font-weight: 800; color: var(--navy); }
.kpi-card .kpi-sub   { font-size: 11px; color: var(--muted); }

.kpi-card.kpi-green  { border-left: 4px solid var(--green); }
.kpi-card.kpi-gold   { border-left: 4px solid var(--gold); }
.kpi-card.kpi-orange { border-left: 4px solid var(--orange); }
.kpi-card.kpi-navy   { border-left: 4px solid var(--navy); }
.kpi-card.kpi-red    { border-left: 4px solid var(--red); }

/* ── Membership Card ───────────────────────────────────────────── */
.membership-card {
  background: linear-gradient(135deg, var(--navy) 0%, #0d2540 100%);
  border-radius: 16px;
  padding: 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

.membership-card::after {
  content: 'CDMA';
  position: absolute;
  right: -10px; top: -20px;
  font-size: 120px;
  font-weight: 900;
  opacity: 0.04;
  color: #fff;
}

.membership-card .card-row { display: flex; align-items: flex-start; justify-content: space-between; }
.membership-card .member-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.membership-card .member-email { font-size: 13px; opacity: .65; }
.membership-card .tier-badge {
  background: var(--gold);
  color: var(--navy);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.membership-card .card-details { margin-top: 28px; display: flex; gap: 32px; }
.membership-card .detail-label { font-size: 10px; font-weight: 600; text-transform: uppercase; opacity: .55; margin-bottom: 2px; }
.membership-card .detail-value { font-size: 15px; font-weight: 700; }

/* ── Status Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.badge-paid     { background: #e8f5e9; color: var(--green); }
.badge-pending  { background: #fff3e0; color: var(--orange); }
.badge-failed   { background: #fde8e8; color: var(--red); }
.badge-board    { background: rgba(26,58,92,0.1); color: var(--navy); }
.badge-admin    { background: rgba(201,162,39,0.15); color: #8a6a0a; }
.badge-basic    { background: #e3f2fd; color: #1565c0; }
.badge-professional { background: #f3e5f5; color: #6a1b9a; }
.badge-corporate    { background: #e8f5e9; color: var(--green); }
.badge-institutional{ background: rgba(201,162,39,0.15); color: #8a6a0a; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f8f9fb; }
td { font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fb; }

/* ── Charts ────────────────────────────────────────────────────── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); padding: 20px; }
.chart-card h4 { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 16px; }
.chart-container { position: relative; height: 220px; }

/* ── Filters ───────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
}

.filters select,
.filters input {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--navy);
}

/* ── Benefits List ─────────────────────────────────────────────── */
.benefits-list { list-style: none; }
.benefits-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.benefits-list li:last-child { border-bottom: none; }
.benefits-list li::before { content: '✓'; color: var(--green); font-weight: 700; }

/* ── Progress Bars ─────────────────────────────────────────────── */
.progress-bar-wrap { background: var(--bg); border-radius: 6px; height: 8px; overflow: hidden; margin-top: 4px; }
.progress-bar { height: 100%; border-radius: 6px; transition: width .4s; }
.progress-bar.green  { background: var(--green); }
.progress-bar.gold   { background: var(--gold); }
.progress-bar.navy   { background: var(--navy); }
.progress-bar.orange { background: var(--orange); }

/* ── Utilities ─────────────────────────────────────────────────── */
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.mt-6  { margin-top: 24px; }
.text-muted  { color: var(--muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-bold   { font-weight: 700; }
.currency::before { content: '$'; }

/* ── Loading / Empty ───────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* ── Mobile menu toggle ────────────────────────────────────────── */
.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.menu-toggle:hover { background: var(--border); }

/* ── Sidebar overlay ───────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.show { display: block; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .auth-brand { display: none; }
  .auth-panel { width: 100%; padding: 40px 24px; }
  .chart-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  /* Sidebar */
  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 100; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }

  /* Hamburger button */
  .menu-toggle { display: flex; }

  /* Topbar */
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar h2 { font-size: 15px; }
  .topbar-date { display: none; }

  /* Pages */
  .page { padding: 14px; }

  /* KPI grid — 2 columns on mobile */
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* Membership card */
  .membership-card { padding: 20px; }
  .membership-card .card-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .membership-card .member-name { font-size: 18px; }
  .membership-card .card-details { flex-wrap: wrap; gap: 16px; margin-top: 16px; }

  /* Stack form rows */
  .form-row { flex-direction: column; gap: 0; }

  /* Touch-friendly targets */
  .btn { min-height: 44px; }
  .btn-primary { font-size: 15px; }
  .nav-item { min-height: 44px; padding: 12px 20px; }

  /* Filters */
  .filters { gap: 8px; }
  .filters select,
  .filters input { flex: 1 1 140px; min-width: 0; }

  /* Charts single column */
  .chart-grid { grid-template-columns: 1fr; }

  /* Modals */
  .modal-box { max-height: 95vh; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .modal-footer .btn { flex: 1; }
}

/* Very small screens */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .auth-panel { padding: 32px 18px; }
  .kpi-card .kpi-value { font-size: 22px; }
}

/* ── Notification ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  transform: translateY(60px);
  opacity: 0;
  transition: all .3s;
  z-index: 9999;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); background: #c62828; }

/* ── Admin Mode ─────────────────────────────────────────────────── */
.admin-btn { display: none !important; }
body.admin-mode .admin-btn { display: inline-flex !important; }

th.admin-th { display: none; }
body.admin-mode th.admin-th { display: table-cell; }

td.admin-td { display: none; white-space: nowrap; }
body.admin-mode td.admin-td { display: table-cell; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .15s;
  flex-shrink: 0;
}
.btn-icon.btn-edit   { background: rgba(26,58,92,0.08);  color: var(--navy); }
.btn-icon.btn-delete { background: rgba(198,40,40,0.08); color: var(--red); margin-left: 4px; }
.btn-icon.btn-edit:hover   { background: var(--navy); color: #fff; }
.btn-icon.btn-delete:hover { background: var(--red);  color: #fff; }

/* ── Modal Overlay ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
  overflow: hidden;
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: translateY(-12px) scale(.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--navy); }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-body .form-group { margin-bottom: 14px; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #f8f9fb;
  flex-shrink: 0;
}

.modal-error {
  color: var(--red);
  font-size: 12px;
  padding: 8px 12px;
  background: #fde8e8;
  border-radius: 6px;
  margin-bottom: 14px;
  display: none;
}

/* ── Confirm Dialog ─────────────────────────────────────────────── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.52);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }

.confirm-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px 24px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.22);
  text-align: center;
  animation: modalIn .18s ease;
}
.confirm-box .confirm-icon { font-size: 36px; margin-bottom: 12px; }
.confirm-box p { font-size: 14px; color: var(--text); margin-bottom: 22px; line-height: 1.7; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
