/* ============================================================
   LMS Enterprise – Design System & App Styles
   Modern Dark-Navy Enterprise Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

@font-face {
  font-display: block;
  font-family: bootstrap-icons;
  src: url("../fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),
       url("../fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");
}

/* ─── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --bg-body: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-header: #ffffff;
  --bg-card: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.10), 0 10px 10px -5px rgba(0,0,0,0.04);

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── DARK MODE ─────────────────────────────────────────────── */
body.dark-mode {
  --bg-body: #020617;
  --bg-surface: #0f172a;
  --bg-surface-2: #1e293b;
  --bg-sidebar: #020617;
  --bg-header: #0f172a;
  --bg-card: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #1e293b;
  --border-light: #334155;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

/* ─── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[ng-cloak], .ng-cloak, [data-ng-cloak], [x-ng-cloak] { display: none !important; }
html { scroll-behavior: smooth; }
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ─── AUTH WRAPPER ──────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
  top: -100px; left: -100px;
  border-radius: 50%;
}

.auth-wrapper::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(14,165,233,0.1) 0%, transparent 70%);
  bottom: -50px; right: -50px;
  border-radius: 50%;
}

.auth-card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  box-shadow: 0 32px 64px rgba(0,0,0,0.4);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 28px;
  color: white;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.auth-logo p { color: rgba(255,255,255,0.5); font-size: 13px; margin-top: 4px; }

.auth-form .form-label { color: rgba(255,255,255,0.7); font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.auth-form .form-control {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #ffffff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  transition: var(--transition);
}

.auth-form .form-control:focus {
  background: rgba(255,255,255,0.08);
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
  outline: none;
  color: #ffffff;
}

.auth-form .form-control::placeholder { color: rgba(255,255,255,0.3); }

.btn-auth {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(79,70,229,0.4);
  margin-top: 8px;
}

.btn-auth:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(79,70,229,0.5);
}

.btn-auth:disabled { opacity: 0.7; transform: none; }

.auth-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ─── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden;
}

body.sidebar-collapsed .sidebar { width: 72px; }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .badge-count { display: none; }
body.sidebar-collapsed .sidebar-footer .btn-logout span { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  gap: 12px;
}

.brand-icon {
  width: 40px; height: 40px;
  min-width: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  overflow: hidden;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
  padding: 4px;
}

.brand-text {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-collapse {
  color: var(--text-sidebar);
  font-size: 18px;
  padding: 4px;
  opacity: 0.5;
  transition: var(--transition);
}
.btn-collapse:hover { opacity: 1; color: #fff; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.user-avatar {
  width: 40px; height: 40px;
  min-width: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
}

.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(148,163,184,0.5);
  padding: 16px 20px 6px;
}

.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  margin: 1px 8px;
  transition: var(--transition);
  position: relative;
}

.nav-link i { font-size: 18px; min-width: 20px; text-align: center; }

.nav-link:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.nav-item.active .nav-link {
  background: linear-gradient(135deg, rgba(79,70,229,0.25), rgba(14,165,233,0.15));
  color: #fff;
  border-left: 3px solid var(--primary-light);
}

.badge-count {
  margin-left: auto;
  background: var(--danger);
  color: white;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  gap: 8px;
}

.btn-dark-mode, .btn-logout {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-sidebar);
  font-size: 16px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-dark-mode:hover { background: rgba(255,255,255,0.07); color: #fff; }
.btn-logout:hover { background: rgba(239,68,68,0.2); color: #f87171; }

/* ─── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.sidebar-collapsed .main-content {
  margin-left: 72px;
  width: calc(100% - 72px);
}

/* ─── TOP HEADER ────────────────────────────────────────────── */
.top-header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.btn-menu-toggle {
  font-size: 20px;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 8px;
  transition: var(--transition);
}
.btn-menu-toggle:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.breadcrumb { font-size: 13px; }
.breadcrumb-item a { color: var(--primary); }
.breadcrumb-item.active { color: var(--text-secondary); }

.company-badge {
  background: linear-gradient(135deg, rgba(79,70,229,0.1), rgba(14,165,233,0.1));
  border: 1px solid rgba(79,70,229,0.2);
  color: var(--primary-light);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-logo-img {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}

.top-search {
  position: relative;
  width: min(420px, 42vw);
}

.top-search > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  z-index: 1;
}

.top-search input {
  padding-left: 36px;
  height: 38px;
}

.top-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 1200;
}

