/* ═══════════════════════════════════════════════════════════════════
   Kora Admin Dashboard — style.css  (matches Kora app design)
═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:        #EEF2F7;
  --surface:   #FFFFFF;
  --surface2:  #F1F5FF;
  --border:    #E2E8F0;
  --text:      #0F172A;
  --muted:     #64748B;
  --primary:   #2563EB;
  --primary-lt:#EFF6FF;
  --green:     #10B981;
  --orange:    #F59E0B;
  --purple:    #8B5CF6;
  --teal:      #0891B2;
  --red:       #EF4444;
  --yellow:    #F59E0B;
  --blue:      #2563EB;
  --radius:    12px;
  --shell-bg:  #EEF2F7;
  --sidebar-w: 240px;
  --sidebar-bg: var(--shell-bg);
  --sidebar-border: #DCE4F0;
  --sidebar-text: #64748B;
  --sidebar-text-strong: #0F172A;
  --sidebar-hover-bg: #F8FAFC;
  --sidebar-active-bg: #E8F0FF;
  --sidebar-active-text: #1D4ED8;
  --sidebar-logo-bg: #DBEAFE;
  --sidebar-logo-text: #1E40AF;
  --sidebar-btn-text: #64748B;
  --sidebar-btn-border: #CBD5E1;
  --sidebar-shadow: 1px 0 10px rgba(15,23,42,0.06);
  --sidebar-badge-border: #CBD5E1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Hidden / util ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-20  { margin-top: 20px; }
.p-0    { padding: 0 !important; }
.p-12   { padding: 12px; }

/* ═══════════════════════ LOGIN ════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #E8F5F2 0%, #F4F6FB 60%, #E0F4EE 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 40px rgba(14,90,78,0.1);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: #fff;
}
.logo-icon.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; }
.logo-text { font-weight: 800; font-size: 20px; color: var(--text); }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; color: var(--text); }
.login-sub   { color: var(--muted); margin-bottom: 28px; }
.login-hint  { color: var(--muted); font-size: 12px; margin-top: 18px; text-align: center; }
.login-error {
  background: rgba(220,38,38,0.08);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* ═══════════════════════ FORMS ════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input,
.form-group select,
.form-group textarea,
.input-full,
.filter-select,
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.input-full:focus,
.filter-select:focus,
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,90,78,0.08);
}
.textarea { resize: vertical; min-height: 90px; }
.filter-select.full,
.input-full { width: 100%; }
.filter-select { width: auto; min-width: 140px; }
.search-input { min-width: 220px; }

/* ═══════════════════════ BUTTONS ══════════════════════════════════ */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover   { opacity: .88; }
.btn-primary:active  { transform: scale(.97); }
.btn-primary.btn-full { width: 100%; }
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-sm:hover { opacity: .8; }
.btn-approve  { background: rgba(5,150,105,.12);  color: var(--green);  }
.btn-reject   { background: rgba(220,38,38,.10);  color: var(--red);    }
.btn-repaid   { background: rgba(37,99,235,.10);  color: var(--blue);   }
.btn-view     { background: rgba(124,58,237,.10); color: var(--purple); }
.btn-delete   { background: rgba(220,38,38,.08);  color: var(--red);    }
.btn-edit     { background: rgba(217,119,6,.10);  color: var(--orange); }
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 16px;
  width: 100%;
  cursor: pointer;
  font-size: 13px;
  transition: color .15s, border-color .15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); }
.btn-refresh {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-refresh svg, .btn-logout svg, .collapse-btn svg, .mobile-menu-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; stroke-width: 1.75; fill: none; flex-shrink: 0;
}
.btn-theme svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.btn-refresh:hover { color: var(--primary); border-color: var(--primary); }

/* ═══════════════════════ APP LAYOUT ═══════════════════════════════ */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, color .15s;
  user-select: none;
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 700; }
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  flex-shrink: 0;
}
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

