:root {
  color-scheme: light;
  --bg: #f4f3f0; --surface: #fcfcfb; --border: #e3e1db; --grid: #e9e7e1;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #8a8983;
  --accent: #1c5cab; --accent-ink: #ffffff;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --neutral: #b9b7b0;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --warn-ink: #7a5200; --crit-ink: #a32222;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --border: #32322f; --grid: #2a2a28;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
    --accent: #6da7ec; --accent-ink: #0b0b0b;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --neutral: #5d5c57;
    --good-ink: #5fd35f; --warn-ink: #fab219; --crit-ink: #f08a8a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 15px; } h3 { font-size: 13px; }
.muted { color: var(--text-2); } .small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand, .login-card h1 { font-size: 17px; font-weight: 700; padding: 0 8px 18px; }
.brand span, .login-card h1 span { color: var(--accent); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { padding: 8px 10px; border-radius: 6px; color: var(--text-2); text-decoration: none; display: flex; justify-content: space-between; }
nav a:hover { background: var(--bg); color: var(--text); }
nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; }
nav .count { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 0 4px; }
.main { padding: 24px 28px 60px; max-width: 1240px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card > h2 { margin-bottom: 4px; }
.card > .sub { color: var(--text-2); font-size: 12px; margin: 0 0 10px; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.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)); }
.tile .label { color: var(--text-2); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; letter-spacing: -0.01em; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 4px; }
.tile .note { color: var(--text-2); font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); flex: none; }
.badge.good { color: var(--good-ink); } .badge.good::before { background: var(--good); }
.badge.warn { color: var(--warn-ink); } .badge.warn::before { background: var(--warning); border-radius: 2px; }
.badge.crit { color: var(--crit-ink); } .badge.crit::before { background: var(--critical); border-radius: 0; transform: rotate(45deg); }
.notice { border-left: 3px solid var(--warning); padding: 8px 12px; background: var(--surface); border-radius: 4px; margin-bottom: 8px; }
.notice.crit { border-left-color: var(--critical); }
.notice.ok { border-left-color: var(--good); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 650; border-top: 1px solid var(--border); border-bottom: 0; }
td.wrap { max-width: 320px; }

.btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--text-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--text-2); cursor: pointer; font: inherit; padding: 4px; text-decoration: underline; }
select, input[type=text], input[type=email], input[type=password] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; max-width: 100%; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.error { color: var(--crit-ink); min-height: 1.2em; margin: 0 0 8px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 340px; max-width: 100%; }
.login-card h1 { padding: 0 0 4px; font-size: 20px; }
.login-card .btn { width: 100%; }

.drop { border: 2px dashed var(--border); border-radius: 10px; padding: 26px; text-align: center; color: var(--text-2); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); border-radius: 12px; padding: 1px 8px; font-size: 12px; white-space: nowrap; }
.chip.suggested { border-style: dashed; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 200px) 1fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.hbar .track { height: 10px; border-radius: 4px; background: transparent; }
.hbar .fill { height: 10px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--text); color: var(--surface); padding: 8px 10px; border-radius: 6px; font-size: 12px; max-width: 280px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tip b { display: block; margin-bottom: 3px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); padding: 20px; width: 360px; max-width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 8px 0 4px; }
  nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; }
  nav a { white-space: nowrap; gap: 6px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; }
  .side-foot .link { white-space: nowrap; font-size: 12px; }
  .main { padding: 16px 16px 48px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .tile .value { font-size: 22px; }
}
@media (min-width: 861px) and (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
