:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-strong: #eaf2ff;
  --line: #d4e1ee;
  --text: #132033;
  --muted: #63758b;
  --brand-navy: #071d33;
  --brand-blue: #0d63ce;
  --brand-blue-dark: #084994;
  --brand-cyan: #16b9d6;
  --brand-lime: #6ed36a;
  --green: var(--brand-blue);
  --green-dark: var(--brand-blue-dark);
  --blue: var(--brand-cyan);
  --amber: #b46a0a;
  --red: #c23030;
  --shadow: 0 14px 38px rgba(7, 29, 51, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fbff 0, var(--bg) 320px),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(243, 247, 251, 0.96);
}

.auth-screen[hidden] {
  display: none;
}

.auth-panel {
  width: min(620px, 100%);
  display: grid;
  gap: 20px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1100;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  backdrop-filter: blur(8px);
}

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

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 2px;
  text-align: center;
}

.brand-logo {
  display: block;
  object-fit: contain;
}

.auth-logo {
  width: min(380px, 100%);
  height: auto;
}

.header-logo {
  width: clamp(178px, 18vw, 260px);
  height: 38px;
}

.brand-product {
  margin: 0;
  color: var(--brand-navy);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0;
}

.app-header .brand-product {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workflow-tabs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.workflow-tab {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #263b52;
  background: transparent;
  font-size: 13px;
  font-weight: 760;
}

.workflow-tab.is-active {
  color: #fff;
  background: var(--brand-blue);
}

.connection-label {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 13px;
}

.view-panel[hidden] {
  display: none;
}

.app-status {
  margin: 14px 20px 0;
}

.app-shell {
  min-height: calc(100vh - 77px);
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(300px, 380px);
  gap: 0;
}

.control-panel,
.inspector-panel {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: #f9fbfe;
}

.inspector-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.workspace-panel {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 20px;
}

.lookup-shell {
  min-height: calc(100vh - 77px);
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 420px);
  gap: 0;
}

.lookup-main,
.lookup-detail {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 20px;
}

.lookup-detail {
  border-left: 1px solid var(--line);
  background: #f9fbfe;
}

.plant-main {
  gap: 22px;
}

.plant-section {
  display: grid;
  gap: 10px;
}

.management-section {
  display: grid;
  gap: 10px;
}

section {
  min-width: 0;
}

.section-title {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 780;
  text-transform: uppercase;
  color: #263b52;
}

.muted-count {
  color: var(--muted);
  font-weight: 650;
  text-transform: none;
}

.split-title {
  margin-top: 12px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #2d435a;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #c6d5e5;
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

select {
  cursor: pointer;
}

select:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #f2f6fa;
}

input[readonly] {
  color: #263b52;
  background: #f2f7fb;
  border-color: #d4e1ee;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 111, 86, 0.14);
}

.primary-action,
.quiet-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 760;
  white-space: nowrap;
}

.primary-action {
  width: 100%;
  padding: 0 16px;
  color: #fff;
  background: var(--green);
}

.inline-action {
  width: auto;
}

.primary-action:hover {
  background: var(--green-dark);
}

.primary-action:disabled,
.quiet-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.quiet-button,
.icon-button {
  padding: 0 12px;
  color: #263b52;
  background: #fff;
  border-color: var(--line);
}

.quiet-button:hover,
.icon-button:hover {
  border-color: #9eb6cf;
  background: var(--surface-strong);
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.circuit-detail-actions {
  display: flex;
  flex-wrap: wrap;
}

.circuit-detail-actions .primary-action {
  flex: 1 1 180px;
}

.danger-action {
  color: #8f1d1d;
  border-color: #efc8c8;
  background: #fff7f7;
}

.danger-action:hover {
  border-color: #d89191;
  background: #fff0f0;
}

.route-search,
.metrics-panel,
.circuits-panel,
.route-canvas,
.results-panel,
.inspector-panel section {
  min-width: 0;
}

.location-picker {
  position: relative;
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.selected-location {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.selected-location.is-set {
  color: var(--green-dark);
  background: #e9f4ff;
  border-color: #b9d8f7;
}

.hardware-picker {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 2px;
}

.hardware-add-grid,
.model-grid,
.plant-grid {
  display: grid;
  gap: 8px;
}

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

.hardware-add-grid input,
.hardware-add-grid select,
.model-grid input {
  min-height: 36px;
  font-size: 12px;
}

.model-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.model-panel summary {
  cursor: pointer;
  color: #263b52;
  font-size: 13px;
  font-weight: 780;
  text-transform: uppercase;
}

.model-panel[open] summary {
  margin-bottom: 10px;
}

.model-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 10px;
}

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

.plant-grid input,
.plant-grid select,
.plant-grid textarea {
  min-height: 36px;
  font-size: 12px;
}

.mux-selector-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.mux-selector-panel[hidden] {
  display: none;
}

.splitter-control[hidden] {
  display: none;
}

.mux-selector-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #263b52;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mux-selector-title .quiet-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 11px;
}

.checkbox-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-lane-grid {
  display: grid;
  gap: 8px;
}

.model-lane-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(140px, 1.2fr);
  gap: 8px;
  align-items: center;
}