/* Main */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--shell-bg);
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 9;
}
.topbar-left h2 { font-size: 20px; font-weight: 800; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.admin-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* Sections */
.section {
  display: none;
  padding: 20px 24px 28px;
  width: 100%;
  max-width: 100%;
}
.section.active { display: block; }

/* ═══════════════════════ CARDS ════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--text); }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-body { padding: 0; overflow-x: auto; }
.card-body.pad { padding: 20px; }

/* 2-col row */
.row-2col {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.row-2col > .card {
  flex: 1 1 0;
  min-width: 0;
}
@media (max-width: 900px) { .row-2col { flex-direction: column; } }

/* ═══════════════════════ STAT CARDS ═══════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  border-left: 4px solid transparent;
}
.stat-card.blue   { border-left-color: var(--blue);   }
.stat-card.green  { border-left-color: var(--green);  }
.stat-card.orange { border-left-color: var(--orange); }
.stat-card.purple { border-left-color: var(--purple); }
.stat-card.teal   { border-left-color: var(--teal);   }
.stat-card.red    { border-left-color: var(--red);    }
.stat-val   { font-size: 28px; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ═══════════════════════ TABLES ════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  color: var(--text);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--surface2); }
.loading { text-align: center; color: var(--muted); padding: 24px !important; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: rgba(5,150,105,.12);   color: var(--green);  }
.badge-orange { background: rgba(217,119,6,.12);   color: var(--orange); }
.badge-red    { background: rgba(220,38,38,.10);   color: var(--red);    }
.badge-blue   { background: rgba(37,99,235,.10);   color: var(--blue);   }
.badge-purple { background: rgba(124,58,237,.10);  color: var(--purple); }
.badge-muted  { background: rgba(107,158,150,.12); color: var(--muted);  }
.badge-yellow { background: rgba(217,119,6,.10);   color: var(--yellow); }
.badge-teal   { background: rgba(8,145,178,.10);   color: var(--teal);   }
.badge-inactive { background: rgba(220,38,38,.08); color: var(--red); }

/* Progress bar */
.progress-bar-wrap { width: 100px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 3px; background: var(--primary); transition: width .3s; }

/* TX summary */
.tx-summary {
  display: flex;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
  flex-wrap: wrap;
  color: var(--muted);
}
.tx-sum-item strong { margin-left: 6px; color: var(--text); }

/* ═══════════════════════ HEALTH ════════════════════════════════════ */
.health-grid { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px; }
.health-item { display: flex; align-items: center; gap: 10px; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.health-dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.health-dot.orange { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.health-dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.health-label { color: var(--muted); font-size: 13px; }
.health-status { color: var(--text); }

/* ═══════════════════════ MESSAGES ══════════════════════════════════ */
.group-list { list-style: none; }
.group-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.group-list-item:hover { background: var(--surface2); color: var(--text); }
.group-list-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 700; }
.msg-container {
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}
.msg-empty { color: var(--muted); text-align: center; padding: 40px; }
.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.msg-bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}
.msg-bubble.other {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ═══════════════════════ MODAL ═════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8,60,51,0.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 16px 48px rgba(14,90,78,0.12);
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--red); border-color: var(--red); }
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 18px; color: var(--text); }
.modal h4 { color: var(--muted); }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 5px; }
.modal-field p { font-size: 14px; color: var(--text); }
hr { border: none; border-top: 1px solid var(--border); }

/* Actions cell */
.actions-cell { display: flex; flex-wrap: wrap; gap: 5px; }

/* ═══════════════════════ TOAST ═════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  max-width: 340px;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .2s ease-out;
  box-shadow: 0 4px 20px rgba(14,90,78,0.1);
  color: var(--text);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red);   }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Hidden / util ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.mt-20  { margin-top: 20px; }
.p-0    { padding: 0 !important; }
.p-12   { padding: 12px; }

/* ═══════════════════════ LOGIN ════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1a2a4a 0%, var(--bg) 70%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.logo-icon {
  width: 40px; height: 40px;
  background: var(--blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: #fff;
}
.logo-icon.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 7px; }
.logo-text { font-weight: 800; font-size: 20px; color: var(--text); }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-sub   { color: var(--muted); margin-bottom: 28px; }
.login-hint  { color: var(--muted); font-size: 12px; margin-top: 18px; text-align: center; }
.login-error {
  background: rgba(244,91,91,0.12);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* ═══════════════════════ FORMS ════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input,
.form-group select,
.form-group textarea,
.input-full,
.filter-select,
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.input-full:focus,
.filter-select:focus,
.search-input:focus {
  border-color: var(--blue);
}
.textarea { resize: vertical; min-height: 90px; }
.filter-select.full,
.input-full { width: 100%; }
.filter-select { width: auto; min-width: 140px; }
.search-input { min-width: 220px; }

/* ═══════════════════════ BUTTONS ══════════════════════════════════ */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover   { opacity: .88; }
.btn-primary:active  { transform: scale(.97); }
.btn-primary.btn-full { width: 100%; }
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-sm:hover { opacity: .8; }
.btn-approve  { background: rgba(46,212,122,.18); color: var(--green); }
.btn-reject   { background: rgba(244,91,91,.18);  color: var(--red);   }
.btn-repaid   { background: rgba(79,142,247,.18); color: var(--blue);  }
.btn-view     { background: rgba(168,85,247,.18); color: var(--purple);}
.btn-delete   { background: rgba(244,91,91,.12);  color: var(--red);   }
.btn-edit     { background: rgba(251,191,36,.18); color: var(--yellow);}
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 16px;
  width: 100%;
  cursor: pointer;
  font-size: 13px;
  transition: color .15s, border-color .15s;
}
.btn-logout:hover { color: var(--red); border-color: var(--red); }
.btn-refresh {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: color .15s;
}
.btn-refresh:hover { color: var(--text); }