.top-search-result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  color: var(--text-primary);
}

.top-search-result:hover { background: var(--bg-surface-2); }
.top-search-result small { display: block; color: var(--text-secondary); font-size: 11px; }
.top-search-empty { padding: 12px; color: var(--text-muted); font-size: 12px; }

.notification-bell {
  position: relative;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 8px;
  transition: var(--transition);
}
.notification-bell:hover { color: var(--primary); background: var(--bg-surface-2); }

.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: white;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.user-dropdown {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: var(--transition);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.user-dropdown:hover { background: var(--bg-surface-2); }

.user-avatar-sm {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  overflow: hidden;
}

.user-avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 1300;
}

.user-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
}

.user-menu button:hover { background: var(--bg-surface-2); }

/* ─── PAGE CONTENT ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── STAT CARDS ────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card.primary::before   { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card.success::before   { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.warning::before   { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.danger::before    { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-card.info::before      { background: linear-gradient(90deg, var(--info), #22d3ee); }
.stat-card.secondary::before { background: linear-gradient(90deg, var(--secondary), #38bdf8); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.stat-icon {
  width: 52px; height: 52px;
  min-width: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.stat-card.primary .stat-icon   { background: rgba(79,70,229,0.12); color: var(--primary); }
.stat-card.success .stat-icon   { background: rgba(16,185,129,0.12); color: var(--success); }
.stat-card.warning .stat-icon   { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-card.danger .stat-icon    { background: rgba(239,68,68,0.12); color: var(--danger); }
.stat-card.info .stat-icon      { background: rgba(6,182,212,0.12); color: var(--info); }
.stat-card.secondary .stat-icon { background: rgba(14,165,233,0.12); color: var(--secondary); }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

.stat-change {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

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

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
}

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

.card-title i { color: var(--primary); }
.card-body { padding: 20px; }

/* ─── TABLES ─────────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg-surface);
}

.search-box {
  position: relative;
  max-width: 300px;
  flex: 1;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

.search-box input {
  padding-left: 36px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-surface-2);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 13.5px;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--bg-surface-2); }

.table-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface);
}

/* ─── BADGES & STATUS ────────────────────────────────────────── */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }

