/* ============================================================
   LendBW — Micro-Lending Management System
   CSS Design System — Dark/Light Professional Fintech UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ---- ROOT VARIABLES ---- */
:root {
  --bg-primary: #0d0f14;
  --bg-secondary: #141720;
  --bg-card: #1a1e2b;
  --bg-card-hover: #1f2435;
  --bg-sidebar: #0f1118;
  --bg-input: #1e2332;
  --bg-modal: #171b27;
  --border: #252b3d;
  --border-light: #2e3550;
  --text-primary: #e8ecf5;
  --text-secondary: #7c87a0;
  --text-muted: #505977;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59,130,246,0.2);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16,185,129,0.15);
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --accent-teal: #14b8a6;
  --sidebar-width: 256px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --bg-primary: #f0f2f8;
  --bg-secondary: #e8eaf2;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f7ff;
  --bg-sidebar: #1a1e2b;
  --bg-input: #f0f2f8;
  --bg-modal: #ffffff;
  --border: #dde1ef;
  --border-light: #c8cce0;
  --text-primary: #1a1e2b;
  --text-secondary: #5a6280;
  --text-muted: #8890aa;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

/* ---- BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font-body); border: none; background: none; }
input, select, textarea { font-family: var(--font-body); font-size: 14px; color: var(--text-primary); }
select option { background: var(--bg-card); }
canvas { max-width: 100%; }

/* ---- PAGES ---- */
.page { display: none; height: 100vh; }
.page.active { display: flex; }

/* ---- LOGIN ---- */
#page-login {
  background: var(--bg-primary);
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: orb-drift 8s ease-in-out infinite;
}
.orb1 { width: 400px; height: 400px; background: var(--accent-blue); top: -10%; left: -5%; animation-delay: 0s; }
.orb2 { width: 350px; height: 350px; background: var(--accent-purple); bottom: -5%; right: 5%; animation-delay: 3s; }
.orb3 { width: 250px; height: 250px; background: var(--accent-teal); top: 40%; left: 40%; animation-delay: 5s; }

@keyframes orb-drift {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(20px,-20px); }
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.login-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.login-brand h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #14b8a6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-brand p { color: var(--text-secondary); font-size: 0.9rem; }

.brand-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.3rem;
  box-shadow: 0 0 24px rgba(59,130,246,0.4);
}
.brand-icon.sm { width: 36px; height: 36px; font-size: 0.9rem; border-radius: 10px; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-shadow: var(--shadow);
}
.login-card h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }

.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
.form-group.full { grid-column: 1 / -1; }

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap i {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  z-index: 1;
}
.input-wrap input {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input-wrap input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}
.pw-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  font-size: 0.85rem;
  z-index: 2;
  line-height: 1;
}
.pw-toggle:hover { color: var(--text-primary); }

.login-row { display: flex; align-items: center; justify-content: space-between; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.85rem; color: var(--text-secondary); }
.checkbox-label input { accent-color: var(--accent-blue); }
.forgot-link { font-size: 0.85rem; color: var(--accent-blue); }

.login-roles {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.role-pill {
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.role-pill:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn-primary:hover { background: #2563eb; box-shadow: 0 0 16px rgba(59,130,246,0.4); transform: translateY(-1px); }
.btn-primary.full { width: 100%; justify-content: center; padding: 0.85rem; }
.btn-primary.sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; }
.btn-primary.xs { padding: 0.3rem 0.65rem; font-size: 0.75rem; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.875rem;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text-primary); border-color: var(--border-light); }
.btn-ghost.sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; }
.btn-ghost.xs { padding: 0.3rem 0.65rem; font-size: 0.75rem; }

