:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e6e9f2;
  --text: #121826;
  --text-2: #5b6478;
  --text-3: #8a93a6;
  --primary: #3b5bfd;
  --primary-2: #eef1ff;
  --ok: #12b76a;
  --ok-bg: #e8f8f0;
  --warn: #f59e0b;
  --warn-bg: #fff6e5;
  --crit: #f04438;
  --crit-bg: #fdecea;
  --sidebar: #0f1729;
  --sidebar-text: #aab3c7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; font-weight: 700; font-size: 15px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #5b7bff, #3b5bfd 55%, #7c4dff);
  display: grid; place-items: center; color: #fff;
}
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--sidebar-text); }
.container-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 18px;
}
.container-chip .name { color: #fff; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container-chip .id { font-family: var(--mono); font-size: 12px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #23304d; color: #fff; display: grid; place-items: center; font-weight: 600; text-transform: uppercase; }
.sidebar-foot .who { flex: 1; min-width: 0; color: #fff; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 0; color: var(--sidebar-text); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--text); }
.content { padding: 28px 32px 48px; max-width: 1400px; width: 100%; }

/* ---------- components ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.mt { margin-top: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 650; margin: 0; }
.card-sub { color: var(--text-2); font-size: 13px; margin: 2px 0 0; }

.kpi .label { color: var(--text-2); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.15; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 4px; }
.kpi .foot { color: var(--text-3); font-size: 12.5px; margin-top: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: #067647; }
.pill.warn, .pill.warning { background: var(--warn-bg); color: #b54708; }
.pill.crit, .pill.critical, .pill.down { background: var(--crit-bg); color: #b42318; }
.pill.plain::before { display: none; }

.delta { font-size: 12.5px; font-weight: 600; }
.delta.up { color: #067647; }
.delta.down { color: #b42318; }

.progress { height: 8px; background: #edf0f7; border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.4s ease; }
.progress.ok > span { background: var(--ok); }
.progress.warning > span { background: var(--warn); }
.progress.critical > span { background: var(--crit); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px 24px; }
.info-grid .k { color: var(--text-3); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.info-grid .v { font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; }

.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.hero h2 { margin: 0; font-size: 18px; }

.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--text-2); font-weight: 600; font-size: 13px; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }
.chart-box.donut { height: 220px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table-wrap table tr:last-child td { border-bottom: 0; }

.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-row .top { display: flex; justify-content: space-between; gap: 10px; font-weight: 500; }
.bar-row .top span:last-child { font-variant-numeric: tabular-nums; color: var(--text-2); }
.bar-row .progress { margin-top: 6px; height: 6px; }

.status-tag { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.status-tag.s2 { background: var(--ok-bg); color: #067647; }
.status-tag.s3 { background: var(--primary-2); color: var(--primary); }
.status-tag.s4 { background: var(--warn-bg); color: #b54708; }
.status-tag.s5 { background: var(--crit-bg); color: #b42318; }
.type-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
select, input[type="text"], input[type="password"] {
  font: inherit; color: var(--text);
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 8px 12px; outline: none;
}
select:focus, input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-2); }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; user-select: none; }

.resource .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.resource .big { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.resource .detail { color: var(--text-2); font-size: 13px; margin-top: 8px; }
.resource .hint { color: var(--text-3); font-size: 12.5px; margin-top: 8px; }

.service { display: flex; align-items: center; gap: 14px; }
.service .dot { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--ok-bg); color: var(--ok); flex-shrink: 0; }
.service .dot.down { background: var(--crit-bg); color: var(--crit); }
.service .dot svg { width: 20px; height: 20px; }
.service .name { font-weight: 600; }

.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); align-items: flex-start; }
.notice + .notice { margin-top: 10px; }
.notice.ok { background: var(--ok-bg); border-color: #b7ebcf; }
.notice.warning { background: var(--warn-bg); border-color: #fde3b0; }
.notice.critical { background: var(--crit-bg); border-color: #f8c9c4; }
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.empty { text-align: center; color: var(--text-3); padding: 36px 12px; }
.skeleton { color: var(--text-3); padding: 60px 0; text-align: center; }
.limits-table td:first-child { color: var(--text-2); }
.limits-table td { white-space: normal; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1000px 600px at 10% -10%, rgba(59, 91, 253, 0.35), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(124, 77, 255, 0.3), transparent 60%),
    var(--sidebar);
}
.login-card {
  width: 100%; max-width: 410px;
  background: var(--surface); border-radius: 20px; padding: 36px 32px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45);
}
.login-card .brand { color: var(--text); padding: 0 0 26px; }
.login-card .brand small { color: var(--text-2); }
.login-card h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.01em; }
.login-card p.lead { color: var(--text-2); margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 14px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--text-3); padding: 6px; }
.login-card .btn.primary { width: 100%; justify-content: center; padding: 12px; font-size: 14px; margin-top: 6px; }
.login-card .btn.primary:disabled { opacity: 0.7; cursor: wait; }
.form-error { background: var(--crit-bg); color: #b42318; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 500; margin-bottom: 16px; display: none; }
.form-error.show { display: block; }
.login-foot { text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 41, 0.45); }
  .menu-btn { display: grid; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 560px) {
  .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 24px; }
  .topbar .updated { display: none; }
}
