/* ========= ROOT VARIABLES ========= */
:root {
  --bg-dark: #0a0f1e;
  --bg-card: #111827;
  --bg-sidebar: #0d1424;
  --bg-input: #1a2236;
  --border: #1e2d45;
  --text-primary: #e8edf5;
  --text-secondary: #8a9bb5;
  --text-muted: #4a5a72;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-glow: rgba(16,185,129,0.15);
  --blue: #3b82f6;
  --blue-glow: rgba(59,130,246,0.15);
  --orange: #f59e0b;
  --orange-glow: rgba(245,158,11,0.15);
  --red: #ef4444;
  --red-glow: rgba(239,68,68,0.15);
  --purple: #8b5cf6;
  --purple-glow: rgba(139,92,246,0.15);
  --sidebar-width: 260px;
  --topbar-height: 65px;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ========= RESET ========= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
input, select, textarea, button { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ========= SCROLLBAR ========= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ========= SIDEBAR ========= */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: var(--transition);
  overflow-y: auto;
}
.sidebar-header {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), #064e3b);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  color: white;
  box-shadow: 0 0 20px var(--accent-glow);
}
.logo-text { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.logo-text .accent { color: var(--accent); }
.logo-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }
.close-sidebar {
  display: none;
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 1.1rem;
  padding: 6px;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}
.nav-link i { width: 18px; font-size: 0.9rem; }
.nav-link:hover { background: var(--bg-input); color: var(--text-primary); }
.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(16,185,129,0.2);
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

/* ========= MAIN WRAPPER ========= */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

/* ========= TOPBAR ========= */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-height);
  background: rgba(17,24,39,0.9);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}
.menu-btn {
  display: none;
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer;
  font-size: 1.2rem; padding: 6px;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.date-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: white;
}

/* ========= CONTENT ========= */
.content { flex: 1; padding: 28px 24px; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ========= PAGE HEADER ========= */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.6rem; font-weight: 800; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 2px; }

/* ========= STAT CARDS ========= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card.green::before { background: var(--accent); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.red::before { background: var(--red); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card.green .stat-icon { background: var(--accent-glow); color: var(--accent); }
.stat-card.blue .stat-icon { background: var(--blue-glow); color: var(--blue); }
.stat-card.orange .stat-icon { background: var(--orange-glow); color: var(--orange); }
.stat-card.red .stat-icon { background: var(--red-glow); color: var(--red); }
.stat-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ========= DASHBOARD GRID ========= */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ========= CARDS ========= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.card-header h2 {
  font-size: 0.95rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-primary);
}
.card-header h2 i { color: var(--accent); }
.card-body { padding: 20px; overflow-x: auto; }
.mt-20 { margin-top: 20px; }

/* ========= QUICK STATS ========= */
.quick-stats { display: flex; flex-direction: column; gap: 14px; }
.qs-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.qs-label { font-size: 0.82rem; color: var(--text-secondary); }
.qs-value { font-size: 0.95rem; font-weight: 700; }
.qs-value.highlight { color: var(--accent); }

/* ========= TABLE ========= */
.table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
  min-width: 550px;
}
.table thead tr {
  background: var(--bg-input);
}
.table th {
  padding: 12px 14px; text-align: left;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table tbody tr:last-child td { border-bottom: none; }
.empty-msg { text-align: center; color: var(--text-muted); font-style: italic; padding: 32px !important; }

/* ========= SEARCH & FILTERS ========= */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 16px;
}
.search-bar i { color: var(--text-muted); }
.search-bar input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 0.88rem; width: 100%;
}
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar select {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
  color: var(--text-primary); font-size: 0.85rem; cursor: pointer;
}

