/* ==========================================================================
   Relay — operations control room
   Calm, high-density UI. Neutral slate surfaces, one accent (blue), severity
   carried by colour + rail + label. 4px spacing scale, 3–4px radii, no
   gradients, no glass.
   ========================================================================== */

:root {
  /* Neutral surfaces */
  --bg:        #0d0f13;
  --bg-elev:   #12151a;
  --panel:     #14181e;
  --panel-2:   #1a1f26;
  --panel-3:   #212832;
  --line:      #232a34;
  --line-2:    #2f3846;

  /* Type — every value below clears WCAG AA 4.5:1 on the surface it is used
     on, including the raised panel and chip-hover surfaces. */
  --text:      #e6e9ee;
  --text-dim:  #99a3b2;
  --text-faint:#8791a0;

  /* Single purposeful accent */
  --accent:      #5b9bff;
  --accent-text: #8fb8ff;
  --accent-bg:   rgba(91, 155, 255, 0.12);
  --accent-line: rgba(91, 155, 255, 0.45);

  /* Severity */
  --sev-critical: #ff5f5a;
  --sev-high:     #ff9c3c;
  --sev-medium:   #e3c04d;
  --sev-low:      #7b8ca3;

  /* Status */
  --ok:   #43c07f;
  --warn: #e3a53f;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --r-sm: 3px;
  --r:    4px;
  --r-md: 6px;

  --rail-w: 212px;
  --topbar-h: 52px;
  --gap: 10px;

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }

/* Any element toggled with the `hidden` attribute must actually hide, even
   when a class sets `display: flex` (filter summary, empty states, runbook). */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Belt and braces against stray horizontal scroll on small screens. */
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { list-style: none; padding: 0; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* --------------------------------------------------------------- focus -- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.chart-frame:focus-visible,
.skip-link:focus-visible { outline-offset: -2px; }

.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--accent);
  color: #0d0f13;
  font-weight: 650;
  border-radius: var(--r);
  transform: translateY(-160%);
  transition: transform 0.14s ease;
}
.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 16px; height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#i-overview path { fill: currentColor; stroke: none; }

.kbd {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  color: var(--text-faint);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
}

/* =================================================================== app == */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ============================================================== rail ==== */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px 12px;
}
.mark {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  color: #0d0f13;
  background: var(--accent);
  border-radius: var(--r);
}
.mark .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.brand-text {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.brand-text small { font-size: 10px; font-weight: 450; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; }

.rail-nav { display: flex; flex-direction: column; gap: 1px; }

.rail-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--r);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.rail-link:hover { background: var(--panel); color: var(--text); }
.rail-link.is-active {
  background: var(--accent-bg);
  color: var(--accent-text);
  border-left-color: var(--accent);
  font-weight: 600;
}
.rail-badge {
  margin-left: auto;
  padding: 0 5px;
  min-width: 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 15px;
  text-align: center;
  color: var(--text);
  background: var(--panel-3);
  border-radius: 9px;
}

.rail-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.rail-link--quiet { margin-bottom: 4px; }
.rail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.rail-meta--dim { color: var(--text-faint); font-family: var(--mono); font-size: 10.5px; }

.dot {
  width: 6px; height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--text-faint);
}
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }

/* ============================================================== shell === */
.shell { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 8px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}

.page-title { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.page-sub { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-faint); }
.page-sub-sep { color: var(--line-2); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 550;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  white-space: nowrap;
}
.pill--env { color: var(--text-dim); background: var(--panel); }
.pill--status { color: var(--text-dim); }
.pill-detail { color: var(--text-faint); }

.topbar-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 8px;
  color: var(--text-faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 28px;
  padding: 0 26px 0 28px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  appearance: none;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus-visible { border-color: var(--accent-line); outline: 2px solid var(--accent); outline-offset: -1px; }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }
.search .kbd { position: absolute; right: 6px; pointer-events: none; }
.search input:focus-visible ~ .kbd { display: none; }