.btn-danger { background: var(--accent-red); color: #fff; padding: 0.45rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.8rem; transition: all var(--transition); display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-danger:hover { opacity: 0.85; }
.btn-warning { background: var(--accent-orange); color: #fff; padding: 0.7rem 1.2rem; border-radius: var(--radius-sm); font-size: 0.875rem; transition: all var(--transition); display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-warning:hover { opacity: 0.85; }

/* ---- APP LAYOUT ---- */
#page-app { flex-direction: row; overflow: hidden; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition);
  z-index: 100;
}
.sidebar.collapsed { width: 68px; min-width: 68px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span:not(.nav-badge),
.sidebar.collapsed .user-meta,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0.75rem; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 1rem 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.brand-text { flex: 1; }
.brand-name { display: block; font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
[data-theme="light"] .brand-name { color: #e8ecf5; }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); }
[data-theme="light"] .brand-sub { color: #7c87a0; }

.sidebar-toggle {
  color: var(--text-muted);
  padding: 0.3rem;
  border-radius: 6px;
  transition: all var(--transition);
  font-size: 0.9rem;
}
.sidebar-toggle:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0.75rem 0.5rem 0.3rem;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  font-size: 0.875rem;
  font-weight: 400;
  position: relative;
}
[data-theme="light"] .nav-item { color: #9ca3c0; }
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
[data-theme="light"] .nav-item:hover { color: #e8ecf5; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59,130,246,0.2), rgba(59,130,246,0.05));
  color: #fff;
  font-weight: 500;
  border-left: 3px solid var(--accent-blue);
  padding-left: calc(0.75rem - 3px);
}

.nav-badge {
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}
.nav-badge.warning { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.nav-badge.danger { background: rgba(239,68,68,0.15); color: var(--accent-red); }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-avatar.sm { width: 30px; height: 30px; font-size: 0.7rem; border-radius: 8px; }
.user-name { display: block; font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="light"] .user-name { color: #e8ecf5; }
.user-role { display: block; font-size: 0.68rem; color: var(--text-muted); }
[data-theme="light"] .user-role { color: #7c87a0; }
.logout-btn { color: var(--text-muted); padding: 0.4rem; border-radius: 6px; transition: all var(--transition); font-size: 0.9rem; }
.logout-btn:hover { color: var(--accent-red); background: rgba(239,68,68,0.1); }

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.mobile-menu-btn { display: none; color: var(--text-secondary); font-size: 1.1rem; }
.breadcrumb { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); font-family: var(--font-display); }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap i { position: absolute; left: 10px; color: var(--text-muted); font-size: 0.8rem; }
.search-wrap input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem 0.45rem 2.1rem;
  color: var(--text-primary);
  width: 220px;
  outline: none;
  transition: border-color var(--transition), width var(--transition);
}
.search-wrap input:focus { border-color: var(--accent-blue); width: 280px; }

.topbar-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  transition: all var(--transition);
  position: relative;
}
.topbar-btn:hover { color: var(--accent-blue); border-color: var(--accent-blue); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--accent-red);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}
.topbar-user { cursor: pointer; }

/* ---- MODULE CONTENT ---- */
.module-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.module { display: none; }
.module.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.module-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
}
.header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.stat-icon.green { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.stat-icon.orange { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.stat-icon.red { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.stat-icon.teal { background: rgba(20,184,166,0.15); color: var(--accent-teal); }

.stat-body { flex: 1; min-width: 0; }
.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.2rem;
}
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.stat-trend { font-size: 0.72rem; display: flex; align-items: center; gap: 0.25rem; }
.stat-trend.up { color: var(--accent-green); }
.stat-trend.down { color: var(--accent-red); }

/* ---- CHARTS ---- */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.chart-card.wide { grid-column: span 1; }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chart-header h3 { font-family: var(--font-display); font-size: 0.95rem; font-weight: 600; }
.chart-legend { display: flex; align-items: center; gap: 1rem; font-size: 0.78rem; color: var(--text-secondary); }
.legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}
.legend-dot.blue { background: var(--accent-blue); }
.legend-dot.green { background: var(--accent-green); }

/* ---- BOTTOM ROW ---- */
.bottom-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
}

/* ---- CARDS / TABLES ---- */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}
.data-table thead tr {
  background: var(--bg-secondary);
}
.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---- BADGES & STATUS ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-active, .badge.active { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.badge-pending, .badge.pending { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.badge-rejected, .badge-defaulted { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.badge-completed { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.badge-suspended { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.badge-blacklisted { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-overdue { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.badge-good { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.badge-high-risk { background: rgba(239,68,68,0.15); color: var(--accent-red); }

/* ---- ACTIVITY ---- */
.activity-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.activity-list { padding: 0.5rem; display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.activity-item:hover { background: var(--bg-card-hover); }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-dot.blue { background: var(--accent-blue); box-shadow: 0 0 6px var(--accent-blue); }
.activity-dot.green { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.activity-dot.orange { background: var(--accent-orange); box-shadow: 0 0 6px var(--accent-orange); }
.activity-dot.red { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
.activity-text { font-size: 0.82rem; flex: 1; }
.activity-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ---- SEARCH BAR ---- */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-bar i { position: absolute; left: 10px; color: var(--text-muted); font-size: 0.8rem; }
.search-bar input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem 0.45rem 2.1rem;
  color: var(--text-primary);
  width: 200px;
  outline: none;
  transition: border-color var(--transition);
}
.search-bar input:focus { border-color: var(--accent-blue); }

.select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  font-size: 0.82rem;
  transition: border-color var(--transition);
}
.select-sm:focus { border-color: var(--accent-blue); }

/* ---- LOANS TABS ---- */
.loans-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  background: var(--bg-card);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}
.tab-btn {
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.tab-btn.active { background: var(--accent-blue); color: #fff; font-weight: 500; }
.tab-count { background: rgba(255,255,255,0.15); padding: 0.05rem 0.4rem; border-radius: 10px; font-size: 0.68rem; }
.tab-count.danger { background: rgba(239,68,68,0.3); color: #fca5a5; }

/* ---- STATS MINI ---- */
.stats-mini {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.mini-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mini-stat.warning { border-color: rgba(245,158,11,0.3); }
.mini-val { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.mini-stat.warning .mini-val { color: var(--accent-orange); }
.mini-label { font-size: 0.75rem; color: var(--text-secondary); }

/* ---- COLLECTIONS ---- */
.risk-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.78rem;
}
.risk-item { display: flex; align-items: center; gap: 0.4rem; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; }
.risk-item.good .risk-dot { background: var(--accent-green); }
.risk-item.warning .risk-dot { background: var(--accent-orange); }
.risk-item.high .risk-dot { background: #f97316; }
.risk-item.default .risk-dot { background: var(--accent-red); }
.risk-item.blacklist .risk-dot { background: #6b7280; }

/* ---- REPORTS ---- */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.report-card:hover { border-color: var(--accent-blue); transform: translateY(-2px); box-shadow: var(--shadow); }
.report-icon {
  width: 44px; height: 44px;
  background: rgba(59,130,246,0.15);
  color: var(--accent-blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.report-icon.red { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.report-icon.green { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.report-icon.orange { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.report-icon.purple { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
.report-card h3 { font-size: 0.9rem; font-weight: 600; }
.report-card p { font-size: 0.78rem; color: var(--text-secondary); flex: 1; }
.report-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem; }

/* ---- NOTIFICATIONS ---- */
.notif-channels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}
.channel-card i { font-size: 1.5rem; color: var(--accent-blue); }
.channel-card .fab.fa-whatsapp { color: #25D366; }
.channel-status { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 10px; }
.channel-status.active { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.channel-status.pending { background: rgba(245,158,11,0.15); color: var(--accent-orange); }

.notif-list { display: flex; flex-direction: column; gap: 0.5rem; }
.notif-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.notif-item.unread { border-left: 3px solid var(--accent-blue); }
.notif-dot-big {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.notif-body { flex: 1; }
.notif-title { font-size: 0.85rem; font-weight: 500; margin-bottom: 0.2rem; }
.notif-desc { font-size: 0.78rem; color: var(--text-secondary); }
.notif-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ---- SETTINGS ---- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.settings-section h3 {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.settings-section h3 i { color: var(--accent-blue); }
.settings-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; }

.loan-products { display: flex; flex-direction: column; gap: 0.5rem; }
.loan-product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.loan-product-item .rate { color: var(--accent-blue); font-weight: 600; }

.branch-list { display: flex; flex-direction: column; gap: 0.5rem; }
.branch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* ---- TOGGLE ---- */
.toggle { position: relative; display: inline-flex; width: 40px; height: 22px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 22px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent-blue); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---- PAGINATION ---- */
.pagination { display: flex; gap: 0.3rem; }
.page-btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
}
.page-btn:hover, .page-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }

/* ---- ACTION BUTTONS ---- */
.action-btns { display: flex; gap: 0.3rem; }
.action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
}
.action-btn.view { background: rgba(59,130,246,0.1); color: var(--accent-blue); }
.action-btn.view:hover { background: var(--accent-blue); color: #fff; }
.action-btn.edit { background: rgba(245,158,11,0.1); color: var(--accent-orange); }
.action-btn.edit:hover { background: var(--accent-orange); color: #fff; }
.action-btn.delete { background: rgba(239,68,68,0.1); color: var(--accent-red); }
.action-btn.delete:hover { background: var(--accent-red); color: #fff; }
.action-btn.approve { background: rgba(16,185,129,0.1); color: var(--accent-green); }
.action-btn.approve:hover { background: var(--accent-green); color: #fff; }

/* ---- DATE RANGE ---- */
.date-range { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--text-secondary); }
.input-sm {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  color: var(--text-primary);
  font-size: 0.78rem;
  outline: none;
}

/* ---- MODALS ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.2s ease;
}
.modal.large { max-width: 760px; }
.modal.xlarge { max-width: 900px; }

@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; }
.modal-close { color: var(--text-muted); font-size: 1rem; padding: 0.3rem; border-radius: 6px; transition: all var(--transition); }
.modal-close:hover { color: var(--accent-red); background: rgba(239,68,68,0.1); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---- MODAL TABS ---- */
.modal-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.modal-tabs .tab-btn {
  border-radius: 0;
  padding: 0.6rem 1rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.modal-tabs .tab-btn.active {
  background: transparent;
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

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

/* ---- FORM GRID ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-grid .form-group input,
.form-grid .form-group select,
.form-grid .form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-grid .form-group input:focus,
.form-grid .form-group select:focus,
.form-grid .form-group textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}
.form-grid .form-group textarea { resize: vertical; min-height: 70px; }

/* ---- UPLOAD ZONE ---- */
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  position: relative;
}
.upload-zone:hover { border-color: var(--accent-blue); color: var(--accent-blue); background: var(--accent-blue-glow); }
.upload-zone i { font-size: 1.5rem; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---- LOAN CALC ---- */
.loan-calc-preview {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}
.calc-item { display: flex; flex-direction: column; gap: 0.2rem; }
.calc-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.calc-val { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.calc-val.highlight { color: var(--accent-blue); }
.calc-val.danger { color: var(--accent-red); }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 9999;
  display: none;
  align-items: center;
  gap: 0.6rem;
  max-width: 340px;
  animation: slideUp 0.2s ease;
}
.toast.show { display: flex; }
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }
.toast i { font-size: 1rem; }
.toast.success i { color: var(--accent-green); }
.toast.error i { color: var(--accent-red); }
.toast.info i { color: var(--accent-blue); }

/* ---- AUDIT LOGS ---- */
.log-action { font-size: 0.78rem; color: var(--text-secondary); }

/* ---- INLINE FORM INPUTS ---- */
input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="date"], input[type="password"], select, textarea {
  font-family: var(--font-body);
}

/* ---- SCROLLBARS ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- SIDEBAR OVERLAY (mobile) ---- */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
#sidebar-overlay.active { display: block; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1100px) {
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
  .loan-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }

  html, body { overflow: hidden; }

  #page-app { flex-direction: row; overflow: hidden; }

  /* Sidebar slides in from left */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed { width: var(--sidebar-width) !important; min-width: var(--sidebar-width) !important; }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .nav-item span:not(.nav-badge),
  .sidebar.collapsed .user-meta,
  .sidebar.collapsed .nav-badge { display: flex; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 0.6rem 0.75rem; }
  .sidebar.collapsed .sidebar-header { justify-content: flex-start; padding: 1rem 1.2rem; }

  .main-content { width: 100%; overflow-y: auto; }

  .mobile-menu-btn { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { width: 96vw; max-width: 96vw; margin: 12px auto; }
  .modal.large { max-width: 96vw; }
  .data-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .table-card { overflow-x: auto; }
  .module { padding: 12px; overflow-y: auto; }
  .module-header { flex-direction: column; gap: 10px; align-items: flex-start; }
  .header-actions { flex-wrap: wrap; gap: 6px; width: 100%; }
  .stats-mini { grid-template-columns: repeat(2, 1fr); }
  .action-btns { flex-wrap: wrap; gap: 3px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
  .notif-channels { grid-template-columns: repeat(2, 1fr); }
  .reports-grid { grid-template-columns: 1fr 1fr; }
  .loan-detail-grid { grid-template-columns: 1fr; }
  .detail-row { font-size: 0.8rem; }
  .topbar { padding: 0 12px; }
  .topbar-actions { gap: 6px; }
  .breadcrumb { font-size: 0.85rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-mini { grid-template-columns: 1fr 1fr; }
  .module { padding: 10px; }
  .topbar { padding: 0 10px; }
  .topbar-right { gap: 6px; }
  .modal { width: 100vw; max-width: 100%; border-radius: 0; margin: 0; min-height: 0; }
  .modal.large { border-radius: 0; }
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .reports-grid { grid-template-columns: 1fr; }
  .notif-channels { grid-template-columns: repeat(2, 1fr); }
  .header-actions .btn-ghost { font-size: 0.75rem; padding: 0.4rem 0.7rem; }
  .stats-card { padding: 1rem; }
  .stats-card-val { font-size: 1.4rem; }
  .schedule-table th, .schedule-table td { font-size: 11px; padding: 4px 6px; }
}

/* ---- LOAN DETAIL ---- */
.loan-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.detail-section {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.detail-section h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.75rem; }
.detail-row { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-secondary); }
.detail-row span:last-child { font-weight: 500; }

.schedule-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; margin-top: 0.5rem; }
.schedule-table th { padding: 0.4rem 0.6rem; text-align: left; font-size: 0.68rem; text-transform: uppercase; color: var(--text-muted); }
.schedule-table td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
.schedule-table tr.paid td { opacity: 0.5; }
.schedule-table .due { color: var(--accent-orange); }
.schedule-table .overdue-row td { background: rgba(239,68,68,0.05); }

/* ================================================================
   LendBW — Portal Addons (appended)
   ================================================================ */

/* Missing CSS variables used by portal */
:root {
  --bg-hover: rgba(255,255,255,0.04);
  --accent-orange: #f97316;
}
[data-theme="light"] {
  --bg-hover: rgba(0,0,0,0.04);
}

/* Icon button */
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  font-size: 15px;
  position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }

/* Badge lg size */
.badge.lg { font-size: 13px; padding: 5px 14px; }

/* input-wrap select support */
.input-wrap select {
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  padding-left: 36px;
  color: var(--text-primary);
  font-size: 14px;
  height: 100%;
  cursor: pointer;
}

/* ================================================================
   DYNAMIC SETTINGS MODULE
   ================================================================ */
.settings-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.stab {
  flex: 1;
  min-width: 100px;
  padding: 8px 14px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.stab:hover  { background: var(--bg-hover); color: var(--text-primary); }
.stab.active { background: var(--accent-blue); color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.stab i { font-size: 12px; }

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

.settings-section.full { grid-column: 1 / -1; }

.branch-list { display: flex; flex-direction: column; gap: 10px; }
.branch-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.branch-item-info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.branch-item-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.branch-item-meta { font-size: 12px; color: var(--text-muted); }
.branch-item-actions { display: flex; gap: 6px; }

.loading-row { text-align: center; color: var(--text-muted); padding: 20px; font-size: 14px; }

.mini-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}
.mini-stat.warning { border-color: rgba(249,115,22,.3); background: rgba(249,115,22,.04); }
.mini-val   { display: block; font-size: 20px; font-weight: 800; color: var(--text-primary); }
.mini-label { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.mini-stat.warning .mini-val { color: var(--accent-orange, #f97316); }

/* Color preview swatch */
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(255,255,255,.2);
  vertical-align: middle;
}

/* ================================================================
   PAGINATION — admin panel
   ================================================================ */
.pagination-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0 8px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover  { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.page-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); box-shadow: 0 4px 12px rgba(59,130,246,.3); }

/* Empty cell */
.empty-cell {
  text-align: center;
  padding: 32px !important;
  color: var(--text-muted);
  font-size: 14px;
}

/* Detail row (borrower view modal) */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--text-muted); }
.detail-row span:last-child  { color: var(--text-primary); font-weight: 500; text-align: right; max-width: 60%; }

/* Loan detail grid */
.loan-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}
@media (max-width: 700px) { .loan-detail-grid { grid-template-columns: 1fr; } }

.detail-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-blue);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Schedule table inside loan detail */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.schedule-table th { padding: 7px 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 10px; border-bottom: 1px solid var(--border); text-align: left; }
.schedule-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.03); color: var(--text-secondary); }
.schedule-table tr.paid td { color: var(--text-muted); }
.schedule-table tr:hover td { background: var(--bg-hover); }

/* Loan product item in settings */
.loan-product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.loan-product-item span:first-child { flex: 1; font-weight: 600; color: var(--text-primary); font-size: 14px; }
.loan-product-item .rate { color: var(--accent-blue); font-weight: 700; }

/* Calc items in loan modal */
.loan-calc-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-top: 8px; }
.calc-item      { background: var(--bg-secondary); border-radius: 8px; padding: 10px 12px; }
.calc-label     { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.calc-val       { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.calc-val.highlight { color: var(--accent-blue); }
.calc-val.danger    { color: var(--accent-red); }

/* Blocked notice (portal apply) */
.blocked-notice {
  background: rgba(249,115,22,.08);
  border: 1px solid rgba(249,115,22,.25);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  font-size: 14px;
  margin-bottom: 20px;
}
.blocked-notice strong { color: var(--text-primary); font-size: 16px; }
.blocked-notice p { color: var(--text-muted); margin: 6px 0 0; line-height: 1.6; }

/* Badge extras */
.badge-good       { background: rgba(16,185,129,.12); color: #10b981; }
.badge-warning    { background: rgba(245,158,11,.12); color: #f59e0b; }
.badge-high-risk  { background: rgba(239,68,68,.12);  color: #ef4444; }
.badge-blacklisted{ background: rgba(107,114,128,.15);color: #6b7280; }
.badge-suspended  { background: rgba(107,114,128,.12);color: #9ca3af; }
.badge-overdue    { background: rgba(239,68,68,.12);  color: #ef4444; }
.badge-defaulted  { background: rgba(239,68,68,.15);  color: #dc2626; }
.badge-completed  { background: rgba(59,130,246,.12); color: #3b82f6; }

/* Info-note (used in some modals) */
.info-note {
  background: rgba(59,130,246,.06);
  border: 1px solid rgba(59,130,246,.15);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

/* ── Risk level radio group (Set Risk modal) ───────────────────── */
.risk-radio-group { display: flex; flex-direction: column; gap: 8px; }
.risk-radio-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  border: 1.5px solid var(--border);
  cursor: pointer; transition: all .18s;
  background: var(--bg-secondary);
}
.risk-radio-item:hover { border-color: var(--accent-blue); background: var(--bg-hover); }
.risk-radio-item input[type="radio"] { display: none; }
.risk-radio-item input[type="radio"]:checked ~ .risk-radio-icon { transform: scale(1.15); }
.risk-radio-item:has(input:checked) { border-color: currentColor; }
.risk-radio-item .risk-radio-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0; transition: transform .2s;
}
.risk-radio-item strong { font-size: 13px; color: var(--text-primary); }
.risk-radio-item small  { font-size: 11px; color: var(--text-muted); }

.risk-radio-item.risk-good       { color: #10b981; }
.risk-radio-item.risk-good:has(input:checked) { background: rgba(16,185,129,.08); }
.risk-radio-item.risk-good .risk-radio-icon { background: rgba(16,185,129,.12); }

.risk-radio-item.risk-warning     { color: #f59e0b; }
.risk-radio-item.risk-warning:has(input:checked) { background: rgba(245,158,11,.08); }
.risk-radio-item.risk-warning .risk-radio-icon { background: rgba(245,158,11,.12); }

.risk-radio-item.risk-high        { color: #f97316; }
.risk-radio-item.risk-high:has(input:checked) { background: rgba(249,115,22,.08); }
.risk-radio-item.risk-high .risk-radio-icon { background: rgba(249,115,22,.12); }

.risk-radio-item.risk-defaulted   { color: #ef4444; }
.risk-radio-item.risk-defaulted:has(input:checked) { background: rgba(239,68,68,.08); }
.risk-radio-item.risk-defaulted .risk-radio-icon { background: rgba(239,68,68,.12); }

.risk-radio-item.risk-blacklisted { color: #6b7280; }
.risk-radio-item.risk-blacklisted:has(input:checked) { background: rgba(107,114,128,.08); }
.risk-radio-item.risk-blacklisted .risk-radio-icon { background: rgba(107,114,128,.12); }

/* ══════════════════════════════════════════════════════════════
   MODAL-BOX  (matches .modal — fixes transparent new modals)
══════════════════════════════════════════════════════════════ */
.modal-box {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  animation: slideUp 0.2s ease;
  overflow: hidden;
}
.modal-box .modal-body { background: var(--bg-modal); }
.modal-box .modal-header { background: var(--bg-modal); border-bottom: 1px solid var(--border); }
.modal-box .modal-footer { background: var(--bg-modal); border-top: 1px solid var(--border); }

/* ── Back button ─────────────────────────────────────────────── */
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  padding: 5px 10px; border-radius: 8px;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-back:hover { color: var(--text-primary); background: var(--bg-card-hover); border-color: var(--border); }

/* ── Modal header with back button layout ───────────────────── */
.modal-header-row {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.modal-header-row h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Permissions Matrix ─────────────────────────────────────── */
.perm-matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-matrix th, .perm-matrix td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; font-weight: 600; color: var(--text-secondary); }
.perm-matrix thead th { background: var(--bg-secondary); color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.perm-matrix tbody tr:hover { background: var(--bg-card-hover); }
.perm-check { width: 16px; height: 16px; accent-color: var(--accent-blue); cursor: pointer; }
.perm-section-header td { background: var(--bg-secondary); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); padding: 6px 10px; }

/* ── Contract Template Editor ───────────────────────────────── */
.contract-template-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.contract-template-card .cth {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.contract-template-card .cth h4 { font-size: 13px; font-weight: 700; margin: 0; }
.contract-template-body { padding: 16px; }
.template-editor {
  width: 100%; min-height: 200px; padding: 12px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1.5px solid var(--border); border-radius: 10px;
  font-family: 'Courier New', monospace; font-size: 12px;
  line-height: 1.6; resize: vertical;
  transition: border-color .2s;
}
.template-editor:focus { border-color: var(--accent-blue); outline: none; }
.template-vars { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.template-var { background: rgba(59,130,246,.12); color: var(--accent-blue); border: 1px solid rgba(59,130,246,.25); border-radius: 6px; padding: 2px 8px; font-size: 11px; font-family: monospace; cursor: pointer; }
.template-var:hover { background: rgba(59,130,246,.2); }

/* ── Portal Contracts Section ───────────────────────────────── */
.portal-contract-card {
  background: var(--portal-card, #fff);
  border: 1px solid var(--portal-border, #e2e8f0);
  border-radius: 14px; padding: 16px; margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 14px;
}
.pcc-icon { width: 44px; height: 44px; border-radius: 10px; background: rgba(16,185,129,.1); color: #10b981; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.pcc-body { flex: 1; min-width: 0; }
.pcc-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.pcc-meta  { font-size: 12px; color: var(--portal-muted, #64748b); margin-bottom: 10px; }
.pcc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Portal Signature Canvas ────────────────────────────────── */
.portal-sig-wrap {
  border: 2px dashed var(--portal-border, #cbd5e1);
  border-radius: 12px; background: #fff;
  position: relative; overflow: hidden;
}
.portal-sig-wrap canvas { display: block; width: 100%; height: 160px; touch-action: none; cursor: crosshair; }
.portal-sig-hint { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; color: #ccc; font-size: 11px; pointer-events: none; user-select: none; }

/* ── General form / settings polish ────────────────────────── */
.form-control { background: var(--bg-input); color: var(--text-primary); border: 1.5px solid var(--border); border-radius: 8px; padding: 9px 12px; width: 100%; transition: border-color .2s; }
.form-control:focus { border-color: var(--accent-blue); outline: none; }
.stab-content { background: var(--bg-primary); }
.settings-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.settings-section h3 { background: var(--bg-secondary); padding: 12px 16px; font-size: 13px; font-weight: 700; border-bottom: 1px solid var(--border); margin: 0; }

/* Responsive modal-box */
@media (max-width: 768px) { .modal-box { width: 96vw; max-width: 96vw; } }
@media (max-width: 480px) { .modal-box { width: 100vw; max-width: 100%; border-radius: 0; } }
