[hidden] { display: none !important; }
:root {
  --bg: #0d1014; --surface: #141920; --surface-2: #1a2029; --line: #252d38; --line-2: #313b49;
  --text: #e3e7ee; --muted: #8b95a5; --faint: #5c6675;
  --accent: #5ad19a; --accent-ink: #062014; --blue: #6aa8ff; --amber: #f0b45a; --red: #f07167; --violet: #b18cff;
  --radius: 8px; --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --line: #e1e5eb; --line-2: #cfd5de;
    --text: #151a21; --muted: #5c6675; --faint: #8b95a5; --accent: #18915a; --accent-ink: #fff;
    --blue: #2f6fd6; --amber: #b7791f; --red: #c9372c; --violet: #7a4fd6; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-weight: 650; letter-spacing: .2px; }
.brand img { width: 24px; height: 24px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav svg { width: 16px; height: 16px; flex: none; }
.nav .spacer { flex: 1; }
.nav .who { font-size: 12px; color: var(--faint); padding: 8px 10px; }
main { padding: 28px 32px 64px; max-width: 1280px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.head h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.2px; }
.head p { margin: 4px 0 0; color: var(--muted); }
.crumb { color: var(--muted); text-decoration: none; font-size: 13px; }
.crumb:hover { color: var(--text); }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
section + section { margin-top: 28px; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.stat .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: -.3px; }
.stat .sub { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 10px; position: relative; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar > i.warn { background: var(--amber); } .bar > i.crit { background: var(--red); }
.bar > b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .5; }

.chart-card { padding: 14px 16px 10px; }
.chart-card .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.chart-card .top span { color: var(--muted); font-size: 12px; }
.chart-card .top strong { font-variant-numeric: tabular-nums; font-weight: 600; }
.chart { width: 100%; height: 120px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--faint); font-size: 10px; font-family: var(--sans); }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.tip { position: fixed; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; font-size: 12px; z-index: 20; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); font-size: 12px; background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .muted, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.wrap-any { overflow-wrap: anywhere; }

/* ---- pills ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.pill.ok::before { background: var(--accent); } .pill.warn::before { background: var(--amber); } .pill.bad::before { background: var(--red); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-family: var(--mono); }

/* ---- buttons & forms ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 10px; cursor: pointer; color: var(--muted); font-size: 12px; min-height: 28px; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
form.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > label { font-weight: 500; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
.field .err { color: var(--red); font-size: 12px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; min-height: 36px; width: 100%; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
.check { display: flex; gap: 8px; align-items: center; }
.types { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.types label { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 12px; cursor: pointer; display: grid; gap: 4px; }
.types label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.types input { position: absolute; opacity: 0; }
.types strong { font-weight: 600; }
.types span { color: var(--muted); font-size: 12px; }
.form-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

pre.log { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font: 12px/1.5 var(--mono); overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-all; margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--accent); }
.alert { border: 1px solid var(--line-2); border-left: 3px solid var(--amber); background: var(--surface); padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.alert.bad { border-left-color: var(--red); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); min-height: 96px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; padding: 20px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgb(0 0 0 / .55); }
dialog h3 { margin: 0 0 8px; font-size: 16px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 16px; opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 30; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; } #toast.bad { border-color: var(--red); }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login .brand { padding: 0 0 20px; }

/* ---- responsive ---- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .types { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: sticky; top: 0; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); z-index: 10; gap: 2px; }
  .brand, .nav .spacer, .nav .who { display: none; }
  .nav a { padding: 8px 10px; min-height: 40px; white-space: nowrap; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  main { padding: 20px 16px 48px; }
  .g3, .g2, .form-cols { grid-template-columns: 1fr; }
  .btn { min-height: 40px; }
  .hide-sm { display: none; }
}
@media (max-width: 480px) { .g4, .types { grid-template-columns: 1fr; } }