/* ═══════════════════════ APP LAYOUT ═══════════════════════════════ */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, color .15s;
  user-select: none;
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(79,142,247,.15); color: var(--blue); font-weight: 600; }
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  flex-shrink: 0;
}
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

/* Main */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 9;
}
.topbar-left h2 { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.admin-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}
.admin-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* Sections */
.section { display: none; padding: 24px 28px; }
.section.active { display: block; }

/* ═══════════════════════ CARDS ════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-body { padding: 0; overflow-x: auto; }
.card-body.pad { padding: 20px; }

/* 2-col row */
.row-2col {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 900px) { .row-2col { flex-direction: column; } }

/* ═══════════════════════ STAT CARDS ═══════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  border-left: 4px solid transparent;
}
.stat-card.blue   { border-left-color: var(--blue);   }
.stat-card.green  { border-left-color: var(--green);  }
.stat-card.orange { border-left-color: var(--orange); }
.stat-card.purple { border-left-color: var(--purple); }
.stat-card.teal   { border-left-color: var(--teal);   }
.stat-card.red    { border-left-color: var(--red);    }
.stat-val   { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ═══════════════════════ TABLES ════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(42,46,69,0.6);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(255,255,255,0.02); }
.loading { text-align: center; color: var(--muted); padding: 24px !important; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: rgba(46,212,122,.15); color: var(--green);  }
.badge-orange { background: rgba(247,164,79,.15);  color: var(--orange); }
.badge-red    { background: rgba(244,91,91,.15);   color: var(--red);    }
.badge-blue   { background: rgba(79,142,247,.15);  color: var(--blue);   }
.badge-purple { background: rgba(168,85,247,.15);  color: var(--purple); }
.badge-muted  { background: rgba(123,130,168,.15); color: var(--muted);  }
.badge-yellow { background: rgba(251,191,36,.15);  color: var(--yellow); }

/* Progress bar */
.progress-bar-wrap { width: 100px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 3px; background: var(--blue); transition: width .3s; }

/* TX summary */
.tx-summary {
  display: flex;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  font-size: 13px;
  flex-wrap: wrap;
}
.tx-sum-item strong { margin-left: 6px; }

/* ═══════════════════════ HEALTH ════════════════════════════════════ */
.health-grid { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px; }
.health-item { display: flex; align-items: center; gap: 10px; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.health-dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.health-dot.orange { background: var(--orange); box-shadow: 0 0 6px var(--orange); }
.health-dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.health-label { color: var(--muted); font-size: 13px; }

/* ═══════════════════════ MESSAGES ══════════════════════════════════ */
.group-list { list-style: none; }
.group-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.group-list-item:hover { background: var(--surface2); color: var(--text); }
.group-list-item.active { background: rgba(79,142,247,.12); color: var(--blue); font-weight: 600; }
.msg-container {
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}
.msg-empty { color: var(--muted); text-align: center; padding: 40px; }
.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.msg-bubble.user {
  align-self: flex-end;
  background: rgba(79,142,247,.18);
  border-bottom-right-radius: 4px;
}
.msg-bubble.other {
  align-self: flex-start;
  background: var(--surface2);
  border-bottom-left-radius: 4px;
}
.msg-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ═══════════════════════ MODAL ═════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--red); border-color: var(--red); }
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 5px; }
.modal-field p { font-size: 14px; }

