/* ============================================================
   CREDITOR Admin Portal — shared styles
   Mirrors public design tokens
   ============================================================ */

:root {
  --green-900: #0B3D2E;
  --green-800: #0F4D3A;
  --green-700: #145A40;
  --green-600: #177046;
  --green-500: #1F8A5C;
  --green-400: #2FA471;
  --green-300: #5DBB8B;
  --green-200: #A8DCC0;
  --green-100: #D6F0E0;
  --green-50:  #EDFAF2;
  --accent-600: #16A34A;
  --accent-500: #22C55E;
  --accent-400: #4ADE80;
  --accent-300: #86EFAC;
  --ink-900: #0F172A;
  --ink-800: #1E293B;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748B;
  --ink-400: #94A3B8;
  --ink-300: #CBD5E1;
  --ink-200: #E2E8F0;
  --ink-100: #F1F5F9;
  --ink-50:  #F8FAFC;
  --white:   #FFFFFF;
  --warning: #B45309;
  --warning-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px;
  --sp-4: 16px; --sp-5: 20px;  --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --sp-16: 64px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-3: 0 12px 32px rgba(15, 23, 42, 0.12);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --sidebar-w: 260px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font-sans); color: var(--ink-900); background: var(--ink-50); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ---- Login page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--green-900) 0%, var(--green-700) 55%, var(--green-600) 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(34,197,94,.12) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,.04) 0%, transparent 35%);
  pointer-events: none;
}
.login-header {
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.login-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}
.login-header .brand img { width: 36px; height: 36px; }
.login-header .back {
  color: rgba(255,255,255,.75);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.login-header .back:hover { color: #fff; }
.login-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 48px;
  position: relative;
  z-index: 1;
}
.login-body h1 {
  color: #fff;
  font-size: clamp(28px, 4vw, 36px);
  margin: 0 0 8px;
  text-align: center;
  letter-spacing: -0.02em;
}
.login-body .subtitle {
  color: rgba(255,255,255,.7);
  font-size: 16px;
  margin: 0 0 40px;
  text-align: center;
  max-width: 420px;
}
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 860px;
}
.role-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--r-xl);
  padding: 28px 24px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  box-shadow: var(--shadow-3);
}
.role-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-500);
  box-shadow: 0 16px 40px rgba(11,61,46,.25);
}
.role-card .icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.role-card .icon.agent { background: var(--green-100); color: var(--green-700); }
.role-card .icon.investor { background: #EEF2FF; color: #4338CA; }
.role-card .icon.staff { background: var(--ink-100); color: var(--ink-700); }
.role-card h3 { margin: 0 0 6px; font-size: 18px; color: var(--ink-900); }
.role-card p { margin: 0 0 20px; font-size: 13px; color: var(--ink-500); line-height: 1.5; }
.role-card .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  background: var(--green-700);
  color: #fff;
  transition: background .15s;
}
.role-card .btn:hover { background: var(--green-600); }
.role-card.investor .btn { background: #4338CA; }
.role-card.investor .btn:hover { background: #3730A3; }
.role-card.staff .btn { background: var(--ink-800); }
.role-card.staff .btn:hover { background: var(--ink-700); }
.login-note {
  margin-top: 32px;
  color: rgba(255,255,255,.55);
  font-size: 12px;
  text-align: center;
}

/* ---- Shell (sidebar + main) ---- */
.admin-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform .25s var(--ease);
}
.sidebar__brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__brand img { width: 32px; height: 32px; }
.sidebar__brand span { font-weight: 700; font-size: 15px; }
.sidebar__brand small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--green-300);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}
.sidebar__role {
  margin: 12px 16px;
  padding: 10px 12px;
  background: rgba(255,255,255,.08);
  border-radius: var(--r-md);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar__role .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-400);
}
.sidebar__nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar__nav a:hover,
.sidebar__nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.sidebar__nav a.active { font-weight: 600; }
.sidebar__nav a svg { flex-shrink: 0; opacity: .85; }
.sidebar__footer {
  padding: 12px 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar__footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,.6);
  padding: 8px;
  border-radius: var(--r-sm);
}
.sidebar__footer a:hover { color: #fff; background: rgba(255,255,255,.06); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--ink-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-900);
}
.topbar .actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.content {
  flex: 1;
  padding: 28px;
  max-width: 1200px;
}

/* Cards & UI primitives */
.card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-1);
}
.stat-card .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--green-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-card .sub {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-600); }
.btn-secondary { background: var(--ink-100); color: var(--ink-900); }
.btn-secondary:hover { background: var(--ink-200); }
.btn-accent { background: var(--accent-500); color: #fff; }
.btn-accent:hover { background: var(--accent-600); }
.btn-ghost { background: transparent; color: var(--green-700); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-700);
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  height: 48px;
  border: 1px solid var(--ink-300);
  border-radius: var(--r-md);
  padding: 0 14px;
  font-size: 15px;
  background: #fff;
  color: var(--ink-900);
  transition: border-color .15s, box-shadow .15s;
}
.textarea {
  height: auto;
  min-height: 96px;
  padding: 12px 14px;
  resize: vertical;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(31, 138, 92, 0.2);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
}
.chip-green { background: var(--green-100); color: var(--green-700); }
.chip-pending { background: var(--ink-100); color: var(--ink-600); }
.chip-warn { background: var(--warning-bg); color: var(--warning); }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-500);
  border-bottom: 1px solid var(--ink-200);
  background: var(--ink-50);
}
table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
table.data tr:hover td { background: var(--green-50); }

/* Stepper */
.stepper {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}
.stepper .step {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--r-md);
  background: var(--ink-100);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  position: relative;
}
.stepper .step.active {
  background: var(--green-100);
  color: var(--green-700);
}
.stepper .step.done {
  background: var(--green-700);
  color: #fff;
}
.stepper .step .n {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.08);
  margin-right: 6px;
  font-size: 11px;
}
.stepper .step.active .n { background: var(--green-500); color: #fff; }
.stepper .step.done .n { background: rgba(255,255,255,.25); }

/* Map layout */
.map-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  height: calc(100vh - 64px - 56px);
  min-height: 520px;
}
.map-container {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-1);
}
#nigeria-map {
  width: 100%;
  height: 100%;
  min-height: 480px;
  background: #E8F5EE;
}
.map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.map-sidebar .metric-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.map-sidebar .metric-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--ink-100);
  font-size: 13px;
}
.map-sidebar .metric-list li:last-child { border-bottom: none; }
.map-sidebar .metric-list .count {
  font-weight: 700;
  color: var(--green-700);
  font-variant-numeric: tabular-nums;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: var(--shadow-2) !important;
  font-family: var(--font-sans) !important;
}
.leaflet-popup-content { margin: 12px 14px !important; font-size: 13px !important; }
.store-popup h4 { margin: 0 0 4px; font-size: 14px; color: var(--green-900); }
.store-popup p { margin: 0; color: var(--ink-500); font-size: 12px; }

/* Geo picker on register */
.geo-picker {
  height: 320px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--ink-300);
  margin-top: 8px;
}
.geo-hint {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-500);
}
.empty svg { margin: 0 auto 16px; opacity: .4; }
.empty h3 { margin: 0 0 8px; color: var(--ink-700); font-size: 16px; }
.empty p { margin: 0 0 20px; font-size: 14px; }

/* Mobile */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--ink-700);
}
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .map-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  #nigeria-map { min-height: 400px; height: 400px; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 20px 16px; }
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 35;
}
.sidebar-overlay.show { display: block; }

/* Success toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green-800);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp .3s var(--ease);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
