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

:root {
  --white: #ffffff;
  --bg: #f8f9fc;
  --bg-card: #ffffff;
  --border: #e8eaf0;
  --border-light: #f0f2f7;
  --text-primary: #0f1623;
  --text-secondary: #4a5568;
  --text-muted: #8a94a6;
  --accent: #1a56db;
  --accent-light: #ebf0ff;
  --accent-hover: #1648c2;
  --green: #059669;
  --green-light: #ecfdf5;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --red: #dc2626;
  --red-light: #fef2f2;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --cyan: #0891b2;
  --shadow-sm: 0 1px 3px rgba(15,22,35,0.06), 0 1px 2px rgba(15,22,35,0.04);
  --shadow: 0 4px 16px rgba(15,22,35,0.08), 0 2px 6px rgba(15,22,35,0.05);
  --shadow-lg: 0 12px 40px rgba(15,22,35,0.12), 0 4px 12px rgba(15,22,35,0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent) 0%, #3b82f6 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 16px;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.sidebar-logo .logo-text { line-height: 1.2; }
.sidebar-logo .logo-text strong {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--text-primary); font-family: var(--font-display);
}
.sidebar-logo .logo-text span {
  font-size: 11px; color: var(--text-muted); font-weight: 400;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section-label {
  padding: 10px 20px 4px;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  border-radius: 0;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  position: relative;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content: '';
  position: absolute; left: -8px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-light);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}
.user-card:hover { background: var(--border-light); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 12px; font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-info strong {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info span { font-size: 11px; color: var(--text-muted); }

/* ── MAIN AREA ── */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700;
  color: var(--text-primary);
}

.topbar-breadcrumb {
  font-size: 12.5px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.topbar-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.topbar-breadcrumb a:hover { color: var(--accent); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.topbar-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--accent); border-color: var(--accent); }
.topbar-icon-btn svg { width: 16px; height: 16px; }
.topbar-icon-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); border: 1.5px solid white;
}