.clock {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
.clock-tz { font-size: 9.5px; color: var(--text-faint); letter-spacing: 0.06em; }

.operator { display: flex; align-items: center; gap: 7px; padding-left: 10px; border-left: 1px solid var(--line); }
.avatar {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  background: var(--accent-bg);
  border: 1px solid var(--accent-line);
  border-radius: 50%;
}
.avatar--xs {
  width: 16px; height: 16px;
  font-size: 8.5px;
  color: var(--text-dim);
  background: var(--panel-3);
  border-color: var(--line-2);
}
.operator-name { display: flex; flex-direction: column; font-size: 11.5px; line-height: 1.2; white-space: nowrap; }
.operator-name small { font-size: 9.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }

/* =============================================================== main === */
main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 20px;
  min-width: 0;
}
main:focus-visible { outline-offset: -3px; }

/* ------------------------------------------------------------ metrics -- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.metric {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 2px 8px;
  padding: 9px 11px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.metric-label {
  grid-column: 1;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.metric-value {
  grid-column: 1;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.metric-spark { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.metric-spark .icon { width: 60px; height: 26px; stroke: none; }

.trend {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 3px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  margin-top: 3px;
}
.trend .icon { width: 11px; height: 11px; stroke-width: 1.9; }
.trend-change { font-weight: 600; }
.trend--good .trend-change { color: var(--ok); }
.trend--bad .trend-change { color: var(--sev-high); }
.trend-context { color: var(--text-faint); }
.trend-context::before { content: "·"; margin-right: 5px; color: var(--line-2); }

/* ------------------------------------------------------------- panels -- */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.panel--detail { position: sticky; top: calc(var(--topbar-h) + 12px); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}
.panel-head--wrap { flex-wrap: wrap; }
.panel-head-main { min-width: 0; }
.panel-title { font-size: 12.5px; font-weight: 650; letter-spacing: -0.005em; }
.panel-sub { font-size: 11px; color: var(--text-faint); }
.panel-head-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.segmented { display: flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; }
.seg {
  padding: 3px 9px;
  font: inherit;
  font-size: 11px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 0;
  border-right: 1px solid var(--line-2);
  cursor: pointer;
}
.seg:last-child { border-right: 0; }
.seg:hover { color: var(--text); background: var(--panel-3); }
.seg.is-active { color: #0d0f13; background: var(--accent); }

/* -------------------------------------------------------------- chart -- */
.readout { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.readout b { color: var(--text); font-weight: 600; }

.chart-frame { padding: 8px 8px 0; border-radius: 0; }
.chart-frame svg { display: block; width: 100%; height: auto; }
.chart-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.grid-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.grid-line--base { stroke: var(--line-2); }
.tick-label { fill: var(--text-faint); font-family: var(--mono); font-size: 9.5px; }
.tick-label--x { text-anchor: middle; }
.tick-label--y { text-anchor: end; }
.area { fill: var(--accent); opacity: 0.1; }
.line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.peak-line { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.55; }
.peak-label { fill: var(--warn); font-family: var(--mono); font-size: 9px; opacity: 0.85; }
.now-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }
.cursor-line { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.7; }
.cursor-dot { fill: var(--panel); stroke: var(--accent); stroke-width: 1.75; }
.hit { fill: transparent; }

.chart-help {
  padding: 6px 11px 9px;
  font-size: 10.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.chart-help .kbd { line-height: 13px; }

/* ------------------------------------------------------------- detail -- */
.detail-body { padding: 10px 11px 12px; }

.detail-title-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 5px; }
.detail-id { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text-dim); }
.detail-title { font-size: 14px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.detail-impact { margin-top: 6px; font-size: 12px; color: var(--text-dim); }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 10px 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.meta-cell { padding: 6px 8px; background: var(--panel-2); }
.meta-key { font-size: 9.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); }
.meta-val { display: flex; align-items: center; gap: 5px; font-size: 12px; margin-top: 1px; }
.meta-val--num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-note { margin-top: 7px; font-size: 10.5px; color: var(--text-faint); }

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 46px 1fr; gap: 8px; padding: 4px 0; }
.tl-time { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); padding-top: 1px; }
.tl-body { font-size: 11.5px; color: var(--text-dim); border-left: 2px solid var(--line-2); padding-left: 8px; }
.tl-item--event .tl-body { border-left-color: var(--accent); color: var(--text); }
.tl-actor { color: var(--text-faint); }