.badge-active    { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-active::before    { background: var(--success); }
.badge-pending   { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-pending::before   { background: var(--warning); }
.badge-overdue   { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-overdue::before   { background: var(--danger); }
.badge-closed    { background: rgba(148,163,184,0.12); color: var(--text-muted); }
.badge-closed::before    { background: var(--text-muted); }
.badge-npa       { background: rgba(239,68,68,0.2); color: #dc2626; }
.badge-npa::before       { background: #dc2626; }
.badge-draft     { background: rgba(148,163,184,0.12); color: var(--text-secondary); }
.badge-approved  { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-rejected  { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-disbursed { background: rgba(99,102,241,0.12); color: var(--primary); }

/* ─── OVERDUE LOANS TABLE ───────────────────────────────────── */
.overdue-table-container .responsive-table {
  overflow-x: auto;
}

.overdue-table {
  min-width: 1120px;
  table-layout: fixed;
}

.overdue-table th,
.overdue-table td {
  padding: 12px 10px;
  vertical-align: middle;
}

.overdue-table th:nth-child(1),
.overdue-table td:nth-child(1) { width: 118px; }
.overdue-table th:nth-child(2),
.overdue-table td:nth-child(2) { width: 170px; }
.overdue-table th:nth-child(3),
.overdue-table td:nth-child(3) { width: 120px; }
.overdue-table th:nth-child(8),
.overdue-table td:nth-child(8) { width: 124px; }

.overdue-table .amount-col {
  width: 132px;
  text-align: right;
}

.overdue-table .count-col {
  width: 96px;
  text-align: center;
}

.overdue-table .status-col {
  width: 112px;
  text-align: center;
}

.overdue-table .action-col {
  width: 104px;
  text-align: center;
}

.overdue-table .text-wrap-cell {
  white-space: normal;
  word-break: break-word;
}

.loan-link-text { color: var(--primary); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tab-btn.active,
.tab-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: rgba(79,70,229,0.08);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.info-row-wide {
  grid-column: 1 / -1;
}
.muted-text { color: var(--text-muted); }

.dpd-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.dpd-pill.warning {
  background: rgba(245,158,11,0.15);
  color: var(--warning);
}

.dpd-pill.danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(79,70,229,0.4); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-secondary {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn-icon:hover { background: var(--bg-surface-2); }

/* ─── FORMS ──────────────────────────────────────────────────── */
.form-control, .form-select {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  background: var(--bg-card);
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-card);
}

.filter-field {
  min-width: 160px;
  flex: 1 1 160px;
}

.image-upload-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.photo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.customer-photo-thumb.large {
  width: 72px;
  height: 72px;
  min-width: 72px;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.responsive-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

.responsive-table table {
  min-width: 760px;
}

.table-container > table,
.responsive-table > table,
.table-container .responsive-table > table {
  width: max-content;
  min-width: 100%;
}

.table-container th,
.table-container td,
.responsive-table th,
.responsive-table td {
  white-space: nowrap;
}

.table-container .text-wrap-cell,
.responsive-table .text-wrap-cell {
  white-space: normal;
}

.table-container::-webkit-scrollbar,
.responsive-table::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-thumb,
.responsive-table::-webkit-scrollbar-thumb {
  background: var(--border, #e2e8f0);
  border-radius: 999px;
}

.table-container::-webkit-scrollbar-track,
.responsive-table::-webkit-scrollbar-track {
  background: var(--bg-surface-2);
  border-radius: 999px;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.detail-list span {
  color: var(--text-secondary);
  font-size: 12px;
}

.detail-list strong {
  text-align: right;
}

.empty-state.compact {
  padding: 18px;
  min-height: 0;
}

.customer-photo-picker {
  display: flex;
  align-items: center;
  gap: 16px;
}

.customer-photo-preview,
.customer-photo-large,
.customer-photo-thumb {
  background: var(--bg-surface-2);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.customer-photo-preview {
  width: 96px;
  height: 96px;
  min-width: 96px;
  border-radius: 8px;
}

.customer-photo-large {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
}

.customer-photo-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  font-size: 10px;
  text-align: center;
}

.customer-photo-thumb.small {
  width: 36px;
  height: 36px;
  min-width: 36px;
}

.customer-photo-preview img,
.customer-photo-large img,
.customer-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.form-control-static {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
}

.readonly-form { align-items: stretch; }

.loan-inline-panel {
  background: var(--bg-surface-2);
  border-radius: 8px;
  padding: 14px;
}

.compact-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  display: grid;
  margin-bottom: 12px;
}

/* ─── MODALS ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

.modal-lg { max-width: 920px; }
.modal-xl { max-width: 1120px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.detail-grid > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-secondary);
}

.detail-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.access-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.access-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
}

.access-panel-header,
.access-module-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.access-panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
}

.access-panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.access-panel-header span {
  font-size: 12px;
  color: var(--text-muted);
}

.access-module {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.access-module-title {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.access-option {
  width: 100%;
  display: block;
  border: 1px solid var(--border-light);
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 9px 10px;
  text-align: left;
  margin-bottom: 6px;
}

.access-option span,
.access-option small {
  display: block;
}

.access-option small {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.access-option.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.15);
}

.access-option.allowed {
  background: rgba(16,185,129,0.08);
}

.access-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { font-size: 20px; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.camera-modal { max-width: 620px; }
.camera-frame {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #0f172a;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
}
.camera-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: white;
  background: rgba(15,23,42,0.86);
}

.modal-box.approval-modal {
  max-width: 940px;
  width: calc(100vw - 40px);
}

.approval-modal .modal-header {
  padding: 14px 18px;
}

.approval-modal .modal-body {
  padding: 16px 18px;
}

.approval-modal .modal-footer {
  padding: 12px 18px;
}

.approval-profile {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-surface);
  margin-bottom: 12px;
}
.approval-profile-main h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.approval-meta {
  display: flex;
  gap: 8px 12px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 12px;
}
.approval-address {
  margin-top: 6px;
  color: var(--text-primary);
  font-size: 12px;
}
.approval-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.approval-section {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 10px 12px;
}
.approval-section h4 {
  margin: 0 0 6px;
  font-size: 13px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}
.info-row:last-child { border-bottom: 0; }
.info-row span { color: var(--text-secondary); }
.info-row strong { text-align: right; }
.approval-emi { margin-top: 10px; }
.approval-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}
.approval-modal .customer-photo-large {
  width: 118px;
  height: 118px;
  min-width: 118px;
  font-size: 11px;
}
.modal-box.approval-modal .compact-table {
  max-height: 220px;
  overflow: auto !important;
}
.table-container.approval-emi-table {
  width: 100%;
  overflow-x: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
.table-container.approval-emi-table table {
  min-width: 600px;
  table-layout: fixed;
}
.table-container.approval-emi-table th,
.table-container.approval-emi-table td {
  white-space: nowrap;
  text-align: right;
}
.table-container.approval-emi-table th:first-child,
.table-container.approval-emi-table td:first-child {
  width: 44px;
  text-align: center;
}
.table-container.approval-emi-table th:nth-child(2),
.table-container.approval-emi-table td:nth-child(2) {
  width: 92px;
  text-align: left;
}
.compact-table table th,
.compact-table table td {
  padding: 6px 8px;
  font-size: 11px;
}

/* ─── CHART CONTAINERS ───────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-wrapper { position: relative; height: 280px; }

/* ─── EMI TABLE ──────────────────────────────────────────────── */
.emi-schedule-table td:not(:first-child) { text-align: right; }
.emi-schedule-table .paid-row { background: rgba(16,185,129,0.05); }
.emi-schedule-table .overdue-row { background: rgba(239,68,68,0.05); }

/* ─── TOAST ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 3000;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-message {
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
}

.toast-success { background: var(--success); color: white; }
.toast-error   { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast-info    { background: var(--info); color: white; }

/* ─── PAGINATION ─────────────────────────────────────────────── */
.pagination-info { font-size: 12px; color: var(--text-secondary); }

.pagination .page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  transition: var(--transition);
  margin: 0 2px;
}

.pagination .page-btn:hover,
.pagination .page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── LOADING ────────────────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  flex-direction: column;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.4; display: block; }
.empty-state h3 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }

/* ─── WORKFLOW STEPS ─────────────────────────────────────────── */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 600;
  position: relative;
}

.step.done    { background: rgba(16,185,129,0.12); color: var(--success); }
.step.current { background: rgba(79,70,229,0.12); color: var(--primary); }
.step.pending { background: var(--bg-surface-2); color: var(--text-muted); }

.step-arrow { color: var(--text-muted); margin: 0 4px; }

.emi-preview-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.emi-preview-pager .pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
}

.emi-preview-pager .page-btn {
  padding: 5px 9px;
  font-size: 11px;
}

/* ─── SIDEBAR OVERLAY (MOBILE) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body {
    overflow-x: auto;
  }
  .sidebar { transform: translateX(-100%); width: 260px !important; }
  .sidebar .brand-text, .sidebar .user-info, .sidebar .nav-section,
  .sidebar .nav-link span, .sidebar .badge-count { display: inline-flex !important; }
  .sidebar .nav-section { display: block !important; }
  .sidebar-user { display: none; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .page-content {
    padding: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .auth-card { padding: 32px 24px; }
  .page-header { align-items: stretch; }
  .page-header > div:last-child,
  .page-header > a,
  .page-header > button { width: 100%; justify-content: center; }
  .page-header .icon-btn,
  .page-header > div:last-child .icon-btn {
    width: 38px;
    min-width: 38px;
    flex: 0 0 38px;
  }
  .table-toolbar { align-items: stretch; }
  .table-toolbar .form-select,
  .table-toolbar .form-control {
    width: 100% !important;
    min-width: 0;
  }
  .table-container,
  .responsive-table,
  .workflow-steps,
  .approval-meta,
  .filter-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
  }
  .table-container {
    max-width: 100%;
    padding-bottom: 2px;
  }
  .table-container table,
  .responsive-table table { min-width: 760px; }
  .table-container .empty-state,
  .table-container .table-footer,
  .table-container .table-toolbar { min-width: 0; }
  .search-box { max-width: none; width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .approval-grid { grid-template-columns: 1fr; }
  .approval-profile { flex-direction: column; }
  .modal-overlay { align-items: flex-start; padding: 12px; }
  .modal-box {
    width: 100%;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 12px;
  }
  .modal-body { padding: 16px; }
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }
  .filter-bar:has(> .btn:first-child) {
    display: flex;
    flex-wrap: nowrap;
  }
  .filter-bar:has(> .btn:first-child) .btn {
    flex: 0 0 auto;
    width: auto;
  }
  .filter-field {
    min-width: 0;
    width: 100%;
  }
  .form-select,
  .form-control {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }
  .filter-bar .btn {
    width: 100%;
    justify-content: center;
  }
  .top-header { gap: 8px; }
  .breadcrumb { display: none; }
  .header-left { flex: 1; min-width: 0; }
  .top-search { width: 100%; }
  .company-badge, .notification-bell, .user-dropdown span { display: none; }
  .customer-photo-picker { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 768px) {
  .table-container::-webkit-scrollbar,
  .responsive-table::-webkit-scrollbar,
  .page-content::-webkit-scrollbar,
  .main-content::-webkit-scrollbar,
  .workflow-steps::-webkit-scrollbar,
  .approval-meta::-webkit-scrollbar,
  .filter-bar::-webkit-scrollbar {
    height: 8px;
  }

  .table-container::-webkit-scrollbar-thumb,
  .responsive-table::-webkit-scrollbar-thumb,
  .page-content::-webkit-scrollbar-thumb,
  .main-content::-webkit-scrollbar-thumb,
  .workflow-steps::-webkit-scrollbar-thumb,
  .approval-meta::-webkit-scrollbar-thumb,
  .filter-bar::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 999px;
  }

  .table-container::-webkit-scrollbar-track,
  .responsive-table::-webkit-scrollbar-track,
  .page-content::-webkit-scrollbar-track,
  .main-content::-webkit-scrollbar-track,
  .workflow-steps::-webkit-scrollbar-track,
  .approval-meta::-webkit-scrollbar-track,
  .filter-bar::-webkit-scrollbar-track {
    background: var(--bg-surface-2);
    border-radius: 999px;
  }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .top-header { padding: 0 16px; }
  .company-badge { display: none; }
}

/* ─── PRINT STYLES ───────────────────────────────────────────── */
.print-report { display: none; }

.print-preview {
  max-height: 360px;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #111;
  box-shadow: var(--shadow-sm);
}

.print-preview table {
  width: 100%;
  border-collapse: collapse;
}

.print-preview th,
.print-preview td {
  padding: 7px 8px;
  border: 1px solid #d1d5db;
}

.template-preview-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.template-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

@media (max-width: 575.98px) {
  .template-preview-header {
    align-items: stretch;
    flex-direction: column;
  }
}

.repayment-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface-2);
}

.repayment-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.repayment-summary span {
  color: var(--text-muted);
  font-size: 13px;
}

.repayment-summary strong {
  text-align: right;
}

.repayment-form .form-label {
  margin-bottom: 6px;
}

.report-period {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0 0 16px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--bg-surface-2);
  font-size: 13px;
  font-weight: 600;
}

.adhoc-builder {
  margin-bottom: 18px;
}

.adhoc-saved-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) auto auto minmax(200px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.adhoc-saved-select,
.adhoc-report-name {
  min-width: 0;
}

.adhoc-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.adhoc-columns-title {
  width: 100%;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.adhoc-column-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface-2);
  cursor: pointer;
  font-size: 13px;
}

.adhoc-column-check input {
  margin: 0;
}

.adhoc-results td,
.adhoc-results th {
  white-space: nowrap;
}

/* ─── AI ASSISTANT ─────────────────────────────────────────── */
.assistant-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1100px;
}

.assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assistant-message {
  display: flex;
}

.assistant-message.user {
  justify-content: flex-end;
}

.assistant-bubble {
  width: min(100%, 920px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.assistant-message.user .assistant-bubble {
  width: auto;
  max-width: min(760px, 90%);
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.assistant-role {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.assistant-message.user .assistant-role {
  color: rgba(255,255,255,0.75);
}

.assistant-text {
  font-size: 14px;
  color: inherit;
}

.assistant-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.assistant-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
}

.assistant-card-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
}

.assistant-card-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.assistant-table {
  margin-top: 12px;
  box-shadow: none;
}

.assistant-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.assistant-input {
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 12px;
  background: var(--bg-body);
  padding-top: 4px;
}

.assistant-input .form-control {
  min-height: 44px;
}

.assistant-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 20px;
}

.assistant-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: assistantTyping 1s infinite ease-in-out;
}

.assistant-typing span:nth-child(2) { animation-delay: 0.12s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.24s; }

@keyframes assistantTyping {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 575.98px) {
  .adhoc-saved-row {
    grid-template-columns: 1fr;
  }

  .adhoc-saved-row .btn {
    width: 100%;
    justify-content: center;
  }

  .repayment-summary div {
    display: block;
  }

  .repayment-summary strong {
    display: block;
    margin-top: 3px;
    text-align: left;
  }

  .assistant-input {
    flex-direction: column;
    position: static;
  }

  .assistant-input .btn {
    width: 100%;
  }
}