.page-content { flex: 1; padding: 28px; }

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

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
}
.card-header h3 {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700;
  color: var(--text-primary); flex: 1;
}
.card-body { padding: 22px; }

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

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.blue { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--green-light); color: var(--green); }
.stat-icon.amber { background: var(--amber-light); color: var(--amber); }
.stat-icon.red { background: var(--red-light); color: var(--red); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.cyan { background: #ecfeff; color: var(--cyan); }

.stat-info { flex: 1; }
.stat-info .stat-label {
  font-size: 12px; font-weight: 500;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.stat-info .stat-value {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 800;
  color: var(--text-primary); line-height: 1.2; margin: 2px 0;
}
.stat-info .stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-change { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.stat-change.up { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer; border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(26,86,219,0.3); }

.btn-success { background: var(--green); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg); color: var(--text-primary); border-color: var(--text-muted); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
}
label .req { color: var(--red); margin-left: 3px; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=tel], input[type=date],
select, textarea {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

input::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a94a6' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--red); margin-top: 4px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px;
  font-size: 11.5px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  text-align: left; background: var(--bg);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

.td-actions { display: flex; gap: 6px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}

/* ── MULTI-STEP FORM ── */
.steps-nav {
  display: flex; gap: 0;
  margin-bottom: 28px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.step-item {
  flex: 1; padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  position: relative; cursor: pointer;
  transition: all var(--transition);
}
.step-item:last-child { border-right: none; }

.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--border); color: var(--text-muted);
  transition: all var(--transition);
}
.step-item.active { background: var(--accent-light); color: var(--accent); }
.step-item.active .step-num { background: var(--accent); color: white; }
.step-item.done { color: var(--green); }
.step-item.done .step-num { background: var(--green); color: white; }

.step-panel { display: none; }
.step-panel.active { display: block; }

/* ── DOCUMENT UPLOAD ── */
.doc-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.doc-upload-item {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background: var(--bg);
}
.doc-upload-item:hover { border-color: var(--accent); background: var(--accent-light); }
.doc-upload-item.uploaded { border-style: solid; border-color: var(--green); background: var(--green-light); }
.doc-upload-item.processing { border-color: var(--amber); background: var(--amber-light); }

.doc-upload-icon { font-size: 28px; margin-bottom: 8px; display: block; }
.doc-upload-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); display: block; }
.doc-upload-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.doc-required-badge {
  position: absolute; top: 8px; right: 8px;
  font-size: 9px; font-weight: 700; padding: 2px 6px;
  border-radius: 10px; background: var(--red-light); color: var(--red);
}
.doc-upload-item input[type=file] { display: none; }

/* ── AI PANEL ── */
.ai-panel {
  background: linear-gradient(135deg, #f0f4ff 0%, #faf8ff 100%);
  border: 1px solid #c7d7ff;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.ai-panel-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.ai-badge {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.ai-status {
  font-size: 13px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 8px;
}
.ai-spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: none;
}
.ai-spinner.active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.ai-result-fields {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-top: 12px;
}
.ai-field-chip {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 12px;
}
.ai-field-chip .chip-label { color: var(--text-muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; }
.ai-field-chip .chip-value { font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.ai-source-tag {
  font-size: 11px; color: var(--text-muted); margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}

/* ── NOTIFICATIONS DROPDOWN ── */
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); z-index: 200; display: none;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.notif-dropdown-header h4 { font-size: 14px; font-weight: 700; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; gap: 10px; cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--accent-light); }
.notif-dot-icon {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 6px;
}
.notif-item-text strong { font-size: 13px; font-weight: 600; display: block; }
.notif-item-text span { font-size: 12px; color: var(--text-muted); }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── PIPELINE STAGES ── */
.pipeline-bar {
  display: flex; gap: 0; margin-bottom: 24px;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; overflow-x: auto;
}
.pipeline-stage {
  flex: 1; min-width: 100px; padding: 12px 10px;
  text-align: center; border-right: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.pipeline-stage:last-child { border-right: none; }
.pipeline-stage:hover { background: var(--bg); }
.pipeline-stage.active-filter { background: var(--accent-light); }
.pipeline-stage-count {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800; color: var(--text-primary);
}
.pipeline-stage-name { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-top: 2px; }

/* ── STAGE PROGRESS (detail view) ── */
.stage-progress {
  display: flex; align-items: center; margin-bottom: 24px; overflow-x: auto; padding-bottom: 4px;
}
.stage-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 90px; position: relative;
}
.stage-step:not(:last-child)::after {
  content: ''; position: absolute;
  top: 14px; left: calc(50% + 14px);
  width: calc(100% - 28px); height: 2px;
  background: var(--border);
}
.stage-step.done:not(:last-child)::after { background: var(--green); }
.stage-step.current:not(:last-child)::after { background: var(--accent); }

.stage-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--text-muted);
  font-size: 11px; font-weight: 700; z-index: 1;
  border: 2px solid var(--border);
}
.stage-step.done .stage-dot { background: var(--green); color: white; border-color: var(--green); }
.stage-step.current .stage-dot { background: var(--accent); color: white; border-color: var(--accent); }
.stage-step-name { font-size: 10.5px; color: var(--text-muted); font-weight: 500; text-align: center; }
.stage-step.current .stage-step-name { color: var(--accent); font-weight: 700; }
.stage-step.done .stage-step-name { color: var(--green); }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,22,35,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(16px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.btn-close-modal {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  font-size: 16px; transition: all var(--transition);
}
.btn-close-modal:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start;
  margin-bottom: 16px;
}
.alert-success { background: var(--green-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--red-light);   color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--amber-light);  color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: var(--accent-light); color: #1e40af; border: 1px solid #bfdbfe; }