.model-lane-row input,
.model-lane-row select {
  min-width: 0;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid #c8d8e8;
  border-radius: 8px;
  background: #fff;
  color: #263b52;
  font-size: 11px;
  font-weight: 740;
}

.checkbox-chip input {
  width: 14px;
  min-height: 14px;
  padding: 0;
}

.checkbox-chip:has(input:checked) {
  border-color: #86bdf0;
  background: #e6f3ff;
  color: #084994;
}

.channel-loss-grid {
  display: grid;
  gap: 6px;
}

.channel-loss-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.75fr) repeat(2, minmax(92px, 1fr));
  gap: 6px;
  align-items: center;
}

.channel-loss-row span {
  color: #263b52;
  font-size: 12px;
  font-weight: 780;
}

.channel-loss-row input {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 11px;
}

.plant-field-label {
  gap: 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.plant-grid select.slot-picker {
  min-height: 104px;
}

.plant-map-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.plant-location-map {
  position: relative;
  width: 100%;
  height: clamp(260px, 34vh, 420px);
  overflow: hidden;
  border: 1px solid #b9cadc;
  border-radius: 8px;
  background: #dce5ed;
}

.plant-location-map.leaflet-container {
  overflow: hidden;
  font: 12px/1.5 Inter, "Segoe UI", Arial, sans-serif;
}

.plant-location-map .leaflet-pane,
.plant-location-map .leaflet-tile,
.plant-location-map .leaflet-marker-icon,
.plant-location-map .leaflet-marker-shadow,
.plant-location-map .leaflet-tile-container,
.plant-location-map .leaflet-pane > svg,
.plant-location-map .leaflet-pane > canvas {
  position: absolute;
  left: 0;
  top: 0;
}

.plant-location-map .leaflet-tile {
  width: 256px;
  height: 256px;
  max-width: none !important;
  max-height: none !important;
  border: 0;
  padding: 0;
}

.plant-location-map .leaflet-marker-icon,
.plant-location-map .leaflet-marker-shadow {
  display: block;
  max-width: none !important;
}

.plant-location-map .leaflet-control-container .leaflet-top,
.plant-location-map .leaflet-control-container .leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.plant-location-map .leaflet-control {
  pointer-events: auto;
}

.plant-location-map .leaflet-top {
  top: 0;
}

.plant-location-map .leaflet-right {
  right: 0;
}

.plant-location-map .leaflet-left {
  left: 0;
}

.plant-location-map .leaflet-bottom {
  bottom: 0;
}

.plant-location-map .leaflet-control {
  float: left;
  clear: both;
  margin: 10px;
}

.plant-location-map .leaflet-right .leaflet-control {
  float: right;
}

.plant-map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.plant-map-status {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.compact-title {
  min-height: 32px;
  margin-bottom: 0;
}

.cable-event-editor {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.cable-slot-summary {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: #263b52;
  font-size: 12px;
}

.cable-slot-summary-title {
  color: var(--muted);
  font-weight: 780;
  text-transform: uppercase;
}

.cable-slot-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.55fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.cable-slot-summary-title + .cable-slot-row {
  border-top: 0;
  padding-top: 0;
}

.cable-slot-row strong {
  font-size: 12px;
}

.cable-slot-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cable-event-list {
  display: grid;
  gap: 8px;
}

.existing-cable-events {
  display: grid;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid #efd4a5;
  border-left: 4px solid #d97706;
  border-radius: 8px;
  background: #fffaf0;
}

.existing-cable-events-title {
  color: #734b0b;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.existing-cable-events > span {
  color: #7d6650;
  font-size: 12px;
}

.existing-cable-event-list {
  display: grid;
  gap: 5px;
}

.cable-event-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.cable-event-row input,
.cable-event-row select {
  min-height: 36px;
  font-size: 12px;
}

.cable-event-notes {
  grid-column: span 3;
}

.remove-cable-event-button {
  min-height: 36px;
}

.plant-browser {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.plant-browser-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.plant-browser-controls input,
.plant-browser-controls select {
  min-height: 36px;
  font-size: 12px;
}

.plant-browser-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 2px 0;
}

.plant-browser-types label {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  color: #314960;
  font-size: 12px;
  font-weight: 720;
}

.plant-browser-types input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.plant-browser-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plant-browser-results {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding-right: 2px;
}

.plant-room-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.plant-room-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.plant-room-header strong {
  color: #21384f;
  overflow-wrap: anywhere;
}

.plant-room-header span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.plant-kind-title {
  color: #38526b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.plant-browser-list {
  display: grid;
  gap: 6px;
}

.plant-browser-item {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid #dce7f2;
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--surface);
}

button.plant-browser-item {
  width: 100%;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

button.plant-browser-item:hover {
  border-color: #9eb6cf;
  background: #f7fbff;
}

.plant-browser-item.is-rack {
  border-left-color: var(--brand-blue);
}

.plant-browser-item.is-location {
  border-left-color: #7c3aed;
}

.plant-browser-item.is-panel {
  border-left-color: var(--green);
}

.plant-browser-item.is-component {
  border-left-color: #9d6b20;
}

.plant-browser-item.is-cable {
  border-left-color: #6f7f8f;
}

.plant-browser-item.is-event {
  border-left-color: #d97706;
}

.plant-browser-cable {
  display: grid;
  gap: 5px;
}

.plant-cable-events {
  display: grid;
  gap: 5px;
  margin-left: 18px;
  padding-left: 10px;
  border-left: 2px solid #e0aa52;
}

.plant-cable-events-title {
  color: #7b510e;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.plant-cable-event {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid #efd4a5;
  border-radius: 6px;
  background: #fff8ea;
}

.plant-cable-event strong {
  color: #65400d;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.plant-cable-event span {
  color: #7d6650;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.plant-browser-item strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.plant-browser-item span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.panel-visual {
  display: grid;
  gap: 8px;
  margin-top: 7px;
  padding-top: 8px;
  border-top: 1px solid #e4edf6;
}

.panel-visual-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-visual-header strong {
  color: #20374e;
  font-size: 12px;
}

.panel-visual-header span,
.panel-visual-status {
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.panel-visual-status.is-error {
  color: var(--red);
}

.panel-visual-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.panel-visual-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #415870;
  font-size: 11px;
  font-weight: 720;
}

.panel-visual-legend-item::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: currentColor;
}

.panel-visual-legend-item.is-open {
  color: #12715f;
}

.panel-visual-legend-item.is-assigned {
  color: #9a5012;
}

.panel-visual-legend-item.is-component {
  color: #5f4bb6;
}

.panel-visual-grid {
  display: grid;
  grid-template-columns: repeat(var(--panel-slot-columns, 12), minmax(54px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.panel-slot-tile {
  min-width: 54px;
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 6px;
  border: 1px solid #cfe0ef;
  border-radius: 7px;
  background: #f7fbff;
  color: #1f354d;
  text-align: center;
}

.panel-slot-tile strong {
  color: inherit;
  font-size: 13px;
  line-height: 1;
}

.panel-slot-tile small,
.panel-slot-tile span {
  min-width: 0;
  color: inherit;
  font-size: 10px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-slot-tile.is-open {
  border-color: #a7d8cf;
  background: #eefbf8;
  color: #105d50;
}

.panel-slot-tile.is-assigned {
  border-color: #e6b47c;
  background: #fff6e8;
  color: #783f0f;
}

.panel-slot-tile.is-component {
  border-color: #c8bffa;
  background: #f5f2ff;
  color: #493895;
}

.panel-slot-tile.is-mixed {
  border-color: #d98b8b;
  background: #fff1f1;
  color: #8e2b2b;
}

.plant-browser-table {
  min-width: 900px;
}

.plant-browser-table tr.is-clickable {
  cursor: pointer;
}

.plant-browser-table tr.is-clickable:hover td {
  background: #f7fbff;
}

.plant-browser-table tr.plant-cable-event-row td {
  background: #fff8ea;
  color: #604817;
}

.plant-browser-table tr.plant-cable-event-row td:first-child {
  padding-left: 24px;
  color: #7b510e;
  font-weight: 850;
}

.wide-field {
  grid-column: 1 / -1;
}

.release-fields,
.wdm-builder-grid,
.wdm-channel-grid,
.search-row {
  display: grid;
  gap: 10px;
}

.wdm-builder-grid,
.wdm-channel-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.next-circuit-label {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.next-circuit-label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.next-circuit-label strong {
  color: var(--brand-blue-dark);
}

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

.location-results {
  position: absolute;
  z-index: 10;
  top: calc(100% - 2px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.location-results.is-open {
  display: grid;
}

.location-option {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #e7eef7;
  background: transparent;
  text-align: left;
  color: var(--text);
}

.location-option:hover,
.location-option:focus {
  background: #eef6ff;
}

.location-option strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.location-option span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.route-settings {
  display: grid;
  grid-template-columns: 1fr 96px;
  align-items: end;
  gap: 12px;
  margin: 4px 0 14px;
}

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

.metric {
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric strong {
  font-size: 20px;
  line-height: 1;
}

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

.compact-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
}

.lookup-list,
.package-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.compact-item,
.package-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

button.compact-item:hover,
button.package-item:hover {
  border-color: #9eb6cf;
  background: #f7fbff;
}

.compact-item.is-selected,
.package-item.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 111, 86, 0.12);
}

.compact-item.is-wdm-channel {
  margin-left: 18px;
  border-left: 4px solid var(--brand-cyan);
  background: #f8fcff;
}

.hardware-room-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.hardware-room-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hardware-room-header strong {
  color: #21384f;
  overflow-wrap: anywhere;
}

.hardware-room-header span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.hardware-room-list {
  display: grid;
  gap: 6px;
}

.package-item.hardware-parent-item {
  border-left: 4px solid var(--brand-blue);
}

.package-item.hardware-child-item {
  margin-left: calc(var(--hardware-depth, 1) * 18px);
  border-left: 4px solid #8dc2b0;
  background: #fbfefd;
}

.compact-item strong,
.package-item strong,
.route-card strong {
  overflow-wrap: anywhere;
}

.compact-item span,
.package-item span {
  color: var(--muted);
  font-size: 12px;
}

.status-banner {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #f0d3a8;
  color: #70440a;
  background: #fff8eb;
}

.route-diagram {
  min-height: 300px;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(36, 111, 86, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(49, 95, 156, 0.06) 1px, transparent 1px),
    #fff;
  background-size: 28px 28px;
  overflow: auto;
}

.route-empty,
.inspector-empty,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.trace-stack {
  display: grid;
  gap: 18px;
  min-width: max-content;
}

.trace-role-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.trace-role-label {
  width: 70px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid #ccd8e6;
  border-radius: 8px;
  background: #f8fbff;
  color: #31465e;
  font-size: 12px;
  font-weight: 780;
  text-align: center;
  text-transform: uppercase;
}

.trace-diagram {
  min-width: 860px;
  display: grid;
  gap: 14px;
}

.trace-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trace-summary-item {
  min-width: 120px;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid #d7e3ef;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.trace-summary-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.trace-summary-item strong {
  color: var(--text);
  font-size: 14px;
}

.trace-lane {
  min-height: 172px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid #cedceb;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(246, 250, 255, 0.92)),
    #fff;
}

.trace-node {
  flex: 0 0 210px;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #bfd2e7;
  border-radius: 8px;
  background: #f9fcff;
}

.trace-node-hardware {
  flex-basis: 240px;
  border-color: #d6c58b;
  background: #fff9e8;
}

.trace-node-mux {
  flex-basis: 240px;
  border-color: #8aa9d6;
  background: #f1f6ff;
}

.trace-node-bulkhead {
  border-color: #86b8d8;
  background: #edf8ff;
}

.trace-node-panel {
  border-color: #a9c5e4;
  background: #f4f9ff;
}

.trace-node-apc {
  border-color: #4c9a5f;
  background: #eef9f0;
}

.trace-node-upc {
  border-color: #4685c7;
  background: #eef6ff;
}

.trace-node-mm {
  border-color: #111827;
  background: #111827;
  color: #f8fafc;
}

.trace-node-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 1px solid #aebfce;
  border-radius: 8px;
  background: #eef3f8;
  color: #27394e;
  font-size: 10px;
  font-weight: 850;
}

.trace-node-hardware .trace-node-icon {
  border-color: #b79438;
  background: #ffe8a8;
  color: #60430a;
}

.trace-node-mux .trace-node-icon {
  border-color: #4f78b3;
  background: #dceaff;
  color: #24486f;
}

.trace-node-bulkhead .trace-node-icon {
  border-color: #1175a8;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.72) 0, rgba(255, 255, 255, 0.72) 3px, transparent 3px, transparent 7px),
    #c8ecff;
  color: #06415f;
}

.trace-node-panel .trace-node-icon {
  border-color: #5e96ce;
  background: #dbeeff;
  color: #123e68;
}

.trace-node-apc .trace-node-icon {
  border-color: #2f7d45;
  background: #d9f4df;
  color: #18562b;
}

.trace-node-upc .trace-node-icon {
  border-color: #2f6fab;
  background: #d9ecff;
  color: #174a78;
}

.trace-node-mm .trace-node-icon {
  border-color: #f8fafc;
  background: #111827;
  color: #f8fafc;
}

.trace-node-mm .trace-node-copy strong,
.trace-node-mm .trace-node-copy span {
  color: #f8fafc;
}

.trace-node-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.trace-node-copy strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.trace-node-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.trace-segment {
  min-width: 180px;
  display: grid;
  gap: 6px;
  align-self: stretch;
  align-content: center;
}

.trace-segment-top,
.trace-segment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #39516a;
  font-size: 11px;
}

.trace-segment-top strong {
  color: #1f364f;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.trace-segment-meta {
  justify-content: center;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.trace-track {
  position: relative;
  height: 56px;
}

.trace-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 26px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-cyan));
  box-shadow: 0 0 0 3px rgba(13, 99, 206, 0.08);
}

.trace-event {
  position: absolute;
  z-index: 2;
  width: 30px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid #9d7130;
  border-radius: 6px;
  background: #fff0cf;
  color: #65400d;
  font-size: 10px;
  font-weight: 850;
  transform: translateX(-50%);
  box-shadow: 0 3px 8px rgba(19, 32, 51, 0.12);
}

.trace-event::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 2px;
  height: 8px;
  background: currentColor;
  transform: translateX(-50%);
}

.trace-event-below::after {
  top: -8px;
  bottom: auto;
}

.trace-event-splice {
  border-color: #a45a12;
  background: #ffe0b8;
}

.trace-event-repair {
  border-color: #b64b4b;
  background: #ffe0e0;
  color: #7c2525;
}

.trace-event-slack-loop,
.trace-event-marker {
  border-color: #4d8c64;
  background: #e3f8e9;
  color: #245a35;
}

.trace-jumper {
  width: 118px;
  flex: 0 0 118px;
  display: grid;
  place-items: center;
  gap: 5px;
  align-content: center;
}

.trace-jumper-line {
  width: 100%;
  height: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      #85651d 0,
      #85651d 9px,
      transparent 9px,
      transparent 14px
    );
}

.trace-jumper span {
  color: #6a4309;
  font-size: 11px;
  font-weight: 760;
  text-align: center;
}

.trace-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.trace-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trace-legend-badge {
  min-width: 24px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid #bdcada;
  border-radius: 5px;
  background: #f7faff;
  color: #30445c;
  font-size: 9px;
  font-weight: 850;
}

.diagram-chain {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.diagram-stack {
  display: grid;
  gap: 16px;
  min-width: max-content;
}

.diagram-path-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.diagram-path-label {
  min-width: 64px;
  padding: 7px 9px;
  border: 1px solid #d3e0ee;
  border-radius: 8px;
  background: #fbfdff;
  color: #263b52;
  font-size: 12px;
  font-weight: 780;
  text-align: center;
  text-transform: uppercase;
}

.diagram-node {
  min-width: 220px;
  max-width: 320px;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #b8dbf2;
  border-radius: 8px;
  background: #eef8ff;
}

.diagram-node.is-hardware {
  border-color: #d7cfaa;
  background: #fff8df;
}

.diagram-node strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.diagram-node span {
  color: var(--muted);
  font-size: 12px;
}

.diagram-edge {
  min-width: 112px;
  display: grid;
  place-items: center;
  gap: 6px;
}

.diagram-line {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.diagram-jumper-edge {
  min-width: 150px;
}

.diagram-jumper-line {
  height: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      #8a6d1f 0,
      #8a6d1f 10px,
      transparent 10px,
      transparent 15px
    );
}

.diagram-edge.diagram-jumper-edge span {
  color: #6a4309;
}

.diagram-edge span {
  color: #2d435a;
  font-size: 12px;
  font-weight: 760;
}

.diagram-edge small {
  max-width: 160px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  overflow-wrap: anywhere;
}

.route-results {
  display: grid;
  gap: 12px;
}

.route-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(28, 37, 33, 0.04);
  text-align: left;
}

.route-card.is-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 111, 86, 0.12);
}

