


/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;800&family=Sora:wght@300;400;500;600;700&display=swap');

/* ════════════════════════════════════════════════════════
   1. DESIGN TOKENS
════════════════════════════════════════════════════════ */
:root {
  /* Green scale */
  --green-950: #0d1f13;
  --green-900: #1a3a22;
  --green-800: #1b4332;
  --green-700: #2d6a4f;
  --green-600: #40916c;
  --green-500: #52b788;
  --green-400: #74c69d;
  --green-300: #95d5b2;
  --green-200: #b7e4c7;
  --green-100: #d8f3dc;
  --green-50:  #f0fdf4;

  /* Amber / warm accent */
  --amber-700: #b45309;
  --amber-600: #d97706;
  --amber-500: #f59e0b;
  --amber-400: #f4a261;
  --amber-300: #fcd34d;
  --amber-100: #fef3c7;
  --amber-50:  #fffbeb;

  /* Status */
  --red-700:   #b91c1c;
  --red-600:   #dc2626;
  --red-100:   #fee2e2;
  --red-50:    #fef2f2;
  --blue-700:  #1d4ed8;
  --blue-600:  #2563eb;
  --blue-100:  #dbeafe;
  --blue-50:   #eff6ff;
  --purple-700:#6d28d9;
  --purple-600:#7c3aed;
  --purple-100:#ede9fe;
  --purple-50: #f5f3ff;

  /* Neutral */
  --gray-950:  #030712;
  --gray-900:  #111827;
  --gray-800:  #1f2937;
  --gray-700:  #374151;
  --gray-600:  #4b5563;
  --gray-500:  #6b7280;
  --gray-400:  #9ca3af;
  --gray-300:  #d1d5db;
  --gray-200:  #e5e7eb;
  --gray-100:  #f3f4f6;
  --gray-50:   #f9fafb;

  /* Semantic aliases */
  --text-primary:   var(--gray-900);
  --text-secondary: var(--gray-700);
  --text-muted:     var(--gray-500);
  --text-faint:     var(--gray-400);
  --border:         var(--gray-200);
  --border-strong:  var(--gray-300);

  /* Backgrounds */
  --bg:        #f0ebe3;
  --bg-tinted: #ede7df;
  --surface:   #ffffff;
  --surface-2: #faf8f5;
  --surface-3: #f5f1ec;

  /* Brand aliases (used throughout components) */
  --green-primary:  var(--green-700);
  --green-light:    var(--green-300);
  --amber:          var(--amber-400);
  --bg-card:        var(--surface);
  --bg-sidebar:     var(--gray-50);
  --bg-hover:       var(--gray-50);

  /* Layout */
  --sidebar-w:  240px;
  --topbar-h:   64px;

  /* Radii */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-2xl: 28px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-md: 0 8px 20px rgba(0,0,0,.1),  0 3px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.12), 0 6px 10px rgba(0,0,0,.07);
  --shadow-xl: 0 24px 60px rgba(0,0,0,.16), 0 8px 16px rgba(0,0,0,.08);

  /* Transitions */
  --ease:      cubic-bezier(.4,0,.2,1);
  --ease-out:  cubic-bezier(0,0,.2,1);
  --ease-in:   cubic-bezier(.4,0,1,1);
  --fast:      120ms;
  --normal:    200ms;
  --slow:      350ms;
}

/* ════════════════════════════════════════════════════════
   2. RESET & BASE
════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Sora', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-secondary);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--green-700);
  text-decoration: none;
  transition: color var(--fast) var(--ease);
}
a:hover { color: var(--green-600); }

img, svg { display: block; }

button { font-family: inherit; }

input, select, textarea {
  font-family: inherit;
}

/* ════════════════════════════════════════════════════════
   3. SIDEBAR
════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--green-950);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--slow) var(--ease);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--green-900) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--green-900); border-radius: 2px; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-brand:hover { background: rgba(255,255,255,.03); }

.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--amber-400), var(--amber-600));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--green-950);
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(244,162,97,.35);
}

.brand-text { overflow: hidden; }
.brand-name    { display: block; font-size: .92rem; font-weight: 700; color: #fff; letter-spacing: .01em; white-space: nowrap; }
.brand-tagline { display: block; font-size: .63rem; color: var(--green-400); font-weight: 400; white-space: nowrap; margin-top: 1px; }

/* Nav */
.sidebar-nav { padding: .6rem 0; flex: 1; }