.runbook { display: flex; flex-direction: column; gap: 4px; }
.runbook-step {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.runbook-step b { color: var(--text-faint); font-family: var(--mono); font-size: 10.5px; font-weight: 600; }
.runbook ol { counter-reset: rb; }

/* ------------------------------------------------------------ buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--panel-3); border-color: #3b4553; }
.btn--primary { color: #0d0f13; background: var(--accent); border-color: var(--accent); }
.btn--primary:hover { background: #74adff; border-color: #74adff; }
.btn--primary .icon { stroke-width: 2.2; }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--panel-2); }
.btn--sm { height: 22px; padding: 0 8px; font-size: 11px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.btn:disabled:hover { background: var(--panel-2); border-color: var(--line-2); }
.btn[hidden] { display: none; }
.btn--ok { color: var(--ok); border-color: rgba(67, 192, 127, 0.4); background: rgba(67, 192, 127, 0.1); }
.btn--ok:hover { background: rgba(67, 192, 127, 0.18); }

/* ------------------------------------------------------------ severity -- */
.sev {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sev);
  white-space: nowrap;
}
.sev-rail { width: 3px; height: 15px; border-radius: 1px; background: var(--sev); flex: none; }
.sev--critical { --sev: var(--sev-critical); }
.sev--high     { --sev: var(--sev-high); }
.sev--medium   { --sev: var(--sev-medium); }
.sev--low      { --sev: var(--sev-low); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 19px;
  padding: 0 6px 0 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--st);
  background: var(--st-bg);
  border: 1px solid var(--st-line);
  border-radius: 10px;
  white-space: nowrap;
}
.status .dot { background: currentColor; width: 5px; height: 5px; }
.status--open          { --st: #a8b3c2; --st-bg: rgba(168, 179, 194, 0.09); --st-line: rgba(168, 179, 194, 0.28); }
.status--investigating { --st: var(--warn);   --st-bg: rgba(227, 165, 63, 0.1);  --st-line: rgba(227, 165, 63, 0.32); }
.status--monitoring    { --st: var(--accent); --st-bg: var(--accent-bg);        --st-line: var(--accent-line); }
.status--acknowledged  { --st: var(--ok);     --st-bg: rgba(67, 192, 127, 0.1); --st-line: rgba(67, 192, 127, 0.32); }
.status--resolved     { --st: var(--text-faint); --st-bg: transparent;        --st-line: var(--line-2); }

/* ------------------------------------------------------------- table --- */
.toolbar { gap: 8px; }

.sev-filter { margin: 0; padding: 0; border: 0; min-width: 0; }
.sev-chips { display: flex; gap: 4px; flex-wrap: wrap; }

.chip-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip-filter input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip-filter:hover { background: var(--panel-3); color: var(--text); }
.chip-filter .dot { background: var(--sev, var(--text-faint)); }
.chip-filter .chip-label { color: var(--text-faint); }
.chip-filter .chip-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.chip-filter:has(input:checked) {
  color: var(--text);
  background: var(--panel-3);
  border-color: var(--line-2);
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .chip-filter:has(input:checked) {
    background: color-mix(in srgb, var(--sev, var(--accent)) 14%, var(--panel-2));
    border-color: color-mix(in srgb, var(--sev, var(--accent)) 45%, transparent);
  }
}
.chip-filter:has(input:checked) .chip-count { color: var(--text-dim); }
.chip-filter:has(input:checked) .chip-label { color: var(--text-dim); }
.chip-filter:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-filter--critical { --sev: var(--sev-critical); }
.chip-filter--high     { --sev: var(--sev-high); }
.chip-filter--medium   { --sev: var(--sev-medium); }
.chip-filter--low      { --sev: var(--sev-low); }

.field { display: flex; align-items: center; gap: 5px; min-width: 0; }
.field-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.field select {
  height: 22px;
  padding: 0 20px 0 7px;
  font: inherit;
  font-size: 11.5px;
  color: var(--text);
  background: var(--panel-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M1 2.6 4 5.6 7 2.6' fill='none' stroke='%2399a3b2' stroke-width='1.2'/%3E%3C/svg%3E")
    no-repeat right 5px center / 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  appearance: none;
  cursor: pointer;
  max-width: 140px;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 11px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--accent-bg);
  border-bottom: 1px solid var(--line);
}
.filter-summary-text b { color: var(--text); font-weight: 600; }

.table-wrap { max-height: 460px; overflow: auto; }

.inc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.inc-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px 11px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.col-age, .inc-table td.col-age { text-align: right; }

.inc-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s ease;
}
.inc-table tbody tr:hover { background: var(--panel-2); }
.inc-table tbody tr.is-selected { background: var(--accent-bg); }
.inc-table tbody tr.is-selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.inc-table td { padding: 7px 11px; vertical-align: middle; }
.inc-table tbody tr:last-child td { border-bottom: 0; }

