:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #080808;
  --panel-strong: #101010;
  --line: #262626;
  --line-strong: #3a1111;
  --text: #fff;
  --muted: #b6b6b6;
  --dim: #787878;
  --accent: #ff1f2d;
  --accent-soft: rgba(255, 31, 45, 0.15);
  --accent-line: rgba(255, 31, 45, 0.55);
  --warning: #f4c542;
  --ok: #f5f5f5;
  --coverage-bg: #062414;
  --coverage-line: #0f5d32;
  --coverage-text: #d8ffe7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #000;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  position: relative;
  flex: 0 0 auto;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}

.brand h1,
.section-heading h2,
.panel-heading h3 {
  margin: 0;
  font-weight: 750;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-status,
.auth-form,
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-status {
  flex: 0 0 auto;
}

.filter-bar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-form {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-form label,
.status-text {
  color: var(--muted);
  font-size: 12px;
}

.auth-form input,
select {
  min-height: 36px;
  background: #050505;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.auth-form button,
.secondary-button,
.tab,
.filter-button {
  min-height: 36px;
  color: var(--text);
  background: #090909;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

.auth-form button,
.secondary-button:hover,
.tab.is-active,
.filter-button.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.status-pill,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--text);
  background: #080808;
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.is-error,
.count-badge.is-error {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: #000;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
}

main {
  padding: 20px 24px 36px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 {
  font-size: 24px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 780;
}

.metric-detail {
  margin-top: 6px;
  color: var(--dim);
  font-size: 12px;
}

.command-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(420px, 2fr) minmax(240px, 0.9fr);
  gap: 14px;
  align-items: stretch;
}

.flow-panel {
  margin-top: 14px;
}

.flow-map,
.architecture-map {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.flow-map {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.architecture-map {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.panel,
.factory-map-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-heading-spaced {
  margin-top: 18px;
}

.panel-heading h3 {
  font-size: 15px;
}

.attention-list,
.fallback-list,
.stacked-list {
  display: grid;
  gap: 10px;
}

.attention-item,
.fallback-item,
.kv-row,
.flow-node,
.architecture-node {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px;
  background: #050505;
}

.flow-node,
.architecture-node {
  min-height: 112px;
  border-left-color: var(--accent-line);
}

.architecture-node {
  border-top: 2px solid var(--accent);
}

.process-graph {
  --graph-columns: 5;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--graph-columns), minmax(136px, 1fr));
  gap: 14px;
  width: 100%;
  min-width: 980px;
  min-height: 392px;
  padding: 8px;
  isolation: isolate;
}

.architecture-map .process-graph {
  min-height: 330px;
}

.process-edge-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.process-node {
  position: relative;
  z-index: 1;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent-line);
  border-radius: 8px;
  padding: 12px;
  background: #050505;
  color: var(--text);
  text-align: left;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

button.process-node:hover,
button.process-node:focus-visible {
  border-color: var(--accent-line);
  outline: none;
}

.process-node.is-ready,
.process-node.is-running,
.process-node.is-healthy,
.process-node.is-fresh,
.process-node.is-configured,
.process-node.is-succeeded,
.process-node.is-snapshot-backed {
  border-top-color: var(--coverage-line);
}

.process-node.is-working,
.process-node.is-research,
.process-node.is-observed-by-events,
.process-node.is-observed-by-jobs,
.process-node.is-observed-by-activity {
  border-top-color: var(--warning);
}

.process-node.is-blocked,
.process-node.is-failed,
.process-node.is-error,
.process-node.is-not-configured {
  border-top-color: var(--accent);
}

.process-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.process-title {
  font-size: 13px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.process-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.attention-item[data-severity="warning"] {
  border-left-color: var(--warning);
}

.attention-item[data-severity="attention"] {
  border-left-color: var(--muted);
}

.item-title {
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.item-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.factory-map-panel {
  min-height: 620px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.manager-node {
  width: min(420px, 100%);
  margin: 0 auto 22px;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 16px;
  background: #0b0303;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(255, 31, 45, 0.08);
}

.manager-node::after {
  content: "";
  display: block;
  width: 1px;
  height: 30px;
  background: var(--accent-line);
  margin: 14px auto -4px;
}

.node-title {
  font-size: 15px;
  font-weight: 780;
}

.node-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.station-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  position: relative;
}

.station-node {
  min-height: 154px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  border: 1px solid var(--line);
  border-top: 3px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-strong);
  color: var(--text);
}

.station-node.is-working,
.station-node.is-blocked {
  border-top-color: var(--accent);
}

.station-node.is-stale {
  border-top-color: var(--warning);
}

.station-node:hover,
.station-node:focus-visible {
  border-color: var(--accent-line);
  outline: none;
}

.station-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #050505;
}

.stat strong {
  display: block;
  font-size: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
}

.detail-grid,
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide-panel {
  grid-column: span 2;
}

.chart-panel {
  min-height: 0;
}

.chart-surface,
.visual-summary {
  height: 296px;
  min-height: 296px;
  max-height: 296px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #020202;
  overflow: hidden;
}

.visual-summary {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  overflow-y: auto;
}

.compact-summary {
  height: 194px;
  min-height: 194px;
  max-height: 194px;
  margin-bottom: 12px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(96px, 0.95fr) minmax(120px, 1.8fr) minmax(44px, auto);
  align-items: center;
  gap: 10px;
}

.summary-label,
.summary-value {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-label {
  color: var(--text);
  font-weight: 680;
}

.summary-value {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-track {
  height: 12px;
  border: 1px solid #2a2a2a;
  border-radius: 999px;
  background: #101010;
  overflow: hidden;
}

.summary-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #ffffff);
}

.summary-row.is-positive .summary-fill,
.summary-row.is-covered .summary-fill,
.summary-row.is-healthy .summary-fill,
.summary-row.is-fresh .summary-fill,
.summary-row.is-ready .summary-fill,
.summary-row.is-passed .summary-fill,
.summary-row.is-approved .summary-fill,
.summary-row.is-configured .summary-fill,
.summary-row.is-succeeded .summary-fill,
.summary-row.is-published .summary-fill,
.summary-row.is-allowed .summary-fill {
  background: linear-gradient(90deg, var(--coverage-line), #7dffad);
}

.summary-row.is-warning .summary-fill,
.summary-row.is-working .summary-fill,
.summary-row.is-research .summary-fill,
.summary-row.is-partial .summary-fill,
.summary-row.is-pending .summary-fill,
.summary-row.is-queued .summary-fill,
.summary-row.is-stale .summary-fill {
  background: linear-gradient(90deg, #7a5a08, var(--warning));
}

.summary-row.is-error .summary-fill,
.summary-row.is-blocked .summary-fill,
.summary-row.is-failed .summary-fill,
.summary-row.is-missing .summary-fill,
.summary-row.is-redacted .summary-fill {
  background: linear-gradient(90deg, #7d050d, var(--accent));
}

.fallback-chart {
  height: 296px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  padding: 18px;
}

.fallback-bar {
  flex: 1 1 8px;
  min-width: 6px;
  max-width: 22px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid #141414;
  border-radius: 6px;
  background: #030303;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 760px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td {
  color: var(--muted);
  background: #030303;
}

th {
  color: var(--text);
  background: #050505;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--line);
}

tbody tr:hover td {
  background: #080808;
}

.cell-number,
.cell-boolean,
.cell-coverage {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-long {
  max-width: 360px;
}

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

.cell-positive {
  color: var(--coverage-text);
  background: #04170d;
}

.cell-warning {
  color: #ffe89a;
  background: #171204;
}

.cell-error,
.cell-redacted {
  color: #ffd6d9;
  background: #1b0406;
}

.cell-exchange.cell-positive,
.cell-coverage.cell-positive {
  color: var(--coverage-text);
  background: var(--coverage-bg);
  border-left: 1px solid var(--coverage-line);
  border-right: 1px solid var(--coverage-line);
  font-weight: 760;
  text-align: center;
}

.cell-redacted {
  font-style: italic;
}

.empty-state,
.error-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #050505;
}

.error-state {
  border-color: var(--accent-line);
  color: var(--text);
}

@media (max-width: 1180px) {
  .command-layout,
  .detail-grid,
  .inventory-grid,
  .flow-map,
  .architecture-map {
    grid-template-columns: 1fr;
  }

  .wide-panel {
    grid-column: auto;
  }

  .station-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .topbar {
    position: static;
  }

  .topbar-status,
  .auth-form,
  .filter-bar {
    width: 100%;
    justify-content: flex-start;
  }

  .tabs,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .health-grid,
  .station-map,
  .flow-map,
  .architecture-map {
    grid-template-columns: 1fr;
  }

  .factory-map-panel {
    min-height: 0;
  }

  th,
  td {
    white-space: normal;
  }
}