.route-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.route-card h3 {
  margin: 0;
  font-size: 16px;
}

.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  color: #24384f;
  background: #eef4fb;
  font-size: 12px;
  font-weight: 720;
}

.pill.good {
  color: #0d4d34;
  background: #e5f7ec;
}

.pill.blue {
  color: #084994;
  background: #e4f2ff;
}

.pill.warn {
  color: #6a4309;
  background: #fff0d4;
}

.route-legs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.leg-token {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #d3e0ee;
  border-radius: 8px;
  background: #fbfdff;
  color: #263b52;
  font-size: 12px;
  font-weight: 700;
}

.warning-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.warning-list.compact {
  margin-top: -2px;
}

.warning-item {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid #f0d3a8;
  border-radius: 8px;
  color: #70440a;
  background: #fff7e6;
  font-size: 12px;
  font-weight: 720;
}

.inspector-panel {
  font-size: 14px;
}

.inspector-detail {
  display: grid;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  overflow-wrap: anywhere;
}

.connector-event-list,
.jumper-list,
.budget-panel,
.assumption-list,
.transaction-list,
.circuit-jumper-panel,
.circuit-jumper-list,
.test-list,
.test-panel {
  display: grid;
  gap: 8px;
}

.hardware-port-panel {
  margin-top: 4px;
}

