:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: radial-gradient(circle at 5% 10%, #dbeafe 0, transparent 35%),
              radial-gradient(circle at 95% 90%, #fde68a 0, transparent 30%),
              var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}
.sidebar {
  width: 260px;
  min-height: 100vh;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, #0f172a, #1e293b);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  overflow-y: auto;
}
.sidebar-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.sidebar-subtitle { color: #94a3b8; font-size: 13px; line-height: 1.5; }
.nav-stack { display: flex; flex-direction: column; gap: 6px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  transition: all .2s ease;
}
.nav-link:hover { background: rgba(148, 163, 184, .2); color: #fff; }
.nav-link.active { background: linear-gradient(135deg, #1d4ed8, #0ea5e9); color: #fff; }
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-user {
  padding: 12px;
  border-radius: 12px;
  background: rgba(148, 163, 184, .12);
  border: 1px solid rgba(148, 163, 184, .12);
}
.sidebar-user-label { font-weight: 700; font-size: 13px; color: #fff; }
.sidebar-user-role { color: #cbd5e1; font-size: 12px; margin-top: 4px; }
.logout-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fecaca;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(248, 113, 113, .15);
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.logout-link:hover {
  color: #fff;
  background: rgba(239, 68, 68, .18);
  transform: translateY(-1px);
}

.main-panel { flex: 1; padding: 24px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-title { margin: 0; font-size: 28px; }
.page-subtitle { color: var(--muted); font-size: 14px; margin-top: 3px; }
.topbar-actions { display: flex; gap: 10px; }

.content { display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  animation: fadeInUp .35s ease;
}
.card h3 { margin-top: 0; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { color: #fff; background: linear-gradient(135deg, #2563eb, #0ea5e9); }
.btn-light { background: #e2e8f0; color: #1e293b; }
.btn-danger { background: #ef4444; color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  width: 100%;
  background: #fff;
  font: inherit;
}
.textarea { min-height: 110px; resize: vertical; }
.stack-form { display: flex; flex-direction: column; gap: 10px; }
.inline-form { display: flex; gap: 10px; align-items: center; }
.top-gap { margin-top: 12px; }

.card-header-row, .filters-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}
.filters-row { grid-template-columns: repeat(4, minmax(130px, 1fr)); }

.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.file-head {
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}
.file-meta { color: var(--muted); font-size: 12px; }
.file-preview {
  border-top: 1px solid var(--line);
  padding: 10px;
  background: #f8fafc;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #334155; }
.table-wrap { overflow-x: auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}
.kpi-card {
  border-radius: 14px;
  color: #fff;
  padding: 14px;
  box-shadow: var(--shadow);
}
.kpi-card .kpi-label { font-size: 12px; opacity: .95; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.kpi-blue { background: linear-gradient(145deg, #1d4ed8, #3b82f6); }
.kpi-green { background: linear-gradient(145deg, #15803d, #22c55e); }
.kpi-amber { background: linear-gradient(145deg, #b45309, #f59e0b); }
.kpi-red { background: linear-gradient(145deg, #b91c1c, #ef4444); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.pill-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #0f172a;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.pill-success { background: #dcfce7; color: #166534; }
.status-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
.admin-note-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.badge { border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.badge.reject { color: #fff; background: #d97706; }
.badge.denial { color: #fff; background: #dc2626; }

.audit-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.audit-card {
  background: #fff;
  width: min(560px, 90vw);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #bfdbfe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.progress-track { margin-top: 10px; width: 100%; background: #e2e8f0; border-radius: 999px; height: 10px; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2563eb, #22c55e); border-radius: 999px; transition: width .3s ease; }

.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #111827; color: #fff; border-radius: 10px; padding: 10px 12px; font-size: 13px; box-shadow: var(--shadow); }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(620px, 94vw);
  background: #fff;
  box-shadow: -10px 0 30px rgba(0, 0, 0, .2);
  padding: 14px;
  overflow-y: auto;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; }

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
}
.auth-card {
  width: min(420px, 90vw);
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.auth-card-wide { width: min(480px, 92vw); }
.eyebrow {
  color: #2563eb;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 800;
}
.auth-copy { color: var(--muted); line-height: 1.6; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input { border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px; }
.alert { border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.alert-danger { background: #fee2e2; color: #b91c1c; }
.alert-success { background: #dcfce7; color: #166534; }
.small-note { color: var(--muted); font-size: 12px; margin-top: 10px; }

.skeleton-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.skeleton-box {
  border-radius: 12px;
  height: 140px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: auto;
    height: auto;
    position: static;
    overflow-y: visible;
  }
  .topbar { flex-direction: column; align-items: flex-start; }
  .filters-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
