/* H1 Monitor UI. Color tokens follow the dataviz reference palette: chrome/ink, accent = categorical
   slot 1 (blue), status = good / warning / critical. Light and dark are both selected, not flipped. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --surface-3: #e9e8e2;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.20);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-track: #cde2fb;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --cell-ok: #c3c2b7;
  --bar: #898781;
  --shadow: 0 8px 28px rgba(11, 11, 11, 0.12);
  --backdrop: rgba(11, 11, 11, 0.32);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --surface-3: #2b2b29;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.20);
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-track: #0d366b;
    --accent-wash: rgba(57, 135, 229, 0.14);
    --cell-ok: #52514e;
    --bar: #898781;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2b2b29;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --accent-track: #0d366b;
  --accent-wash: rgba(57, 135, 229, 0.14);
  --cell-ok: #52514e;
  --bar: #898781;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  --backdrop: rgba(0, 0, 0, 0.55);
}

/* ---- base ---- */

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }

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

code, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

p { margin: 0; }

.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.icon.fill { fill: currentColor; stroke: none; }

.muted { color: var(--ink-2); }
.faint { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}
.topbar-inner { height: 56px; padding: 0 20px;
  display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -0.01em; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); }
.nav { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 12.5px; white-space: nowrap;
}
.status-pill:hover { text-decoration: none; border-color: var(--border-strong); color: var(--ink); }

/* status dots: the color is always paired with a text label next to it */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); flex: none; display: inline-block; }
.dot.live { position: relative; background: var(--accent); }
.dot.live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent);
  animation: pulse 1.8s ease-out infinite; }
.dot.accent { background: var(--accent); }
.dot.good { background: var(--good); }
.dot.warning { background: var(--warning); }
.dot.critical { background: var(--critical); }
.dot.neutral { background: var(--cell-ok); }
.dot.hollow { background: transparent; box-shadow: inset 0 0 0 1.5px var(--axis); }
@keyframes pulse {
  from { transform: scale(1); opacity: .5; }
  to { transform: scale(2.6); opacity: 0; }
}

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

.container { padding: 24px 20px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; }
.grid-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar-inner { height: auto; padding: 8px 16px 6px; gap: 6px 12px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .nav a { padding: 6px 7px; font-size: 13px; }
  .container { padding: 20px 16px 56px; }
  /* always stacked: side by side, the clock would wrap whenever the counter gains a digit */
  .live-hero { flex-direction: column; align-items: flex-start; gap: 10px; }
  .live-hero .live-clock { text-align: left; }
}

/* ---- cards ---- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); min-height: 52px; flex-wrap: wrap; }
.card-head .hint { color: var(--ink-2); font-size: 12.5px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); color: var(--ink-2); font-size: 12.5px; }
.empty { padding: 32px 20px; text-align: center; color: var(--ink-2); }

/* ---- buttons & controls ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 88%, #000); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.danger:hover { color: var(--critical); }
.btn .icon, .icon-btn .icon { width: 16px; height: 16px; }
.is-busy .icon-spin, [aria-busy="true"] .icon-spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.textarea { height: auto; min-height: 140px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash); }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 32px; }

.field { display: grid; gap: 6px; align-content: start; }
.field + .field { margin-top: 16px; }
.field-row > .field { margin-top: 0; }
.field label, .label { font-weight: 550; font-size: 13px; }
.field .help { color: var(--ink-2); font-size: 12.5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); flex-wrap: wrap; }
.seg button, .seg a { border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 12.5px;
  padding: 4px 10px; border-radius: 7px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button:hover, .seg a:hover { color: var(--ink); text-decoration: none; }
.seg [aria-pressed="true"], .seg [aria-current="page"], .seg [aria-selected="true"] {
  background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--border); }
.seg .count { color: var(--muted); font-variant-numeric: tabular-nums; }

/* switch */
.switch { position: relative; width: 36px; height: 20px; border-radius: 999px; border: 0; padding: 0;
  background: var(--axis); cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch[aria-busy="true"] { opacity: .6; cursor: progress; }
.switch-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; }

/* badges: neutral chip, a colored dot carries the state, the text says it */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); font-size: 12px;
  white-space: nowrap; font-weight: 500; }
.badge .dot { width: 7px; height: 7px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2);
  font-size: 12px; border: 1px solid var(--border); white-space: nowrap; }