/* ═══════════════════════ TOAST ═════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  max-width: 340px;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .2s ease-out;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red);   }
.toast.info    { border-left: 3px solid var(--blue);  }
@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ═══════════════════════ DARK MODE ══════════════════════════════════ */
body.dark {
  --bg: #0D1117;
  --surface: #161B22;
  --surface2: #1C2128;
  --border: #30363D;
  --text: #E6EDF3;
  --muted: #8B949E;
  --shell-bg: #0D1117;
  --sidebar-bg: var(--shell-bg);
  --sidebar-border: #20262E;
  --sidebar-text: rgba(255,255,255,0.62);
  --sidebar-text-strong: #FFFFFF;
  --sidebar-hover-bg: rgba(255,255,255,0.09);
  --sidebar-active-bg: rgba(96,165,250,0.24);
  --sidebar-active-text: #BFDBFE;
  --sidebar-logo-bg: rgba(59,130,246,0.3);
  --sidebar-logo-text: #93C5FD;
  --sidebar-btn-text: rgba(255,255,255,0.45);
  --sidebar-btn-border: rgba(255,255,255,0.12);
  --sidebar-shadow: 2px 0 24px rgba(0,0,0,0.22);
  --sidebar-badge-border: rgba(255,255,255,0.1);
}
body.dark .login-screen {
  background: radial-gradient(ellipse at 50% 0%, #1a2550 0%, #0D1117 70%);
}
body.dark ::-webkit-scrollbar-thumb { background: #30363D; }

/* Theme toggle button */
.btn-theme {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: border-color .15s;
}
.btn-theme:hover { border-color: var(--blue); }

/* ═══════════════════════ ADMIN LEVEL BADGES ═════════════════════════ */
.badge-super     { background: rgba(14,158,132,.15); color: #0E9E84; border: 1px solid rgba(14,158,132,.3); }
.badge-admin-lvl { background: rgba(37,99,235,.15);  color: var(--blue); }
.badge-moderator { background: rgba(217,119,6,.15);  color: #D97706; }
.badge-viewer    { background: rgba(107,158,150,.15); color: var(--muted); }
.badge-inactive  { background: rgba(220,38,38,.12);  color: var(--red); }
.badge-green     { background: rgba(5,150,105,.15);  color: var(--green); }

/* ═══════════════════════ PERMISSION MATRIX ══════════════════════════ */
.perm-check { color: var(--green); font-weight: 700; }
.perm-cross { color: var(--red);   font-weight: 700; }
.perm-warn  { color: var(--yellow); font-weight: 700; }

.btn-full   { width: 100%; margin-top: 8px; }
.input-full { width: 100%; }
.mt-20      { margin-top: 20px; }
.pad        { padding: 16px; }

/* ═══════════════════════════════════════════════════════════════════
   PRO FEATURES — charts, sidebar collapse, pagination, sorting,
   CSV export, date range, bulk select, live feed, skeletons, etc.
═══════════════════════════════════════════════════════════════════ */

/* ── Sidebar collapse ──────────────────────────────────────────── */
.sidebar         { transition: width .2s ease; overflow: hidden; }
.main            { transition: margin-left .2s ease; }
.collapse-btn    {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1;
  margin-left: auto; padding: 2px 6px; border-radius: 6px;
  transition: color .15s;
}
.collapse-btn:hover { color: var(--text); }
.app.collapsed .sidebar            { width: 56px; }
.app.collapsed .logo-text          { display: none; }
.app.collapsed .nav-item span:nth-child(2) { display: none; }
.app.collapsed .nav-item           { justify-content: center; padding: 10px; }
.app.collapsed .sidebar-footer     { display: none; }
.app.collapsed .main               { margin-left: 56px; }
.app.collapsed .sidebar-brand      { padding: 18px 12px; justify-content: center; }
.app.collapsed .collapse-btn       { margin-left: 0; }

/* ── Skeleton loaders ──────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel {
  display: inline-block; border-radius: 4px;
  background: linear-gradient(90deg, var(--border) 25%, var(--surface2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skel-s { width: 60px;  height: 12px; }
.skel-m { width: 100px; height: 12px; }
.skel-l { width: 150px; height: 12px; }
.skel-xl{ width: 200px; height: 12px; }
.skel-row td { padding: 15px 16px !important; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 56px 24px; gap: 12px; color: var(--muted); text-align: center;
}
.empty-state .empty-icon  { font-size: 44px; opacity: .4; }
.empty-state .empty-title { font-size: 15px; font-weight: 700; color: var(--text); }
.empty-state .empty-sub   { font-size: 13px; max-width: 260px; line-height: 1.6; }

/* ── Chart containers ──────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { padding: 20px; }
.chart-wrap { position: relative; height: 200px; }

/* ── Sparkline / trend in stat cards ──────────────────────────── */
.stat-inner  { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-right  { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sparkline   { width: 64px; height: 30px; }
.stat-trend  {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; display: inline-block;
}
.stat-trend.up   { background: rgba(46,212,122,.15); color: var(--green); }
.stat-trend.down { background: rgba(244,91,91,.15);  color: var(--red);   }
.stat-trend.flat { background: rgba(123,130,168,.12); color: var(--muted); }

/* ── Table column sort ─────────────────────────────────────────── */
.tbl th[data-sort]             { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover       { color: var(--text); }
.tbl th[data-sort]::after      { content: ' ↕'; font-size: 9px; opacity: .35; }
.tbl th[data-sort].sort-asc::after  { content: ' ↑'; opacity: 1; color: var(--blue); }
.tbl th[data-sort].sort-desc::after { content: ' ↓'; opacity: 1; color: var(--blue); }

/* ── Sticky table headers ──────────────────────────────────────── */
.tbl thead th { position: sticky; top: 0; z-index: 2; }

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  justify-content: flex-end; flex-wrap: wrap;
}
.pagination-info { color: var(--muted); font-size: 12px; margin-right: auto; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.page-btn:hover        { background: var(--surface2); }
.page-btn.active       { background: var(--blue); color: #fff; border-color: var(--blue); }
.page-btn:disabled     { opacity: .4; cursor: not-allowed; }
.rows-per-page {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  padding: 5px 8px; font-size: 12px; cursor: pointer;
}

/* ── Export & date-range buttons ───────────────────────────────── */
.btn-export {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px; padding: 7px 13px;
  cursor: pointer; font-size: 12px; font-weight: 600;
  transition: color .15s, border-color .15s; white-space: nowrap;
}
.btn-export:hover { color: var(--green); border-color: var(--green); }
.date-range { display: flex; align-items: center; gap: 6px; }
.date-range label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.date-range input[type="date"] {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; color: var(--text);
  font-size: 12px; font-family: inherit; cursor: pointer;
}
body.dark input[type="date"] { color-scheme: dark; }

/* ── Bulk-select bar ───────────────────────────────────────────── */
.bulk-bar {
  display: none; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(79,142,247,.08);
  border-bottom: 1px solid rgba(79,142,247,.2);
  font-size: 13px; font-weight: 600; color: var(--blue);
}
.bulk-bar.show    { display: flex; }
.bulk-bar-count   { margin-right: auto; }
.tbl .col-chk     { width: 40px; padding-left: 16px !important; }
.tbl input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--blue); }

/* ── Live event feed ───────────────────────────────────────────── */
.live-feed {
  max-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px;
}
.feed-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 12px;
  animation: feedIn .3s ease-out;
}
@keyframes feedIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feed-dot        { width: 8px; height: 8px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; }
.feed-dot.green  { background: var(--green); box-shadow: 0 0 5px var(--green); }
.feed-dot.red    { background: var(--red);   box-shadow: 0 0 5px var(--red);   }
.feed-dot.blue   { background: var(--blue);  box-shadow: 0 0 5px var(--blue);  }
.feed-dot.orange { background: var(--orange); }
.feed-text       { flex: 1; line-height: 1.5; }
.feed-time       { color: var(--muted); font-size: 11px; white-space: nowrap; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--green);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: blink 1.5s ease-in-out infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(1.4); }
}

/* ── KYC queue cards ───────────────────────────────────────────── */
.kyc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; padding: 16px;
}
.kyc-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  background: var(--surface); display: flex; flex-direction: column; gap: 8px;
}
.kyc-name  { font-weight: 700; font-size: 14px; }
.kyc-phone { color: var(--muted); font-size: 12px; }

/* ── Loan aging buckets ────────────────────────────────────────── */
.aging-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 16px;
}
.aging-cell {
  border-radius: 10px; padding: 16px; text-align: center;
  border: 1px solid var(--border);
}
.aging-label   { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.aging-val     { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.aging-amount  { font-size: 12px; color: var(--muted); }
.aging-current { background: rgba(46,212,122,.07); border-color: rgba(46,212,122,.2); }
.aging-mild    { background: rgba(251,191,36,.07);  border-color: rgba(251,191,36,.2); }
.aging-mod     { background: rgba(247,164,79,.08);  border-color: rgba(247,164,79,.2); }
.aging-severe  { background: rgba(244,91,91,.07);   border-color: rgba(244,91,91,.2);  }

/* ── Reconciliation reports ────────────────────────────────────── */
.recon-row-crit { background: rgba(244,91,91,.05) !important; }
.recon-row-warn { background: rgba(251,191,36,.05) !important; }
.recon-run-btn  {
  background: linear-gradient(135deg,#1a3a8f,#2563eb);
  color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.recon-run-btn:hover { opacity: .88; }

/* ── Group pool / health column ────────────────────────────────── */
.health-badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.hb-healthy  { background: rgba(46,212,122,.15); color: var(--green); }
.hb-due      { background: rgba(251,191,36,.15); color: var(--yellow); }
.hb-critical { background: rgba(244,91,91,.15);  color: var(--red); }
.hb-danger   { background: rgba(244,91,91,.2);   color: var(--red); }
.hb-active   { background: rgba(123,130,168,.12); color: var(--muted); }

/* ── Kbd shortcut hint ─────────────────────────────────────────── */
.kbd {
  display: inline-block; padding: 1px 6px;
  border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; font-size: 10px; font-family: monospace;
  color: var(--muted); background: var(--surface2);
}

/* ── Dark mode additions ───────────────────────────────────────── */
body.dark .recon-run-btn { background: linear-gradient(135deg,#1e3a8a,#3b82f6); }
body.dark .feed-item     { border-color: var(--border); }
body.dark .kyc-card      { background: var(--surface2); }

/* ═══════════════════════ UPGRADE PACK ════════════════════════════ */

/* ── Global Search Modal (Ctrl+K) ──────────────────────────────── */
.gsearch-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 80px; z-index: 300; backdrop-filter: blur(3px);
}
.gsearch-overlay.hidden { display: none !important; }
.gsearch-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: 100%; max-width: 580px;
  box-shadow: 0 24px 64px rgba(0,0,0,.5); overflow: hidden;
}
.gsearch-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.gsearch-icon { font-size: 18px; color: var(--muted); flex-shrink: 0; display: flex; align-items: center; }
.gsearch-icon svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.gsearch-input {
  flex: 1; border: none; background: transparent;
  font-size: 16px; color: var(--text); outline: none; font-family: inherit;
}
.gsearch-results { max-height: 400px; overflow-y: auto; padding: 8px; }
.gsearch-section-label {
  padding: 6px 10px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; color: var(--muted); letter-spacing: .5px;
}
.gsearch-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background .1s;
}
.gsearch-item:hover, .gsearch-item.active { background: var(--surface2); }
.gsearch-item-icon { font-size: 16px; width: 28px; text-align: center; flex-shrink: 0; }
.gsearch-item-main { flex: 1; min-width: 0; }
.gsearch-item-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-item-sub   { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-item-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.gsearch-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
.gsearch-footer {
  padding: 10px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 16px; font-size: 11px; color: var(--muted);
}
.gsearch-footer-key { display: inline-flex; align-items: center; gap: 5px; }

/* ── Confirm Modal ─────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 250; backdrop-filter: blur(2px);
}
.confirm-overlay.hidden { display: none !important; }
.confirm-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; max-width: 440px; width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,.4); animation: confirmIn .18s ease-out;
}
@keyframes confirmIn {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.confirm-icon  { font-size: 36px; margin-bottom: 12px; }
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.confirm-body  { font-size: 14px; color: var(--muted); margin-bottom: 18px; line-height: 1.6; }
.confirm-reason { width: 100%; margin-bottom: 18px; }
.confirm-btns   { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-cancel {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.confirm-cancel:hover { opacity: .8; }
.confirm-ok {
  background: var(--red); color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.confirm-ok.safe { background: var(--blue); }
.confirm-ok:hover { opacity: .88; }

/* ── Date preset chips ─────────────────────────────────────────── */
.date-presets { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.preset-chip {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 11px; font-weight: 600; cursor: pointer;
  background: var(--surface2); color: var(--muted);
  transition: background .12s, color .12s, border-color .12s; white-space: nowrap;
}
.preset-chip:hover, .preset-chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Auto-refresh ──────────────────────────────────────────────── */
.auto-refresh-wrap {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; color: var(--muted); transition: color .15s, border-color .15s; user-select: none;
}
.auto-refresh-wrap:hover { color: var(--text); border-color: var(--blue); }
.auto-refresh-wrap.active { color: var(--green); border-color: var(--green); }
.auto-refresh-wrap.active .ar-dot {
  background: var(--green); box-shadow: 0 0 5px var(--green); animation: blink 1.5s infinite;
}
@keyframes blink { 50% { opacity: .3; } }
.ar-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.ar-countdown { font-size: 10px; color: var(--muted); margin-left: 2px; }

/* ── Nav badges ────────────────────────────────────────────────── */
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px;
  background: var(--red); color: #fff; border-radius: 9px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; line-height: 1;
}
.nav-badge.orange { background: var(--orange); }
.nav-badge.blue   { background: var(--blue); }
.app.collapsed .nav-badge { display: none; }

/* ── Unread dot on nav ─────────────────────────────────────────── */
.nav-unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); margin-left: auto; animation: blink 2s infinite;
}

/* ── Mobile sidebar ────────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 9;
}
.mobile-menu-btn {
  display: none; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; cursor: pointer;
  font-size: 18px; color: var(--muted); line-height: 1;
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%); transition: transform .25s ease;
    width: var(--sidebar-w) !important; z-index: 10;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.visible { display: block; }
  .main { margin-left: 0 !important; }
  .mobile-menu-btn { display: flex; align-items: center; }
  .topbar { padding: 12px 16px; }
  .section { padding: 16px; }
  .collapse-btn { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .aging-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Column visibility toggle ──────────────────────────────────── */
.col-vis-wrap { position: relative; display: inline-block; }
.col-vis-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 12px; font-weight: 600;
  transition: color .15s;
}
.col-vis-btn:hover { color: var(--text); border-color: var(--blue); }
.col-vis-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; min-width: 180px; z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); display: none;
}
.col-vis-dropdown.open { display: block; }
.col-vis-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background .1s;
}
.col-vis-item:hover { background: var(--surface2); }
.col-vis-item input[type="checkbox"] { accent-color: var(--blue); width: 14px; height: 14px; }

