:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #18202b;
  --muted: #657080;
  --line: #d9dee7;
  --accent: #147a6c;
  --accent-2: #7a4f12;
  --warn: #9a3412;
  --bad: #9f1239;
  --good: #166534;
  --blue: #1d4ed8;
  --tab: #edf1f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(14px, 2vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 9px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #b7dec8;
  color: var(--good);
  background: #f0fdf4;
}

.status-pill.warn,
.status-pill.boundary {
  border-color: #fed7aa;
  color: var(--warn);
  background: #fff7ed;
}

.status-pill.bad {
  border-color: #fecdd3;
  color: var(--bad);
  background: #fff1f2;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  overflow: auto;
  padding: 8px clamp(12px, 2vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.tab-button {
  min-width: 88px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--tab);
  color: var(--ink);
  cursor: pointer;
}

.tab-button.active {
  border-color: #a7c8c2;
  background: #e7f5f2;
  color: #115e59;
}

main {
  padding: clamp(12px, 2vw, 28px);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 16px;
}

.section-head {
  min-height: 46px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.section-head > div {
  min-width: 0;
}

.section-head.compact {
  min-height: 36px;
  align-items: flex-start;
}

.live-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.live-section + .live-section {
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.compact-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  background: var(--panel);
  color: var(--ink);
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
}

.signal-grid.compact {
  grid-template-columns: repeat(6, minmax(132px, 1fr));
}

.signal {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.signal strong {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.signal.bad {
  border-color: #fecdd3;
  background: #fff1f2;
}

.spark {
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.spark span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.pipeline-rail {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 6px;
  overflow: auto;
  max-width: 100%;
}

.pipeline-rail div {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #c8d6e2;
  border-radius: 8px;
  background: #eef6fb;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.two-column,
.info-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.info-grid section,
.summary-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  min-width: 0;
  overflow: auto;
}

.table-frame {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: auto;
  max-width: 100%;
}

.global-table-search { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.global-table-search input { max-width: 100%; }
.data-table { min-width: 0; }
.table-controls, .table-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px; }
.table-controls { background: #f8fafc; border-bottom: 1px solid var(--line); }
.table-controls label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.table-controls input, .table-controls select { min-width: 0; max-width: 210px; }
.table-controls button, .table-pagination button, .column-choice button { padding: 5px 8px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; }
.table-controls button:hover, .table-pagination button:hover { background: var(--tab); }
.data-table button:disabled { opacity: .45; cursor: not-allowed; }
.data-table :focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.table-pagination { font-size: 12px; }
.table-pagination > span:first-child { margin-right: auto; }
.table-filter-status { padding: 0 10px; font-size: 12px; overflow-wrap: anywhere; }
.table-scroll { overflow: auto; max-width: 100%; max-height: 65vh; overscroll-behavior: contain; }
.table-scroll > table { width: max-content; min-width: 100%; table-layout: fixed; }
.table-scroll th { position: sticky; overflow-wrap: anywhere; }
.table-scroll td { max-width: 600px; overflow-wrap: anywhere; }
.table-column-head { display: flex; align-items: center; gap: 5px; }
.table-column-head button { border: 0; background: transparent; color: inherit; font-weight: 700; padding: 4px 0; text-align: left; white-space: normal; }
.table-scroll th > input { width: 100%; min-width: 0; padding: 5px; margin-top: 6px; font-size: 11px; }
.column-drag { cursor: grab; user-select: none; }
.column-resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 7px; cursor: col-resize; touch-action: none; border-right: 2px solid #cbd5e1; }
.column-chooser { flex-basis: auto; }
.column-chooser[open] { flex-basis: 100%; }
.column-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); padding: 8px; margin-top: 8px; }
.column-list p { font-size: 12px; }
.column-choice { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 4px; }
.column-choice > label:first-child { min-width: 180px; flex: 1; }
.column-choice input[type=checkbox] { width: auto; }
.column-choice input[type=number] { width: 75px; }
@media (max-width: 600px) {
  .table-controls > label { flex: 1 1 160px; }
  .table-controls input, .table-controls select { width: 100%; }
  .table-pagination { gap: 6px; }
  .table-scroll { max-height: 60vh; }
  .table-scroll > table { display: block; width: 100%; min-width: 0; }
  .table-scroll > table > thead { display: block; overflow-x: auto; }
  .table-scroll > table > thead > tr { display: flex; }
  .table-scroll > table > thead th { flex-shrink: 0; }
  .table-scroll > table > tbody { display: block; }
  .table-scroll > table > tbody > .data-row { display: block; padding: 8px 0; border-top: 2px solid var(--line); }
  .table-scroll > table > tbody > .data-row > td { display: grid; grid-template-columns: minmax(100px, 42%) minmax(0, 1fr); gap: 8px; padding: 5px 8px; }
  .table-scroll > table > tbody > .data-row > td::before { content: attr(data-label); color: var(--muted); font-weight: 600; }
  .table-scroll > table > tbody > .shadow-detail-row { display: block; }
  .table-scroll > table > tbody > .shadow-detail-row > td { display: block; max-width: 100%; overflow: auto; }
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.35;
}

th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
}

tr:hover td {
  background: #fbfdff;
}

.shadow-detail-row td {
  background: #f8fafc;
  padding: 12px;
}

details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.8fr);
  gap: 12px;
}

.detail-grid section {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.detail-grid table {
  min-width: 640px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.muted {
  color: var(--muted);
}

.empty {
  padding: 18px;
  color: var(--muted);
}

ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

@media (max-width: 1100px) {
  .signal-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .two-column,
  .info-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .signal-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tab-button {
    min-width: 82px;
  }

  .pipeline-rail {
    grid-template-columns: repeat(7, minmax(96px, 1fr));
  }
}

@media (max-width: 480px) {
  .signal-grid {
    grid-template-columns: 1fr;
  }
}

/* Audit lanes remain peers, with bounded scrolling instead of a long page. */
.audit-grid { display:grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap:16px; align-items:start; }
.audit-grid > * { min-width:0; }
.audit-group-control { display:block; margin:12px 0; }
.ten-row-viewport .table-scroll { max-height: 540px; overflow:auto; }
.ten-row-viewport .data-row { height:44px; }
.ten-row-viewport .data-row td { height:44px; box-sizing:border-box; padding-top:6px; padding-bottom:6px; }
.ten-row-viewport .data-row td > span { display:block; max-height:32px; overflow:auto; }
.ten-row-viewport pre { max-height:240px; overflow:auto; white-space:pre-wrap; }
@media(max-width:760px) { .audit-grid { grid-template-columns:minmax(0,1fr); } }

@media(max-width:760px) {
  .ten-row-viewport .data-row { height:auto; }
  .ten-row-viewport .data-row td { height:auto; min-height:44px; }
}