/* ── RISK SCORE ── */
.risk-card {
  border-radius: var(--radius); padding: 20px;
  display: flex; gap: 16px; align-items: center;
}
.risk-card.LOW    { background: var(--green-light);  border: 1px solid #a7f3d0; }
.risk-card.MEDIUM { background: var(--amber-light);  border: 1px solid #fcd34d; }
.risk-card.HIGH   { background: var(--red-light);    border: 1px solid #fca5a5; }
.risk-card.CRITICAL{ background: #fff0f0; border: 1px solid #ef4444; }

.risk-score-circle {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 22px; font-weight: 800;
  flex-shrink: 0;
}
.LOW .risk-score-circle    { background: var(--green); color: white; }
.MEDIUM .risk-score-circle { background: var(--amber); color: white; }
.HIGH .risk-score-circle   { background: var(--red); color: white; }
.CRITICAL .risk-score-circle { background: #b91c1c; color: white; }

/* ── MISC ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; margin-bottom: 12px; }
.empty-state h4 { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 {
  font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--text-primary);
}
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.section-title {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 8px;
}

.filter-bar {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; margin-bottom: 16px;
}
.filter-bar input, .filter-bar select {
  width: auto; min-width: 160px; padding: 8px 12px; font-size: 13px;
}

.pagination {
  display: flex; gap: 4px; align-items: center; margin-top: 16px; justify-content: center;
}
.page-btn {
  min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--white); color: var(--text-secondary);
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); text-decoration: none;
}
.page-btn:hover { background: var(--bg); color: var(--text-primary); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
}

/* ── TOAST ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 12px 16px; min-width: 280px; max-width: 380px;
  display: flex; gap: 10px; align-items: center;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--accent); }
.toast-msg { font-size: 13.5px; font-weight: 500; flex:1; }

/* ── LOGIN ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #fafbff 50%, #f8f0ff 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 40px;
  border: 1px solid var(--border);
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .logo-box {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  font-size: 24px; font-weight: 800; color: white;
  font-family: var(--font-display);
}
.login-logo h1 { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--text-primary); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Full Mobile / Tablet / Desktop
   ═══════════════════════════════════════════════════════════ */

/* ── Mobile menu button — hidden on desktop ── */
.mobile-menu-btn {
  display: none;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-primary);
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,22,35,.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════
   TABLET  (≤ 1024px)
══════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }

  .stats-grid { grid-template-columns: repeat(3, 1fr); }

  .form-row-3 { grid-template-columns: 1fr 1fr; }

  .pipeline-bar { overflow-x: auto; }

  /* Table — allow horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
}

/* ══════════════════════
   MOBILE  (≤ 768px)
══════════════════════ */
@media (max-width: 768px) {

  /* Sidebar — off-canvas */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    width: 260px !important;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(15,22,35,.18);
  }

  /* Main area — full width */
  .main-area { margin-left: 0 !important; }

  /* Show hamburger */
  .mobile-menu-btn { display: flex; }

  /* Topbar */
  .topbar {
    padding: 0 14px;
    height: 56px;
    gap: 10px;
  }
  .topbar-title { font-size: 15px; }
  .topbar-breadcrumb { display: none; }

  /* Page content */
  .page-content { padding: 14px; }

  /* Page header — stack on small screens */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Stats grid — 2 columns */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-info .stat-value { font-size: 20px; }

  /* Forms — single column */
  .form-row,
  .form-row-3 { grid-template-columns: 1fr !important; gap: 0; }

  /* Step nav — horizontal scroll */
  .steps-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .step-item { min-width: 72px; padding: 10px 6px; }
  .step-item > div:last-child { font-size: 9.5px; }

  /* Cards */
  .card-header { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .card-header h3 { font-size: 14px; }
  .card-body { padding: 16px; }

  /* Tables — scrollable */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
  table { min-width: 560px; }
  thead th { padding: 9px 12px; font-size: 10.5px; }
  tbody td { padding: 11px 12px; font-size: 12.5px; }

  /* Pipeline bar */
  .pipeline-bar { overflow-x: auto; flex-wrap: nowrap; }
  .pipeline-stage { min-width: 80px; }
  .pipeline-stage-count { font-size: 18px; }
  .pipeline-stage-name { font-size: 10px; }

  /* Stage progress */
  .stage-progress { padding-bottom: 8px; }
  .stage-step { min-width: 72px; }
  .stage-step-name { font-size: 9.5px; }

  /* Filter bar — stack */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .btn { width: 100% !important; min-width: unset; }

  /* Document upload grid — 2 cols */
  .doc-upload-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .doc-upload-item { padding: 12px 8px; }
  .doc-upload-icon { font-size: 22px; }
  .doc-upload-label { font-size: 11px; }

  /* AI panel */
  .ai-panel { padding: 14px; }
  .ai-result-fields { grid-template-columns: 1fr 1fr; }

  /* Modals — full screen bottom sheet on mobile */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100% !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92vh;
  }
  .modal::before {
    content: '';
    display: block;
    width: 38px; height: 4px;
    background: var(--border);
    border-radius: 4px;
    margin: 12px auto 0;
  }
  .modal-header { padding: 14px 20px; }
  .modal-body   { padding: 16px 20px; }
  .modal-footer { padding: 14px 20px; }

  /* Notification dropdown — full width */
  .notif-dropdown { width: calc(100vw - 28px); right: -60px; }

  /* Toast — full width bottom */
  #toast-container {
    bottom: 16px; right: 14px; left: 14px;
  }
  .toast { min-width: unset; max-width: 100%; }

  /* Login card */
  .login-card { padding: 28px 20px; }

  /* Risk card */
  .risk-card { flex-direction: column; text-align: center; }

  /* Buttons in action rows */
  .td-actions { gap: 4px; }
  .btn-sm { padding: 5px 10px; font-size: 12px; }

  /* Section title */
  .section-title { font-size: 13px; }

  /* Sidebar footer user card — compact */
  .user-info strong { font-size: 12px; }
  .user-info span   { font-size: 10.5px; }
}

/* ══════════════════════
   SMALL PHONES  (≤ 420px)
══════════════════════ */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr !important; }

  .step-item { min-width: 58px; }
  .step-num  { width: 22px; height: 22px; font-size: 10px; }

  .doc-upload-grid { grid-template-columns: 1fr; }

  .page-content { padding: 10px; }

  .topbar { padding: 0 10px; }

  .card-body { padding: 12px; }

  /* Hide text in topbar icon buttons on very small screens */
  .topbar-actions .topbar-icon-btn { width: 32px; height: 32px; }

  table { min-width: 480px; }
}