/* ---- tables ---- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 550; font-size: 12px; color: var(--ink-2); padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .right { text-align: right; }
.table .shrink { width: 1%; white-space: nowrap; }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--ink); }
.th-sort[data-dir="asc"]::after { content: "↑"; }
.th-sort[data-dir="desc"]::after { content: "↓"; }
.row-actions { display: inline-flex; gap: 2px; opacity: .55; transition: opacity .12s; }
tr:hover .row-actions, .row-actions:focus-within { opacity: 1; }
.cell-handle { font-weight: 550; }
.cell-target { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px;
  word-break: break-all; min-width: 200px; }
.cell-desc { color: var(--ink-2); max-width: 360px; min-width: 180px; font-size: 12.5px; }
.cell-desc .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.is-removed td { color: var(--muted); }
.is-removed .cell-target { text-decoration: line-through; }

/* ---- KPI tiles ---- */

.kpi { padding: 18px 20px; }
.kpi .label { color: var(--ink-2); font-weight: 500; font-size: 12.5px; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.15; }
.kpi .sub { color: var(--ink-2); font-size: 12.5px; margin-top: 4px; }

/* ---- live cycle panel ---- */

.live-card { padding: 22px 22px 18px; transition: opacity .2s; }
.live-card.stale { opacity: .6; }
.live-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.phase { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; }
.phase-meta { color: var(--ink-2); font-size: 12.5px; }
.live-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 18px;
  flex-wrap: wrap; }
.hero-figure { font-size: 52px; font-weight: 650; line-height: 1; letter-spacing: -0.03em; }
.hero-figure .of { font-size: 18px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: 6px; }
.live-clock { text-align: right; }
.live-clock .big { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.live-clock .small { color: var(--ink-2); font-size: 12.5px; }

.meter { position: relative; height: 8px; border-radius: 999px; background: var(--accent-track); margin-top: 16px;
  overflow: visible; }
.meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: var(--accent);
  transition: width .5s ease; }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px;
  background: var(--ink); opacity: .55; transition: left 1s linear; }
.meter.idle .meter-fill { background: var(--bar); }

.chips { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; color: var(--ink-2); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 7px; }
.chip strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.cycle-map-wrap { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.cycle-map { display: grid; grid-template-columns: repeat(auto-fill, 10px); gap: 3px; }
.cell { width: 10px; height: 10px; border-radius: 2.5px; background: transparent;
  box-shadow: inset 0 0 0 1px var(--axis); cursor: pointer; }
.cell.s-o { background: var(--cell-ok); box-shadow: none; }
.cell.s-c { background: var(--accent); box-shadow: none; }
.cell.s-e { background: var(--warning); box-shadow: none; }
.cell.s-x { background: var(--critical); box-shadow: none; }
.cell.s-f { background: var(--accent); box-shadow: none; animation: blink 1s ease-in-out infinite alternate; }
.cell:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
@keyframes blink { from { opacity: 1; } to { opacity: .3; } }

.legend { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 14px; }
.legend button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; background: none;
  color: var(--ink-2); font: inherit; font-size: 12.5px; padding: 3px 8px; border-radius: 7px; cursor: pointer; }
.legend button:hover { background: var(--surface-2); color: var(--ink); }
.legend button[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border); color: var(--ink); }
.legend .sw { width: 10px; height: 10px; border-radius: 2.5px; flex: none; }
.legend .count { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.sw.s-p { box-shadow: inset 0 0 0 1px var(--axis); }
.sw.s-o { background: var(--cell-ok); }
.sw.s-c { background: var(--accent); }
.sw.s-e { background: var(--warning); }
.sw.s-x { background: var(--critical); }
.sw.s-f { background: var(--accent); opacity: .55; }
.state-list { margin-top: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2);
  display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 180px; overflow: auto; overscroll-behavior: contain;
  font-size: 13px; }
.state-list a { color: var(--ink); }
/* one fixed-height line: names come and go every second, so wrapping would shift everything below */
.inflight { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; height: 24px; overflow: hidden;
  white-space: nowrap; margin-top: 12px; color: var(--ink-2); font-size: 12.5px; }