@media print {
  .sidebar, .top-header, .btn, .modal-overlay, .page-content > :not(.print-report) { display: none !important; }
  .main-content { margin-left: 0 !important; width: 100% !important; }
  .page-content { padding: 0 !important; }
  .print-report {
    display: block !important;
    color: #111;
    background: #fff;
    font-family: Arial, sans-serif;
    font-size: 12px;
  }
  .print-report h1 {
    font-size: 22px;
    margin: 4px 0 2px;
    text-align: left;
  }
  .print-report .print-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
  }
  .print-report .report-title {
    text-align: left;
    font-weight: 700;
    font-size: 16px;
  }
  .print-report .report-logo {
    max-width: 110px;
    max-height: 72px;
    object-fit: contain;
  }
  .print-report .report-meta {
    text-align: left;
    color: #555;
    margin-bottom: 0;
  }
  .print-report .columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
  }
  .print-report h2 {
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #111;
    padding-bottom: 6px;
    margin: 0 0 8px;
  }
  .print-report table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
  }
  .print-report th,
  .print-report td {
    border: 1px solid #bbb;
    padding: 7px 8px;
    text-align: left;
  }
  .print-report th { background: #f1f5f9; }
  .print-report .amount,
  .print-report td:last-child,
  .print-report th:last-child { text-align: right; }
  .print-report .totals th { background: #e2e8f0; }
  .print-report .empty {
    border: 1px solid #ddd;
    padding: 8px;
    color: #777;
    margin-bottom: 16px;
  }
}
