/* ==========================================================================
   Relay — operations control room
   Neutral surfaces, one accent (blue), severity colours reserved for state.
   ========================================================================== */

:root {
  --bg:        #f3f4f6;
  --surface:   #ffffff;
  --surface-2: #f7f8f9;
  --surface-3: #eef0f3;
  --line:      #dde0e5;
  --line-2:    #c9ced5;
  --text:      #15181c;
  --text-2:    #4d5560;
  --text-3:    #646c77;

  --accent:        #2356c4;
  --accent-hover:  #1b479f;
  --accent-soft:   #e8eefb;
  --accent-ink:    #ffffff;
  --focus:         #2356c4;

  --sev-critical:      #b42318;
  --sev-critical-soft: #fdecea;
  --sev-high:          #b54708;
  --sev-high-soft:     #fdf0e3;
  --sev-medium:        #8a6500;
  --sev-medium-soft:   #fbf4dc;
  --sev-low:           #4d5a6a;
  --sev-low-soft:      #eceff3;

  --good: #17754a;
  --bad:  #b42318;

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

  --radius: 4px;
  --rail-w: 64px;
  --bar-h: 44px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0e1012;
    --surface:   #16191c;
    --surface-2: #1b1f23;
    --surface-3: #22272c;
    --line:      #2a3036;
    --line-2:    #3a4148;
    --text:      #e7e9ec;
    --text-2:    #aab2bc;
    --text-3:    #8f98a3;

    --accent:        #7ea3ff;
    --accent-hover:  #9bb8ff;
    --accent-soft:   #1c2740;
    --accent-ink:    #0b1020;
    --focus:         #9bb8ff;

    --sev-critical:      #ff8a80;
    --sev-critical-soft: #3a1a18;
    --sev-high:          #ffae6b;
    --sev-high-soft:     #3a2412;
    --sev-medium:        #e8c55a;
    --sev-medium-soft:   #332a10;
    --sev-low:           #aab5c3;
    --sev-low-soft:      #252b33;

    --good: #5fcf98;
    --bad:  #ff8a80;

    color-scheme: dark;
  }
}

/* ---------- Base ---------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, figure, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }

.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; }

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

/* Visible, consistent keyboard focus everywhere. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute; left: 8px; top: -40px; z-index: 50;
  padding: 6px 10px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* ---------- Shell --------------------------------------------------------- */

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

.frame { min-width: 0; display: flex; flex-direction: column; }

/* ---------- Navigation rail ---------------------------------------------- */

.rail {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  padding: 10px 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 20;
}

.rail-brand {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--text); color: var(--surface);
  font-weight: 700; font-size: 14px; letter-spacing: -0.02em;
}

.rail-list { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0 6px; }