/* ══════════════════════
   DESKTOP ONLY tweaks  (≥ 1280px)
══════════════════════ */
@media (min-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
  .page-content { padding: 28px 32px; }
}

/* ── Smooth sidebar transitions on all sizes ── */
.sidebar { will-change: transform; }

/* ── Safe area for notched phones ── */
.topbar {
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
@media (max-width: 768px) {
  .page-content {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Multi-step form nav buttons — mobile ── */
@media (max-width: 768px) {
  .steps-nav .step-item > div:last-child {
    display: none; /* hide labels on very narrow, show only numbers */
  }
  /* Step action buttons row */
  [style*="justify-content:space-between"] {
    flex-wrap: wrap;
    gap: 10px;
  }
  [style*="justify-content:flex-end"] {
    flex-wrap: wrap;
  }
}

/* ── Grid layout fixes for view page ── */
@media (max-width: 900px) {
  /* Application view — single column */
  div[style*="grid-template-columns:2fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }
  /* Settings two-col layout */
  div[style*="grid-template-columns:200px 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }
  div[style*="grid-template-columns:200px 1fr"] > div:first-child {
    position: static !important;
  }
}

/* ── Detail info grids on view pages ── */
@media (max-width: 600px) {
  div[style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Existing loans table on form ── */
@media (max-width: 768px) {
  #existingLoansTable { min-width: 700px; }
}

/* ── User card in table ── */
@media (max-width: 768px) {
  .user-avatar { width: 28px; height: 28px; font-size: 10px; }
}

/* ── Profile page ── */
@media (max-width: 900px) {
  div[style*="grid-template-columns:280px 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }
}

/* ── Ensure inputs don't zoom on iOS ── */
@media (max-width: 768px) {
  input[type=text], input[type=email], input[type=password],
  input[type=number], input[type=tel], input[type=date],
  select, textarea {
    font-size: 16px !important; /* prevents iOS zoom on focus */
  }
}

/* ── Step panels — ensure they show correctly on mobile ── */
.step-panel { animation: none; }

/* ── Wider tables get scroll hint shadow ── */
.table-wrap {
  position: relative;
}
.table-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, rgba(248,249,252,.9));
  pointer-events: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}
@media (min-width: 769px) {
  .table-wrap::after { display: none; }
}
