:root {
  --bg-base: #0b0f1f;
  --bg-panel: #12172b;
  --bg-panel-2: #171d38;
  --border-color: #262f4d;
  --text-primary: #e8eaf5;
  --text-muted: #8892b0;
  --indigo: #6366f1;
  --indigo-light: #818cf8;
  --indigo-dark: #4338ca;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }

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

.sidebar {
  width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  flex-shrink: 0;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 32px;
  padding: 0 8px;
}

.sidebar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-light), var(--indigo-dark));
  box-shadow: 0 0 12px var(--indigo);
}

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

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--text-muted); font-size: 14.5px; font-weight: 500;
  transition: all .15s ease;
}

.nav-item:hover { background: var(--bg-panel-2); color: var(--text-primary); }

.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(99,102,241,.05));
  color: var(--indigo-light);
  border: 1px solid rgba(99,102,241,.3);
}

.nav-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin: 20px 10px 8px;
}

.main-content { flex: 1; padding: 28px 32px; max-width: 100%; overflow-x: hidden; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 28px;
}

.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; }
.topbar .subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-panel); border: 1px solid var(--border-color);
  padding: 8px 14px; border-radius: 999px; font-size: 13.5px;
}

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-light), var(--indigo-dark));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: white;
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: 1.5fr 1fr; }

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

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .stat-label {
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}

.stat-card .stat-value {
  font-size: 26px; font-weight: 700; margin-top: 10px;
}

.stat-card .stat-trend {
  font-size: 12.5px; margin-top: 6px; color: var(--text-muted);
}

.icon-badge {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.badge-indigo { background: rgba(99,102,241,.15); color: var(--indigo-light); }
.badge-green { background: rgba(34,197,94,.15); color: var(--success); }
.badge-amber { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-red { background: rgba(239,68,68,.15); color: var(--danger); }

.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.card-subtitle { font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; }

/* ---------- Progress ---------- */
.progress-bar {
  width: 100%; height: 8px; border-radius: 999px;
  background: var(--bg-panel-2); overflow: hidden; margin-top: 10px;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--indigo-light));
}

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border-color); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border-color); }
tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13.5px; margin-bottom: 6px; color: var(--text-muted); font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--bg-panel-2); border: 1px solid var(--border-color);
  color: var(--text-primary); font-size: 14px; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--indigo); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--indigo), var(--indigo-dark)); color: white; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--bg-panel-2); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-block { width: 100%; }

.alert {
  padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-error { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); color: #86efac; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(99,102,241,.15), transparent 40%), var(--bg-base);
  padding: 20px;
}
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--bg-panel); border: 1px solid var(--border-color);
  border-radius: 18px; padding: 36px 32px;
}
.auth-box .brand { text-align: center; margin-bottom: 28px; }
.auth-box .brand .dot { display: inline-block; }
.auth-box h2 { text-align: center; margin: 0 0 6px; font-size: 20px; }
.auth-box .sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 26px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 13.5px; color: var(--text-muted); }
.auth-footer a { color: var(--indigo-light); font-weight: 600; }
