/* Infra health dashboard. Dark by default; light only when Telegram's Mini App asks. */

:root {
  color-scheme: dark;
  --bg: #0e1317;
  --panel: #151c21;
  --panel-2: #1b242a;
  --line: #26323a;
  --line-2: #33424c;
  --text: #e4eaed;
  --muted: #98a6af;
  --faint: #6f7d86;
  --accent: #6cb8e6;
  --data: #6cb8e6;
  --data-fill: rgba(108, 184, 230, 0.12);
  --data-band: rgba(108, 184, 230, 0.2);
  --grid: rgba(228, 234, 237, 0.07);
  --ok: #3fcf7f;
  --warn: #f0b43c;
  --crit: #f26461;
  --stale: #85929b;
  --none: #5d6a73;
  --crit-wash: rgba(242, 100, 97, 0.08);
  --warn-wash: rgba(240, 180, 60, 0.06);
  --focus: #9fd3f2;
  /* Chart series, fixed order. 1-3 pass the colour-vision checks on their own; 4-8 rely on the legend. */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --radius: 10px;
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --panel-2: #eef1f3;
  --line: #dde3e7;
  --line-2: #c9d2d8;
  --text: #172026;
  --muted: #55636c;
  --faint: #76848d;
  --accent: #1f6fae;
  --data: #1f6fae;
  --data-fill: rgba(31, 111, 174, 0.1);
  --data-band: rgba(31, 111, 174, 0.16);
  --grid: rgba(23, 32, 38, 0.08);
  --ok: #1b8a4c;
  --warn: #a86b00;
  --crit: #c93633;
  --stale: #6b7780;
  --focus: #1f6fae;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-feature-settings: "tnum" 1, "cv11" 1;
  min-height: 100vh;
  min-height: 100dvh;
}

body.modal-open { overflow: hidden; }

a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

.boot { padding: 40px; color: var(--muted); }

.skip {
  position: absolute; left: 12px; top: -40px; z-index: 50;
  background: var(--panel-2); padding: 8px 12px; border-radius: 8px;
}
.skip:focus { top: 8px; }

/* ---------- status marks: shape and label, never colour alone ---------- */

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  white-space: nowrap;
}
.status[data-s="warn"] { color: var(--warn); }
.status[data-s="crit"] { color: var(--crit); }
.status[data-s="ok"] .status-text { color: var(--muted); }

.sdot {
  display: inline-block; width: 9px; height: 9px; flex: none;
  background: var(--none); border-radius: 50%;
  transition: background-color 400ms ease, transform 400ms ease;
}
[data-s="ok"] > .sdot { background: var(--ok); }
[data-s="warn"] > .sdot {
  background: var(--warn); border-radius: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 10px; height: 9px;
}
[data-s="crit"] > .sdot {
  background: var(--crit); border-radius: 1px; transform: rotate(45deg) scale(0.85);
}
[data-s="stale"] > .sdot {
  background: transparent; box-shadow: inset 0 0 0 2px var(--stale);
}
[data-s="none"] > .sdot { width: 8px; height: 2px; border-radius: 1px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  cursor: pointer; font-weight: 500;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.btn:hover { background: var(--line); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: #2a7ab0; border-color: #2a7ab0; color: #fff; min-height: 42px; width: 100%; }
.btn-primary:hover { background: #3288c2; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); min-height: 32px; padding: 0 10px; }
.btn-quiet:hover { color: var(--text); background: var(--panel-2); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; color: var(--muted); font-size: 15px;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 52px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 650; font-size: 15px; white-space: nowrap;
}
.nav ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: 6px 12px; border-radius: 7px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { color: var(--text); background: var(--panel-2); }
.live {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; white-space: nowrap;
}
.user { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.user-name { color: var(--muted); }

.live-dot {
  position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); transition: background-color 400ms ease;
}
.live-dot[data-state="down"], .live-dot[data-stale="true"] { background: var(--stale); }
.live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--ok); opacity: 0;
}
.live-dot.beat::after { animation: beat 1.1s ease-out 1; }
@keyframes beat {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(3.2); opacity: 0; }
}

.banner {
  position: sticky; top: 52px; z-index: 15;
  padding: 7px 24px; font-size: 13px;
  background: var(--panel-2); color: var(--warn);
  border-bottom: 1px solid var(--line);
}

/* ---------- layout ---------- */