.hardware-port-controls,
.hardware-port-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hardware-port-controls select {
  flex: 1 1 220px;
  min-width: 0;
}

.hardware-port-editor {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.hardware-port-install {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.hardware-port-install .section-title {
  margin-bottom: 0;
}

.budget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.budget-grid {
  display: grid;
  gap: 8px;
}

.budget-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.budget-item span {
  color: var(--muted);
  font-size: 12px;
}

.budget-item strong {
  overflow-wrap: anywhere;
}

.connector-event-title {
  color: #263b52;
  font-size: 13px;
  font-weight: 780;
  text-transform: uppercase;
}

.connector-event {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.transaction-item,
.circuit-jumper-item,
.test-item {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.transaction-item span,
.circuit-jumper-item span,
.test-item span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.circuit-jumper-item.is-retired {
  opacity: 0.68;
}

.circuit-jumper-form {
  margin-top: 4px;
}

.circuit-hardware-form {
  margin-bottom: 10px;
}

.wdm-hardware-actions,
.circuit-hardware-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.test-form {
  margin-top: 4px;
}

.jumper-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.jumper-item.is-unresolved {
  border-color: #f0d3a8;
  background: #fffaf0;
}

.jumper-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.jumper-header strong,
.jumper-connectors {
  overflow-wrap: anywhere;
}

.jumper-connectors {
  color: #21364d;
  font-size: 13px;
  font-weight: 780;
}

.jumper-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.connector-event strong {
  font-size: 13px;
}

.connector-event span,
.assumption-list span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.assumption-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-top: 2px;
}

.strand-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 410px);
  overflow: auto;
}

.strand-group {
  display: grid;
  gap: 8px;
}

.strand-group-title {
  color: #263b52;
  font-size: 13px;
  font-weight: 780;
}

.strand-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.strand-table th,
.strand-table td {
  padding: 8px;
  border-bottom: 1px solid #e7eef7;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

.strand-table th {
  color: #344a63;
  background: #f2f7fc;
  font-weight: 780;
}

.strand-table tr:last-child td {
  border-bottom: 0;
}

.hardware-port-row {
  cursor: pointer;
}

.hardware-port-row:hover td,
.hardware-port-row.is-selected td {
  background: #eef6ff;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(260px, 320px) 1fr;
  }

  .lookup-shell {
    grid-template-columns: 1fr;
  }

  .inspector-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .lookup-detail {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .strand-list {
    max-height: 360px;
  }
}

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workflow-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .workflow-tab {
    flex: 1;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel,
  .inspector-panel {
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .form-grid,
  .metrics-grid,
  .hardware-add-grid,
  .model-grid,
  .plant-grid,
  .plant-browser-controls,
  .wdm-builder-grid,
  .wdm-channel-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .cable-event-row {
    grid-template-columns: 1fr;
  }

  .cable-slot-row {
    grid-template-columns: 1fr;
  }

  .cable-event-notes {
    grid-column: auto;
  }

  .route-settings {
    grid-template-columns: 1fr;
  }

  .search-row {
    grid-template-columns: 1fr;
  }
}
