/* hostmon — palette per dataviz reference instance; roles, not raw hex, in the body */
:root {
  color-scheme: light;
  --page:         #f9f9f7;
  --surface-1:    #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary:#52514e;
  --muted:        #898781;
  --grid:         #e1e0d9;
  --baseline:     #c3c2b7;
  --border:       rgba(11,11,11,0.10);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b;
  --meter-track: #cde2fb;
  --spark-bg: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:         #0d0d0d;
    --surface-1:    #1a1a19;
    --text-primary: #ffffff;
    --text-secondary:#c3c2b7;
    --muted:        #898781;
    --grid:         #2c2c2a;
    --baseline:     #383835;
    --border:       rgba(255,255,255,0.10);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --meter-track: #184f95;
    --spark-bg: #2c2c2a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }

.top {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.brand { font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.top nav { display: flex; gap: 12px; }
.top nav a { color: var(--text-secondary); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.top nav a.active, .top nav a:hover { color: var(--text-primary); background: var(--grid); }
.clock { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 20px 60px; }
.pagetitle { font-size: 20px; margin: 8px 0 14px; }
.pagetitle .count { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 8px; }
.dim { color: var(--text-secondary); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }

/* ---- fleet table */
table.fleet { width: 100%; border-collapse: collapse; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table.fleet th, table.fleet td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grid); }
table.fleet th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.fleet tr:last-child td { border-bottom: 0; }
table.fleet td.num, table.fleet th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hostlink { font-weight: 600; text-decoration: none; }
.hostlink:hover { text-decoration: underline; }
.errflag { color: var(--st-warning); margin-left: 4px; cursor: help; }
.empty { color: var(--muted); text-align: center; padding: 28px !important; }

.cellmeter { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.meter { width: 74px; height: 4px; border-radius: 2px; background: var(--meter-track); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 2px; }
.meter .sev-ok { background: var(--series-1); }
.meter .sev-warn { background: var(--st-warning); }
.meter .sev-crit { background: var(--st-critical); }

/* status badges: colored dot + text label (never color alone) */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.st-ok::before { background: var(--st-good); }
.badge.st-warning::before { background: var(--st-warning); }
.badge.st-critical::before { background: var(--st-critical); }
.badge.st-stale::before { background: var(--muted); }
.tag { font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

/* status dot beside hostname: color + title tooltip (never color alone) */
.statusdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-left: 8px; background: var(--muted); cursor: default; }
.statusdot.st-ok { background: var(--st-good); }
.statusdot.st-warning { background: var(--st-warning); }
.statusdot.st-critical { background: var(--st-critical); }
.statusdot.st-stale { background: var(--muted); }

/* ---- sparklines */
.spark { background: var(--spark-bg); border-radius: 3px; display: block; }
.sparkwrap { display: inline-block; line-height: 0; }
.spark-line { fill: none; stroke: var(--series-1); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: var(--series-1); opacity: .1; }
.spark-dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.spark-mid { stroke: var(--baseline); stroke-width: 1; }
.spark-up-line { fill: none; stroke: var(--series-1); stroke-width: 1.5; stroke-linejoin: round; }
.spark-up-area { fill: var(--series-1); opacity: .12; }
.spark-down-line { fill: none; stroke: var(--series-2); stroke-width: 1.5; stroke-linejoin: round; }
.spark-down-area { fill: var(--series-2); opacity: .12; }

/* ---- host page */
.hosthead { margin-bottom: 6px; }
.identline { margin: 2px 0; font-size: 13px; }
.rangebar { display: flex; gap: 6px; margin: 14px 0 6px; }
.rangebtn { text-decoration: none; font-size: 13px; color: var(--text-secondary); padding: 3px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-1); }
.rangebtn.active { color: var(--text-primary); font-weight: 600; border-color: var(--baseline); }
.errbox { border: 1px solid var(--st-warning); border-radius: 8px; padding: 8px 12px; margin: 10px 0; font-size: 13px; color: var(--text-secondary); background: var(--surface-1); }

.chartsec h2 { font-size: 15px; margin: 22px 0 8px; color: var(--text-primary); }
.chartgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.chart { margin: 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 8px; }
.chart figcaption { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.chart-body { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .baseline { stroke: var(--baseline); stroke-width: 1; }
/* 20 SVG units ≈ 15px rendered at typical chart width (viewBox scales down) */
.chart-svg .yt { fill: var(--muted); font-size: 20px; text-anchor: end; font-variant-numeric: tabular-nums; }
.chart-svg .xt { fill: var(--muted); font-size: 20px; text-anchor: middle; font-variant-numeric: tabular-nums; }
.chart-svg .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .end-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart-svg .crosshair { stroke: var(--baseline); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 2px 2px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend .lg i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: 7px 10px; font-size: 12px;
  min-width: 130px; max-width: 260px;
}
.tooltip .tt-time { color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.tooltip .tt-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .tt-row .k { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tooltip .tt-row .k i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tooltip .tt-row .v { font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* ---- top processes + status */
.topgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.toptable { width: 100%; border-collapse: collapse; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 13px; }
.toptable th, .toptable td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; }
.toptable th { color: var(--muted); font-weight: 500; font-size: 12px; }
.toptable td.num, .toptable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.toptable tr:last-child td { border-bottom: 0; }

.statuslist { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; max-width: 560px; }
.statuslist dt { color: var(--muted); }
.statuslist dd { margin: 0; }

/* ---- auth + forms */
.flash { border-radius: 8px; padding: 9px 14px; margin: 0 0 12px; font-size: 13px; background: var(--surface-1); border: 1px solid var(--border); }
.flash-error { border-color: var(--st-critical); }
.flash-success { border-color: var(--st-good); }
.logincard { max-width: 360px; margin: 8vh auto 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 22px 26px; }
.small { font-size: 12px; }
.sectitle { font-size: 15px; margin: 24px 0 10px; }
.secgrid { display: flex; flex-wrap: wrap; gap: 14px; }
.secform { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; min-width: 300px; }
.secform h3 { margin: 0 0 10px; font-size: 14px; }
form label { display: block; margin: 10px 0; font-size: 13px; color: var(--text-secondary); }
form input[type=password] { display: block; width: 100%; margin-top: 4px; padding: 7px 9px; font: inherit; color: var(--text-primary); background: var(--page); border: 1px solid var(--baseline); border-radius: 7px; box-sizing: border-box; }
form input[type=password]:focus { outline: 2px solid var(--series-1); outline-offset: 0; border-color: transparent; }
form button { font: inherit; font-weight: 600; padding: 7px 16px; margin-top: 6px; border-radius: 8px; border: 1px solid var(--baseline); background: var(--surface-1); color: var(--text-primary); cursor: pointer; }
form button:hover { background: var(--grid); }
form button.danger { border-color: var(--st-critical); color: var(--st-critical); }
form button.danger:hover { background: var(--st-critical); color: #fff; }
.logoutform { margin: 0; }
.linkbtn { background: none; border: none; color: var(--text-secondary); font: inherit; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.linkbtn:hover { color: var(--text-primary); background: var(--grid); }
.deleteform { margin-left: auto; align-self: flex-start; }
.hosthead { display: flex; gap: 16px; }