.nav-group { margin-bottom: .25rem; }

.nav-group-label {
  display: block;
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--green-600);
  padding: .65rem 1rem .2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .52rem 1rem;
  color: #a7c8b5;
  font-size: .81rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
  white-space: nowrap;
}
.nav-item:hover  { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: var(--green-900);
  color: var(--amber-400);
  border-left-color: var(--amber-400);
}

.nav-icon { font-size: .95rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge-count {
  margin-left: auto;
  background: var(--amber-600);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  padding: .08rem .45rem;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Footer */
.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.version { font-size: .63rem; color: var(--green-600); }

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ════════════════════════════════════════════════════════
   4. MAIN WRAPPER & TOPBAR
════════════════════════════════════════════════════════ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--slow) var(--ease);
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-xs);
}

.topbar-left  { display: flex; align-items: center; gap: .9rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--gray-600);
  padding: .3rem; border-radius: var(--radius-sm);
  display: none; align-items: center; justify-content: center;
  transition: color var(--fast) var(--ease);
}
.sidebar-toggle:hover { color: var(--gray-900); }

.page-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* User pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: var(--gray-100);
  border-radius: 40px;
  padding: .28rem .75rem .28rem .28rem;
  cursor: pointer;
  transition: background var(--fast) var(--ease);
}
.user-pill:hover { background: var(--gray-200); }

.user-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .76rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-info   { display: flex; flex-direction: column; }
.user-name   { font-size: .78rem; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.user-role   { font-size: .63rem; color: var(--text-muted); }

.topbar-icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.topbar-icon-btn:hover { background: var(--gray-100); color: var(--gray-900); }

.logout-btn { color: var(--gray-500); text-decoration: none; font-size: .95rem; }
.logout-btn:hover { color: var(--red-600); }

/* Notification dot */
.notif-dot {
  position: relative;
}
.notif-dot::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red-600);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* ════════════════════════════════════════════════════════
   5. FLASH MESSAGES
