/* Palette lifted directly from the reference prototype
   (copper_reclamation_dashboard_53.html) — same tokens, same values. */
:root {
  --bg: #0a0e14;
  --panel: #141c28;
  --panel-alt: #0f1620;
  --border: #1c2530;
  --border-strong: #232b36;
  --border-hover: #33404f;
  --text: #e6edf3;
  --text-dim: #c9d1d9;
  --muted: #9da7b3;
  --muted-2: #7d8590;
  --accent: #58a6ff;
  --accent-bright: #79b8ff;
  --accent-bg: #132030;
  --accent-btn: #1f6feb;
  --accent-btn-hover: #3081f5;
  --green: #3fb950;
  --green-bg: #123321;
  --red: #ff5c5c;
  --red-bg: #3a1414;
  --amber: #f2a93b;
  --amber-bg: #2a1f10;
  --purple: #a371f7;
  --bg-badge: var(--panel);
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

h1 { font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--text); }
h2 { font-size: 14.5px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 700; color: var(--text-dim); margin: 20px 0 8px; }
a { color: var(--accent); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel-alt);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar nav a {
  margin-left: 1.1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.topbar nav a:hover { color: var(--accent-bright); }
.topbar-user { margin-left: 1.1rem; color: var(--muted-2); font-size: 12px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 14px; }

.app-shell { display: flex; align-items: flex-start; }
.content { flex: 1 1 auto; min-width: 0; max-width: 1080px; margin: 0 auto; padding: 1.75rem 1.5rem; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.6; }

/* In-page section index -- sticky under the topbar on long pages */
.page-toc {
  position: sticky;
  top: 53px; /* topbar height */
  z-index: 15;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.page-toc a { color: var(--muted); text-decoration: none; font-weight: 600; }
.page-toc a:hover { color: var(--accent-bright); }
.page-toc a.back-to-top { margin-left: auto; }

/* Compact single-line candidate-pool rows */
.pool-row { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; padding: 3px 0; }
.pool-cable-id { font-weight: 600; color: var(--text); }
.pool-count { color: var(--muted); }

/* Results rendered inline under a clicked table row */
tr.inline-results-row > td { background: var(--panel-alt); padding: 1rem; }

.sticky-action-bar {
  position: sticky;
  bottom: 0;
  padding: 0.6rem 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
  z-index: 5;
}
.panes { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.pane {
  flex: 1 1 320px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 1.1rem;
}

form { display: flex; flex-direction: column; gap: 0.75rem; }
textarea { font-family: monospace; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 12px; color: var(--muted); }
/* Checkbox/radio labels use the opposite layout from value-input labels
   (input beside its text, not stacked above it) -- opt-in via this class
   rather than changing the shared `label` rule, so every existing
   text-input label elsewhere in the app is untouched. */
label.choice {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
label.choice input { flex: 0 0 auto; }

input, select, textarea {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12.5px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  background: var(--accent-btn);
  color: white;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}
button:hover { background: var(--accent-btn-hover); }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 12.5px; }
th, td { text-align: left; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(88, 166, 255, 0.06); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-badge);
  border: 1px solid var(--border-strong);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-high { background: var(--green-bg); color: var(--green); border-color: transparent; }
.badge-low { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.badge-none, .badge-unknown, .badge-failed { background: var(--red-bg); color: var(--red); border-color: transparent; }
.badge-success { background: var(--green-bg); color: var(--green); border-color: transparent; }
.badge-pending { background: var(--panel); color: var(--muted); }
.badge-partial { background: var(--amber-bg); color: var(--amber); border-color: transparent; }

.filters { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center; flex-wrap: wrap; }
.filters button {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-weight: 600;
  padding: 5px 12px;
}
.filters button:hover { border-color: var(--border-hover); color: var(--text-dim); background: var(--panel); }
.filters button.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-bright); }
.filters .filter-label { color: var(--muted-2); font-size: 11.5px; }
#result { margin-top: 1.5rem; }
.result-box {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 1rem;
}
.result-box.duplicate { border-color: var(--amber); }
pre.details {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 11.5px;
  color: var(--text-dim);
}
.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 1rem 0;
  font-size: 12.5px;
}
.detail-grid dt { color: var(--muted-2); }
.detail-grid dd { margin: 0; color: var(--text-dim); }

/* Pair Matrix */
.matrix-banner {
  border: 1px solid var(--amber);
  background: var(--amber-bg);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 12px;
  color: #e8c988;
}
.matrix-toolbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
}
.matrix-filter { display: flex; align-items: center; gap: 0.4rem; font-size: 13px; cursor: pointer; }
.matrix-legend { display: flex; align-items: center; gap: 0.4rem; font-size: 12px; color: var(--muted); }
.matrix-legend-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  margin-left: 0.6rem;
}
.matrix-legend-swatch:first-child { margin-left: 0; }
.msec {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
  width: 100%;
  background: var(--panel);
}
.msec-header {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.9rem;
  font-weight: 700;
  font-size: 13px;
}
.msec-count { font-weight: 400; color: var(--muted); font-size: 11px; }
.msec-hotspot-note { font-size: 10.5px; color: #ff8f8f; padding: 0.3rem 0.9rem 0; }
.msec-colhead {
  display: flex;
  align-items: flex-end;
  font-family: monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 0 6px 50px;
  height: 130px;
  color: var(--text-dim);
  overflow: hidden;
  background: var(--panel-alt);
}
/* Column codes (e.g. "MF0101A01") are too wide to fit horizontally once
   a section has more than a handful of columns spread across the full
   page width -- at any font size, real column widths get narrower than
   the text itself, which is what actually caused headers to visually
   overlap/misalign with the cells below them. Vertical text needs only
   the font's own line-box width per column (roughly constant regardless
   of code length), which is what the column width is already sized to. */
.msec-colhead .mh-col {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}
.msec-colhead .mh-col.branch-col { color: var(--amber); font-weight: 700; }
.msec-colhead .mh-col.hotspot-gap { animation: hotspot-flash-text 1.4s ease-in-out infinite; }
@keyframes hotspot-flash-text { 0%, 100% { color: inherit; } 50% { color: var(--red); } }
.msec canvas { display: block; }
.matrix-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 11.5px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.1s;
  max-width: 280px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.matrix-tooltip .tt-title { font-weight: 700; margin-bottom: 4px; font-size: 12.5px; }
.matrix-tooltip .tt-row { margin-top: 3px; color: var(--muted); }

/* Line Diagram edge hover box (graph_common.js showFloatingBox) */
.graph-floating-box {
  position: fixed;
  display: none;
  pointer-events: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  font-family: monospace;
  z-index: 1000;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.graph-floating-box .gfb-title { font-weight: 700; margin-bottom: 6px; font-size: 12.5px; font-family: Arial, sans-serif; }
.graph-floating-box .gfb-row { margin-top: 3px; color: var(--muted); }
.graph-floating-box .gfb-fid-row { margin-top: 2px; padding-left: 8px; }
.graph-floating-box .gfb-fid-free { color: #3fb950; }
.graph-floating-box .gfb-fid-none { color: var(--muted-2); }

/* Line Diagram + Investigate */
.stat-grid { display: flex; gap: 0.9rem; margin: 1rem 0; flex-wrap: wrap; }
.stat, .inv-stat {
  min-width: 110px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 16px;
}
.stat .n, .inv-stat .n { font-size: 20px; font-weight: 700; color: var(--text); }
.stat .l, .inv-stat .l { font-size: 10px; color: var(--muted-2); margin-top: 2px; }
.canvas-scroll {
  height: 640px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  margin: 1rem 0;
  background: var(--bg);
}
.canvas-outer { position: relative; }
#unplaced-terminals-box {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: #141c28ee;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 11px;
  max-width: 340px;
  color: var(--muted);
  line-height: 1.5;
  z-index: 5;
}
#unplaced-terminals-box b { color: var(--purple); display: block; margin-bottom: 5px; font-size: 11.5px; }
#unplaced-terminals-box .term-row { display: flex; justify-content: space-between; gap: 8px; padding: 0; }
#unplaced-terminals-box .flag-row { color: var(--red); font-weight: 600; }
#unplaced-terminals-box .box-note { margin-top: 6px; color: var(--muted-2); font-size: 10px; }
/* Same visual language as #unplaced-terminals-box, but normal document flow
   (below the map canvas) instead of absolutely overlaying it. */
#line-map-unmapped-box {
  background: #141c28ee;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 13px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}
#line-map-unmapped-box b { color: var(--purple); display: block; margin-bottom: 5px; font-size: 11.5px; }
#line-map-unmapped-box .term-row { display: flex; justify-content: space-between; gap: 8px; padding: 0; }
#line-map-unmapped-box .box-note { margin-top: 6px; color: var(--muted-2); font-size: 10px; }
.origin-note {
  font-size: 11.5px;
  color: var(--accent-bright);
  padding: 0.5rem 0.8rem;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 0.6rem;
}
.term-row { font-size: 11.5px; padding: 0.2rem 0; color: var(--muted); }
.term-row-active { color: var(--red); font-weight: 600; }
.term-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 0.75rem 0; }
.term-card {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
}
.term-card .addr { font-weight: 600; font-size: 12px; color: var(--text); margin-bottom: 3px; }
.term-card .cnt { font-size: 11px; color: var(--muted-2); }
.chain-block { margin-bottom: 1.5rem; }
.chain-title { font-weight: 700; font-size: 13.5px; margin-bottom: 0.4rem; color: var(--text); }
.chain-warning {
  color: #ff9d4d;
  background: var(--amber-bg);
  border: 1px solid #5c4520;
  border-radius: 6px;
  font-size: 11px;
  padding: 8px 10px;
  margin: 0.5rem 0;
}
.chain-row { display: flex; gap: 4px; overflow-x: auto; padding: 8px 4px 16px; }
.hop-box {
  flex: 0 0 auto;
  min-width: 78px;
  border-radius: 7px;
  padding: 7px 8px;
  font-size: 9.5px;
  line-height: 1.4;
  text-align: center;
  border: 1.5px solid;
}
.hop-box.ok { background: #0f2318; border-color: #2b6b3f; color: #8fd6a3; }
.hop-box.not-applicable { background: #1a1f28; border-color: #3a4452; color: #9da7b3; }
.hop-box.ambiguous { border-color: #f2a93b; }

/* Cable detail: weight/value + threshold verdict cards (ported from the
   reference prototype's .weight-card/.threshold-card) */
.weight-card { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 16px 18px; }
.weight-card .wc-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.weight-card .wc-chip { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); }
.weight-card .wc-big { font-size: 26px; font-weight: 700; color: var(--text); }
.weight-card .wc-sub { font-size: 11px; color: var(--muted-2); margin-bottom: 12px; }
.weight-card .wc-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); padding: 4px 0; border-top: 1px solid var(--border); }
.weight-card .wc-row b { color: var(--text); font-weight: 600; }
.weight-card .wc-unrouted { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #3a4452; font-size: 11px; color: #ff9d4d; }
.weight-card .wc-value { font-size: 18px; font-weight: 700; color: var(--green); margin-top: 6px; }
.weight-card .wc-value-note { font-size: 10.5px; font-weight: 400; color: var(--muted-2); }
.weight-card .wc-value-spot { font-size: 11px; color: var(--muted-2); margin-bottom: 12px; }

.threshold-card { display: flex; align-items: center; gap: 18px; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 16px 20px; margin-bottom: 10px; }
.threshold-card .tc-num { font-size: 30px; font-weight: 800; }
.threshold-card .tc-label { font-size: 11px; color: var(--muted-2); }
.threshold-card .tc-verdict { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 6px; margin-left: auto; }
.threshold-card.retain .tc-verdict { background: var(--green-bg); color: var(--green); }
.threshold-card.remove .tc-verdict { background: var(--red-bg); color: var(--red); }
.threshold-card.unknown .tc-verdict { background: var(--amber-bg); color: var(--amber); }

/* Financial report -- generate/review/export from a saved reassignment
   scenario (replaces the Phase 14 fb-card cross-check, which wrongly
   treated an uploaded workbook as a reference to validate against). */
.fb-report-table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.fb-report-table th, .fb-report-table td { padding: 6px 10px; font-size: 12px; border-bottom: 1px solid var(--border); text-align: right; }
.fb-report-table th:first-child, .fb-report-table td:first-child { text-align: left; }
.fb-report-table thead th { color: var(--muted-2); font-weight: 600; font-size: 11px; }
.fb-report-table input[type="number"] { width: 90px; background: var(--panel-alt); border: 1px solid var(--border-strong); border-radius: 6px; color: var(--text); padding: 3px 6px; font-size: 12px; text-align: right; }
.fb-report-subtotal td { font-weight: 700; color: var(--text); border-top: 1px solid var(--border-strong); }
.fb-report-actions { margin-top: 0.75rem; display: flex; gap: 0.6rem; }

@media print {
  body * { visibility: hidden; }
  .fb-report-print, .fb-report-print * { visibility: visible; }
  .fb-report-print { position: absolute; top: 0; left: 0; width: 100%; }
  .fb-report-actions, .topbar, .page-toc { display: none !important; }
}

/* Status-weight breakdown bar (Phase 13) */
.status-weight-bar { display: flex; height: 36px; border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.status-weight-bar div { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--bg); }
.status-weight-legend { display: flex; gap: 1rem; font-size: 10.5px; color: var(--muted); margin-bottom: 1rem; }
.status-weight-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sw-active { background: var(--red); }
.sw-reclaimable { background: var(--green); }
.sw-unconfirmed { background: #8fa3c8; }
.sw-unrouted { background: var(--amber); }
.status-weight-legend .sw-active::before { background: var(--red); }
.status-weight-legend .sw-reclaimable::before { background: var(--green); }
.status-weight-legend .sw-unconfirmed::before { background: #8fa3c8; }
.status-weight-legend .sw-unrouted::before { background: var(--amber); }

/* Files list: collapsible file-card accordion (ported from the reference
   prototype's .file-card) */
.file-card { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.file-card-header { padding: 14px 18px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.file-card-header:hover { background: #171f2c; }
.file-card-title { font-size: 13.5px; font-weight: 700; color: var(--text); font-family: monospace; }
.file-card-meta { font-size: 10.5px; color: var(--muted-2); margin-top: 3px; font-family: inherit; font-weight: 400; }
.file-card-chevron { color: var(--muted-2); font-size: 14px; transition: transform 0.15s; flex-shrink: 0; }
.file-card.open .file-card-chevron { transform: rotate(90deg); }
.file-card-body { display: none; padding: 0 18px 18px; }
.file-card.open .file-card-body { display: block; }
.file-card-findings, .file-card-gaps { margin: 0.4rem 0; padding-left: 1.1rem; font-size: 11.5px; }
.file-card-findings li { color: var(--green); }
.file-card-gaps li { color: var(--amber); }

/* Investigate: confirmed-used pill (ported from the reference prototype's
   .inv-badge) */
.inv-badge { font-size: 9.5px; padding: 2px 7px; border-radius: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.inv-badge.ok { background: var(--green-bg); color: var(--green); }
.inv-badge.gap { background: var(--red-bg); color: var(--red); }

/* Notes tab (Phase 15, ported from the reference prototype) */
.note-filters { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.note-filters .chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.note-filters .chip:hover { border-color: var(--border-hover); color: var(--text-dim); }
.note-filters .chip.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent-bright); }
.note-card { background: var(--panel); border: 1px solid var(--border); border-left-width: 3px; border-radius: 6px; padding: 9px 11px; margin-bottom: 9px; }
.note-card .tag { font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; margin-bottom: 4px; display: inline-block; }
.note-card .ttl { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.note-card .bd { font-size: 11px; color: var(--muted); line-height: 1.5; white-space: pre-wrap; }
.note-card.gotcha { border-left-color: var(--red); }
.note-card.gotcha .tag { color: var(--red); }
.note-card.open { border-left-color: var(--amber); }
.note-card.open .tag { color: var(--amber); }
.note-card.design { border-left-color: var(--purple); }
.note-card.design .tag { color: var(--purple); }
.note-card.confirmed { border-left-color: var(--green); }
.note-card.confirmed .tag { color: var(--green); }
.note-card.custom { border-left-color: var(--accent); }
.note-card.custom .tag { color: var(--accent); }
.note-card .note-actions { display: flex; gap: 6px; }
.note-card .note-actions button { padding: 2px 8px; font-size: 10.5px; }
#addnote { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 1rem; margin-top: 1.5rem; }
.note-hint { font-size: 10.5px; color: var(--muted-2); margin-top: 6px; }
.hop-box.gap {
  background: #2a1212;
  border-color: #8a2f2f;
  color: #ff9d9d;
  animation: pulse-hotspot 2s ease-in-out infinite;
}
@keyframes pulse-hotspot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(255, 92, 92, 0); }
}

/* Reassignment path comparison page -- move stepper + current/proposed
   side-by-side panels (Phase 1 of the reassignment-review workflow). */
.cmp-stepper { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; }
.cmp-stepper select { margin-left: auto; }
.cmp-body { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.cmp-panel { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 14px 16px; }
.cmp-panel h3 { margin-top: 0; font-size: 13px; }
/* 3-column grid so ~10 segment facts (tier counts + material/capacity/
   gauge/length/weight/routing) take ~4 rows instead of 10 -- keeps the
   diagram above it visible without scrolling past a long single column. */
.reason-card { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 20px; margin-top: 0.75rem; }
.reason-row { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); padding: 4px 0; border-top: 1px solid var(--border); }
.reason-row b { color: var(--text); font-weight: 600; }
.reason-row:first-child { border-top: none; }
.reason-card .reason-row:nth-child(-n+3) { border-top: none; }
.cmp-panel-right .reason-card { margin-bottom: 1rem; }
.cmp-cable-block { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-strong); }
.cmp-cable-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.cmp-cable-block h4 { margin: 0 0 0.5rem; font-size: 12.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.cmp-pairs-table td { vertical-align: top; }
.cmp-pairs-table summary { cursor: pointer; color: var(--text-dim); font-size: 12px; }
.cmp-pairs-table details[open] summary { margin-bottom: 6px; }

.vote-controls { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.vote-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 6px;
  background: var(--bg-badge);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  cursor: pointer;
  margin-right: 4px;
}
.vote-btn svg { display: block; }
.vote-btn:hover { border-color: var(--muted); color: var(--text); }
.vote-up.vote-btn-active { background: var(--green-bg); color: var(--green); border-color: transparent; }
.vote-down.vote-btn-active { background: var(--red-bg); color: var(--red); border-color: transparent; }
.vote-reason-display { font-size: 11px; color: var(--muted); display: block; margin-top: 4px; }
.vote-reason-box { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.vote-reason-input { width: 100%; min-height: 50px; font-size: 11.5px; padding: 4px 6px; background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); border-radius: 6px; }
.vote-reason-submit { align-self: flex-start; }

/* Reassignment full plan diagram, Line Diagram Combined view, Compare stepper --
   all three share this layout via graph_common.js's mountSvgGraph()/wirePanZoom(). */
.diagram-layout { display: flex; gap: 12px; margin-top: 0.5rem; align-items: flex-start; }
.diagram-canvas-outer {
  flex: 1 1 auto;
  min-width: 0;
  height: 75vh;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #0b0f19;
  /* Real scrollbars, not a CSS transform forcing everything to shrink to
     fit -- the graph renders at its true pixel size (see mountSvgGraph's
     <svg width/height>) and anything past this box's own fixed size is a
     genuine horizontal/vertical scroll, never a zoomed-out miniature. */
  overflow: auto;
  position: relative;
}
/* wrap is sized to its own content (the SVG's real pixel width/height,
   not "100%") so outer's overflow:auto has something to scroll around. */
.diagram-canvas-wrap svg { display: block; }
/* The page's normal max-width:1080px reading column (see .content above)
   is far too narrow for a pannable/zoomable diagram -- let these three
   pages use the full window width instead. */
.content:has(.diagram-layout) { max-width: none; }

/* Popout mode ("Pop out" button -> popOutWindow() appends ?popout=1, read
   by base.html before paint) -- the popped-out window shows just the
   graph canvas, full-viewport, none of the page's nav bar, dashboard
   sidebar, filters, hints, or terminal-outline sidebar. Each diagram page
   marks its own non-canvas markup with .page-chrome for this to hide. */
.popout-mode .topbar,
.popout-mode .page-chrome,
.popout-mode .diagram-sidebar {
  display: none !important;
}
.popout-mode .content { padding: 0; max-width: none; }
.popout-mode .diagram-layout { margin-top: 0; height: 100vh; }
.popout-mode .diagram-canvas-outer { height: 100vh; border: none; border-radius: 0; }
/* Line Diagram's cable toggle is deliberately kept outside .page-chrome
   (see line_diagram.html) so it still works in a popped-out window --
   give it a little breathing room instead of sitting flush against the
   window edge, and shrink the canvas by roughly that same amount so the
   page itself doesn't gain a scrollbar underneath the canvas's own one. */
.popout-mode #combined-cable-filter {
  padding: 10px 14px 0;
  margin-bottom: 0;
}
.popout-mode #combined-cable-filter:has(button) ~ .diagram-layout .diagram-canvas-outer {
  height: calc(100vh - 46px);
}
.popout-mode .cmp-body { display: block; }
.popout-mode .cmp-panel-left { padding: 0; border: none; background: transparent; }

.diagram-sidebar {
  flex: 0 0 280px;
  height: 75vh;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px;
}
.diagram-sidebar-title { font-size: 11px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.diagram-box { cursor: move; }
.diagram-box-dragging rect { stroke-width: 2.2; }
.diagram-term-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.diagram-term-row:hover { background: var(--panel-alt); border-color: var(--border-strong); }
.diagram-term-row.diagram-match { border-color: var(--amber); background: var(--amber-bg); }
.diagram-term-row .t-label { font-weight: 600; font-size: 12px; color: var(--text); }
.diagram-term-row .t-meta { font-size: 10.5px; color: var(--muted-2); }
.diagram-section-label { font-size: 10.5px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; margin: 10px 0 4px; letter-spacing: 0.04em; }
.diagram-highlight { fill: #fde047 !important; font-weight: 700; }

.doc-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.doc-list li { border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; background: var(--panel); }
.doc-list a { font-weight: 600; font-size: 13.5px; }
.doc-list p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.doc-page { max-width: 760px; margin-top: 12px; line-height: 1.7; }
.doc-page h2 { margin-top: 24px; }
.doc-page code { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-size: 12px; }
.doc-page ul, .doc-page ol { padding-left: 20px; }