/* ========= BUTTONS ========= */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: white;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-input); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 0.76rem; border-radius: 7px; }
.btn-danger { background: var(--red-glow); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-info { background: var(--blue-glow); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }

/* ========= BADGES ========= */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
}
.badge-green { background: var(--accent-glow); color: var(--accent); }
.badge-orange { background: var(--orange-glow); color: var(--orange); }
.badge-red { background: var(--red-glow); color: var(--red); }
.badge-blue { background: var(--blue-glow); color: var(--blue); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ========= MEETINGS ========= */
.meetings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.meeting-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: var(--transition);
}
.meeting-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.meeting-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.meeting-card h3 { font-size: 0.95rem; font-weight: 700; }
.meeting-date { font-size: 0.78rem; color: var(--accent); font-weight: 600; }
.meeting-detail { font-size: 0.8rem; color: var(--text-muted); margin: 4px 0; }
.meeting-detail span { color: var(--text-secondary); }
.meeting-minutes { margin-top: 10px; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }
.empty-card {
  grid-column: 1/-1; text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-card i { font-size: 3rem; margin-bottom: 12px; display: block; }

/* ========= REPORTS ========= */
.reports-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.report-card {
  padding: 28px 24px; text-align: center;
  transition: var(--transition); cursor: default;
}
.report-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.report-icon {
  width: 56px; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin: 0 auto 16px;
}
.report-icon.green { background: var(--accent-glow); color: var(--accent); }
.report-icon.blue { background: var(--blue-glow); color: var(--blue); }
.report-icon.orange { background: var(--orange-glow); color: var(--orange); }
.report-icon.purple { background: var(--purple-glow); color: var(--purple); }
.report-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.report-card p { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 18px; line-height: 1.5; }

/* ========= MODALS ========= */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 500;
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-header h2 {
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.modal-header h2 i { color: var(--accent); }
.close-modal {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 1.1rem; padding: 4px;
  transition: color 0.2s;
}
.close-modal:hover { color: var(--text-primary); }
.modal-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  position: sticky; bottom: 0; background: var(--bg-card);
}

/* ========= FORM ELEMENTS ========= */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  color: var(--text-primary); font-size: 0.88rem;
  outline: none; transition: border-color 0.2s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-group select { cursor: pointer; }
.readonly-input { opacity: 0.6; cursor: not-allowed; }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }

/* ========= TOAST ========= */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-card); border: 1px solid var(--accent);
  color: var(--text-primary); padding: 14px 20px;
  border-radius: 12px; display: flex; align-items: center; gap: 10px;
  font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--shadow); z-index: 1000;
  transform: translateY(100px); opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast i { color: var(--accent); }
.toast.show { transform: translateY(0); opacity: 1; }

/* ========= RESPONSIVE ========= */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 40px rgba(0,0,0,0.5); }
  .close-sidebar { display: block; }
  .main-wrapper { margin-left: 0; }
  .menu-btn { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 14px; }
  .topbar { padding: 0 14px; }
  .date-badge { display: none; }
  .page-header h1 { font-size: 1.2rem; }
  .modal { border-radius: 14px; }
}

/* ========= PROGRESS BAR ========= */
.progress-bar-wrap {
  background: var(--bg-input); border-radius: 99px; height: 6px; overflow: hidden;
}
.progress-bar { height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.5s ease; }

/* ========= PRINT STYLES ========= */
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { position: fixed; inset: 0; background: white; color: black; padding: 30px; }
}

/* ========= M-PESA BUTTON ========= */
.btn-mpesa {
  background: linear-gradient(135deg, #00a651, #005a2d);
  color: white; border: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.btn-mpesa:hover { background: linear-gradient(135deg, #00c460, #006b35); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,166,81,0.3); }

/* ========= USER INFO (Sidebar) ========= */
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--bg-input); border-radius: 10px;
  border: 1px solid var(--border);
}
.user-name { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); }
.user-email { font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

/* ========= LOGOUT BUTTON ========= */
.logout-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: 1px solid var(--border);
  width: 100%; justify-content: center;
}
.logout-btn:hover { background: var(--red-glow); color: var(--red); border-color: rgba(239,68,68,0.2); }

/* ========= USER AVATAR (Topbar) ========= */
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: white;
  overflow: hidden; position: relative;
  cursor: pointer; flex-shrink: 0;
}

