:root {
  --bg: #0e0f12;
  --bg-elev: #15171c;
  --bg-card: #1b1e25;
  --border: #2a2f3a;
  --text: #eef1f7;
  --muted: #9aa3b2;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --danger: #f87171;
  --success: #34d399;
  --warning: #fbbf24;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --border: #dde2eb;
  --text: #111827;
  --muted: #5b6474;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark.sm { width: 34px; height: 34px; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-row h1 { margin: 0; font-size: 18px; font-weight: 650; }
.brand-title { font-weight: 650; font-size: 14px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(148, 163, 184, 0.1); color: var(--text); }
.nav-item.active { background: rgba(56, 189, 248, 0.14); color: var(--accent); font-weight: 600; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 6px;
}

.dot-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.footer-actions { display: flex; gap: 8px; }

.main-content {
  padding: 24px 28px;
  max-width: 1360px;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.topbar h2 { margin: 0 0 2px 0; font-size: 20px; font-weight: 650; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

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

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

.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.card-title {
  margin: 0 0 14px 0;
  font-size: 15px;
  font-weight: 650;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-ok { background: rgba(52, 211, 153, 0.14); color: var(--success); }
.badge-warn { background: rgba(251, 191, 36, 0.14); color: var(--warning); }
.badge-danger { background: rgba(248, 113, 113, 0.14); color: var(--danger); }
.badge-info { background: rgba(56, 189, 248, 0.14); color: var(--accent); }
.badge-muted { background: rgba(148, 163, 184, 0.14); color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06131c; font-weight: 650; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { border-color: rgba(248, 113, 113, 0.4); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(148, 163, 184, 0.1); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-full { width: 100%; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 12.5px; color: var(--muted); font-weight: 550; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13.5px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.search-input { width: 240px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.checkbox-row input { width: auto; }

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.alert-error { background: rgba(248, 113, 113, 0.14); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.3); }

.toast-area { margin-bottom: 14px; }
.toast {
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.toast-ok { border-color: rgba(52, 211, 153, 0.4); color: var(--success); }
.toast-err { border-color: rgba(248, 113, 113, 0.4); color: var(--danger); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-header h3 { margin: 0; font-size: 16px; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
}
