:root {
  --bg: #f6f5f1;
  --bg-gradient: linear-gradient(165deg, #f6f5f1 0%, #edeae3 40%, #f2f0eb 100%);
  --glass: rgba(255,255,255,0.72);
  --glass-border: rgba(0,0,0,0.05);
  --glass-hover: rgba(255,255,255,0.88);
  --text: #1b1b1b;
  --text-secondary: #555;
  --text-muted: #999;
  --accent: #2d5be3;
  --accent-light: #4a73f5;
  --accent-soft: rgba(45,91,227,0.08);
  --accent-glow: rgba(45,91,227,0.15);
  --success: #1a9a5c;
  --success-soft: rgba(26,154,92,0.08);
  --danger: #dc3b3b;
  --danger-soft: rgba(220,59,59,0.08);
  --warning: #d4851e;
  --warning-soft: rgba(212,133,30,0.08);
  --sidebar-bg: rgba(255,255,255,0.55);
  --sidebar-active: rgba(45,91,227,0.06);
  --input-bg: rgba(0,0,0,0.025);
  --input-border: rgba(0,0,0,0.08);
  --input-focus: rgba(45,91,227,0.18);
  --divider: rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 6px 24px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.05), 0 20px 48px rgba(0,0,0,0.08);
  --blur: blur(28px);
  --modal-bg: rgba(255,255,255,0.97);
  --card-radius: 16px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* Ambient bg blobs */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}
body::before {
  width: 700px; height: 700px; right: -200px; top: -200px;
  background: radial-gradient(circle, rgba(45,91,227,0.04), transparent 65%);
}
body::after {
  width: 600px; height: 600px; left: -100px; bottom: -200px;
  background: radial-gradient(circle, rgba(26,154,92,0.035), transparent 65%);
}

#app { position: relative; z-index: 1; min-height: 100vh; }

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

/* ─── SIDEBAR ────────────────────────────── */
.sidebar {
  width: 256px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--glass-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
  margin-bottom: 32px;
}

.brand-badge, .avatar-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
}

.brand-badge {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  font-size: 16px;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 8px rgba(45,91,227,0.25);
}

.avatar-badge {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  font-size: 12px;
  box-shadow: 0 2px 6px rgba(45,91,227,0.2);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-top: 1px;
}

/* Nav buttons */
.nav-btn, .ghost-btn, .primary-btn, .danger-btn, .icon-btn, .tab-btn, .theme-btn {
  border: none;
  transition: all var(--transition);
}

.nav-btn {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.nav-btn:hover { background: var(--sidebar-active); color: var(--text); }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-btn .nav-icon {
  width: 22px;
  text-align: center;
  font-size: 16px;
}

.nav-spacer { flex: 1; }

.side-footer {
  border-top: 1px solid var(--divider);
  padding-top: 14px;
  margin-top: 14px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin-bottom: 8px;
}

/* ─── MAIN ───────────────────────────────── */
.main {
  flex: 1;
  margin-left: 256px;
  padding: 28px 32px 40px;
  min-width: 0;
  max-width: 1280px;
}

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

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
  font-weight: 400;
}

/* ─── GRID ───────────────────────────────── */
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); margin-bottom: 20px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ─── GLASS CARDS ────────────────────────── */
.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.glass:hover {
  box-shadow: var(--shadow), 0 0 0 1px var(--glass-border);
}

.card { padding: 20px; }

/* Stats */
.stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 8px;
  font-weight: 500;
}

.section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 14px;
}

/* ─── BUTTONS ────────────────────────────── */
.primary-btn, .theme-btn, .ghost-btn, .danger-btn {
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45,91,227,0.2);
}
.primary-btn:hover {
  box-shadow: 0 4px 16px rgba(45,91,227,0.3);
  transform: translateY(-1px);
}

.ghost-btn {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
}
.ghost-btn:hover { background: rgba(0,0,0,0.05); }

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
}
.danger-btn:hover { background: rgba(220,59,59,0.14); }

.theme-btn {
  width: 100%;
  text-align: left;
  background: var(--input-bg);
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}
.theme-btn:hover { background: rgba(0,0,0,0.05); }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}
.icon-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text);
  transform: translateY(-1px);
}

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

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--divider);
  text-align: left;
  font-size: 13px;
}
.table th {
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  padding-bottom: 10px;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(0,0,0,0.015); }
.table tbody tr:last-child td { border-bottom: none; }

/* ─── BADGES ─────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ─── PROGRESS BARS ──────────────────────── */
.bar {
  width: 100%;
  height: 6px;
  background: var(--input-bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: inherit;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── KPI MINI ───────────────────────────── */
.kpis-mini {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.kpi-mini {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--input-bg);
  transition: background var(--transition);
}
.kpi-mini:hover { background: rgba(0,0,0,0.04); }
.kpi-mini .k {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.kpi-mini .v {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ─── FORMS ──────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  font-size: 14px;
  transition: all var(--transition);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--input-focus);
  background: rgba(255,255,255,0.6);
}
.field textarea { min-height: 86px; resize: vertical; }

/* ─── AUTH ────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 42px 38px;
}

.auth-head { text-align: center; margin-bottom: 32px; }
.auth-head h1 {
  font-family: var(--font-display);
  margin: 14px 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}
.auth-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── ALERTS ─────────────────────────────── */
.error-box, .success-box {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.3s ease;
}
.error-box { background: var(--danger-soft); color: var(--danger); }
.success-box { background: var(--success-soft); color: var(--success); }

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

/* ─── MODAL ──────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  padding: 28px;
  background: var(--modal-bg);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ─── UTILITY ────────────────────────────── */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ─── MOBILE TOP ─────────────────────────── */
.mobile-top { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px 32px; }
  .mobile-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--divider);
  }
  .form-grid, .kpis-mini { grid-template-columns: 1fr; }
  .page-title { font-size: 22px; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .grid.cards { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .grid.stats { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 22px; }
}

/* ─── MOBILE NAV ─────────────────────────── */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  display: none;
}
.mobile-nav-overlay.open { display: block; }

.mobile-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 260px;
  z-index: 51;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  background: var(--modal-bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-sidebar.open { transform: translateX(0); }

/* ─── SCROLLBAR ──────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }

/* ─── DARK MODE ──────────────────────────── */
body.dark {
  --bg: #111113;
  --bg-gradient: linear-gradient(165deg, #111113 0%, #17171b 40%, #111113 100%);
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.06);
  --glass-hover: rgba(255,255,255,0.07);
  --text: #eaeaea;
  --text-secondary: #aaa;
  --text-muted: #666;
  --accent: #6b8aff;
  --accent-light: #8aa4ff;
  --accent-soft: rgba(107,138,255,0.1);
  --accent-glow: rgba(107,138,255,0.15);
  --success: #4ade80;
  --success-soft: rgba(74,222,128,0.08);
  --danger: #f87171;
  --danger-soft: rgba(248,113,113,0.08);
  --warning: #fbbf24;
  --warning-soft: rgba(251,191,36,0.08);
  --sidebar-bg: rgba(255,255,255,0.025);
  --sidebar-active: rgba(107,138,255,0.08);
  --input-bg: rgba(255,255,255,0.04);
  --input-border: rgba(255,255,255,0.08);
  --input-focus: rgba(107,138,255,0.18);
  --divider: rgba(255,255,255,0.05);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 6px 24px rgba(0,0,0,0.15);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.3), 0 20px 48px rgba(0,0,0,0.3);
  --modal-bg: rgba(20,20,24,0.98);
}

body.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }
body.dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
