:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-soft: #263348;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 245px;
  background: #0b1220;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  padding: 6px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.brand small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
}
.nav-link:hover { background: var(--bg-card); text-decoration: none; }
.nav-link.active { background: rgba(56, 189, 248, 0.16); color: var(--accent); }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }

.main { flex: 1; padding: 24px 28px; max-width: 1440px; width: 100%; overflow-x: hidden; }
h1 { margin: 0 0 18px; font-size: 22px; }
h2 { margin: 0 0 12px; font-size: 16px; }

.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; margin-bottom: 20px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-val { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; border: 1px solid transparent; }
.flash.ok { background: rgba(34,197,94,0.14); border-color: rgba(34,197,94,0.4); color: #86efac; }
.flash.error { background: rgba(239,68,68,0.14); border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.flash.info { background: rgba(56,189,248,0.14); border-color: rgba(56,189,248,0.4); color: #7dd3fc; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.badge-ok { background: rgba(34,197,94,0.18); color: #86efac; }
.badge-warn { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge-err { background: rgba(239,68,68,0.18); color: #fca5a5; }
.badge-muted { background: rgba(148,163,184,0.18); color: #cbd5e1; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  font-size: 13px;
}
textarea { min-height: 110px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding-top: 18px; }
.checkbox-row input { width: auto; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 7px; border: 1px solid transparent;
  background: var(--accent); color: #082f49; font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #334155; }
.btn-danger { background: rgba(239,68,68,0.2); color: #fca5a5; border-color: rgba(239,68,68,0.4); }
.btn-danger:hover { background: rgba(239,68,68,0.35); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.login-box { max-width: 390px; margin: 90px auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.pagination { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { border-bottom: none; margin-bottom: 0; padding-bottom: 6px; width: 100%; }
  .sidebar-footer { margin-top: 0; border-top: none; padding-top: 0; margin-left: auto; }
}
