:root {
  --bg: #0f1419;
  --bg-elev: #171d25;
  --bg-soft: #1e2630;
  --line: #2a3441;
  --text: #e7ecf2;
  --muted: #8b98a8;
  --accent: #3d9cfd;
  --ok: #3ecf8e;
  --warn: #e6b84d;
  --danger: #ef6b6b;
  --font: "Segoe UI", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2738 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
}

a { color: var(--accent); text-decoration: none; }
button, input, select {
  font: inherit;
  color: inherit;
}

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

.side {
  border-right: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.92);
  padding: 20px 14px;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}
.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 24px;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 4px;
}
.nav-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-btn.active {
  background: var(--bg-soft);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.main { padding: 20px 24px 40px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}
.meta { color: var(--muted); font-size: 12px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 160px;
}
.btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn:hover { border-color: #3d4b5c; }
.btn.primary { background: #1f4f86; border-color: #2f6fad; }
.btn.danger { background: #5a2a2a; border-color: #8a3d3d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.muted { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.badge.ok { color: var(--ok); border-color: #2f6b4f; }
.badge.warn { color: var(--warn); border-color: #7a6430; }
.badge.danger { color: var(--danger); border-color: #7a3a3a; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; }
.error {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0;
  min-height: 1.2em;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 20;
}
.drawer.open { transform: translateX(0); }
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 15;
}
.backdrop.open { opacity: 1; pointer-events: auto; }

.health-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.chart-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.chart-card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.chart-wrap {
  position: relative;
  height: 220px;
}
.empty { padding: 24px; color: var(--muted); text-align: center; }

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