════════════════════════════════════════════════════════ */
.flash {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.5rem;
  font-size: .84rem;
  font-weight: 500;
}
.flash-success { background: var(--green-50);  color: #166534; border-bottom: 2px solid var(--green-200); }
.flash-error   { background: var(--red-50);    color: var(--red-700); border-bottom: 2px solid var(--red-100); }
.flash-warning { background: var(--amber-50);  color: var(--amber-700); border-bottom: 2px solid var(--amber-100); }
.flash-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: inherit; opacity: .55;
  line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* ════════════════════════════════════════════════════════
   6. PAGE CONTENT
════════════════════════════════════════════════════════ */
.page-content {
  padding: 1.5rem;
  flex: 1;
  max-width: 1440px;
  width: 100%;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h2, .page-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.page-subtitle {
  font-size: .82rem;
  color: var(--text-muted);
  margin: .2rem 0 0;
}

/* ════════════════════════════════════════════════════════
   7. CARDS
════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: .75rem;
}

.card-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.card-body { padding: 1.25rem; }

/* ════════════════════════════════════════════════════════
   8. STAT CARDS
════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: box-shadow var(--normal) var(--ease), transform var(--normal) var(--ease);
  cursor: default;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card.accent {
  border-color: var(--green-300);
  background: linear-gradient(135deg, #f0fdf4, #e8f5e9);
}

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.stat-icon.green  { background: var(--green-100); color: var(--green-700); }
.stat-icon.amber  { background: var(--amber-100); color: var(--amber-600); }
.stat-icon.blue   { background: var(--blue-100);  color: var(--blue-600); }
.stat-icon.purple { background: var(--purple-100);color: var(--purple-600); }
.stat-icon.red    { background: var(--red-100);   color: var(--red-600); }

.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: .74rem; color: var(--text-muted); font-weight: 500; }
.stat-sub   { font-size: .7rem;  color: var(--green-600); font-weight: 600; }

/* ════════════════════════════════════════════════════════
   9. TABLES
════════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}

thead th {
  background: var(--gray-50);
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .68rem 1rem;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--fast) var(--ease);
}
tbody tr:hover   { background: var(--gray-50); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: .72rem 1rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

tfoot td {
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .8rem;
  color: var(--text-muted);
  background: var(--gray-50);
  border-top: 1px solid var(--border);
}

td.actions { white-space: nowrap; }

/* ════════════════════════════════════════════════════════
   10. BUTTONS
════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-family: 'Sora', sans-serif;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--fast) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--green-500); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary   { background: var(--green-700); color: #fff; box-shadow: 0 2px 6px rgba(27,67,50,.2); }
.btn-primary:hover { background: var(--green-800); color: #fff; box-shadow: 0 4px 12px rgba(27,67,50,.25); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1.5px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border-strong);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--green-600); color: var(--green-700); }

.btn-danger   { background: var(--red-50);    color: var(--red-600);    border: 1.5px solid var(--red-100); }
.btn-danger:hover { background: var(--red-100); }

.btn-warning  { background: var(--amber-100); color: var(--amber-700);  border: 1.5px solid #fde68a; }
.btn-warning:hover { background: #fef3c7; }

.btn-info     { background: var(--blue-100);  color: var(--blue-700);   border: 1.5px solid #bae6fd; }
.btn-info:hover { background: #bae6fd; }

.btn-ghost    { background: transparent; border: none; color: var(--text-muted); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text-primary); }

.btn-sm  { padding: .3rem .65rem; font-size: .75rem; border-radius: var(--radius-sm); }
.btn-lg  { padding: .7rem 1.5rem; font-size: .88rem; }
.btn-xl  { padding: .85rem 2rem;  font-size: .95rem; border-radius: var(--radius-lg); }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* Icon-only button */
.btn-icon {
  padding: .45rem;
  border-radius: var(--radius-sm);
}

/* ════════════════════════════════════════════════════════
   11. FORMS
════════════════════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.form-group       { display: flex; flex-direction: column; gap: .35rem; }
.form-group.full  { grid-column: 1 / -1; }
.form-group.half  { grid-column: span 1; }

label, .form-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.required::after { content: ' *'; color: var(--red-600); }

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=date],
input[type=tel],
input[type=url],
select,
textarea {
  width: 100%;
  padding: .52rem .85rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: 'Sora', sans-serif;
  font-size: .83rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(64,145,108,.12);
}

input::placeholder { color: var(--text-faint); }

textarea { resize: vertical; min-height: 90px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  background-size: 1rem;
  padding-right: 2.2rem;
  cursor: pointer;
}

input[type=checkbox],
input[type=radio] {
  width: 16px; height: 16px;
  accent-color: var(--green-600);
  cursor: pointer;
}

.form-hint   { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }
.form-error  { font-size: .72rem; color: var(--red-600); margin-top: .15rem; }

/* Input group (icon prefix/suffix) */
.input-group { position: relative; }
.input-group .input-icon {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
  display: flex; align-items: center;
}
.input-group input { padding-left: 2.25rem; }

/* Filter bar */
.filter-bar, .filters-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* Search input shorthand */
.search-input { min-width: 200px; max-width: 280px; }
.form-control { /* legacy alias */
  width: 100%;
  padding: .48rem .8rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .83rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.form-control:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(64,145,108,.12); }

/* ════════════════════════════════════════════════════════
   12. BADGES
════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Semantic colours */
.badge-green,  .badge-success  { background: #dcfce7; color: #15803d; }
.badge-red,    .badge-danger   { background: var(--red-100);    color: var(--red-700); }
.badge-amber,  .badge-warning  { background: var(--amber-100);  color: var(--amber-700); }
.badge-blue,   .badge-info     { background: var(--blue-100);   color: var(--blue-700); }
.badge-purple               { background: var(--purple-100); color: var(--purple-700); }
.badge-gray,   .badge-neutral  { background: var(--gray-100);   color: var(--gray-600); }

/* Role badges */
.badge-admin          { background: var(--amber-100); color: var(--amber-700); }
.badge-branch_manager { background: var(--blue-100);  color: var(--blue-700); }
.badge-accountant     { background: var(--purple-100);color: var(--purple-700); }
.badge-field_officer  { background: #dcfce7;          color: #166534; }

/* Status shortcuts */
.text-success { color: #16a34a; }
.text-danger  { color: var(--red-600); }
.text-warning { color: var(--amber-600); }
.text-muted   { color: var(--text-muted); font-size: .8rem; }
.text-info    { color: var(--blue-600); }

/* ════════════════════════════════════════════════════════
   13. MODAL
════════════════════════════════════════════════════════ */
body.modal-open { overflow: hidden; }

.modal-backdrop,
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(13, 31, 19, .7);
  backdrop-filter: blur(4px);
}
.modal-backdrop.open,
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: min(700px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modal-pop .18s var(--ease-out);
}
.modal-lg  { width: min(960px, 100%); }
.modal-sm  { width: min(440px, 100%); }
.modal-xs  { width: min(360px, 100%); }

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.modal-close {
  width: 30px; height: 30px;
  background: var(--gray-100);
  border: none; border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  font-size: 1rem;
  transition: background var(--fast) var(--ease);
}
.modal-close:hover { background: var(--gray-200); }

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .65rem;
  padding: .9rem 1.4rem;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  position: sticky;
  bottom: 0;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════
   14. TABS
════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.1rem;
  font-family: 'Sora', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.tab-btn:hover  { color: var(--text-primary); }
.tab-btn.active { color: var(--green-700); border-bottom-color: var(--green-700); }

.tab-content        { display: none; }
.tab-content.active { display: block; }

/* ════════════════════════════════════════════════════════
   15. ALERTS
════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .83rem;
  line-height: 1.5;
}
.alert-success { background: var(--green-50);  color: #166534; border: 1px solid var(--green-200); }
.alert-danger  { background: var(--red-50);    color: #991b1b; border: 1px solid var(--red-100); }
.alert-warning { background: var(--amber-50);  color: var(--amber-700); border: 1px solid var(--amber-100); }
.alert-info    { background: var(--blue-50);   color: var(--blue-700);  border: 1px solid var(--blue-100); }

.info-box { /* legacy alias for alert-info */
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .83rem;
  color: var(--blue-700);
}

/* ════════════════════════════════════════════════════════
   16. TOAST
════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  pointer-events: none;
}

.toast {
  min-width: 270px; max-width: 380px;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-lg);
  color: #fff;
  font-size: .84rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s var(--ease-out);
  pointer-events: auto;
}
.toast button {
  margin-left: auto; background: transparent; border: 0;
  color: inherit; cursor: pointer; opacity: .8;
  padding: .1rem;
}
.toast button:hover { opacity: 1; }

.toast-success { background: #15803d; }
.toast-error   { background: #991b1b; }
.toast-warning { background: #92400e; }
.toast-info    { background: #075985; }

.toast.hide { opacity: 0; transform: translateX(24px); transition: all .22s var(--ease-in); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════════════════════════════
   17. PAGINATION
════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .3rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-link {
  min-width: 32px; height: 32px;
  padding: 0 .6rem;
  border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600;
  color: var(--gray-600);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--fast) var(--ease);
  font-family: inherit;
}
.page-link:hover         { background: var(--gray-100); border-color: var(--gray-300); color: var(--gray-900); }
.page-link.current       { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.page-link:disabled, .page-link[disabled] { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ════════════════════════════════════════════════════════
   18. LOADING & EMPTY STATES
════════════════════════════════════════════════════════ */
.loading-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem 1.5rem; gap: .75rem;
  color: var(--text-muted); font-size: .85rem;
}

.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3 { font-size: .95rem; color: var(--text-secondary); margin-bottom: .35rem; }
.empty-state p  { font-size: .82rem; }

/* ════════════════════════════════════════════════════════
   19. CHARTS (bar chart helpers)
════════════════════════════════════════════════════════ */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-container {
  padding: 1rem;
  min-height: 160px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}
.bar-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 2px; height: 100%;
  justify-content: flex-end;
}
.bar-fill {
  width: 100%; background: var(--green-primary);
  border-radius: 3px 3px 0 0; min-height: 2px;
}
.bar-label { font-size: .64rem; color: var(--text-muted); }

/* Chart bar list (horizontal) */
.chart-bar-list { list-style: none; }
.chart-bar-item {
  display: flex; align-items: center;
  gap: .75rem; margin-bottom: .6rem; font-size: .8rem;
}
.chart-bar-label {
  width: 90px; flex-shrink: 0; color: var(--gray-600); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chart-bar-track {
  flex: 1; background: var(--gray-100); border-radius: 4px;
  height: 8px; overflow: hidden;
}
.chart-bar-fill {
  height: 100%; border-radius: 4px;
  background: var(--green-600);
  transition: width 1.2s var(--ease-out);
}
.chart-bar-fill.amber  { background: var(--amber-400); }
.chart-bar-fill.blue   { background: var(--blue-600); }
.chart-bar-fill.purple { background: var(--purple-600); }
.chart-bar-fill.red    { background: var(--red-600); }
.chart-bar-value {
  width: 80px; text-align: right;
  color: var(--text-secondary); font-weight: 600; flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════
   20. DETAIL / VIEW PANELS
════════════════════════════════════════════════════════ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}
.detail-item label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
  display: block;
}
.detail-item p {
  font-size: .88rem; color: var(--text-primary);
  font-weight: 500; margin-top: .2rem;
}

/* ════════════════════════════════════════════════════════
   21. LOGIN PAGE
════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--green-950);
}

.login-left {
  width: 440px; flex-shrink: 0;
  background: var(--surface);
  display: flex; flex-direction: column;
  justify-content: center;
  padding: 3rem 3.5rem;
}

.login-right {
  flex: 1;
  background: linear-gradient(140deg, var(--green-800) 0%, var(--green-950) 55%, #0a1a0f 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.login-right::before {
  content: '';
  position: absolute;
  width: 640px; height: 640px; border-radius: 50%;
  background: radial-gradient(circle, rgba(82,183,136,.1) 0%, transparent 70%);
  top: -200px; right: -200px;
}
.login-right::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(circle, rgba(244,162,97,.06) 0%, transparent 70%);
  bottom: -100px; left: 40px;
}


.login-tagline { font-size: .85rem; color: var(--gray-600); margin-bottom: 2rem; line-height: 1.65; }
.login-form h2 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 1.5rem; }

.right-stat-card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: .85rem;
  color: #fff; position: relative; z-index: 1;
  max-width: 320px; width: 100%;
  backdrop-filter: blur(8px);
}
.right-stat-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem; color: var(--amber-400); margin-bottom: .25rem;
}
.right-stat-card p { font-size: .8rem; color: rgba(255,255,255,.65); }

/* ════════════════════════════════════════════════════════
   22. UTILITY CLASSES
════════════════════════════════════════════════════════ */
/* Spacing */
.mt-1 { margin-top: .5rem; }  .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }.mb-4 { margin-bottom: 2rem; }
.ml-auto { margin-left: auto; } .mr-auto { margin-right: auto; }
.p-0 { padding: 0; }