.rail-link {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px 6px;
  border-radius: var(--radius);
  color: var(--text-3);
  text-decoration: none;
  font-size: 10.5px; font-weight: 500;
}
.rail-link svg { width: 18px; height: 18px; fill: currentColor; }
.rail-link svg .stroke { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
a.rail-link:hover { background: var(--surface-3); color: var(--text); }
.rail-link[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.rail-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px;
  width: 2px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.rail-link.is-disabled { opacity: .55; cursor: default; }

.rail-badge {
  position: absolute; top: 3px; right: 8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px;
  background: var(--sev-critical); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.rail-badge:empty { display: none; }
@media (prefers-color-scheme: dark) { .rail-badge { color: #1a0d0c; } }

/* ---------- Status bar ---------------------------------------------------- */

.statusbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  min-height: var(--bar-h);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.statusbar-id { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.product { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.env {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  padding: 1px 6px; border: 1px solid var(--line); border-radius: var(--radius);
}

.statusbar-state {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
  font-weight: 500;
}
.state-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--sev-critical);
  box-shadow: 0 0 0 3px var(--sev-critical-soft);
}
.state-dot[data-level="ok"] { background: var(--good); box-shadow: none; }
.state-dot[data-level="high"] { background: var(--sev-high); box-shadow: 0 0 0 3px var(--sev-high-soft); }
.state-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state-text span { color: var(--text-2); font-weight: 400; }

.statusbar-meta {
  margin-left: auto;
  display: flex; gap: 18px;
}
.meta-item { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.meta-item dt {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); font-weight: 600;
}
.meta-item dd { font-variant-numeric: tabular-nums; }
#utc-clock { font-family: var(--mono); font-size: 12px; }

/* ---------- Main + panels ------------------------------------------------- */

.main {
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  padding: 12px 16px 24px;
  align-content: start;
}
.main:focus { outline: none; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 14px 8px;
}
.panel-title, .main, .panel { scroll-margin-top: calc(var(--bar-h) + 12px); }
.panel-title { font-size: 13px; font-weight: 600; letter-spacing: 0; }
.panel-title:focus-visible { outline-offset: 4px; }
.panel-sub { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Metrics ------------------------------------------------------- */

.metric-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.metric {
  padding: 11px 14px 12px;
  border-left: 1px solid var(--line);
  min-width: 0;
}
.metric:first-child { border-left: 0; }

.metric-label {
  display: block;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3);
}
.metric-value {
  display: block;
  margin-top: 3px;
  font-size: 22px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.metric-unit { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.metric-trend {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.trend-delta { font-weight: 600; white-space: nowrap; }
.trend-delta[data-tone="good"] { color: var(--good); }
.trend-delta[data-tone="bad"]  { color: var(--bad); }
.trend-delta[data-tone="neutral"] { color: var(--text-2); }
.trend-arrow { display: inline-block; font-size: 9px; margin-right: 3px; transform: translateY(-1px); }
.trend-ctx { color: var(--text-3); }

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

.throughput .panel-head { padding-bottom: 2px; }
.chart {
  position: relative;
  padding: 4px 14px 6px;
}
.chart-svg { display: block; width: 100%; height: 168px; overflow: visible; }
.chart-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.chart-grid line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart-grid text, .chart-x text {
  fill: var(--text-3); font-size: 10.5px; font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.chart-bar { fill: var(--accent); opacity: .78; }
.chart-bar.is-over { fill: var(--sev-high); opacity: .9; }
.chart-bar.is-now { opacity: 1; }
.chart-bar.is-active { opacity: 1; }
.chart-hit { fill: transparent; }
.chart-cursor { fill: var(--text); opacity: .06; }
.chart-threshold { stroke: var(--sev-high); stroke-width: 1; stroke-dasharray: 4 3; shape-rendering: crispEdges; }
.chart-threshold-label { fill: var(--sev-high); font-size: 10.5px; font-weight: 600; }

.chart-foot {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 2px 14px 8px;
  font-size: 12px; color: var(--text-2);
}
.chart-readout { font-variant-numeric: tabular-nums; min-height: 1.45em; }
.chart-readout strong { color: var(--text); font-weight: 600; }
.chart-legend { display: flex; gap: 14px; color: var(--text-3); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 1px; background: var(--accent); opacity: .78; }
.swatch-over { background: var(--sev-high); opacity: .9; }
.swatch-line { width: 14px; height: 0; border-top: 1px dashed var(--sev-high); border-radius: 0; background: none; opacity: 1; }

.chart-table {
  border-top: 1px solid var(--line);
  padding: 0 14px;
}
.chart-table summary {
  cursor: pointer;
  padding: 7px 0;
  font-size: 12px; color: var(--text-2);
  width: max-content; max-width: 100%;
}
.chart-table summary:hover { color: var(--text); }
.table-scroll { overflow-x: auto; padding-bottom: 10px; }
.mini-table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.mini-table th, .mini-table td { padding: 3px 8px; border: 1px solid var(--line); text-align: right; }
.mini-table th { color: var(--text-3); font-weight: 600; }

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

.incidents {
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-items: start;
}

/* ---------- Filters ------------------------------------------------------- */

.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--line);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 0;
}
.field > legend { margin-bottom: 4px; float: left; width: 100%; }
.field-sev .seg { clear: both; }
.field-search { flex: 1 1 200px; }

input[type="search"], select {
  height: 30px;
  padding: 0 9px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 0;
}
input[type="search"] { width: 100%; }
input[type="search"]::placeholder { color: var(--text-3); }
select { padding-right: 6px; }
input[type="search"]:hover, select:hover { border-color: var(--text-3); }
input[type="search"]:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus);
}

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg-opt { position: relative; display: block; }
.seg-opt + .seg-opt { border-left: 1px solid var(--line-2); }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span {
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 9px;
  font-size: 12px; color: var(--text-2);
  cursor: pointer; user-select: none;
  white-space: nowrap;
}
.seg-opt span .sev-glyph { opacity: .45; }
.seg-opt input:checked + span { background: var(--surface-3); color: var(--text); font-weight: 600; }
.seg-opt input:checked + span .sev-glyph { opacity: 1; }
.seg-opt input:hover + span { color: var(--text); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.seg-count { color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn-quiet { border-color: transparent; color: var(--text-2); }
.btn-quiet:hover { color: var(--text); }
.btn-quiet[disabled] { visibility: hidden; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { width: 100%; height: 34px; }
kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 0 4px; border: 1px solid currentColor; border-radius: 3px; opacity: .75;
}

/* ---------- Incident table ----------------------------------------------- */

.table-wrap { position: relative; }

.inc-table { width: 100%; border-collapse: collapse; }
.inc-table th, .inc-table td {
  padding: 0 10px;
  height: 44px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.inc-table th:first-child, .inc-table td:first-child { padding-left: 14px; }
.inc-table th:last-child, .inc-table td:last-child { padding-right: 14px; }
.inc-table thead th {
  height: 30px;
  background: var(--surface-2);
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
.inc-table th.num, .inc-table td.num { text-align: right; }
.inc-table tbody tr:last-child td { border-bottom: 0; }
.inc-table tbody tr { cursor: pointer; }
.inc-table tbody tr:hover td { background: var(--surface-2); }
.inc-table tbody tr.is-selected td { background: var(--accent-soft); }
.inc-table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.sort {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 0; margin: 0;
  background: none; border: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
  cursor: pointer;
}
.sort:hover { color: var(--text); }
.sort-ind { width: 8px; font-size: 8px; }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--text); }
th[aria-sort="ascending"] .sort-ind::after { content: "▲"; }
th[aria-sort="descending"] .sort-ind::after { content: "▼"; }

.col-sev { width: 104px; }
.col-age { width: 76px; }
.col-status { width: 128px; }
.col-owner { width: 110px; }
.col-svc { width: 132px; }

.inc-link {
  display: block;
  max-width: 100%;
  padding: 3px 0;
  background: none; border: 0; margin: 0;
  text-align: left; cursor: pointer;
}
.inc-id { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); display: block; }
.inc-title {
  display: block;
  font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
tr.is-selected .inc-id { color: var(--accent); }
.inc-link:hover .inc-title { text-decoration: underline; text-underline-offset: 2px; }
.inc-link:focus-visible { outline-offset: 1px; }

td.col-id { max-width: 0; } /* lets the title ellipsise inside the flexible column */
.svc { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.age { font-variant-numeric: tabular-nums; white-space: nowrap; }
.owner { white-space: nowrap; }
.owner.is-unassigned { color: var(--sev-high); font-style: italic; }

/* Severity chip: glyph + word, never colour alone. */
.sev {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 7px 0 6px;
  border-radius: 3px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.sev-glyph { width: 9px; height: 9px; flex: none; fill: currentColor; }
.sev[data-sev="critical"] { color: var(--sev-critical); background: var(--sev-critical-soft); }
.sev[data-sev="high"]     { color: var(--sev-high);     background: var(--sev-high-soft); }
.sev[data-sev="medium"]   { color: var(--sev-medium);   background: var(--sev-medium-soft); }
.sev[data-sev="low"]      { color: var(--sev-low);      background: var(--sev-low-soft); }
.seg-opt[data-sev="critical"] .sev-glyph { color: var(--sev-critical); }
.seg-opt[data-sev="high"] .sev-glyph     { color: var(--sev-high); }
.seg-opt[data-sev="medium"] .sev-glyph   { color: var(--sev-medium); }
.seg-opt[data-sev="low"] .sev-glyph      { color: var(--sev-low); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; white-space: nowrap; color: var(--text-2);
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid currentColor; flex: none;
}
.status[data-status="open"] { color: var(--sev-high); font-weight: 600; }
.status[data-status="investigating"]::before { background: currentColor; }
.status[data-status="investigating"] { color: var(--text); }
.status[data-status="acknowledged"]::before { background: var(--accent); border-color: var(--accent); }
.status[data-status="acknowledged"] { color: var(--text); }
.status[data-status="monitoring"]::before { border-style: dotted; }

/* Empty state */
.empty {
  padding: 28px 16px 32px;
  text-align: center;
  border-top: 1px dashed var(--line-2);
  margin: 0 14px 14px;
}
.empty-title { font-weight: 600; font-size: 13px; }
.empty-body { margin: 4px auto 12px; color: var(--text-2); max-width: 44ch; }

/* ---------- Detail panel -------------------------------------------------- */

.detail { position: sticky; top: calc(var(--bar-h) + 12px); }

.detail-head { padding: 12px 14px 12px; border-bottom: 1px solid var(--line); }
.detail-kicker { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.detail-id { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.detail-title { margin-top: 6px; font-size: 15px; font-weight: 600; line-height: 1.3; }
.detail-title:focus-visible { outline-offset: 3px; }

.detail-fields {
  display: grid; grid-template-columns: auto 1fr;
  gap: 7px 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.detail-fields dt { color: var(--text-3); font-size: 12px; }
.detail-fields dd { font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

.detail-action { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.detail-action .hint { margin-top: 8px; font-size: 12px; color: var(--text-3); }
.ack-done {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--text-2);
}
.ack-done strong { color: var(--text); font-weight: 600; }
.ack-check { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--accent); }
.ack-undo { margin-top: 8px; }

.detail-section { padding: 12px 14px 14px; }
.detail-section h4 {
  margin: 0 0 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
}
.timeline { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.detail-note { margin-top: 6px; font-size: 12px; color: var(--sev-high); }
.timeline li { display: grid; grid-template-columns: 58px 1fr; gap: 10px; font-size: 12.5px; }
.timeline time { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); padding-top: 1px; }
.timeline .is-new { animation: flash 1.6s ease-out 1; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }

.detail-empty { padding: 28px 16px; text-align: center; color: var(--text-2); }
.detail-empty p + p { margin-top: 4px; color: var(--text-3); font-size: 12px; }

/* ---------- Responsive ---------------------------------------------------- */

@media (max-width: 1180px) {
  .incidents { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; }
}

@media (max-width: 900px) {
  .metric-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .meta-hide-sm { display: none; }
}

/* Narrow: table rows become stacked records so titles never get squeezed. */
@media (max-width: 900px) {
  /* Header collapses into a compact sort bar (only sortable columns shown). */
  .inc-table, .inc-table thead, .inc-table tbody { display: block; }
  .inc-table thead tr {
    display: flex; align-items: center; gap: 16px;
    padding: 0 14px; height: 30px;
    background: var(--surface-2); border-bottom: 1px solid var(--line);
  }
  .inc-table thead tr::before {
    content: "Sort"; font-size: 10.5px; font-weight: 600; letter-spacing: .06em;
    text-transform: uppercase; color: var(--text-3);
  }
  .inc-table thead th { display: block; height: auto; width: auto; padding: 0 !important; border: 0; background: none; }
  .inc-table thead th:not([aria-sort]) { display: none; }
  .inc-table thead .sort { color: var(--text-2); }
  .inc-table tbody tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    padding: 10px 12px 10px 14px;
    border-bottom: 1px solid var(--line);
    position: relative;
  }
  .inc-table tbody tr:last-child { border-bottom: 0; }
  .inc-table tbody td {
    display: block; height: auto; padding: 0 !important; border: 0; background: none !important;
  }
  .inc-table tbody tr:hover { background: var(--surface-2); }
  .inc-table tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  .inc-table tbody tr.is-selected td:first-child { box-shadow: none; }
  td.col-id { order: 1; flex: 1 1 0; max-width: none; min-width: 0; }
  td.col-age { order: 2; flex: none; width: auto; color: var(--text-2); }
  td.col-sev { order: 3; width: auto; }
  td.col-svc { order: 4; width: auto; }
  td.col-owner { order: 5; width: auto; flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--text-2); }
  td.col-status { order: 6; width: auto; margin-left: auto; }
  .inc-title { white-space: normal; }

}

/* Phone: rail becomes a bottom tab bar. */
@media (max-width: 720px) {
  :root { --rail-w: 0px; }
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .shell { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    height: auto;
    flex-direction: row;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .rail-brand { display: none; }
  .rail-list { flex-direction: row; justify-content: space-around; padding: 0; }
  .rail-list li { flex: 1 1 0; }
  .rail-link { padding: 5px 2px; }
  .rail-link[aria-current="page"]::before { left: 20%; right: 20%; top: -5px; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; }
  .rail-badge { right: calc(50% - 20px); }

  .statusbar {
    flex-wrap: wrap; gap: 4px 12px;
    padding: 6px 12px;
  }
  .statusbar-state { order: 3; flex: 1 1 100%; font-size: 12.5px; }
  .statusbar-meta { gap: 12px; }
  .meta-item dt { display: none; }
  .meta-item:last-child { display: none; }

  .main { padding: 10px 10px 20px; gap: 10px; }

  .metric { padding: 10px 12px; }
  .metric-value { font-size: 19px; }

  .chart { padding: 4px 8px 4px; }
  .chart-svg { height: 140px; }
  .chart-legend { display: none; }

  .filters { padding: 0 12px 10px; }
  .field-search { flex-basis: 100%; }
  .field-sev { flex: 1 1 100%; }
  .seg { display: flex; }
  .seg-opt { flex: 1 1 0; }
  .seg-opt span { justify-content: center; padding: 0 4px; }
  .seg-count { display: none; }
  .field-status { flex: 1 1 auto; }
  select { width: 100%; }

  .empty { margin: 0 12px 12px; }
}

@media (max-width: 380px) {
  .rail-label { font-size: 10px; }
  .env { display: none; }
}

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

@media (forced-colors: active) {
  .sev, .rail-link[aria-current="page"], .inc-table tbody tr.is-selected td { border: 1px solid CanvasText; }
  .chart-bar { fill: CanvasText; }
  .chart-bar.is-over { fill: Highlight; }
}
