:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.04);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --other: #b5b3ab;
  --accent: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --critical-text: #b42727;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.05);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --other: #5f5e59;
    --accent: #3987e5;
    --good-text: #0ca30c;
    --critical-text: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --hover: rgba(255, 255, 255, 0.05);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --other: #5f5e59;
  --accent: #3987e5;
  --good-text: #0ca30c;
  --critical-text: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-2); font-weight: 500; }
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; text-decoration: none; }
.top nav { display: flex; gap: 4px; }
.top nav a {
  text-decoration: none; color: var(--text-2);
  padding: 4px 10px; border-radius: 6px;
}
.top nav a:hover { background: var(--hover); }
.top nav a[aria-current="page"] { color: var(--text); background: var(--hover); font-weight: 500; }
.updated { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.theme-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; color: var(--text-2);
}
.theme-btn:hover { background: var(--hover); }
.banner {
  margin: 12px 24px 0; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
}

main { padding: 20px 24px 48px; max-width: 1440px; margin: 0 auto; transition: opacity .2s; }
main.loading { opacity: .6; }

/* ---------------------------------------------------------------- shared pieces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-width: 0;
}
.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.section-head .sub { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.sub-text { color: var(--text-2); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.status svg { flex: none; }

/* meter: fill carries severity, track is a tint of the fill */
.meter-row { display: grid; grid-template-columns: 64px 1fr; gap: 2px 10px; align-items: center; margin-top: 10px; }
.meter-row .label { color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-row .value { grid-column: 2; font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; }
.meter-row .value strong { color: var(--text); font-weight: 600; }
.meter {
  --fill: var(--accent);
  height: 8px; border-radius: 4px; overflow: hidden;
  background: color-mix(in srgb, var(--fill) 18%, var(--surface));
}
.meter > span { display: block; height: 100%; background: var(--fill); border-radius: 4px; min-width: 2px; }
.meter.warning { --fill: var(--warning); }
.meter.critical { --fill: var(--critical); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile .t-label { color: var(--text-2); font-size: 12px; }
.tile .t-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.tile .t-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* range filter (one row, above the charts it scopes) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--hover); color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- overview */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.srv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.srv-head a { text-decoration: none; }
.srv-head a:hover h2 { text-decoration: underline; }
.srv-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.srv.offline .srv-body { opacity: .55; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--grid); }
.kv .k { color: var(--text-2); font-size: 12px; }
.kv .v { font-weight: 600; }
.kv .v small { font-weight: 400; color: var(--muted); font-size: 12px; }
.problems { margin: 12px 0 0; padding: 10px 0 0; list-style: none; border-top: 1px solid var(--grid); display: grid; gap: 6px; }
.problems li { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-2); }
.problems li strong { color: var(--text); font-weight: 600; }
.spark-wrap { margin-top: 12px; }
.spark-wrap .sub-text { margin-bottom: 2px; }

/* ---------------------------------------------------------------- charts */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.chart-card h3 { margin-bottom: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; font-size: 12px; color: var(--text-2); }
.legend span.item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.key-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; flex: none; }
.key-rect { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.plot { position: relative; width: 100%; }
.plot .u-over { cursor: crosshair; }
.u-cursor-x { border-right: 1px solid var(--muted) !important; }
.tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 140px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
  font-size: 12px; color: var(--text-2);
}
.tip .tip-time { color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.tip .tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip .tip-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 12px; padding: 24px 0; text-align: center; }

details.data-table { margin-top: 6px; font-size: 12px; }
details.data-table summary { color: var(--muted); cursor: pointer; width: max-content; }
details.data-table .scroll { max-height: 240px; overflow: auto; margin-top: 6px; }

/* svg columns */
svg.cols { display: block; width: 100%; overflow: visible; }
svg.cols text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.cols .grid { stroke: var(--grid); stroke-width: 1; }
svg.cols .base { stroke: var(--axis); stroke-width: 1; }
svg.cols .hit { fill: transparent; outline: none; cursor: default; }
svg.cols g.col:hover .bar, svg.cols g.col:focus-within .bar { filter: brightness(1.15); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.app-row { cursor: pointer; }
tr.app-row:hover td, tr.app-row:focus-visible td { background: var(--hover); }
tr.app-row td:first-child { width: 1%; }
tr.ctr td { color: var(--text-2); font-size: 12px; background: color-mix(in srgb, var(--page) 60%, var(--surface)); }
tr.ctr td.name { padding-left: 32px; }
tr.stopped td { color: var(--muted); }
.caret { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
tr[aria-expanded="true"] .caret { transform: rotate(90deg); }
.pill { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--hover); color: var(--text-2); font-size: 11px; }

.back { color: var(--text-2); text-decoration: none; font-size: 13px; }
.back:hover { text-decoration: underline; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.small-multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .updated { order: 3; width: 100%; margin-left: 0; }
  main { padding: 16px 16px 40px; }
  .banner { margin: 12px 16px 0; }
  .servers { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------- sign-in */
.who { color: var(--muted); font-size: 12px; }
.ghost-btn {
  border: 1px solid var(--border); border-radius: 6px; background: transparent;
  padding: 4px 10px; cursor: pointer; color: var(--text-2); font-size: 13px;
}
.ghost-btn:hover { background: var(--hover); color: var(--text); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; max-width: none; }
.login-card { width: 100%; max-width: 360px; padding: 28px; display: grid; gap: 6px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-2); margin-bottom: 14px; }
.login-card h1 { font-size: 22px; margin-bottom: 12px; }
.login-card label { font-size: 13px; color: var(--text-2); margin-top: 6px; }
.login-card input {
  width: 100%; font: inherit; color: var(--text); background: var(--page);
  border: 1px solid var(--axis); border-radius: 8px; padding: 9px 11px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
}
.pw-toggle:hover { background: var(--hover); }
.login-error {
  margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  color: var(--critical-text); background: color-mix(in srgb, var(--critical) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--critical) 35%, transparent);
}
.btn-primary {
  margin-top: 14px; border: 0; border-radius: 8px; padding: 10px 14px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .65; cursor: progress; }
.login-foot { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------------------------------------------------------------- overview app list */
.apps-brief { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--grid); }
.apps-brief table { font-size: 12px; }
.apps-brief th, .apps-brief td { padding: 4px 6px; border-bottom: 0; }
.apps-brief th { background: transparent; position: static; }
.apps-brief td.app-name { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.apps-brief td.app-name .why { color: var(--text-2); }
.apps-brief tr.stopped td { color: var(--muted); }
.apps-brief .kind { color: var(--muted); font-size: 11px; margin-left: 4px; }
.apps-brief .ico { width: 1%; padding-right: 0; }
.apps-brief .ico svg { display: block; }
.more-link { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--accent); text-decoration: none; font-weight: 500; }
.more-link:hover { text-decoration: underline; }
.srv-head .details { font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.srv-head .details:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) { .who { display: none; } }