/* ── Clickable table rows ──────────────────────────────────────── */
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover td { background: rgba(79,142,247,.06); }

/* ── User activity timeline ────────────────────────────────────── */
.timeline { padding: 0; list-style: none; margin: 0; }
.timeline-item { position: relative; padding: 0 0 18px 28px; border-left: 2px solid var(--border); }
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--surface);
}
.timeline-dot.green  { background: var(--green); }
.timeline-dot.orange { background: var(--orange); }
.timeline-dot.red    { background: var(--red); }
.timeline-dot.purple { background: var(--purple); }
.timeline-date  { font-size: 10px; color: var(--muted); margin-bottom: 2px; }
.timeline-event { font-size: 13px; font-weight: 600; color: var(--text); }
.timeline-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Inline edit ───────────────────────────────────────────────── */
.inline-edit-input {
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text);
  padding: 4px 8px; font-size: 13px; font-family: inherit; outline: none;
}
.inline-edit-input:focus { border-color: var(--blue); }
.input-full {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; box-sizing: border-box;
}
.input-full:focus { border-color: var(--blue); }
textarea.input-full { resize: vertical; min-height: 80px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

/* ── PDF / Print ───────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .card-actions, .actions-cell,
  .btn-export, .pagination, .bulk-bar,
  #toast-container, #modal-overlay, .gsearch-overlay,
  .confirm-overlay, .sidebar-overlay { display: none !important; }
  .main { margin-left: 0 !important; }
  .section { padding: 12px !important; }
  .section.active { display: block !important; }
  body { background: #fff !important; }
  .tbl th, .tbl td { font-size: 11px !important; padding: 7px 10px !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; }
  .stat-card, .kpi-card, .metric-pill { border: 1px solid #ccc !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   VISUAL REDESIGN — Dark Sidebar · KPI Layout · Glassmorphic Topbar
═══════════════════════════════════════════════════════════════════ */

/* ── Dark Sidebar ───────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg) !important;
  border-right: 1px solid var(--sidebar-border) !important;
  box-shadow: var(--sidebar-shadow);
}
.sidebar-brand {
  border-bottom-color: var(--sidebar-border) !important;
}
.sidebar-brand .logo-text { color: var(--sidebar-text-strong) !important; }
.sidebar-brand .logo-icon {
  background: var(--sidebar-logo-bg) !important;
  color: var(--sidebar-logo-text) !important;
}
.collapse-btn { color: var(--sidebar-btn-text) !important; }
.collapse-btn:hover { color: var(--sidebar-text-strong) !important; }

.sidebar-nav .nav-item { color: var(--sidebar-text) !important; }
.sidebar-nav .nav-item:hover {
  background: var(--sidebar-hover-bg) !important;
  color: var(--sidebar-text-strong) !important;
}
.sidebar-nav .nav-item.active {
  background: var(--sidebar-active-bg) !important;
  color: var(--sidebar-active-text) !important;
  font-weight: 600;
}
.nav-badge { border-color: var(--sidebar-badge-border) !important; }
.nav-unread-dot { background: #F87171 !important; }

.sidebar-footer { border-top-color: var(--sidebar-border) !important; }
.sidebar-footer .btn-logout {
  border-color: var(--sidebar-btn-border) !important;
  color: var(--sidebar-btn-text) !important;
}
.sidebar-footer .btn-logout:hover {
  color: #FCA5A5 !important;
  border-color: rgba(239,68,68,0.45) !important;
  background: rgba(239,68,68,0.08) !important;
}

/* Dark mode picks up sidebar values via body.dark CSS variables above. */

/* ── Glassmorphic Topbar ────────────────────────────────────────── */
.topbar {
  background: var(--shell-bg) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border-bottom: 1px solid var(--border) !important;
}
.topbar-left h2 {
  font-size: 20px !important;
  font-weight: 800 !important;
  letter-spacing: -0.3px;
}
body.dark .topbar { background: var(--shell-bg) !important; }

/* ── KPI Grid (4 large cards) ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(15,23,42,0.04);
  transition: box-shadow .2s, transform .18s;
}
.kpi-card:hover {
  box-shadow: 0 8px 24px rgba(15,23,42,0.09);
  transform: translateY(-2px);
}
.kpi-icon-wrap {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(148,163,184,0.14);
  color: #64748B;
  flex-shrink: 0;
}
.kpi-icon-wrap svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
}
.kpi-body { flex: 1; min-width: 0; }
.kpi-val {
  font-size: 26px; font-weight: 800; color: var(--text);
  letter-spacing: -0.5px; line-height: 1.1; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ── Metric Pills Row (6 compact) ───────────────────────────────── */
.metric-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .metric-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .metric-row { grid-template-columns: repeat(2, 1fr); } }