/* Display */
.flex           { display: flex; }
.inline-flex    { display: inline-flex; }
.grid           { display: grid; }
.block          { display: block; }
.hidden         { display: none; }

/* Flex helpers */
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.items-end      { align-items: flex-end; }
.justify-between{ justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.flex-wrap      { flex-wrap: wrap; }
.flex-1         { flex: 1; }
.flex-col       { flex-direction: column; }
.gap-1          { gap: .5rem; }
.gap-2          { gap: 1rem; }
.gap-3          { gap: 1.5rem; }

/* Text */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-sm     { font-size: .82rem; }
.text-xs     { font-size: .72rem; }
.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }
.uppercase   { text-transform: uppercase; letter-spacing: .05em; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whitespace-nowrap { white-space: nowrap; }

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

/* Rounded */
.rounded-full { border-radius: 9999px; }
.rounded      { border-radius: var(--radius); }

/* Overflow */
.overflow-auto   { overflow: auto; }
.overflow-hidden { overflow: hidden; }

/* Width */
.w-full  { width: 100%; }
.min-w-0 { min-width: 0; }

/* ════════════════════════════════════════════════════════
   23. RESPONSIVE
════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }
  .main-wrapper { margin-left: 0; }

  .login-right { display: none; }
  .login-left  { width: 100%; padding: 2.5rem 2rem; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
  .detail-grid{ grid-column: 1; grid-template-columns: 1fr; }
  .charts-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .modal-backdrop, .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
  .toast-container { left: 1rem; right: 1rem; }
  .toast { min-width: 0; width: 100%; }
}

@media (max-width: 540px) {
  .page-content { padding: 1rem; }
  .stats-grid   { grid-template-columns: 1fr; }
  .topbar       { padding: 0 1rem; }
  .card-header  { padding: .75rem 1rem; }
  .card-body    { padding: 1rem; }
}

/* ════════════════════════════════════════════════════════
   24. PRINT
════════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .toast-container,
  .page-header .btn, .flash,
  .modal-backdrop, .modal-overlay { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  table { font-size: .75rem; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ════════════════════════════════════════════════════════
   25. SCROLLBAR (Webkit)
════════════════════════════════════════════════════════ */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* =========================
   LOGIN BRAND
========================= */
.login-brand{
    display:flex;
    align-items:center;
    gap:1rem;
    margin-bottom:1.5rem;
}

.login-logo{
    width:70px;
    height:70px;
    object-fit:contain;
    border-radius:14px;
    background:#fff;
    padding:6px;
    box-shadow:0 4px 18px rgba(0,0,0,0.08);
}

.login-brand-text h1{
    margin:0;
    font-size:2rem;
    font-weight:800;
    line-height:1.1;
    color:#0a1a0f;
}

.login-brand-text small{
    display:block;
    margin-top:.25rem;
   color:#1b4332;
    font-size:.85rem;
    letter-spacing:.5px;
}

/* =========================
   SIDEBAR BRAND
========================= */
.sidebar-brand{
    display:flex;
    align-items:center;
    gap:12px;
    padding:14px 18px;
}

.brand-logo{
    width:48px;
    height:48px;
    border-radius:12px;
    background:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    box-shadow:0 4px 12px rgba(0,0,0,0.08);
    flex-shrink:0;
}

.brand-logo img{
    width:100%;
    height:100%;
    object-fit:contain;
    padding:4px;
}

.brand-text{
    display:flex;
    flex-direction:column;
    line-height:1.1;
}

.brand-name{
    font-size:1.1rem;
    font-weight:700;
    color:#fff;
}

.brand-tagline{
    font-size:.72rem;
    color:#40916c;
    margin-top:2px;
    letter-spacing:.4px;
}