:root {
  --bg: #0b1120;
  --panel: #131c30;
  --panel-2: #18233c;
  --border: #223052;
  --text: #e2e8f0;
  --muted: #8fa0bf;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.15);
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 224px;
  background: #101828;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  z-index: 10;
}

.brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 22px;
}

.brand-dot {
  width: 12px; height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  flex-shrink: 0;
}

.brand-sub {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: auto;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-link {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
}

.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.nav-link.active {
  color: #fff;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }

.admin-name { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; }

.logout-link { font-size: 12px; color: var(--red); text-decoration: none; font-weight: 600; }
.logout-link:hover { text-decoration: underline; }

/* ---------- Main ---------- */
.main { margin-left: 224px; padding: 26px 30px 60px; }

.page-title { font-size: 21px; font-weight: 800; margin-bottom: 20px; }

.flash {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 13px;
}

.flash-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.kpi-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value { font-size: 22px; font-weight: 800; margin-top: 6px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- Panels & tables ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}

.panel-title { font-size: 13px; font-weight: 800; margin-bottom: 14px; color: var(--text); }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

td { padding: 10px; border-bottom: 1px solid rgba(34, 48, 82, 0.5); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 11px; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
}
.badge-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-purple { background: var(--accent-soft); color: #c4b5fd; }

/* ---------- Forms ---------- */
input, select, textarea {
  background: #0e1728;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { filter: brightness(1.12); }
.btn-danger { background: var(--red); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { flex: 1; min-width: 140px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; min-width: 180px; }

/* ---------- Chart ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
  padding: 10px 6px 0;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%;
  max-width: 46px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
  min-height: 4px;
}
.bar-col span { font-size: 10px; color: var(--muted); font-weight: 700; }

/* ---------- Two columns ---------- */
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.link { color: #a78bfa; text-decoration: none; font-weight: 700; }
.link:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 30px;
}
.login-brand { font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: var(--muted); margin-bottom: 24px; }
.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin-bottom: 14px;
}
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; margin-top: 6px; }

@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 18px 8px; }
  .brand { justify-content: center; font-size: 0; }
  .brand::after { content: 'PC'; font-size: 15px; color: #fff; font-weight: 800; }
  .brand-sub, .admin-name { display: none; }
  .nav-link { text-align: center; font-size: 11px; padding: 10px 4px; }
  .main { margin-left: 64px; padding: 20px 14px 50px; }
  .cols, .cols-2 { grid-template-columns: 1fr; }
}
