:root {
  color-scheme: light;
  --bg: #eef2f6;
  --card: #ffffff;
  --ink: #142030;
  --muted: #5a6778;
  --accent: #1f73c0;
  --button: #1f73c0;
  --button-ink: #ffffff;
  --page-ink: var(--ink);
  --page-muted: var(--muted);
  --accent-ink: var(--accent);
  --line: #e2e7ee;
  --track: #eaeef3;
  --raise: #f5f7fa;
  --soft: #e6f0f9;
  --selected-ink: var(--accent);
  --info: var(--accent);
  --idle: #7b8794;
  --series-2: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --nav-height: 0px;
  --top: env(safe-area-inset-top, 0px);
  --right: env(safe-area-inset-right, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px);
  --gutter: clamp(12px, 3.4vw, 32px);
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1720;
  --card: #1a2531;
  --ink: #eef3f8;
  --muted: #a2b1c2;
  --accent: #5aa6ee;
  --button: #3d8fd9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--page-ink); font-size: .875rem; line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
h1:focus { outline: none; }
h1, h2, h3, p { margin: 0; }
.icon {
  width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Layout */
.layout {
  max-width: 1320px; margin: auto;
  padding: calc(10px + var(--top)) calc(var(--gutter) + var(--right))
    calc(16px + max(var(--nav-height), var(--bottom))) calc(var(--gutter) + var(--left));
}
main { min-width: 0; }
#view { display: grid; gap: 10px; min-width: 0; }
#view > * { min-width: 0; }

/* Navigation: bottom bar on phones, sidebar on wide screens */
nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
  padding: 6px max(8px, var(--right)) calc(6px + var(--bottom)) max(8px, var(--left));
  background: var(--card); border-top: 1px solid var(--line);
}
.brand { display: none; }
.tab-button {
  position: relative; min-width: 0; min-height: 50px; padding: 5px 2px; border: 0; border-radius: 12px;
  background: transparent; color: var(--muted); display: grid; justify-items: center; align-content: center; gap: 3px;
  font-size: .6875rem; font-weight: 650; line-height: 1.15;
}
.tab-button .icon { width: 22px; height: 22px; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-button[aria-current="page"] { color: var(--selected-ink); background: var(--soft); }
.nav-badge {
  position: absolute; top: 6px; left: calc(50% + 7px); width: 9px; height: 9px; border-radius: 50%;
  background: var(--critical); box-shadow: 0 0 0 2px var(--card);
}
.nav-badge.tone-warning { background: var(--warning); }
.nav-badge.tone-serious { background: var(--serious); }
@media (max-width: 719px) {
  .tab-button:not(.tab-overview, .tab-containers, .tab-events, .tab-more) { display: none; }
}

/* Screen heading */
.heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 4px 2px 2px; }
/* The title takes what the status leaves, at least 42%; a long title wraps, the status keeps its words. */
.heading-copy { flex: 1 1 0; min-width: 42%; display: grid; gap: 1px; }
.eyebrow { color: var(--page-muted); font-size: .75rem; font-weight: 600; letter-spacing: .02em; }
h1.long { font-size: clamp(1.25rem, 5.4vw, 1.6rem); }
h1 { font-size: clamp(1.5rem, 6.4vw, 1.9rem); line-height: 1.15; letter-spacing: -.02em; overflow-wrap: anywhere; color: var(--page-ink); }
.data-age { color: var(--page-muted); font-size: .75rem; margin-top: 2px; }
.nowrap { white-space: nowrap; }
.heading-actions { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; padding-top: 2px; }
/* A long status wraps to two lines beside the title, never over it. */
.heading-actions .pill { white-space: normal; min-width: 0; }
.heading-actions .pill > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; line-height: 1.2; }
.icon-button {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: var(--card); color: var(--ink);
}
.back-link {
  justify-self: start; display: inline-flex; align-items: center; gap: 2px; min-height: 32px; margin-left: -6px;
  padding: 0 8px 0 2px; border: 0; border-radius: 8px; background: transparent; color: var(--page-ink);
  font-size: .8125rem; font-weight: 600;
}
.back-link .icon { width: 18px; height: 18px; }

/* Notices */
.notice {
  margin-bottom: 10px; padding: 11px 13px; background: var(--card); color: var(--ink);
  border-radius: 12px; font-weight: 600; border-left: 4px solid var(--warning);
}
.notice button { display: block; margin-top: 9px; }