.layout {
  display: grid; gap: 24px;
  grid-template-columns: minmax(0, 1fr) 400px;
  align-items: start;
  padding: 20px 24px 48px;
}
.layout:focus { outline: none; }
.main { display: grid; gap: 20px; min-width: 0; }
.rail {
  position: sticky; top: 72px;
  max-height: calc(100dvh - 92px); overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.rail:empty { display: none; }

.empty-state {
  padding: 32px; border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--muted);
}

/* ---------- alerts strip ---------- */

.alerts {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color 400ms ease, background-color 400ms ease;
}
.alerts[data-state="crit"] { border-color: color-mix(in srgb, var(--crit) 45%, var(--line)); background: color-mix(in srgb, var(--crit) 5%, var(--panel)); }
.alerts[data-state="warn"] { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.alerts h2 { font-size: 13px; color: var(--muted); font-weight: 500; }
.alerts .count { color: var(--text); }
.quiet { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.quiet .sdot { background: var(--ok); }
.alerts-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-width: 0; }
.alert { min-width: 0; max-width: 100%; }
.alert-link {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
  padding: 6px 12px; border-radius: 8px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; cursor: pointer;
}
.alert-link:hover { border-color: var(--line-2); }
.alert[data-s="crit"] .alert-link { border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.alert-host { color: var(--muted); }
.alert-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.alert-since { color: var(--faint); font-size: 12.5px; white-space: nowrap; }
.tag { font-size: 11.5px; padding: 1px 6px; border-radius: 4px; background: var(--line); color: var(--muted); }

/* ---------- fleet groups and host cards ---------- */

.fleet { display: grid; gap: 12px; }
.fleet-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.fleet-head h2 { font-size: 15px; }
.fleet-sum { font-size: 12.5px; color: var(--faint); }

.hostcards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); }
.hostcard {
  display: grid; gap: 14px; align-content: start;
  padding: 18px 20px 20px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-top: 3px solid var(--none);
  transition: border-color 500ms ease;
}
.hostcard[data-s="ok"] { border-top-color: var(--ok); }
.hostcard[data-s="warn"] { border-top-color: var(--warn); }
.hostcard[data-s="crit"] { border-top-color: var(--crit); }
.hostcard[data-s="stale"] { border-top-color: var(--stale); }
.hostcard-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.hostcard-head h3 { font-size: 20px; overflow-wrap: anywhere; }
.hostcard-head h3 a { color: var(--text); text-decoration: none; }
.hostcard-head h3 a:hover { text-decoration: underline; }
.hostcard.extonly { background: color-mix(in srgb, var(--panel) 55%, var(--bg)); border-style: dashed; border-top-style: solid; }
.hostcard.extonly .hostcard-head h3 a { color: var(--muted); }
.hostcard-head .status { font-size: 13.5px; }
.hostcard-meta { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; margin-left: auto; color: var(--faint); font-size: 12.5px; }
.sub { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.headline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.head-cell {
  display: grid; grid-template-columns: 1fr; gap: 2px;
  padding: 12px 14px 8px; border-radius: var(--radius); text-align: left;
  background: var(--panel-2); border: 1px solid transparent; cursor: pointer;
  transition: border-color 400ms ease, background-color 400ms ease;
}
div.head-cell { cursor: default; }
.head-cell:hover { border-color: var(--line-2); }
.head-cell[data-s="warn"] { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.head-cell[data-s="crit"] { border-color: color-mix(in srgb, var(--crit) 55%, transparent); background: color-mix(in srgb, var(--crit) 6%, var(--panel-2)); }
.head-label { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-cell .value .num { font-size: 28px; }
.head-sub { font-size: 12px; color: var(--faint); min-height: 1.3em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 28px;
  padding: 2px 10px; border-radius: 999px; font-size: 12.5px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); text-decoration: none;
  transition: border-color 400ms ease;
}
.pill:hover { border-color: var(--line-2); }
.pill[data-s="warn"] { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.pill[data-s="crit"] { border-color: color-mix(in srgb, var(--crit) 60%, var(--line)); background: color-mix(in srgb, var(--crit) 8%, var(--panel-2)); }
.pill[data-s="stale"] { color: var(--muted); }
.head-cell .spark { height: 34px; margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; font-size: 13px; cursor: pointer;
  transition: border-color 400ms ease;
}
.chip:hover { border-color: var(--line-2); }
.chip[data-s="crit"] { border-color: color-mix(in srgb, var(--crit) 50%, var(--line)); }
.chip[data-s="warn"] { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }

.attention { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.attention > .muted { font-size: 13px; }
.attn {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; padding: 6px 10px; border-radius: 8px; text-align: left;
  background: transparent; border: 1px solid transparent; cursor: pointer;
}
.attn:hover { background: var(--panel-2); border-color: var(--line); }
.attn-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-val { font-weight: 600; white-space: nowrap; }

/* ---------- values and sparklines ---------- */

.value { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; }
.value .num { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.value .unit { font-size: 13px; color: var(--muted); }
.value.big .num { font-size: 32px; }

.spark { display: block; width: 100%; height: 30px; overflow: hidden; }
.spark-line { fill: none; stroke: var(--data); stroke-width: 1.5px; stroke-linejoin: round; transition: stroke 400ms ease; }
.spark-area { fill: var(--data-fill); stroke: none; }
[data-s="warn"] > .spark .spark-line { stroke: var(--warn); }
[data-s="crit"] > .spark .spark-line { stroke: var(--crit); }
[data-s="stale"] > .spark .spark-line { stroke: var(--stale); }
[data-s="warn"] > .spark .spark-area { fill: color-mix(in srgb, var(--warn) 12%, transparent); }
[data-s="crit"] > .spark .spark-area { fill: color-mix(in srgb, var(--crit) 12%, transparent); }

/* ---------- host page ---------- */

.hosthead { display: grid; gap: 6px; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; justify-self: start; }
.back::before { content: "‹ "; }
.back:hover { color: var(--text); }
.hosthead-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; }
.hosthead h1 { font-size: 24px; }
.hosthead .status { font-size: 14px; }

.jump ul { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }

.group { display: grid; gap: 10px; scroll-margin-top: 72px; }
.group-head { display: flex; align-items: baseline; gap: 12px; }
.group-head h2 { font-size: 15px; }
.group-head h2:focus { outline: none; }
.group-head h2:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.group-count { margin-left: auto; font-size: 12px; color: var(--faint); }

.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); }
.tile {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto;
  align-items: baseline; gap: 4px 8px;
  padding: 12px 14px 10px; border-radius: var(--radius); text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line);
  cursor: pointer; min-width: 0;
  transition: border-color 400ms ease, background-color 400ms ease;
}
.tile:hover { border-color: var(--line-2); }
.tile[data-s="ok"] { border-left-color: color-mix(in srgb, var(--ok) 70%, var(--line)); }
.tile[data-s="warn"] { border-left-color: var(--warn); background: color-mix(in srgb, var(--panel) 94%, var(--warn)); }
.tile[data-s="crit"] { border-left-color: var(--crit); background: color-mix(in srgb, var(--panel) 92%, var(--crit)); }
.tile[data-s="stale"] { border-left-color: var(--stale); }
.tile[data-s="stale"] .value { color: var(--muted); }
.tile-title { grid-column: 1 / -1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .value { grid-column: 1; }
.tile .status { grid-column: 2; justify-self: end; }
.tile .status[data-s="ok"] .status-text, .tile .status[data-s="none"] .status-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tile .spark { grid-column: 1 / -1; margin-top: 2px; }

/* ---------- inline charts and the process table ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.range { display: inline-flex; align-items: center; gap: 10px; }
.range-label { font-size: 12.5px; color: var(--faint); }
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); }
.ichart-fig {
  margin: 0; min-width: 0; padding: 12px 14px 10px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
}
.ichart-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.ichart-note { font-weight: 400; color: var(--faint); font-size: 12px; }
.chart-wrap.ichart-wrap { min-height: 190px; }
.ichart { min-height: 190px; transition: opacity 200ms ease; }
.ichart.loading { opacity: 0.45; }
.ichart .u-legend { margin-top: 2px; }
.ichart .u-legend .u-series { padding: 0 8px 0 0; }

.ptable-wrap { max-width: 760px; overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.ptable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ptable th, .ptable td { padding: 8px 14px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.ptable thead th { border-top: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.ptable th:first-child { text-align: left; width: 100%; }
.ptable tbody th { font-weight: 500; }
.proc-name { color: var(--text); text-decoration: none; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.proc-name:hover { text-decoration: underline; }
.ptable-wrap > .muted { padding: 12px 14px; }

/* ---------- events ---------- */

.events { padding: 14px 16px 16px; display: grid; gap: 10px; }
.events h2 { font-size: 14px; }
.events-list { list-style: none; margin: 0; padding: 0; display: grid; }
.event { padding: 9px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.event:first-child { border-top: 0; }
.event-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.event-kind { font-size: 12px; color: var(--muted); padding: 0 6px; border-radius: 4px; background: var(--panel-2); white-space: nowrap; }
.event[data-kind="probe_error"] .event-kind { color: var(--warn); }
.event-subject { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.event-time { margin-left: auto; font-size: 12px; color: var(--faint); white-space: nowrap; }
.event-msg { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.event-host { color: var(--faint); }

.fresh { animation: slide-in 450ms cubic-bezier(.2, .7, .3, 1); }
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- detail dialog ---------- */

.detail {
  width: min(1240px, calc(100vw - 48px)); max-height: calc(100dvh - 48px);
  padding: 0; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--text);
  overflow: auto; overscroll-behavior: contain;
}
.detail::backdrop { background: rgba(4, 8, 10, 0.68); }
.detail[open] { animation: rise 220ms cubic-bezier(.2, .7, .3, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.detail-inner { display: grid; gap: 16px; padding: 20px 24px 24px; }
.detail-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: start; }
.detail-title { font-size: 19px; }
.detail-sub { color: var(--muted); margin-top: 2px; }
.detail-now { display: grid; justify-items: end; gap: 2px; }
.detail-controls { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.seg-btn {
  min-height: 32px; padding: 0 12px; border-radius: 6px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--line-2); color: var(--text); }
.siblings { display: flex; flex-wrap: wrap; gap: 4px; }
.siblings .seg-btn { border: 1px solid var(--line); min-height: 30px; }

.chart-wrap { position: relative; min-height: 240px; }
.chart { min-height: 240px; transition: opacity 200ms ease; }
.chart.loading { opacity: 0.45; }
.chart-msg {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  color: var(--muted); pointer-events: none;
}
.chart-msg button { pointer-events: auto; }
.chart-legend { color: var(--faint); font-size: 12.5px; }
.detail-events h3 { font-size: 14px; margin-bottom: 4px; }
.events-list.compact .event { padding: 7px 0; }

/* uPlot */
.uplot { font-family: var(--font); color: var(--muted); }
.u-legend { font-size: 12.5px; color: var(--muted); text-align: left; margin-top: 6px; }
.u-legend .u-marker { border-radius: 2px; }
.u-legend th { font-weight: 500; }
.u-legend .u-series:first-child th { display: none; }
.u-legend .u-value { color: var(--text); }
.u-cursor-x, .u-cursor-y { border-color: var(--line-2) !important; }
.u-select { background: var(--data-band); }

/* ---------- login ---------- */

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); display: grid; gap: 14px; justify-items: stretch;
  padding: 28px 28px 24px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
}
.login-card .brand { font-size: 14px; color: var(--muted); }
.login-card h1 { font-size: 24px; }
.login-error {
  padding: 10px 12px; border-radius: 8px; color: var(--text);
  background: color-mix(in srgb, var(--crit) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--crit) 45%, var(--line));
}
.login-error:empty { display: none; }
.widget-box { min-height: 44px; display: grid; place-items: center; }
.or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12.5px; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.login-status { color: var(--muted); min-height: 1.4em; }

/* ---------- logs ---------- */

.layout.wide { grid-template-columns: minmax(0, 1fr); }
.layout.wide > .rail { display: none; }

.tabs ul, .subtabs ul { display: flex; flex-wrap: wrap; gap: 2px; list-style: none; margin: 0; padding: 0; }
.tabs { border-bottom: 1px solid var(--line); margin-top: 4px; }
.tab {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px;
  color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.subtabs a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
}
.subtabs a:hover { color: var(--text); background: var(--panel); }
.subtabs a[aria-current="page"] { color: var(--text); background: var(--panel-2); }
.h1-sub { color: var(--muted); font-weight: 500; }

[data-s="today"] > .sdot { background: var(--accent); border-radius: 2px; }
.status[data-s="today"] { color: var(--accent); }

.logs-body { display: grid; gap: 24px; min-width: 0; }
.logs-loading { padding: 12px 0; }
.logs-msg {
  display: grid; gap: 10px; justify-items: start; padding: 18px 20px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
}
.card { padding: 16px 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.card > h2, .card summary h2 { font-size: 15px; }
.mono, .qv-lines { font-family: ui-monospace, "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }

.logsrc { display: grid; gap: 12px; }
.logsrc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.logsrc-head h2 { font-size: 18px; }
.logsrc-meta { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.logsrc-head .btn-quiet { margin-left: auto; }
.logsrc-grid { display: grid; gap: 20px; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

.cal { display: grid; gap: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.cal-month { display: grid; gap: 6px; }
.cal-title { font-size: 13px; font-weight: 500; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-wd { font-size: 11px; color: var(--faint); text-align: center; }
.cal-day {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; min-height: 30px;
  border-radius: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums;
  color: var(--text); text-decoration: none; background: var(--panel-2); border: 1px solid transparent;
}
.cal-day .sdot { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; }
.cal-day[data-s="warn"] > .sdot { width: 7px; height: 6px; }
.cal-day[data-s="ok"] { background: color-mix(in srgb, var(--ok) 14%, var(--panel-2)); }
.cal-day[data-s="warn"] { background: color-mix(in srgb, var(--warn) 16%, var(--panel-2)); }
.cal-day[data-s="crit"] { background: color-mix(in srgb, var(--crit) 16%, var(--panel-2)); }
.cal-day[data-s="today"] { border-color: var(--accent); }
a.cal-day:hover { border-color: var(--line-2); }
.cal-day.out { background: transparent; color: var(--faint); }
.cal-day[data-col="2"] { grid-column-start: 2; }
.cal-day[data-col="3"] { grid-column-start: 3; }
.cal-day[data-col="4"] { grid-column-start: 4; }
.cal-day[data-col="5"] { grid-column-start: 5; }
.cal-day[data-col="6"] { grid-column-start: 6; }
.cal-day[data-col="7"] { grid-column-start: 7; }
.cal-key { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 0; padding: 0; }

.dtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.dtable th, .dtable td { padding: 7px 12px; text-align: left; border-top: 1px solid var(--line); vertical-align: top; }
.dtable thead th { border-top: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.dtable .num { text-align: right; white-space: nowrap; }
.dtable tbody th { font-weight: 500; }
.daytable-wrap, .acc-wrap { border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); overflow-x: auto; }
.daytable tbody tr { position: relative; }
.daytable tbody tr:hover { background: var(--panel-2); }
.daytable .day { white-space: nowrap; }
.row-link { color: var(--text); text-decoration: none; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:hover .day-date { text-decoration: underline; }
.day-wd { color: var(--faint); font-weight: 400; }
.daytable .gaps { color: var(--warn); font-size: 12.5px; min-width: 12ch; }
.daytable tr[data-status="missing"] td, .daytable tr[data-status="missing"] .day-date { color: var(--muted); }
.more-btn { margin: 10px 12px; }

.logday { display: grid; gap: 16px; grid-template-columns: minmax(400px, 520px) minmax(0, 1fr);
  grid-template-areas: "head head" "sum qv" "dl qv" "objs qv"; grid-template-rows: auto auto auto 1fr; align-items: start; }
.logday-head { grid-area: head; display: grid; gap: 6px; }
.logday-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.logday-title h2 { font-size: 20px; }
.src-name { color: var(--muted); font-weight: 500; }
.day-step { display: inline-flex; gap: 6px; margin-left: auto; }
.day-step .btn { min-height: 32px; padding: 0 10px; text-decoration: none; color: var(--text); font-size: 13px; }
.logday-sum { grid-area: sum; display: grid; gap: 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px 16px; margin: 0; }
.fact dt { font-size: 12px; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.gap-list h3 { font-size: 13px; font-weight: 500; color: var(--warn); margin-bottom: 4px; }
.gap-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; }
.dl { grid-area: dl; display: grid; gap: 12px; }
.dl-row, .dl-range { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.btn-go { color: var(--text); text-decoration: none; background: color-mix(in srgb, var(--accent) 18%, var(--panel-2)); border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
.btn-go:hover { background: color-mix(in srgb, var(--accent) 28%, var(--panel-2)); }
.btn-go[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; background: var(--panel-2); border-color: var(--line-2); }
.dl-msg { font-size: 13px; color: var(--muted); }
.dl-msg[data-err="true"] { color: var(--crit); }
.objs { grid-area: objs; padding: 0; }
.objs summary { display: flex; align-items: baseline; gap: 6px; padding: 14px 18px; cursor: pointer; list-style: none; }
.objs summary::-webkit-details-marker { display: none; }
.objs summary::before { content: "▸"; color: var(--muted); }
.objs[open] summary::before { content: "▾"; }
.objs-wrap { max-height: 60vh; overflow: auto; border-top: 1px solid var(--line); }
.objtable th, .objtable td { padding: 6px 8px; }
.objtable th:first-child { padding-left: 14px; }
.objtable td:last-child { padding-right: 14px; }
.objtable tbody th { font-weight: 400; white-space: nowrap; }

.field { display: grid; gap: 4px; min-width: 0; }
.field label, .field .label { font-size: 12.5px; color: var(--muted); }
.field input, .field select {
  font: inherit; color: var(--text); background: var(--bg); min-height: 36px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 8px; min-width: 0; width: 100%;
}
.field input[type="date"], .field input[type="time"] { color-scheme: inherit; }
.field input[aria-invalid="true"] { border-color: var(--crit); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; min-height: 36px; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

.qv { grid-area: qv; display: grid; gap: 12px; }
.qv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.qv-status { font-size: 12.5px; color: var(--muted); }
.qv-status[data-trunc="true"] { color: var(--warn); }
.qv-form { display: grid; gap: 10px 12px; grid-template-columns: minmax(240px, 2.4fr) repeat(2, minmax(130px, 1fr)) repeat(2, minmax(110px, 0.8fr)) auto; align-items: end; }
.qv-qrow { display: flex; gap: 10px; align-items: center; }
.qv-qrow input { flex: 1 1 auto; }
.qv-moderow { display: flex; gap: 6px; align-items: center; }
.qv-moderow input { width: 80px; }
.qv-moderow input:disabled { opacity: 0.45; }
.qv-unmask { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.qv-err:empty { display: none; }
.qv-err { display: grid; gap: 8px; justify-items: start; color: var(--crit); font-size: 13.5px; }
.qv-lines {
  max-height: 75vh; min-height: 200px; overflow: auto; overscroll-behavior: contain;
  font-size: 12.5px; line-height: 1.55; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 0; transition: opacity 150ms ease;
}
.qv-lines.loading { opacity: 0.5; }
.qv-empty { padding: 16px; color: var(--muted); font-family: var(--font); }
.ll {
  display: grid; grid-template-columns: 12ch 5ch minmax(0, 32ch) minmax(0, 1fr); gap: 0 10px;
  padding: 1px 12px; content-visibility: auto; contain-intrinsic-size: auto 19px;
}
.ll:hover { background: var(--panel-2); }
.ll-ts { color: var(--faint); white-space: nowrap; }
.ll-lvl { font-weight: 600; }
.ll-mod { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-msg { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.ll[data-level="ERROR"] { background: var(--crit-wash); }
.ll[data-level="ERROR"] .ll-lvl { color: var(--crit); }
.ll[data-level="WARN"] { background: var(--warn-wash); }
.ll[data-level="WARN"] .ll-lvl { color: var(--warn); }
.ll[data-level="INFO"] .ll-lvl { color: var(--accent); }
.ll[data-level="DEBUG"] .ll-lvl, .ll[data-level="DEBUG"] .ll-msg { color: var(--muted); }
.ll[data-level="TRACE"] .ll-lvl, .ll[data-level="TRACE"] .ll-msg { color: var(--faint); }
.ll mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text); border-radius: 2px; }

.acc { display: grid; gap: 10px; }
.acc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.acc-wrap { max-height: 75vh; overflow: auto; }
.acctable td { white-space: nowrap; }
.acctable .detail-cell { white-space: normal; min-width: 24ch; color: var(--muted); }
.act-hi { background: color-mix(in srgb, var(--warn) 22%, var(--line)); color: var(--text); }

@media (max-width: 1400px) {
  .logday { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "sum" "dl" "qv" "objs"; grid-template-rows: none; }
  .qv-form { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
  .qv-mode { grid-column: span 2; }
}
@media (max-width: 1000px) {
  .logsrc-grid { grid-template-columns: minmax(0, 1fr); }
  .cal { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .cal-key { grid-column: 1 / -1; }
}

/* ---------- smaller screens ---------- */

@media (max-width: 1280px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; max-height: none; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar {
    height: auto; flex-wrap: wrap; gap: 4px 12px; padding: 8px 14px 0;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .nav { order: 4; flex-basis: 100%; overflow-x: auto; margin: 0 -14px; padding: 0 10px 6px; scrollbar-width: none; }
  .live { margin-left: auto; font-size: 12.5px; }
  .user-name { display: none; }
  .banner { top: 0; position: relative; padding: 7px 14px; }
  .layout { padding: 14px 12px 40px; gap: 16px; }
  .main { gap: 16px; }
  .hostcard { padding: 14px; }
  .hostcard-meta { margin-left: 0; flex-basis: 100%; }
  .headline { gap: 6px; }
  .head-cell { padding: 10px 10px 6px; }
  .head-cell .value .num { font-size: 22px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 10px 8px; }
  .value .num { font-size: 20px; }
  .headline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .ichart-fig { padding: 10px 8px 8px; }
  .chart-wrap.ichart-wrap, .ichart { min-height: 150px; }
  .ptable th, .ptable td { padding: 8px 10px; }
  .seg-btn { padding: 0 10px; }
  .alerts { padding: 10px 12px; }
  .alert-link { flex-wrap: wrap; }
  .alert-text { white-space: normal; }
  .attn { grid-template-columns: auto minmax(0, 1fr) auto; }
  .detail { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; margin: 0; }
  .detail-inner { padding: 14px 14px 24px; }
  .detail-head { grid-template-columns: minmax(0, 1fr) auto; }
  .detail-now { grid-column: 1 / -1; grid-row: 2; justify-items: start; }
  .value.big .num { font-size: 26px; }
  .tab { padding: 0 12px; }
  .logsrc-head h2 { font-size: 16px; }
  .logsrc-head .btn-quiet { margin-left: 0; }
  .card { padding: 14px 12px; }
  .daytable thead, .acctable thead { display: none; }
  .daytable, .daytable tbody, .acctable, .acctable tbody { display: block; }
  .daytable tr, .acctable tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px;
    padding: 10px 12px; border-top: 1px solid var(--line);
  }
  .daytable tbody tr:first-child, .acctable tbody tr:first-child { border-top: 0; }
  .daytable th, .daytable td, .acctable td { padding: 0; border: 0; text-align: left; }
  .daytable .num, .acctable .num { text-align: left; }
  .daytable .day { grid-column: 1; }
  .daytable .st { grid-column: 2; justify-self: end; }
  .daytable td[data-label]::before, .acctable td[data-label]::before {
    content: attr(data-label) " "; color: var(--faint); font-size: 11.5px; font-family: var(--font);
  }
  .daytable .gaps { grid-column: 1 / -1; order: 9; }
  .daytable .gaps:empty { display: none; }
  .daytable .cov { grid-column: 1 / -1; }
  .acctable .detail-cell { grid-column: 1 / -1; min-width: 0; }
  .acctable td { white-space: normal; overflow-wrap: anywhere; }
  .acctable .acc-ts { order: -2; white-space: nowrap; }
  .acctable .acc-act { order: -1; justify-self: end; }
  .acctable td.acc-ts::before, .acctable td.acc-act::before { content: none; }
  .acctable .acc-src { grid-column: 1 / -1; overflow-wrap: normal; word-break: break-all; }
  .cal { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .logday-title h2 { font-size: 17px; flex-basis: 100%; }
  .day-step { margin-left: 0; }
  .qv-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qv-search, .qv-mode, .qv-unmask { grid-column: 1 / -1; }
  .dl-range .field { flex: 1 1 130px; }
  .qv-lines { font-size: 12px; max-height: 70vh; }
  .ll { grid-template-columns: auto auto minmax(0, 1fr); padding: 3px 10px; }
  .ll-mod { grid-column: 3; }
  .ll-msg { grid-column: 1 / -1; }
  .objtable th, .objtable td { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
  .live-dot.beat::after { animation: none; }
}

@media (forced-colors: active) {
  .sdot { forced-color-adjust: none; }
  .tile, .hostcard, .alert-link, .pill, .ichart-fig { border: 1px solid CanvasText; }
}

/* ---------- rename title ---------- */

.rename-btn {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 32px; height: 32px; margin-left: 4px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.rename-btn:hover { color: var(--text); background: var(--panel-2); }
.rename-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; letter-spacing: 0; }
.rename-input {
  flex: 1 1 200px; min-width: 0; max-width: 360px; min-height: 36px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 16px;
}
.rename-actions { display: inline-flex; gap: 6px; }
.rename-msg { flex-basis: 100%; color: var(--crit); font-size: 13px; }
.rename-msg:empty { display: none; }