.inc-id {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-text);
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 2px;
}
.inc-id:hover { text-decoration: underline; }
.inc-title { display: block; font-size: 12.5px; color: var(--text); margin-top: 1px; }
.inc-svc { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.inc-age { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11.5px; color: var(--text-dim); }
.inc-owner { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.owner-unassigned { color: var(--text-faint); font-style: italic; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 20px 44px;
  text-align: center;
}
.empty-mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  margin-bottom: 2px;
  color: var(--text-faint);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 50%;
}
.empty-title { font-size: 13px; font-weight: 600; }
.empty-body { max-width: 34ch; font-size: 11.5px; color: var(--text-faint); }
.empty .btn { margin-top: 4px; }

.empty--inline {
  padding: 22px 12px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  background: var(--panel-2);
}

.page-foot { padding: 0 2px; font-size: 10.5px; color: var(--text-faint); }
.page-foot code { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }

.noscript {
  margin: 12px 16px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--warn);
  border-radius: var(--r);
}

/* ============================================================== toast === */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 24px);
  padding: 7px 8px 7px 11px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--ok);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 0);
  animation: toast-in 0.16s ease-out;
}
.toast[hidden] { display: none; }
.toast-icon { color: var(--ok); stroke-width: 2.2; }
.toast-text { font-size: 12px; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================== responsive = */

/* Detail drops below the chart; metrics wrap 2×2. */
@media (max-width: 1180px) {
  :root { --rail-w: 60px; }
  .brand-text, .rail-link span:not(.rail-badge), .rail-meta { display: none; }
  .rail-link { justify-content: center; padding: 7px 0; }
  .rail-link .icon { width: 17px; height: 17px; }
  .rail-badge {
    position: absolute;
    margin: 0;
    transform: translate(9px, -7px);
    min-width: 14px;
    font-size: 9px;
    line-height: 13px;
  }
  .rail-link { position: relative; }
  .rail-brand { justify-content: center; padding: 4px 0 12px; }

  .split { grid-template-columns: minmax(0, 1fr); }
  .panel--detail { position: static; }
}

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operator-name, .search .kbd { display: none; }
  .search { min-width: 150px; }
  .pill--status .pill-detail { display: none; }
  .page-foot { display: none; }
}