/* Cards */
.card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 14px; min-width: 0; container-type: inline-size; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; min-height: 24px; }
.card-head h2, .gauge-head h2 { font-size: .9375rem; line-height: 1.25; font-weight: 650; }
.card-aside { color: var(--muted); font-size: .75rem; text-align: right; }
.card h3 { font-size: .75rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 4px; }
.card-alert { box-shadow: inset 3px 0 0 var(--critical); }
.hint { color: var(--muted); font-size: .75rem; }
.card > .hint { margin-bottom: 8px; }
.state-code { display: block; color: var(--muted); font-size: .6875rem; font-weight: 400; overflow-wrap: anywhere; }
.secondary, .link-button {
  min-height: 40px; padding: 4px 12px; border: 0; border-radius: 10px; background: var(--track); color: var(--ink); font-weight: 600;
}
.link-button { width: 100%; margin-top: 6px; background: transparent; color: var(--accent-ink); }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 46px;
  border: 0; border-radius: 12px; background: var(--button); color: var(--button-ink); font-weight: 650;
}
.primary:disabled { background: var(--track); color: var(--muted); }

/* Status marks */
.sev { width: 20px; height: 20px; flex: none; }
.sev-bg { fill: var(--tone); }
.sev-glyph { fill: none; stroke: var(--on-tone); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.sev-dot { fill: var(--on-tone); }
.sev-critical { --tone: var(--critical); --on-tone: #ffffff; }
.sev-serious { --tone: var(--serious); --on-tone: #0b0b0b; }
.sev-warning { --tone: var(--warning); --on-tone: #0b0b0b; }
.sev-good { --tone: var(--good); --on-tone: #ffffff; }
.sev-info { --tone: var(--info); --on-tone: var(--on-info, #ffffff); }
.sev-idle { --tone: var(--idle); --on-tone: #ffffff; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 3px 10px 3px 5px;
  border-radius: 999px; font-size: .75rem; font-weight: 650; white-space: nowrap;
}
.pill .sev { width: 16px; height: 16px; }
.pill.tone-critical { background: var(--critical-tint); color: var(--critical-tint-ink); }
.pill.tone-serious { background: var(--serious-tint); color: var(--serious-tint-ink); }
.pill.tone-warning { background: var(--warning-tint); color: var(--warning-tint-ink); }
.pill.tone-good { background: var(--good-tint); color: var(--good-tint-ink); }
.pill.tone-info { background: var(--info-tint); color: var(--info-tint-ink); }
.pill.tone-idle { background: var(--idle-tint); color: var(--idle-tint-ink); }

/* Loading, empty and error states */
.loading { display: flex; align-items: center; gap: 10px; padding: 8px 2px; color: var(--muted); font-size: .8125rem; }
.spinner {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--track); border-top-color: var(--accent);
}
.chart-skeleton { height: 140px; margin-top: 4px; border-radius: 10px; background: var(--raise); }
/* A card whose source is not current: a note with the last confirmed time,
   no good marks, and its graphics drained of colour. */
.source-note {
  display: flex; align-items: flex-start; gap: 7px; margin: -2px 0 10px; padding: 7px 9px; border-radius: 10px;
  background: var(--warning-tint); color: var(--warning-tint-ink); font-size: .75rem; line-height: 1.35;
}
.source-note .sev { width: 15px; height: 15px; margin-top: 1px; }
.source-note.checking { background: var(--idle-tint); color: var(--idle-tint-ink); }
.source-note.compact { margin: 6px 0 0; padding: 4px 8px; align-items: center; }
.source-note.compact .sev { margin-top: 0; }
.card > .source-note:first-child { margin-top: 0; }
.unconfirmed .sev-good { --tone: var(--idle); }
.unconfirmed .pill.tone-good { background: var(--idle-tint); color: var(--idle-tint-ink); }
.unconfirmed :is(.heat-groups, .bars, .meter, .stack, .gauge-svg, .spark, .ring-svg) { filter: grayscale(.85); opacity: .8; }
.empty.failed { padding: 10px; border-radius: 12px; background: var(--warning-tint); color: var(--warning-tint-ink); }
.empty.failed .empty-hint { color: inherit; }
.retry-button { margin-top: 8px; min-height: 36px; }
.empty.failed .retry-button { background: var(--card); color: var(--ink); }
.priority { padding: 0; overflow: hidden; }
.priority-button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0;
  background: transparent; color: var(--ink); text-align: left;
}
.priority-button > .sev { width: 26px; height: 26px; }
.priority-button > .icon { width: 18px; height: 18px; color: var(--muted); }
.priority-title { font-size: .9375rem; font-weight: 700; line-height: 1.3; text-wrap: balance; }
.priority-advice { color: var(--muted); font-size: .75rem; }
.priority-critical { box-shadow: inset 4px 0 0 var(--critical); }
.priority-warning { box-shadow: inset 4px 0 0 var(--warning); }
.priority-good { box-shadow: inset 4px 0 0 var(--good); }
.priority-idle { box-shadow: inset 4px 0 0 var(--idle); }
.priority-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 0 14px 12px 52px;
}
.priority-foot .retry-button { margin-top: 0; }
.priority-missing { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; }
.priority-missing .sev { width: 15px; height: 15px; }
@media (hover: hover) { button.priority-button:hover { background: var(--raise); } }
.backup-running { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .75rem; font-weight: 600; }
.backup-running .sev { width: 15px; height: 15px; }
.empty { display: flex; gap: 10px; align-items: flex-start; padding: 6px 2px; }
.empty .sev { width: 20px; height: 20px; margin-top: 1px; }
.empty-title { font-weight: 600; }
.empty-hint { color: var(--muted); font-size: .75rem; margin-top: 2px; }
.card > .empty + .empty { margin-top: 6px; }

/* Lists */
.items { display: grid; }
.item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 48px; padding: 9px 2px;
  border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; min-width: 0;
}
.items > .item:first-child { border-top: 0; }
.item > .sev { width: 22px; height: 22px; }
.item-button { border-radius: 0; }
.item-button > .icon { width: 16px; height: 16px; color: var(--muted); }
.item-copy { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item-title { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.item-sub { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; display: flex; align-items: center; gap: 5px; }
.item-sub .sev { width: 14px; height: 14px; }
.item-value { flex: none; display: grid; justify-items: end; gap: 1px; font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; max-width: 45%; }
.item-value small { color: var(--muted); font-size: .6875rem; font-weight: 500; }
@media (hover: hover) {
  .item-button:hover, .more-item:hover, .bar-row:hover { background: var(--raise); }
  .icon-button:hover, .secondary:hover { background: var(--track); }
}

/* Definition lists */
.details, .hero-facts { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); margin: 0; font-size: .8125rem; }
.details dt, .details dd, .hero-facts dt, .hero-facts dd { padding: 7px 0; border-top: 1px solid var(--line); }
.details dt:first-of-type, .details dd:first-of-type, .hero-facts dt:first-of-type, .hero-facts dd:first-of-type { border-top: 0; }
.details dt, .hero-facts dt { color: var(--muted); padding-right: 12px; }
.details dd, .hero-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.bindings { list-style: none; padding: 0; margin: 0; }
.bindings li + li { margin-top: 3px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.stat { display: grid; gap: 1px; padding: 10px 12px; background: var(--raise); border-radius: 12px; min-width: 0; }
.stat-label, .stat-sub { color: var(--muted); font-size: .6875rem; }
.stat-label { font-weight: 600; }
.stat-value { font-size: 1.25rem; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.stat-warning .stat-value { color: var(--warning-ink); }
@container (min-width: 520px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Overview hero */
.overview-grid { display: grid; gap: 10px; min-width: 0; }
.hero-main { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; align-items: center; }
.ring { position: relative; width: 112px; height: 112px; }
.ring-svg { display: block; width: 100%; height: 100%; }
.ring-track, .ring-seg { fill: none; stroke-width: 12; }
.ring-track { stroke: var(--track); }
.ring-good { stroke: var(--good); }
/* Anything not good tints the OK arc, so the ring never reads all good. */
.worst-info .ring-good { stroke: var(--info-tint); }
.worst-warning .ring-good { stroke: var(--warning-tint); }
.worst-critical .ring-good { stroke: var(--critical-tint); }
.ring-info { stroke: var(--info); }
.ring-warning { stroke: var(--warning); }
.ring-critical { stroke: var(--critical); }
.ring-unknown { stroke: var(--idle); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-value { font-size: 1.5rem; line-height: 1.1; font-weight: 750; letter-spacing: -.02em; }
.ring-total { font-size: .875rem; font-weight: 600; color: var(--muted); }
.ring-label { max-width: 74px; margin: 1px auto 0; font-size: .6875rem; line-height: 1.2; color: var(--muted); }
.ring-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); font-size: .75rem; font-weight: 600; }
.ring-legend li { display: inline-flex; align-items: center; gap: 5px; }
.legend-title { color: var(--muted); }
.ring-legend .sev { width: 15px; height: 15px; }
.hero .empty { margin-top: 10px; padding: 10px; border-radius: 12px; background: var(--warning-tint); color: var(--warning-tint-ink); }
.hero .empty-hint { color: inherit; }

/* Gauges */
.gauges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gauge { display: grid; padding: 12px 12px 10px; align-content: start; }
.gauge-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 6px; min-height: 26px; }
.gauge-head h2 { color: var(--muted); font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gauge-head .pill { min-height: 22px; min-width: 0; padding: 2px 8px 2px 4px; font-size: .6875rem; white-space: normal; }
.gauge-head .pill .sev { width: 14px; height: 14px; }
.gauge-dial { position: relative; width: 100%; max-width: 150px; margin: 2px auto 0; }
.gauge-svg { display: block; width: 100%; height: auto; }
.gauge-track, .gauge-fill { fill: none; stroke-width: 10; stroke-linecap: round; }
.gauge-track { stroke: var(--track); }
.gauge-fill { stroke: var(--accent); }
.gauge-svg.tone-warning .gauge-fill { stroke: var(--warning); }
.gauge-svg.tone-critical .gauge-fill { stroke: var(--critical); }
.gauge-tick { stroke-width: 2.5; stroke-linecap: round; }
.tick-ref { stroke: var(--idle); }
.tick-warning { stroke: var(--warning); background: var(--warning); }
.tick-critical { stroke: var(--critical); background: var(--critical); }
.gauge-reading { position: absolute; left: 0; right: 0; top: 41%; text-align: center; transform: translateY(-50%); }
.gauge-value { font-size: 1.5rem; font-size: clamp(1.125rem, 15cqi, 1.75rem); font-weight: 750; letter-spacing: -.02em; }
.gauge-sub { margin-top: -6px; text-align: center; font-size: .75rem; color: var(--muted); min-height: 2.5em; }
.gauge-spark { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.gauge-caption, .spark-caption { color: var(--muted); font-size: .6875rem; margin-top: 3px; }
.spark { display: block; width: 100%; height: 30px; overflow: visible; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: url(#fade); }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.fade-top { stop-color: var(--accent); stop-opacity: .28; }
.fade-bottom { stop-color: var(--accent); stop-opacity: 0; }
.spark-mark { fill: var(--critical); }

/* Segmented controls */
.segments { display: flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--track); max-width: 100%; }
.segments button {
  flex: 1 1 auto; min-width: 0; min-height: 34px; padding: 4px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: .75rem; font-weight: 650; white-space: nowrap;
}
.segments button[aria-pressed="true"] { background: var(--soft); color: var(--selected-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.card-head .segments { flex: none; }
.card-head .segments button { min-height: 30px; padding: 3px 9px; }

/* Charts */
.history-card > .segments { margin-bottom: 10px; }
.chart-title { font-size: .8125rem; font-weight: 600; margin-bottom: 4px; }
.chart-note { color: var(--muted); font-size: .75rem; margin: -6px 0 4px; }
.item-meta { color: var(--muted); font-size: .6875rem; font-weight: 600; }
.chart { position: relative; width: 100%; min-width: 0; min-height: 120px; }
.chart:has(> .empty) { min-height: 0; }
.chart canvas { display: block; }
.chart .u-over { touch-action: pan-y; }
.chart .u-cursor-x { border-right: 1px solid var(--muted); }
.chart .u-cursor-pt { border-radius: 50%; }
.chart-tip {
  position: absolute; z-index: 3; top: 0; left: var(--x, 0); display: grid; gap: 2px; padding: 6px 9px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14); font-size: .75rem; pointer-events: none; white-space: nowrap;
}
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { font-size: .875rem; }
.tip-row span, .tip-time { color: var(--muted); }
.tip-key, .legend-line { display: inline-block; width: 12px; height: 3px; border-radius: 2px; background: var(--key); }
.chart-summary { color: var(--muted); font-size: .75rem; margin-top: 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 0 0 4px; padding: 0; font-size: .75rem; }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-box { display: inline-block; width: 12px; height: 10px; border-radius: 3px; }
.chart-values { margin-top: 6px; font-size: .75rem; }
.chart-values summary { color: var(--accent-ink); cursor: pointer; padding: 6px 0; font-weight: 600; width: max-content; max-width: 100%; }
.chart-values .hint { margin: 2px 0 6px; }
.values { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.values th, .values td { text-align: left; padding: 5px 4px; border-top: 1px solid var(--line); }
.values th { color: var(--muted); font-weight: 600; }
.values td + td, .values th + th { text-align: right; }

/* Containers */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px 7px 8px; border-radius: 12px;
  background: var(--card); color: var(--ink); font-size: .75rem; font-weight: 650;
}
.chip .sev { width: 16px; height: 16px; }
.heat-groups { display: flex; flex-wrap: wrap; gap: 14px 18px; }
.heat-group { flex: 1 1 100%; min-width: 0; }
.heat-group.heat-small { flex: 0 1 auto; }
.heat-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: .75rem; }
.heat-name { font-weight: 650; overflow-wrap: anywhere; }
.heat-count { color: var(--muted); white-space: nowrap; }
.heat-title .chip { padding: 2px 8px 2px 4px; background: var(--critical-tint); color: var(--critical-tint-ink); }
.heat-title .chip .sev { width: 14px; height: 14px; }
.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(28px, 1fr)); gap: 4px; }
.heat-small .heat-grid { grid-template-columns: repeat(var(--cols), 30px); }
.heat-small .heat-title { gap: 10px; }
.tile {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 7px;
  background: var(--heat-2); color: #ffffff; font-size: .75rem; font-weight: 800; line-height: 1;
}
.tile.heat-0 { background: var(--heat-0); }
.tile.heat-1 { background: var(--heat-1); }
.tile.heat-2 { background: var(--heat-2); }
.tile.heat-3 { background: var(--heat-3); }
.tile.heat-4 { background: var(--heat-4); }
.tile-down, .tile-missing, .tile.tile-alerted { background: var(--critical); color: #ffffff; box-shadow: none; }
.tile-unhealthy { background: var(--serious); color: #0b0b0b; }
.tile-restarting, .tile-paused, .tile-warned { background: var(--warning); color: #0b0b0b; }
.tile-unconfirmed, .tile-unknown, .tile-unverified, .tile-confirming, .tile-healthunknown { background: var(--track); color: var(--ink); box-shadow: inset 0 0 0 2px var(--warning); }
.tile-stopped, .tile-expected { background: var(--track); color: var(--muted); }
.tile-stopped { box-shadow: inset 0 0 0 2px var(--warning); color: var(--ink); }
.heat-grid .tile { cursor: pointer; }
@media (hover: hover) { .heat-grid .tile:hover { transform: scale(1.08); } }
.map-hint { display: flex; align-items: center; gap: 4px; margin: -4px 0 10px; color: var(--muted); font-size: .75rem; }
.map-hint .icon { width: 14px; height: 14px; }
.name-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.name-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; padding: 3px 10px 3px 4px;
  border: 0; border-radius: 9px; background: var(--raise); color: var(--ink); font-size: .75rem; font-weight: 600; text-align: left;
}
.name-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-chip .tile { flex: none; width: 20px; height: 20px; border-radius: 5px; font-size: .625rem; }
@media (hover: hover) { .name-chip:hover { background: var(--track); } }
@media (hover: hover) { .heat-grid .tile:hover { outline: 2px solid var(--ink); outline-offset: 1px; } }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: .6875rem; }
.legend-ramp, .legend-state { display: inline-flex; align-items: center; gap: 6px; }
.ramp { display: inline-flex; gap: 2px; }
.ramp i { width: 12px; height: 12px; border-radius: 3px; }
.ramp .heat-0 { background: var(--heat-0); }
.ramp .heat-1 { background: var(--heat-1); }
.ramp .heat-2 { background: var(--heat-2); }
.ramp .heat-3 { background: var(--heat-3); }
.ramp .heat-4 { background: var(--heat-4); }
.legend-state .tile { width: 16px; height: 16px; border-radius: 4px; font-size: .625rem; }
.containers-grid, .detail-grid, .two-columns { display: grid; gap: 10px; min-width: 0; }
.tops, .detail-charts { display: grid; gap: 10px; min-width: 0; align-content: start; }
.bars { display: grid; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 34px; padding: 4px 2px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font-size: .75rem;
}
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: calc(var(--value) * 100%); border-radius: 4px; background: var(--accent); }
.bar-value { min-width: 4.4em; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.search {
  display: flex; align-items: center; gap: 8px; min-height: 42px; margin-bottom: 4px; padding: 0 12px;
  border-radius: 12px; background: var(--track); color: var(--muted);
}
.search input {
  flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1rem;
}
.search input:focus { outline: none; }
.search:focus-within { outline: 2px solid var(--accent-ink); outline-offset: 1px; }
.search input::placeholder { color: var(--muted); opacity: 1; }

/* Meters */
.meter { position: relative; height: 10px; margin: 8px 0 4px; border-radius: 5px; background: var(--track); }
.meter-thin { height: 6px; margin: 6px 0 2px; }
.meter-fill {
  position: absolute; inset: 0 auto 0 0; width: calc(var(--value) * 100%); min-width: 6px;
  border-radius: inherit; background: var(--accent);
}
.meter-fill.tone-warning { background: var(--warning); }
.meter-fill.tone-critical { background: var(--critical); }
.meter-tick {
  position: absolute; top: -3px; bottom: -3px; left: calc(var(--at) * 100%); width: 2px; margin-left: -1px;
  border-radius: 1px; box-shadow: 0 0 0 1px var(--card);
}
.meter-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 12px; color: var(--muted); font-size: .6875rem; }
.key-tick { display: inline-block; width: 2px; height: 12px; border-radius: 1px; }
.key-tick.tick-critical { margin-left: 8px; }
.disk + .disk { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.disk-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.disk-head strong { display: block; }
.disk-mount { color: var(--muted); font-size: .75rem; }
.disk-value { text-align: right; white-space: nowrap; }
.disk-head .disk-value strong { display: inline; font-size: 1.5rem; line-height: 1.1; font-weight: 750; }
.disk-value span { color: var(--muted); font-size: .75rem; margin-left: 4px; }
.disk-caption { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--muted); }
.disk-caption .sev { width: 15px; height: 15px; }
.disk-inodes { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 8px; font-size: .75rem; color: var(--muted); }
.disk-inodes .meter { margin: 0; }
.disk-inode-value { font-variant-numeric: tabular-nums; }
.storage-summary { margin-bottom: 12px; }
.storage-summary strong { font-size: 1.25rem; font-weight: 750; }
.storage-summary span { color: var(--muted); font-size: .8125rem; }
.storage-row + .storage-row { margin-top: 12px; }
.storage-head { display: flex; justify-content: space-between; gap: 8px; font-size: .8125rem; }
.storage-head span { color: var(--muted); font-variant-numeric: tabular-nums; }
.stack { display: flex; gap: 2px; height: 12px; margin: 6px 0 3px; border-radius: 4px; background: var(--track); overflow: hidden; }
.stack > span { flex: none; width: calc(var(--value) * 100%); min-width: 3px; }
.stack-used { background: var(--accent); }
.stack-free { background: var(--series-2); }
.storage-free { color: var(--muted); font-size: .75rem; }

/* Security */
.status-line { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.status-line .sev { width: 22px; height: 22px; }
.stats.stats-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.timeline { margin: 4px 0 8px; }
.timeline-track { position: relative; height: 34px; border-radius: 10px; background: var(--raise); }
.timeline-track::before { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; margin-top: -1px; background: var(--line); }
.timeline-grid { position: absolute; top: 8px; bottom: 8px; left: calc(var(--at) * 100%); width: 1px; background: var(--line); }
.timeline-dot {
  position: absolute; top: 50%; left: calc(8px + var(--at) * (100% - 16px)); width: 24px; height: 24px; margin: -12px 0 0 -12px;
  padding: 0; border: 0; border-radius: 50%; background: transparent;
}
.timeline-dot::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--info); box-shadow: 0 0 0 2px var(--raise);
}
.timeline-axis { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: .6875rem; }
.port-open .item-value { color: var(--warning-ink); }

/* Backups */
.backup + .backup { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.backup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.backup-head strong { display: block; }
.backup .meter { margin-top: 12px; }
.backup-scale { position: relative; height: 16px; color: var(--muted); font-size: .6875rem; margin-bottom: 4px; }
.backup-limit { position: absolute; top: 0; left: calc(var(--at) * 100%); transform: translateX(-50%); white-space: nowrap; }

/* Events */
.filters { display: grid; gap: 8px; min-width: 0; }
.filters .segments { flex-wrap: wrap; background: var(--card); }
.filters .segments button { flex: 1 0 auto; }
.filters .segments.chip-group { gap: 6px; padding: 0; background: transparent; }
.filters .chip-group button { flex: 0 0 auto; min-height: 32px; padding: 4px 12px; border-radius: 999px; background: var(--card); }
.filters .chip-group button[aria-pressed="true"] { background: var(--soft); }
.filters .segments button[aria-pressed="false"] { color: var(--muted); }
.card .day { margin: 16px 0 2px; }
.card .day:first-of-type { margin-top: 0; }
.timeline-list .item { position: relative; }
.timeline-list .item::before {
  content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--line); z-index: 0;
}
.timeline-list .item:first-child::before { top: 50%; }
.timeline-list .item:last-child::before { bottom: 50%; }
.timeline-list .item:only-child::before { display: none; }
.timeline-list .item > .sev { position: relative; z-index: 1; border-radius: 50%; box-shadow: 0 0 0 3px var(--card); }
.timeline-list .item { border-top: 0; }

/* Sites */
.site + .site { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.site-name { min-width: 0; display: grid; gap: 3px; }
.site-name strong { overflow-wrap: anywhere; }
.site-status { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .75rem; }
.site-status .sev { width: 15px; height: 15px; }
.site-latency { flex: none; display: grid; text-align: right; }
.site-latency strong { font-size: 1.125rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.site-latency span { color: var(--muted); font-size: .6875rem; }
.site-spark { margin-top: 8px; }
.site-spark .spark { height: 36px; }
.cert { margin-top: 10px; }
.cert-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 24px; font-size: .75rem; }
.cert-label { color: var(--muted); }
.cert-head .pill { min-height: 22px; padding: 2px 8px 2px 4px; font-size: .6875rem; }
.cert-head .pill .sev { width: 14px; height: 14px; }
.cert .meter { margin: 6px 0 0; }
@container (min-width: 640px) {
  .site { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: center; }
  .site-spark, .cert { margin-top: 0; }
}

/* More and settings */
.more-list { display: grid; padding: 4px 14px; }
.more-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 2px;
  border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left;
}
.more-item:first-child { border-top: 0; }
.more-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--soft); color: var(--selected-ink); flex: none; }
.more-item > .icon { width: 16px; height: 16px; color: var(--muted); }
.home-card .hint { margin-bottom: 10px; }
.home-card .primary + .hint { margin: 10px 0 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px 16px; list-style: none; margin: 12px 0 0; padding: 0; font-size: .75rem; font-weight: 600; }
.swatches li { display: inline-flex; align-items: center; gap: 6px; }

/* Floating tooltip */
.tooltip {
  position: fixed; z-index: 50; left: var(--x, 0); top: var(--y, 0); display: grid; gap: 1px; max-width: 260px; padding: 7px 10px;
  border-radius: 9px; background: var(--ink); color: var(--card); font-size: .75rem; pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}

/* Compact Telegram mode: what needs attention comes first */
@media (max-width: 719px) and (max-height: 600px) {
  .overview-grid > .alerts-card { order: -1; }
  .overview-grid > .priority { order: -2; }
  .hero-main { grid-template-columns: 96px minmax(0, 1fr); }
  .ring { width: 96px; height: 96px; }
  .ring-value { font-size: 1.25rem; }
  .hero-facts dt, .hero-facts dd { padding: 5px 0; }
  .ring-legend { margin-top: 8px; padding-top: 8px; }
  h1 { font-size: 1.4rem; }
}

/* Wide screens: sidebar and grids */
@media (min-width: 720px) {
  .layout {
    display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start;
    padding-top: calc(20px + var(--top)); padding-bottom: max(24px, var(--bottom));
  }
  .layout:has(nav[hidden]) { display: block; }
  nav {
    position: sticky; top: calc(20px + var(--top)); display: flex; flex-direction: column; gap: 2px;
    max-height: calc(100vh - 40px); padding: 12px; border: 0; border-radius: var(--radius); overflow-y: auto;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
  .brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--soft); color: var(--selected-ink); }
  .brand strong { display: block; font-size: .9375rem; }
  .brand small { color: var(--muted); font-size: .75rem; }
  .tab-button {
    display: flex; justify-content: flex-start; gap: 11px; min-height: 42px; padding: 6px 12px;
    font-size: .875rem; font-weight: 600;
  }
  .tab-button .icon { width: 20px; height: 20px; }
  .tab-more { display: none; }
  .tab-settings { margin-top: auto; }
  .nav-badge { position: static; margin-left: auto; }
  #view { gap: 14px; }
  .heading { padding-top: 0; }
  .card { padding: 16px; }
  .tops { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: minmax(0, 9.5rem) minmax(0, 1fr) auto; }
  .filters { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .filters .segments { justify-self: start; }
}

@media (min-width: 1100px) {
  .overview-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
  .overview-grid > .priority { grid-column: 1 / -1; grid-row: 1; }
  .overview-grid > .hero { grid-column: 1 / span 4; grid-row: 2; }
  .overview-grid > .gauges { grid-column: 5 / span 8; grid-row: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .overview-grid > .alerts-card { grid-column: 1 / span 5; grid-row: 3; align-self: start; }
  .overview-grid > .history-card { grid-column: 6 / span 7; grid-row: 3; }
  .overview-grid > .summary-card { grid-column: 1 / -1; }
  .hero { display: grid; align-content: center; }
  .hero-main { grid-template-columns: 1fr; justify-items: center; gap: 16px; }
  .hero .ring { width: 150px; height: 150px; }
  .hero .ring-value { font-size: 2rem; }
  .hero-facts { width: 100%; }
  .ring-legend { justify-content: center; }
  .gauge { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "head head" "dial spark" "sub spark"; column-gap: 14px; }
  .gauge-head { grid-area: head; }
  .gauge-dial { grid-area: dial; }
  .gauge-sub { grid-area: sub; }
  .gauge-spark { grid-area: spark; align-self: end; border-top: 0; padding-top: 0; }
  .gauge-spark .spark { height: 64px; }
  .containers-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; align-items: start; }
  .containers-grid > .heat-card { grid-column: span 7; }
  .containers-grid > .tops { grid-column: span 5; grid-template-columns: 1fr; gap: 14px; }
  .containers-grid > .list-card { grid-column: 1 / -1; }
  .list-card .items { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .list-card .items > .item:nth-child(2) { border-top: 0; }
  .detail-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
  .detail-grid > .container-detail { grid-column: span 5; }
  .detail-grid > .detail-charts { grid-column: span 7; }
  .detail-grid > .events-card { grid-column: 1 / -1; }
  .two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
  .backups-card { max-width: 820px; }
}

/* Motion, only when the viewer allows it */
@media (prefers-reduced-motion: no-preference) {
  #view.entering { animation: view-in .26s cubic-bezier(.2, .7, .2, 1) both; }
  #view.entering .gauge-fill { animation: sweep .95s cubic-bezier(.2, .7, .2, 1) .08s both; }
  #view.entering .ring-seg { animation: ring-grow .95s cubic-bezier(.2, .7, .2, 1) .05s both; }
  #view.entering .bar-fill, #view.entering .meter-fill, #view.entering .stack > span {
    transform-origin: left center; animation: grow .7s cubic-bezier(.2, .7, .2, 1) .1s both;
  }
  #view.entering .tile { animation: pop .4s ease-out both; }
  .spinner { animation: spin .9s linear infinite; }
  .chart-skeleton { background: linear-gradient(90deg, var(--raise) 30%, var(--track) 50%, var(--raise) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s ease-in-out infinite; }
  @keyframes spin { to { transform: rotate(1turn); } }
  @keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
  .item-button, .more-item, .bar-row, .segments button, .tab-button { transition: background-color .15s, color .15s; }
  .chart-tip, .tooltip { transition: opacity .12s; }
  @keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
  @keyframes sweep { from { stroke-dashoffset: var(--arc); } }
  @keyframes ring-grow { from { stroke-dasharray: 0 var(--circ); } }
  @keyframes grow { from { transform: scaleX(0); } }
  @keyframes pop { from { opacity: 0; transform: scale(.7); } }
}

@media (forced-colors: active) {
  .sev-bg { fill: CanvasText; }
  .sev-glyph { stroke: Canvas; }
  .sev-dot { fill: Canvas; }
  .meter-fill, .bar-fill, .stack > span { background: Highlight; }
}
