:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg-card: #1a2035;
  --bg-accent: #1f2640;
  --gold: #c8a84b;
  --gold2: #e2c46a;
  --text: #e8eaf0;
  --text-muted: #7a8299;
  --border: rgba(200,168,75,0.15);
  --border2: rgba(255,255,255,0.07);
  --danger: #e05555;
  --success: #4caf82;
  --warning: #e09055;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border2);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  font-size: 1rem; font-weight: 600; color: var(--gold);
  border-bottom: 1px solid var(--border2);
}
.sidebar-nav { flex: 1; padding: 16px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 0.88rem; transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-accent); color: var(--text); }
.nav-item.active { background: rgba(200,168,75,0.12); color: var(--gold); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border2);
  display: flex; flex-direction: column; gap: 8px;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 500; font-size: 0.88rem; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }
.btn-logout {
  background: none; border: 1px solid var(--border2); color: var(--text-muted);
  padding: 6px 12px; border-radius: 4px; font-size: 0.8rem; cursor: pointer;
  transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* MAIN */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px 0;
}
.page-title { font-size: 1.5rem; font-weight: 600; }
.page-content { padding: 24px 32px; flex: 1; }

/* CARDS */
.card {
  background: var(--bg-card); border: 1px solid var(--border2);
  border-radius: 10px; overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border2);
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; }
.card-body { padding: 20px; }
.cat-header-row { display: flex; align-items: center; justify-content: space-between; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border2);
  border-radius: 10px; padding: 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-icon { font-size: 1.5rem; margin-bottom: 4px; }
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--gold); line-height: 1; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); }
.kpi-sub { font-size: 0.85rem; color: var(--gold2); font-weight: 500; }

/* CHARTS */
.charts-row { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
.chart-card .card-body { padding: 16px 20px; }

/* TABLE */
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--border2); }
.table td { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 0.9rem; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 6px; font-size: 0.85rem; font-weight: 500;
  text-decoration: none; cursor: pointer; border: none; transition: all 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--gold); color: #0f0d08; }
.btn-primary:hover { background: var(--gold2); }
.btn-outline { background: none; border: 1px solid var(--border2); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: none; border: 1px solid rgba(224,85,85,0.3); color: var(--danger); }
.btn-danger:hover { background: rgba(224,85,85,0.1); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px; background: var(--bg-accent);
  border: 1px solid var(--border2); border-radius: 6px;
  color: var(--text); font-family: inherit; font-size: 0.9rem;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--gold);
}
.form-group textarea { resize: vertical; }

/* BADGES */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 0.75rem; font-weight: 500; background: var(--bg-accent); color: var(--text-muted);
}
.badge-success { background: rgba(76,175,130,0.15); color: var(--success); }
.badge-warning { background: rgba(224,144,85,0.15); color: var(--warning); }
.badge-error { background: rgba(224,85,85,0.15); color: var(--danger); }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 0.88rem; }
.alert-error { background: rgba(224,85,85,0.12); border: 1px solid rgba(224,85,85,0.3); color: #f08080; }
.alert-success { background: rgba(76,175,130,0.12); border: 1px solid rgba(76,175,130,0.3); color: #80c8a0; }

/* MODAL */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border2);
  border-radius: 10px; padding: 28px; width: 100%; max-width: 520px;
}
.modal-box h3 { font-size: 1.05rem; margin-bottom: 20px; }

/* TOAST */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  background: var(--bg-card); border: 1px solid var(--border2);
  padding: 12px 20px; border-radius: 8px; font-size: 0.88rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4); transition: opacity 0.3s;
}
.toast.hidden { display: none; }
.toast.error { border-color: rgba(224,85,85,0.4); color: #f08080; }

/* PROGRESS BAR */
.progress-bar-wrap { background: var(--bg-accent); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--gold); border-radius: 4px; transition: width 0.3s; }

/* LOGIN */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--bg-card); border: 1px solid var(--border2); border-radius: 12px; padding: 40px; width: 360px; }
.login-logo { font-size: 2.5rem; text-align: center; margin-bottom: 12px; }
.login-title { font-size: 1.4rem; font-weight: 600; text-align: center; color: var(--gold); margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 28px; }
.login-form .btn { margin-top: 4px; }

/* MISC */
.text-muted { color: var(--text-muted); }
.hidden { display: none !important; }

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

/* Toggle switch */
.toggle-switch { position:relative; display:inline-block; width:48px; height:26px; cursor:pointer; }
.toggle-switch input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; top:0; left:0; right:0; bottom:0; background:#3a3f4b; border-radius:26px; transition:.3s; }
.toggle-slider:before { content:''; position:absolute; width:20px; height:20px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:.3s; }
.toggle-switch input:checked + .toggle-slider { background:var(--gold); }
.toggle-switch input:checked + .toggle-slider:before { transform:translateX(22px); }

.badge-warning { background:#7a5c00; color:#f0c040; }
