:root {
  --bg: #0e1116;
  --panel: #151a21;
  --panel-2: #1b212a;
  --line: #262e3a;
  --text: #e6eaf0;
  --muted: #8a94a6;
  --accent: #5b8def;
  --accent-ink: #fff;
  --ok: #3ccf8e;
  --warn: #f0b04a;
  --bad: #ef6b6b;
  --radius: 12px;
  --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --panel: #fff; --panel-2: #f0f2f5; --line: #e1e5eb; --text: #151a21; --muted: #667085;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
code, pre, textarea.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
p.sub { color: var(--muted); margin: 0 0 20px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 18px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; }
.side a { color: var(--muted); padding: 8px 10px; border-radius: 8px; display: block; }
.side a:hover { background: var(--panel-2); color: var(--text); }
.side a.active { background: var(--panel-2); color: var(--text); font-weight: 600; }
.side .grow { flex: 1; }
.main { padding: 28px 32px 60px; max-width: 1200px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.field > span { color: var(--text); font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; margin: 0; max-height: 480px; white-space: pre-wrap; word-break: break-word; }
.banner { border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.secret { font-family: var(--mono); background: var(--bg); border: 1px dashed var(--accent); padding: 10px 12px; border-radius: 8px; word-break: break-all; }

.chart { width: 100%; height: 160px; }
.chart rect.bar { fill: var(--accent); }
.chart rect.bar:hover { fill: color-mix(in srgb, var(--accent) 70%, white); }
.chart text { fill: var(--muted); font-size: 10px; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.hbar .track { grid-column: 1 / -1; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--accent); }

.modal-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 30px rgb(0 0 0 / .3); }
.toast.bad { border-color: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); padding: 10px 16px; }
  .side .brand { width: 100%; padding-bottom: 8px; }
  .side .grow { display: none; }
  .main { padding: 20px 16px 50px; }
  .g2, .g3 { grid-template-columns: 1fr; }
}