/* Rail becomes a bottom tab bar; table becomes stacked cards. */
@media (max-width: 720px) {
  :root { --topbar-h: 46px; }

  .app { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    z-index: 40;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-elev);
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .rail-brand, .rail-foot { display: none; }
  .rail-nav { flex-direction: row; width: 100%; }
  .rail-nav li { flex: 1 1 0; min-width: 0; }
  .rail-link {
    flex-direction: column;
    gap: 2px;
    padding: 4px 2px 3px;
    font-size: 9px;
    letter-spacing: -0.01em;
    border-left: 0;
    border-top: 2px solid transparent;
    border-radius: var(--r-sm);
  }
  .rail-link span:not(.rail-badge) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .rail-link.is-active { border-left-color: transparent; border-top-color: var(--accent); }
  .rail-link .icon { width: 15px; height: 15px; }
  .rail-badge {
    position: absolute;
    top: 1px;
    left: 50%;
    margin-left: 5px;
    transform: none;
    min-width: 13px;
    font-size: 8.5px;
    line-height: 12px;
  }

  main { padding: 10px 10px calc(66px + env(safe-area-inset-bottom, 0px)); }

  .topbar { flex-wrap: wrap; padding: 6px 10px; gap: 6px 8px; }
  .topbar-title { display: flex; align-items: center; gap: 8px; }
  .topbar-tools { width: 100%; gap: 8px; }
  .search { flex: 1 1 auto; min-width: 0; }
  .search input { height: 26px; }
  .clock { display: none; }
  .operator { padding-left: 0; border-left: 0; }

  .metric { padding: 8px 9px; }
  .metric-value { font-size: 19px; }
  .metric-spark .icon { width: 48px; height: 22px; }

  .panel-head { padding: 7px 9px; }
  .panel--chart .panel-head { flex-wrap: wrap; }
  .panel--chart .panel-head-tools { margin-left: auto; }
  .panel-head-tools { width: 100%; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .sev-filter { grid-column: 1 / -1; }
  .field { min-width: 0; }
  .field select { flex: 1 1 auto; min-width: 0; max-width: none; width: 100%; }

  /* Stacked incident cards: each cell labels itself. */
  .table-wrap { max-height: none; overflow: visible; }
  .inc-table thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .inc-table, .inc-table tbody, .inc-table tr, .inc-table td, .inc-table th { display: block; width: 100%; }
  .inc-table tbody { padding: 8px; }
  .inc-table tbody tr {
    margin-bottom: 7px;
    padding: 8px 9px;
    background: var(--panel-2);
    border: 1px solid var(--line-2);
    border-left: 2px solid var(--sev, var(--line-2));
    border-radius: var(--r);
  }
  .inc-table tbody tr:last-child { margin-bottom: 0; }
  .inc-table tbody tr.is-selected { background: var(--accent-bg); border-color: var(--accent-line); }
  .inc-table tbody tr.is-selected td:first-child { box-shadow: none; }
  .inc-table td { padding: 3px 0; border-bottom: 0; }
  .inc-table td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 74px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-faint);
  }
  .inc-table td.cell-primary { padding-bottom: 5px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  .inc-table td.cell-primary::before { display: none; }
  .inc-table td.cell-primary .inc-id { font-size: 12.5px; }
  .inc-table td.col-age, .inc-table td.col-age::before { text-align: left; }
  .inc-owner { justify-content: flex-start; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .filter-summary { flex-wrap: wrap; gap: 6px; }
  .toast { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}

/* Very narrow: single-column metric cards keep four across only above 480. */
@media (max-width: 400px) {
  .metric-spark { display: none; }
  .metric-value { font-size: 18px; }
  .chart-frame { padding: 6px 4px 0; }
  .chart-help { display: none; }
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .rail-link { font-size: 8.5px; }
}

@media (min-width: 1680px) {
  main { padding: 14px 22px 24px; gap: 14px; }
  .table-wrap { max-height: 560px; }
}
