:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --sidebar-bg: #111827;
  --sidebar-bg-active: #1f2937;
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #ffffff;
  --page-bg: #f3f4f6;
  --border-color: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0891b2;
  --info-bg: #cffafe;
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text-main);
  font-size: 0.9375rem;
}

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.25rem 1.25rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  padding: 1.1rem 1.25rem 0.4rem;
  font-weight: 600;
}

.sidebar-scroll { flex: 1; overflow-y: auto; padding-bottom: 1rem; }

.sidebar-nav { padding-bottom: 0.25rem; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--sidebar-text);
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; opacity: 0.85; }

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--primary);
}

.sidebar-nav .nav-link.active i { opacity: 1; color: #a5b4fc; }

.sidebar-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.75rem;
  color: #6b7280;
}

/* ---------- Main column ---------- */
.main-col {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--text-main); }
.topbar-title .text-muted-sep { color: var(--text-muted); font-weight: 400; margin: 0 0.35rem; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.5rem 0.3rem 0.3rem;
  border-radius: 999px;
  background: var(--page-bg);
}

.user-chip .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.content-area { padding: 1.75rem; flex: 1; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header-clean {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

/* ---------- Stat tiles ---------- */
.stat-tile {
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  background: #fff;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  height: 100%;
}

.stat-tile .icon-box {
  width: 44px;
  height: 44px;
  border-radius: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.stat-tile .stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; color: var(--text-main); }
.stat-tile .stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

.icon-box.tone-indigo { background: var(--primary-light); color: var(--primary); }
.icon-box.tone-green  { background: var(--success-bg); color: var(--success); }
.icon-box.tone-cyan   { background: var(--info-bg); color: var(--info); }
.icon-box.tone-amber  { background: #fef3c7; color: #b45309; }
.icon-box.tone-rose   { background: #ffe4e6; color: #be123c; }

/* ---------- Quick action cards ---------- */
.quick-action {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  background: #fff;
  text-decoration: none;
  color: var(--text-main);
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
  height: 100%;
}

.quick-action:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.12);
  transform: translateY(-1px);
  color: var(--text-main);
}

.quick-action .icon-box { width: 40px; height: 40px; font-size: 1rem; }
.quick-action .qa-title { font-weight: 600; font-size: 0.9rem; }
.quick-action .qa-sub { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Tables ---------- */
.table-clean thead th {
  background: #f9fafb;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table-clean tbody td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: #fafafe; }

/* ---------- Badges ---------- */
.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-soft.badge-rural { background: var(--success-bg); color: #15803d; }
.badge-soft.badge-urban { background: var(--info-bg); color: #0e7490; }
.badge-soft.badge-neutral { background: var(--page-bg); color: var(--text-muted); }
.badge-soft.badge-approved { background: var(--success-bg); color: #15803d; }
.badge-soft.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-soft.badge-pending { background: var(--page-bg); color: var(--text-muted); }
.badge-soft.badge-system-error { background: #fef3c7; color: #b45309; }

/* ---------- Filter bar ---------- */
.filter-bar {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.filter-bar .filter-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.filter-bar .form-select { font-size: 0.8125rem; }

/* ---------- Pagination ---------- */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.pagination-bar .results-note { font-size: 0.8rem; color: var(--text-muted); }

.pagination { margin-bottom: 0; }

.pagination .page-link {
  border-color: var(--border-color);
  color: var(--text-main);
  font-size: 0.8125rem;
  padding: 0.35rem 0.65rem;
}

.pagination .page-link:hover { background: var(--primary-light); color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .page-item.disabled .page-link { color: #c7cbd1; background: transparent; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 0.82rem; color: var(--text-main); }

.form-select, .form-control {
  border-color: var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

.form-select:focus, .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control-mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8125rem;
  background: #0b1021;
  color: #d1e0ff;
  border-color: #0b1021;
  line-height: 1.55;
}

textarea.form-control-mono::placeholder { color: #64748b; }
textarea.form-control-mono:focus { box-shadow: 0 0 0 3px rgba(79,70,229,0.35); }

.hint-box {
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  border-radius: 0.5rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  color: #3730a3;
  margin-bottom: 0.75rem;
}

.hint-box code { color: #4338ca; background: rgba(255,255,255,0.6); padding: 0.05rem 0.3rem; border-radius: 0.25rem; }

.step-select-row .form-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
  font-size: 0.875rem;
}

.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-outline-primary { color: var(--primary); border-color: var(--primary); font-weight: 600; font-size: 0.8125rem; }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }

.btn { border-radius: 0.5rem; }

/* ---------- Alerts ---------- */
.alert { border-radius: 0.6rem; border: 1px solid transparent; font-size: 0.875rem; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }

.page-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem; }
.page-heading h1 { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.page-heading p { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.85rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2rem; opacity: 0.4; display: block; margin-bottom: 0.6rem; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-col { margin-left: 0; }
}