.inflight > * { flex: none; }
.inflight .tag { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- activity feed ---- */

/* overscroll-behavior: the wheel scrolls only the feed, never hands off to the page at its ends.
   overflow-anchor: rows are prepended every second; if the browser picked one of them as the page's
   scroll anchor it would scroll the whole page down to "keep it in place". */
.feed { list-style: none; margin: 0; padding: 4px 0; max-height: 470px; overflow-y: auto;
  overscroll-behavior: contain; overflow-anchor: none; }
.feed li { display: grid; grid-template-columns: 64px 10px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 6px 20px; font-size: 13px; }
.feed li.new { animation: rise .35s ease-out; }
.feed li.sys { color: var(--ink-2); }
.feed li.sys .what { font-weight: 550; color: var(--ink); }
.feed .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.feed .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .what a { font-weight: 550; }
.feed .res { color: var(--ink-2); margin-left: 6px; }
.feed .meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes rise { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* side panels */
.panel-list { display: grid; }
.panel-row { padding: 16px 20px; display: grid; gap: 8px; }
.panel-row + .panel-row { border-top: 1px solid var(--border); }
.panel-row .row-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-row .row-title h3 { display: inline-flex; align-items: center; gap: 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; color: var(--ink-2); font-size: 13px; }
.kv b { color: var(--ink); font-weight: 550; font-variant-numeric: tabular-nums; text-align: right;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter.thin { height: 6px; margin-top: 2px; }

/* ---- changes list ---- */

.changes-list { list-style: none; margin: 0; padding: 0; }
.changes-list li { display: grid; grid-template-columns: 92px 96px minmax(110px, 180px) minmax(0, 1fr); gap: 12px;
  align-items: baseline; padding: 9px 20px; border-bottom: 1px solid var(--border); font-size: 13px; }
.changes-list li:last-child { border-bottom: 0; }
.changes-list li.flash { animation: flash 2.4s ease-out; }
.changes-list .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.changes-list .kind { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 12.5px; }
.changes-list .prog { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.changes-list .tgt { min-width: 0; }
.changes-list .tgt code { word-break: break-all; }
.changes-list .det { display: block; color: var(--ink-2); font-size: 12px; }
@keyframes flash { from { background: var(--accent-wash); } to { background: transparent; } }
@media (max-width: 720px) {
  .changes-list li { grid-template-columns: 1fr auto; }
  .changes-list .tgt { grid-column: 1 / -1; }
  .feed li { grid-template-columns: 56px 10px minmax(0, 1fr); padding: 6px 16px; }
  .feed .meta { display: none; }
}

/* ---- chart ---- */

.chart { position: relative; padding: 8px 20px 14px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .target { stroke: var(--ink-2); stroke-width: 1; opacity: .7; }
.chart .target-label { fill: var(--ink-2); font-size: 11px; }
.chart .bar { fill: var(--bar); }
.chart .bar.latest { fill: var(--accent); }
.chart .bar.error { fill: var(--critical); }
.chart .bar.stopped { fill: var(--axis); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.hover { opacity: .8; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 12.5px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---- tooltip ---- */

.tip { position: fixed; z-index: 60; pointer-events: none; max-width: 300px; padding: 8px 10px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 12.5px;
  color: var(--ink-2); opacity: 0; transition: opacity .08s; }
.tip.show { opacity: 1; }
.tip .tip-title { color: var(--ink); font-weight: 600; margin-bottom: 2px; word-break: break-all; }
.tip .tip-line { display: flex; gap: 6px; align-items: center; }

/* ---- toasts ---- */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); color: var(--ink);
  animation: rise .2s ease-out; }
.toast .dot { margin-top: 6px; }
.toast.out { opacity: 0; transition: opacity .25s; }

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

dialog { border: 1px solid var(--border-strong); border-radius: 14px; padding: 0; background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--backdrop); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.dialog-body { padding: 16px 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }

/* ---- program page ---- */

.crumbs { color: var(--ink-2); font-size: 13px; margin-bottom: 8px; }
.prog-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prog-title h1 { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 21px; }
.meta-line { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: 12.5px; margin-top: 8px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.notice .dot { margin-top: 6px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1 1 220px; max-width: 360px; }
.toolbar .spacer { flex: 1; }
.last-check { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; font-size: 13px; color: var(--ink-2); }
.last-check strong { color: var(--ink); font-weight: 600; }

/* ---- misc ---- */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px;
  border-top: 1px solid var(--border); color: var(--ink-2); font-size: 13px; }
.dur { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.dur-track { position: relative; flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); }
.dur-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--bar); }
.dur-fill.error { background: var(--critical); }
.dur-target { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--ink-2); opacity: .7; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); padding: 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .cell, .sw, .dot { forced-color-adjust: none; }
}