.metric-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .15s;
}
.metric-pill::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  border-radius: 2px 2px 0 0;
}
.metric-pill.danger::before  { background: var(--red);    }
.metric-pill.warning::before { background: var(--orange); }
.metric-pill.success::before { background: var(--green);  }
.metric-pill.info::before    { background: var(--blue);   }
.metric-pill:hover { box-shadow: 0 4px 14px rgba(15,23,42,0.07); }
.metric-pill-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted);
}
.metric-pill-val {
  font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1;
}
.metric-pill.danger  .metric-pill-val { color: var(--red);    }
.metric-pill.warning .metric-pill-val { color: var(--orange); }
.metric-pill.success .metric-pill-val { color: var(--green);  }

/* ── Health panel — card grid ───────────────────────────────────── */
.health-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  padding: 16px !important;
}
.health-item {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px 14px !important;
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
}
.health-label { font-size: 12px !important; font-weight: 500 !important; }

/* ── Dark mode adjustments ──────────────────────────────────────── */
body.dark .kpi-card  { background: var(--surface); box-shadow: none; }
body.dark .kpi-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.35); }
body.dark .metric-pill { box-shadow: none; }
body.dark .metric-pill:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.3); }
body.dark .health-item { background: rgba(255,255,255,0.03) !important; }
body.dark .kpi-icon-wrap {
  background: rgba(148,163,184,0.16);
  color: #94A3B8;
}
