:root {
  --bg-primary: #0d1410;
  --bg-secondary: #131c15;
  --bg-tertiary: #1a251c;
  --bg-card: rgba(26, 37, 28, 0.75);
  --bg-card-solid: #16201780;
  --border-color: rgba(255, 222, 89, 0.12);
  --border-hover: rgba(255, 222, 89, 0.35);
  --accent: #FFDE59;
  --accent-hover: #ffe985;
  --accent-glow: rgba(255, 222, 89, 0.22);
  --accent-soft: rgba(255, 222, 89, 0.08);
  --green: #4CAF50;
  --green-soft: rgba(76, 175, 80, 0.12);
  --text-primary: #eef2ee;
  --text-secondary: #a3b0a4;
  --text-muted: #6c796d;
  --success: #4CAF50;
  --danger: #f44336;
  --warning: #f59e0b;
  --info: #3b9eeb;
  --muted-badge: #6c796d;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --sidebar-w: 264px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 222, 89, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 88% 85%, rgba(76, 175, 80, 0.06) 0%, transparent 40%);
  pointer-events: none; z-index: 0;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: #2a3a2c; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #384c3b; }
a { color: inherit; text-decoration: none; }

/* ─── Layout ─── */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
  transition: margin-left .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; }
.sidebar-brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.sidebar-brand h1 { font-size: 1.15rem; font-weight: 800; letter-spacing: .3px; }
.brand-accent { color: var(--accent); }
.sidebar-brand small { color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 14px 14px; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .8px; color: var(--text-muted); font-weight: 700; margin: 18px 10px 8px; }
.nav-section:first-child { margin-top: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: .89rem; font-weight: 500;
  margin-bottom: 2px; position: relative;
  transition: background .15s, color .15s;
}
.nav-link i { width: 18px; text-align: center; color: var(--text-muted); transition: color .15s; }
.nav-link:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-link:hover i { color: var(--accent); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active i { color: var(--accent); }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 800; padding: 1px 7px; border-radius: 9px;
}

.sidebar-user { border-top: 1px solid var(--border-color); padding: 14px; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: var(--radius-sm); }
.user-chip:hover { background: var(--bg-tertiary); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--green));
  color: #0d1410; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.user-meta { min-width: 0; display: flex; flex-direction: column; }
.user-meta strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--text-muted); font-size: .72rem; }
.logout-btn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); }
.logout-btn:hover { background: var(--danger); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 28px; border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; background: rgba(13, 20, 16, 0.85); backdrop-filter: blur(8px); z-index: 5;
}
.topbar h2 { font-size: 1.2rem; font-weight: 700; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.1rem; cursor: pointer; }
.content { padding: 26px 28px 60px; max-width: 1400px; width: 100%; }

/* ─── Cards & grid ─── */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 22px; backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-header .muted { color: var(--text-muted); font-size: .82rem; }

.stat-tile { display: flex; align-items: center; gap: 16px; }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
}
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.danger { background: rgba(244,67,54,.12); color: var(--danger); }
.stat-icon.info { background: rgba(59,158,235,.12); color: var(--info); }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .8rem; margin-top: 2px; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data th {
  text-align: left; padding: 11px 14px; color: var(--text-muted);
  font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border-color); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
table.data tbody tr:hover { background: rgba(255,255,255,0.02); }
table.data tbody tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .82rem; }

/* ─── Badges ─── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge-success { background: rgba(76,175,80,.15); color: var(--success); }
.badge-danger { background: rgba(244,67,54,.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info { background: rgba(59,158,235,.15); color: var(--info); }
.badge-muted { background: rgba(255,255,255,.06); color: var(--text-secondary); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #14200f; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 0 3px var(--accent-glow); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { border-color: var(--border-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-hover); }
.btn-sm { padding: 6px 11px; font-size: .78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Forms ─── */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin: 14px 0 6px; }
label:first-of-type { margin-top: 0; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], input[type=email], textarea, select {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-tertiary);
  color: var(--text-primary); font-family: inherit; font-size: .88rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 180px; }
.form-help { color: var(--text-muted); font-size: .76rem; margin-top: 5px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .field { display: flex; flex-direction: column; min-width: 160px; }
.filters label { margin: 0 0 5px; }

/* ─── Alerts ─── */
.alert { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: var(--radius-md); font-size: .87rem; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: rgba(76,175,80,.1); color: #8ee493; border-color: rgba(76,175,80,.25); }
.alert-danger { background: rgba(244,67,54,.1); color: #ff9b92; border-color: rgba(244,67,54,.25); }
.alert-warning { background: rgba(245,158,11,.1); color: #fbc373; border-color: rgba(245,158,11,.25); }
.alert-info { background: rgba(59,158,235,.1); color: #8fc7f5; border-color: rgba(59,158,235,.25); }

/* ─── Misc ─── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.4rem; margin-bottom: 12px; opacity: .5; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 7px 13px; border-radius: var(--radius-sm); background: var(--bg-tertiary); border: 1px solid var(--border-color); font-size: .82rem; }
.pagination a:hover { border-color: var(--border-hover); }
.pagination .current { background: var(--accent); color: #14200f; font-weight: 700; }
.chart-box { position: relative; height: 280px; }
.progress { height: 8px; border-radius: 6px; background: var(--bg-tertiary); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--accent)); }
.avatar-initial { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-tertiary); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .82rem; }
.section-title { font-size: .95rem; font-weight: 700; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 18px; }
.tabs a { padding: 10px 16px; font-size: .85rem; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: .87rem; }
.kv dt { color: var(--text-muted); }
.kv dd { font-weight: 500; }

/* ─── Login page ─── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-wrap { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.login-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 12px; object-fit: cover; }
.login-brand h1 { font-size: 1.5rem; font-weight: 800; }
.login-brand p { color: var(--text-muted); font-size: .85rem; margin-top: 4px; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; margin-left: calc(var(--sidebar-w) * -1); box-shadow: var(--shadow-lg); }
  .sidebar.open { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .content { padding: 18px 16px 50px; }
  .topbar { padding: 14px 16px; }
}
