:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e3e2dd;
  --line-strong: #cfcdc6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --good-ink: #067806; --warn-ink: #8a5d00; --crit-ink: #b02a2a;
  --good-bg: #e6f4e6; --warn-bg: #fdf3dc; --crit-bg: #fbe6e6; --info-bg: #e5eefa;
  --grid: #ebeae6;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 2px 8px rgb(0 0 0 / 0.04);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2c2c2a; --line-strong: #3a3a37;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
    --accent: #3987e5; --accent-ink: #86b6ef;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --good-ink: #5fd05f; --warn-ink: #fab219; --crit-ink: #ff8a8a;
    --good-bg: #16301a; --warn-bg: #352a10; --crit-bg: #3a1a1a; --info-bg: #182a40;
    --grid: #262624;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2c2c2a; --line-strong: #3a3a37;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
  --accent: #3987e5; --accent-ink: #86b6ef;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --good-ink: #5fd05f; --warn-ink: #fab219; --crit-ink: #ff8a8a;
  --good-bg: #16301a; --warn-bg: #352a10; --crit-bg: #3a1a1a; --info-bg: #182a40;
  --grid: #262624;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: var(--accent-ink); }
button { font: inherit; color: inherit; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px 0; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.brand .host { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .spacer { flex: 1; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--good); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.pulse.yellow { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.pulse.red { background: var(--crit); box-shadow: 0 0 0 3px color-mix(in srgb, var(--crit) 25%, transparent); }
.pulse.grey { background: var(--text-3); box-shadow: none; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; cursor: pointer; color: var(--text-2); line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  text-decoration: none; color: var(--text-2); padding: 9px 12px 10px; font-size: 14px; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
nav.tabs a:hover { color: var(--text); }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--crit); color: #fff; font-weight: 600; }
nav.tabs .badge.yellow { background: var(--warn); color: #000; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }
.demo-banner { background: var(--info-bg); color: var(--text); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- layout ---------- */
.grid { display: grid; gap: 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)); }
@media (max-width: 900px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .g3, .g2 { grid-template-columns: 1fr; } }
@media (max-width: 380px) { .g4 { grid-template-columns: 1fr; } }
section { margin-top: 26px; }
section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-2); margin: 0; font-weight: 650; }
.section-head .grow { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 650; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head .grow { flex: 1; min-width: 0; }

/* ---------- stat tiles ---------- */
.tile .label { font-size: 13px; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; }
.tile .value { font: 600 26px/1.15 var(--mono); letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 14px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.tile .sub { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.meter { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--good); }
.meter > i.yellow { background: var(--warn); }
.meter > i.red { background: var(--crit); }

/* ---------- attention list ---------- */
.att { display: flex; flex-direction: column; gap: 8px; }
.att-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; text-decoration: none; color: var(--text); border: 1px solid transparent; }
.att-item:hover { border-color: var(--line-strong); }
.att-item.red { background: var(--crit-bg); }
.att-item.yellow { background: var(--warn-bg); }
.att-item.info { background: var(--info-bg); }
.att-item .ico { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; margin-top: 1px; }
.att-item.red .ico { background: var(--crit); }
.att-item.yellow .ico { background: var(--warn); color: #000; }
.att-item.info .ico { background: var(--accent); }
.att-item b { font-weight: 600; }
.att-item .d { font-size: 13px; color: var(--text-2); }
.all-good { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 10px; background: var(--good-bg); }
.all-good .ico { width: 26px; height: 26px; border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* ---------- status chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 2px 9px 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; font-weight: 500; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.chip.good { background: var(--good-bg); color: var(--good-ink); }
.chip.good::before { background: var(--good); }
.chip.yellow { background: var(--warn-bg); color: var(--warn-ink); }
.chip.yellow::before { background: var(--warn); }
.chip.red { background: var(--crit-bg); color: var(--crit-ink); }
.chip.red::before { background: var(--crit); }
.chip.plain::before { display: none; }

/* ---------- key/value lists ---------- */
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: 14px; }
dl.kv dt { color: var(--text-2); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12.5px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; }
.bar-cell { position: relative; min-width: 90px; }
.hbar { height: 6px; border-radius: 3px; background: var(--s1); margin-top: 7px; min-width: 2px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 9px; padding: 7px 13px; cursor: pointer; font-size: 14px; font-weight: 550; color: var(--text); text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 45%, var(--line-strong)); }
.btn.danger:hover { background: var(--crit-bg); }
.btn.danger.solid { background: var(--crit); color: #fff; border-color: var(--crit); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.seg button { border: none; background: none; padding: 4px 11px; border-radius: 7px; font-size: 13px; cursor: pointer; color: var(--text-2); font-weight: 550; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

/* ---------- charts ---------- */
.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font: 11px var(--mono); }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.12; }
.chart .event-line { stroke: var(--text-3); stroke-dasharray: 2 3; stroke-width: 1; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .limit { stroke: var(--crit); stroke-dasharray: 4 4; stroke-width: 1; opacity: 0.6; }
.chart .limit-label { fill: var(--crit-ink); font: 11px var(--sans); }
.tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); white-space: nowrap; min-width: 120px;
}
.tip .t { color: var(--text-2); margin-bottom: 3px; font-size: 12px; }
.tip .row { display: flex; align-items: center; gap: 7px; }
.tip .row .v { margin-left: auto; padding-left: 12px; font-family: var(--mono); font-weight: 600; }
.sw { width: 10px; height: 3px; border-radius: 2px; display: inline-block; flex: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.chart-title b { font-size: 14px; font-weight: 600; }
.chart-title .now { font: 600 14px var(--mono); }

/* ---------- apps ---------- */
.app-card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.app-card .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.app-card .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.app-card .mini .k { font-size: 12px; color: var(--text-3); }
.app-card .mini .v { font: 600 15px var(--mono); }
.logbox { margin-top: 12px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; max-height: 320px; overflow: auto; font: 12px/1.5 var(--mono); }
.logbox div { white-space: pre-wrap; overflow-wrap: anywhere; }
.logbox .ts { color: var(--text-3); }

/* ---------- backups ---------- */
.dots { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 12px; }
.dots i { width: 12px; height: 18px; border-radius: 3px; background: var(--good); opacity: 0.9; }
.dots i.miss { background: var(--surface-2); outline: 1px dashed var(--line-strong); outline-offset: -1px; }
.dots i.today { outline: 2px solid var(--text); outline-offset: 1px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; padding: 20px; width: min(420px, 100%); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3); }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 6px 0; color: var(--text-2); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.code-input { width: 100%; font: 600 26px var(--mono); letter-spacing: 0.35em; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); margin-top: 12px; }
.err { color: var(--crit-ink); font-size: 14px; margin-top: 8px; min-height: 1em; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(360px, 100%); }
.login .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login .logo h1 { font-size: 20px; margin: 0; }
.login label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 4px; font-weight: 550; }
.login input { width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; }
.login input:focus, .code-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 10px; }

.empty { color: var(--text-3); padding: 18px 0; text-align: center; font-size: 14px; }
.loading { color: var(--text-3); padding: 40px 0; text-align: center; }
.foot { margin-top: 40px; color: var(--text-3); font-size: 12.5px; text-align: center; }
.rebooting { text-align: center; padding: 60px 16px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
td.num, .brand h1 { white-space: nowrap; }
@media (max-width: 560px) {
  .brand .host { display: none; }
  .hide-sm { display: none; }
  main { padding-top: 14px; }
  .tile .value { font-size: 22px; }
}
