/* Topology page specific styles */

body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; margin: 0; }

/* ── Sticky chrome wrapper ──────────────────────────────────────────
   .top-bar pins page-header + filter card at the top of the viewport.
   Class name preserved (referenced by style.css chrome-collapse rules
   + topology.js click-outside guards). */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(15,23,42,0.08);
}

/* ── Page header (parity with settings.html) ────────────────────────
   Same class names, same DOM order: .back · h1 · .build-chip ·
   .user-chip · .btn-logout. Variables resolve to the LIGHT theme
   defined in style.css :root (settings.html overrides them inline for
   its dark theme — same structural CSS, page-appropriate palette). */
.page-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.page-header .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.page-header .back:hover { background: #f1f5f9; color: var(--text); }
.page-header h1 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header .user-chip { font-size: 13px; color: var(--text-muted); }
.page-header .build-chip {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
  opacity: 0.75;
}
/* Settings cog icon (matches index.html .hdr-icon look) */
.page-header .hdr-icon {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--text-muted);
  background: transparent;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}
.page-header .hdr-icon:hover, .page-header .hdr-icon:focus-visible {
  background: #f1f5f9; color: var(--accent); outline: none;
}
.page-header .hdr-icon:active { transform: scale(0.92); }
.page-header .hdr-gear svg {
  animation: topo-hdr-gear-idle 14s linear infinite;
  transform-origin: 50% 50%;
}
.page-header .hdr-gear:hover svg, .page-header .hdr-gear:focus-visible svg {
  animation: topo-hdr-gear-spin 1.4s linear infinite;
}
@keyframes topo-hdr-gear-idle { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes topo-hdr-gear-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
/* Logout button — ambient red breathing + tilt-shake on hover, mirrors
   settings.html .btn-logout pattern. */
.page-header .btn-logout {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background 0.18s, color 0.18s, transform 0.18s;
  animation: topo-logout-breathe 4s ease-in-out infinite;
}
.page-header .btn-logout svg {
  width: 20px; height: 20px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 50% 55%;
}
.page-header .btn-logout::before {
  content: ''; position: absolute; inset: 4px;
  border-radius: 10px;
  background: radial-gradient(closest-side, rgba(239,68,68,0.32), transparent 75%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.page-header .btn-logout:hover, .page-header .btn-logout:focus-visible {
  background: rgba(239,68,68,0.10); color: #ef4444; animation: none; outline: none;
}
.page-header .btn-logout:hover::before, .page-header .btn-logout:focus-visible::before { opacity: 1; }
.page-header .btn-logout:hover svg, .page-header .btn-logout:focus-visible svg {
  animation: topo-logout-shake 0.6s ease-in-out;
}
.page-header .btn-logout:active { transform: scale(0.92); }
@keyframes topo-logout-breathe {
  0%, 100% { color: var(--text-muted); }
  50%      { color: rgba(239,68,68,0.78); }
}
@keyframes topo-logout-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20%      { transform: translateX(2px) rotate(6deg); }
  40%      { transform: translateX(-2px) rotate(-4deg); }
  60%      { transform: translateX(1px) rotate(3deg); }
  80%      { transform: translateX(-1px) rotate(-2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .page-header .btn-logout, .page-header .btn-logout:hover svg,
  .page-header .hdr-gear svg, .page-header .hdr-gear:hover svg { animation: none; }
}

/* ── Card pattern (parity with settings.html section.card) ──────────
   Same structure: rounded outer + optional <header> + <div class="body">.
   Used for the controls panel and the canvas wrapper. */
section.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
section.card > header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
section.card > header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
section.card > .body { padding: 16px 20px; }

/* ── Controls card overrides ───────────────────────────────────────
   The controls section uses class="card controls" so chrome-collapse
   selectors (style.css `body.chrome-collapsed .controls`) keep working.
   Below we override style.css's .controls structural rules (which were
   designed for the rack dashboard) so the card visual wins. */
.top-bar > section.card.controls {
  margin: 10px 12px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  /* Reset rack-dashboard inheritance: */
  padding: 0;
  border-bottom: 1px solid var(--border);
  display: block;
}
.top-bar > section.card.controls > .body {
  padding: 10px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.top-bar > section.card.controls > .body > * + * { margin-top: 0; }

/* ── Main + canvas card ────────────────────────────────────────────
   <main class="topology"> fills remaining viewport; canvas card
   stretches to fill; .topology-main + .topology-wrap classes preserved
   (referenced by topology.js viewport math + banner injection). */
main.topology {
  flex: 1;
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
main.topology > section.card.card-canvas {
  flex: 1;
  min-height: 320px;
  overflow: hidden;
  background: var(--bg-card);
}
main.topology > section.card.card-canvas > .topology-main {
  height: 100%;
  position: relative;
  overflow: hidden;
}

.search-wrap {
  position: relative;
  flex: 1 1 280px;
  min-width: 240px;
  max-width: 460px;
}
.search-wrap input {
  width: 100%;
  padding: 7px 32px 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  font-family: var(--font-sans, -apple-system, sans-serif);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
#topo-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: #f1f5f9;
  border: none;
  color: #64748b;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}
#topo-search-clear:hover { background: #fde68a; color: #78350f; }

#topo-recenter {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 18px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  font-weight: 700;
}
#topo-recenter:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: rotate(180deg);
}
#topo-recenter:active {
  transform: rotate(360deg);
}

/* Zoom controls */
.zoom-controls {
  display: inline-flex;
  align-items: stretch;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.zoom-controls button {
  background: white;
  border: none;
  padding: 0 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  transition: background 0.15s;
  border-right: 1px solid var(--border);
  min-width: 30px;
}
.zoom-controls button:last-child { border-right: none; }
.zoom-controls button:hover { background: #eff6ff; color: var(--accent); }
.zoom-controls button:active { background: var(--accent); color: white; }
#topo-zoom-level {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 56px;
  cursor: pointer;
}
#topo-zoom-level:hover { background: #fef3c7; color: #78350f; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

/* .topology-main height is handled by the flex layout above
   (main.topology > .card-canvas > .topology-main fills remaining
   viewport). The legacy `height: calc(100vh - 180px)` was removed
   because the new card structure no longer pins a known offset. */
.topology-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: linear-gradient(#f8fafc 1px, transparent 1px) 0 0 / 20px 20px,
              linear-gradient(90deg, #f8fafc 1px, transparent 1px) 0 0 / 20px 20px,
              #ffffff;
}
#topology-svg {
  display: block;
  min-width: 100%;
  min-height: 100%;
}

/* SVG rack node */
.rack-node rect {
  fill: white;
  stroke: #305496;
  stroke-width: 1.5;
  rx: 6;
  filter: drop-shadow(0 1px 2px rgba(15,23,42,0.1));
  transition: stroke 0.15s, stroke-width 0.15s;
}
.rack-node:hover rect {
  stroke-width: 3;
  stroke: #2563eb;
  cursor: pointer;
}
.rack-node.dimmed rect { opacity: 0.25; }
.rack-node.highlight rect { stroke: #f59e0b; stroke-width: 3; }
/* Search match / fade */
.rack-node.search-match rect {
  stroke: #f59e0b;
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.7));
}
.rack-node.search-match text.rack-id { fill: #b45309; }
.rack-node.search-fade { opacity: 0.22; }
.rack-node.search-fade:hover { opacity: 0.7; }

.rack-node text.rack-id {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 10.5px;
  font-weight: 700;
  fill: #0f172a;
  text-anchor: middle;
  dominant-baseline: text-before-edge;
  pointer-events: none;
}
.rack-node text.rack-desc {
  font-family: -apple-system, 'Segoe UI', sans-serif;
  font-size: 8.5px;
  fill: #64748b;
  text-anchor: middle;
  dominant-baseline: text-before-edge;
  pointer-events: none;
}
.rack-node[data-system="OPS"] rect { stroke: #2563eb; }
.rack-node[data-system="CYB"] rect { stroke: #dc2626; }
.rack-node[data-system="BCK"] rect { stroke: #9333ea; }
.rack-node[data-system="SIM"] rect { stroke: #ea580c; fill: #fff7ed; }
.rack-node[data-system="TEST"] rect { stroke: #64748b; fill: #f1f5f9; stroke-dasharray: 4 2; }
.rack-node[data-system="OPS/BCK"] rect { stroke: #1e40af; }
.rack-node[data-external] rect { fill: #fef3c7; stroke: #d97706; stroke-dasharray: 3 3; }
.rack-node[data-category="wan_remote"] rect { fill: #ede9fe; stroke: #6d28d9; stroke-width: 2; }
.rack-node[data-category="wan_atcc"] rect { fill: #dbeafe; stroke: #1d4ed8; stroke-width: 2; }
.rack-node[data-category="wan_core"] rect { fill: #fef3c7; stroke: #b45309; stroke-width: 2; }
.rack-node[data-system="WAN"] text.rack-id { font-size: 10px; }

.tier-bg.tier-wan { fill: rgba(237, 233, 254, 0.4); stroke: #a78bfa; }
.rack-node.focused rect { stroke: #f59e0b; stroke-width: 3; fill: #fef3c7; }

.conn-badge rect { rx: 7; ry: 7; stroke: none; }
.conn-badge text { font-family: -apple-system, sans-serif; font-size: 9px; font-weight: 700; fill: white; pointer-events: none; }
.conn-badge.net rect { fill: #2563eb; }
.conn-badge.sig rect { fill: #be185d; }
.conn-badge.voi rect { fill: #7c3aed; }

/* Focus banner */
#focus-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.97);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  font-family: -apple-system, sans-serif;
  /* v1.11.2 — z-index bumped from 20 to 210 so banner sits ABOVE the ☰
     FAB (z:200) even in edge cases where `.hidden-by-focus` fails to
     apply. Banner itself has a ✕ close button so user can always
     dismiss it regardless of FAB state. */
  z-index: 210;
  max-width: 90%;
  min-width: 500px;
  transition: box-shadow 0.15s;
}
#focus-banner.dragged {
  /* When user has dragged, left/top are set inline — no centering transform */
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}
#focus-banner.dragging {
  transition: none;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  cursor: grabbing !important;
}
#focus-banner.dragging .fb-head { cursor: grabbing; }
#focus-banner .fb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: grab;
  user-select: none;
}
#focus-banner .fb-head-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#focus-banner .fb-drag-handle {
  color: #64748b;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -4px;
  padding: 0 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}
#focus-banner .fb-head:hover .fb-drag-handle { color: #fbbf24; }
#focus-banner .fb-reset-pos {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  color: #cbd5e1;
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
#focus-banner .fb-reset-pos:hover {
  background: rgba(251,191,36,0.18);
  color: #fbbf24;
  border-color: rgba(251,191,36,0.4);
}
#focus-banner .fb-title {
  font-size: 14px;
  font-weight: 700;
  color: #fbbf24;
  font-family: 'SF Mono', Menlo, monospace;
}
#focus-banner .fb-stats {
  font-size: 11px;
  color: #cbd5e1;
  margin-left: 12px;
}
#focus-banner .fb-close {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
#focus-banner .fb-close:hover { background: rgba(255,255,255,0.2); }
#focus-banner .fb-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 16px;
  margin-top: 10px;
  max-height: 62vh;
  overflow-y: auto;
}
#focus-banner .fb-col h4 {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}
#focus-banner .fb-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 11px;
  line-height: 1.45;
}
#focus-banner .fb-col li { padding: 2px 0; }
#focus-banner .fb-col li.empty { color: #64748b; font-style: italic; }

/* Tier labels */
.tier-label {
  font-family: -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 700;
  fill: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.tier-bg {
  fill: rgba(226, 232, 240, 0.35);
  stroke: #cbd5e1;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  rx: 6;
}

/* Edges */
.edge {
  fill: none;
  opacity: 0.55;
  transition: opacity 0.15s, stroke-width 0.15s;
}
.edge:hover { opacity: 1; stroke-width: 3; }
.edge.dimmed { opacity: 0.06; }
.edge.highlight { opacity: 1; stroke-width: 3; }
.edge[data-cable-type="fiber"][data-cable-kind="network"] { stroke: #2563eb; stroke-width: 1.4; }
.edge[data-cable-type="fiber"][data-cable-kind="signal"]  { stroke: #be185d; stroke-width: 1.4; }
.edge[data-cable-type="fiber"][data-cable-kind="voice"]   { stroke: #7c3aed; stroke-width: 1.2; stroke-dasharray: 5 3; }
.edge[data-cable-type="kvm_fiber"] { stroke: #eab308; stroke-width: 1.6; }
.edge[data-cable-type="serial"]    { stroke: #ea580c; stroke-width: 1.4; stroke-dasharray: 2 2; }
.edge[data-cable-type="coax"]      { stroke: #0891b2; stroke-width: 1.6; stroke-dasharray: 6 2; }
.edge[data-cable-type="copper"]    { stroke: #059669; stroke-width: 1.4; stroke-dasharray: 4 2; }

/* Tooltip */
.tooltip {
  position: absolute;
  background: rgba(15,23,42,0.96);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-family: -apple-system, sans-serif;
  pointer-events: none;
  z-index: 100;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  line-height: 1.5;
}
.tooltip .t-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  color: #fbbf24;
}
.tooltip .t-row {
  font-size: 11px;
  opacity: 0.9;
}
.tooltip .t-row .lbl { color: #94a3b8; min-width: 70px; display: inline-block; }

.legend-item .swatch.dashed {
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
}

/* Tooltip — equipment preview */
.tooltip .tip-eq-head {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-weight: 700;
  color: #fbbf24;
  font-size: 11px;
}
.tooltip .tip-eq-list { margin-top: 4px; max-height: 180px; overflow-y: auto; }
.tooltip .tip-eq-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 10.5px;
}
.tooltip .tip-eq-row code {
  background: rgba(255,255,255,0.12);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, monospace;
  color: #fbbf24;
  font-size: 10px;
  font-weight: 600;
}
.tooltip .tip-eq-desc { flex: 1; color: #cbd5e1; }
.tooltip .tip-prm, .tooltip .tip-ip, .tooltip .tip-host {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  font-family: monospace;
  font-weight: 600;
}
.tooltip .tip-prm  { background: #fbbf24; color: #78350f; }
.tooltip .tip-ip   { background: #60a5fa; color: #0f172a; }
.tooltip .tip-host { background: #fef3c7; color: #78350f; }
.tooltip .tip-eq-more { font-size: 9px; font-style: italic; color: #94a3b8; margin-top: 4px; padding-top: 4px; border-top: 1px dashed rgba(255,255,255,0.1); }

/* Focus banner — structured edge cards (1 card per cable) */
#focus-banner .fb-edge-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
#focus-banner .fb-edge-card {
  padding: 6px 8px;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--cable-color, #64748b);
  border-radius: 4px;
  font-size: 10.5px;
  transition: background 0.15s;
}
#focus-banner .fb-edge-card:hover { background: rgba(255,255,255,0.08); }
#focus-banner .fb-edge-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
#focus-banner .fb-edge-arrow {
  font-size: 13px;
  color: var(--cable-color);
  font-weight: 700;
  flex-shrink: 0;
}
#focus-banner .fb-edge-endpoint {
  font-family: 'SF Mono', Menlo, monospace;
  font-weight: 700;
  color: #fbbf24;
  cursor: pointer;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(251,191,36,0.1);
  transition: background 0.15s;
  font-size: 11px;
}
#focus-banner .fb-edge-endpoint:hover { background: rgba(251,191,36,0.3); }
#focus-banner .fb-edge-type {
  font-size: 9px;
  font-weight: 700;
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
#focus-banner .fb-edge-side {
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.05em;
}
#focus-banner .fb-side-main   { background: #2563eb; color: white; }
#focus-banner .fb-side-backup { background: #7c3aed; color: white; }
#focus-banner .fb-edge-pos {
  background: #be185d;
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}
#focus-banner .fb-edge-pos:hover { background: #9f1239; }
#focus-banner .fb-edge-note {
  color: #e2e8f0;
  font-size: 10px;
  margin: 2px 0;
}
#focus-banner .fb-edge-detail {
  color: #94a3b8;
  font-style: italic;
}
#focus-banner .fb-edge-foms {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  margin: 3px 0;
  font-size: 10px;
}
#focus-banner .fb-edge-foms-label {
  font-weight: 700;
  color: #fbbf24;
  font-size: 9px;
  font-family: 'SF Mono', Menlo, monospace;
}
#focus-banner .fb-fom-chip {
  background: #fbbf24;
  color: #78350f;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
}
#focus-banner .fb-fom-chip:hover {
  background: #fde68a;
  box-shadow: 0 0 0 2px rgba(251,191,36,0.5);
}
#focus-banner .fb-edge-spec {
  color: #94a3b8;
  font-size: 9.5px;
  font-style: italic;
  font-family: 'SF Mono', Menlo, monospace;
}
#focus-banner .fb-edge-empty {
  color: #64748b;
  font-style: italic;
  font-size: 10px;
  padding: 6px 8px;
}

/* Focus banner — equipment + positions detail */
#focus-banner .fb-col-wide { grid-column: 1 / -1; }
#focus-banner .fb-sub-stats {
  font-size: 10px;
  color: #cbd5e1;
  font-weight: 500;
  font-style: italic;
  margin-left: 6px;
}
#focus-banner .fb-eq-list {
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
#focus-banner .fb-eq-row, #focus-banner .fb-eq-list li {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 3px;
  font-size: 10.5px;
  align-items: center;
}
#focus-banner .fb-eq-row:nth-child(even),
#focus-banner .fb-eq-list li:nth-child(even) { background: rgba(255,255,255,0.03); }
#focus-banner .fb-eq-row:hover,
#focus-banner .fb-eq-list li:hover { background: rgba(251,191,36,0.12); }
#focus-banner code.fb-eq-id {
  background: rgba(255,255,255,0.12);
  color: #fbbf24;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, monospace;
  font-weight: 700;
  text-align: left;
}
#focus-banner .fb-eq-list li code {
  background: rgba(255,255,255,0.1);
  color: #fbbf24;
  padding: 1px 4px;
  border-radius: 2px;
  font-family: 'SF Mono', Menlo, monospace;
}
#focus-banner .fb-eq-desc {
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#focus-banner .fb-eq-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
}
#focus-banner .fb-eq-badges span {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 2px;
  font-family: 'SF Mono', Menlo, monospace;
  font-weight: 600;
}
#focus-banner .fb-ref { background: rgba(255,255,255,0.12); color: #cbd5e1; }
#focus-banner .fb-mfr { background: rgba(255,255,255,0.08); color: #94a3b8; font-style: italic; }
#focus-banner .fb-sn  { background: rgba(100,116,139,0.35); color: #e2e8f0; }
#focus-banner .fb-prm { background: #fbbf24; color: #78350f; }
#focus-banner .fb-ip  { background: #60a5fa; color: #0f172a; }
#focus-banner .fb-host { background: #fef3c7; color: #78350f; font-weight: 700; }

/* Neptuno block in focus banner */
#focus-banner .fb-nep {
  background: linear-gradient(180deg, rgba(192, 132, 252, 0.08), rgba(168, 85, 247, 0.05));
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 3px solid #a855f7;
}
#focus-banner .fb-nep-iface { color: #e9d5ff; }

/* ── Mobile page-header parity with settings.html ─────────────────
   Same breakpoint (520px), same padding shrink, same chip downsizing,
   so rack-dashboard ↔ topology ↔ settings feel identical at every
   viewport width. */
@media (max-width: 520px) {
  .page-header { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; gap: 10px; }
  .page-header h1 { font-size: 15px; }
  .page-header .user-chip { display: none; }
  .page-header .build-chip { font-size: 10px; padding: 2px 6px; }
  main.topology { padding: 0 8px 8px; }
  .top-bar > section.card.controls { margin: 8px 8px 8px; }
  .top-bar > section.card.controls > .body { padding: 8px 10px; gap: 8px; }
}

/* ============================================================
   Mobile responsive (added v1.8.1 — fix bugs #2, #3, #4)
   ============================================================ */

/* Bug #2: Focus banner responsive on mobile — no edge cut, close button visible, full content fits */
@media (max-width: 768px), (max-height: 500px) {
  #focus-banner {
    /* v1.11.1 — Full-width sheet with content-aware sizing. max-height
       reduced to min(40vh, 340px) so the topology SVG ALWAYS has ≥60%
       of viewport to show the focused node + connections. Overflow
       scroll inside banner if content exceeds. */
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    transform: none !important;
    max-height: min(40vh, 340px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
  }
  /* Default / .anchor-bottom — banner sits at the bottom of the viewport */
  #focus-banner:not(.anchor-top),
  #focus-banner.anchor-bottom {
    top: auto !important;
    bottom: env(safe-area-inset-bottom, 0) !important;
    border-radius: 14px 14px 6px 6px;
  }
  /* .anchor-top — banner sits at the top (used when focused node is in the
     lower half of the viewport so it doesn't cover the node) */
  #focus-banner.anchor-top {
    top: env(safe-area-inset-top, 8px) !important;
    bottom: auto !important;
    border-radius: 6px 6px 14px 14px;
  }
  #focus-banner.dragged {
    /* User has dragged — respect the absolute position inline styles.
       Switch to position: absolute so left/top (in main-relative coords)
       take effect, not fixed-bottom anchor. Per anh 2026-04-17 — mobile
       must allow free-drag of the focus banner. */
    position: absolute !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    /* inline style.left/top from JS takes priority — no !important here.
       width falls back to a sensible default for the floating state. */
    width: min(90vw, 420px) !important;
    max-width: 420px !important;
    border-radius: 12px;
  }
  #focus-banner .fb-head {
    position: sticky;
    top: 0;
    background: rgba(15,23,42,0.97);
    margin: -10px -12px 8px;
    padding: 8px 12px;
    border-radius: 14px 14px 0 0;
    z-index: 5;
    cursor: grab;  /* hint draggability */
  }
  #focus-banner.dragging .fb-head { cursor: grabbing; }
  #focus-banner .fb-drag-handle {
    /* v1.10.0 — mobile drag enabled; show handle */
    display: inline-flex !important;
    font-size: 18px;
    min-width: 28px;
    min-height: 28px;
    align-items: center;
    justify-content: center;
  }
  #focus-banner .fb-reset-pos {
    /* Show reset button on mobile too — user needs way to undo drag */
    display: inline-flex !important;
  }
  #focus-banner .fb-close,
  #focus-banner button[aria-label="Close"],
  #focus-banner .fb-head button {
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
    font-size: 16px;
    padding: 6px 10px;
  }
  #focus-banner .fb-title { font-size: 13px; }
  #focus-banner .fb-col, #focus-banner .fb-col-wide {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
  #focus-banner .fb-eq-list { font-size: 11px; }
  #focus-banner .fb-eq-row {
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 4px;
  }
  /* Edge cards within focus banner — single column */
  #focus-banner .fb-edge-cards,
  #focus-banner .fb-edges {
    grid-template-columns: 1fr !important;
  }
}

/* Bug #4: Hover → tap on touch devices.
   Show :hover-style tooltips on first tap (browsers do this natively for some elements,
   but for SVG nodes + custom popovers we use JS-based tap-to-show). The CSS below
   ensures hover styles APPLY on tap (.tap-hover class added by JS) */
@media (hover: none) and (pointer: coarse) {
  /* Tooltips visible on tap (JS adds .tap-active class) */
  .tooltip.tap-active {
    display: block !important;
    opacity: 1 !important;
  }
  /* Topology controls — bigger touch targets */
  .topology-main button,
  .filter-chip, .fchip {
    min-height: 36px;
    min-width: 36px;
  }
  /* SVG nodes — visual hint they're tappable */
  g.node {
    cursor: pointer;
  }
  /* v1.10.0 — drag handle now VISIBLE on touch (Pointer Events support)
     so user can drag focus banner on mobile. */
}

/* Bug #3: Pinch-zoom container — disable user-select on SVG so pinch works smoothly */
@media (hover: none) and (pointer: coarse) {
  #topology-svg {
    touch-action: none;  /* let JS handle all touch (pinch + pan) */
    user-select: none;
    -webkit-user-select: none;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   PATH QUERY UI — form, status, sidebar panel, SVG highlights
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Path query form in the controls card ──────────────────────────── */
.path-query-group {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
/* NLP single-line input row */
.path-nlp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  flex: 0 0 100%;
}
.path-nlp-row input[type="text"] {
  flex: 1 1 auto;
  padding: 5px 10px;
  border: 1px solid var(--accent, #2563eb);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  height: 32px;
  font-style: italic;
}
.path-nlp-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
  font-style: normal;
}
.path-export-btn {
  font-size: 12px;
  margin-left: auto;
}
.path-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
}
.path-inputs input[type="text"] {
  flex: 1 1 160px;
  min-width: 130px;
  max-width: 260px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  height: 32px;
}
.path-inputs input[type="text"]:focus {
  outline: none;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.path-arrow {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
  padding: 0 2px;
}
#path-channel {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  height: 32px;
  cursor: pointer;
}
.btn-primary-sm {
  padding: 5px 14px;
  background: var(--accent, #2563eb);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  height: 32px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary-sm:hover { background: #1d4ed8; }
.btn-primary-sm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost-sm {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  height: 32px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s;
}
.btn-ghost-sm:hover { background: var(--bg-hover, rgba(0,0,0,0.06)); }

.path-status {
  width: 100%;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  margin-top: 2px;
}
.path-status-info    { color: var(--text-muted); background: transparent; }
.path-status-success { color: #065f46; background: #d1fae5; }
.path-status-warn    { color: #92400e; background: #fef3c7; }
.path-status-error   { color: #7f1d1d; background: #fee2e2; }

/* dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .path-status-success { color: #6ee7b7; background: #064e3b; }
  .path-status-warn    { color: #fcd34d; background: #451a03; }
  .path-status-error   { color: #fca5a5; background: #450a0a; }
}

/* ── Main layout — sidebar panel alongside canvas ──────────────────── */
#topology-main {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  gap: 0;
  align-items: stretch;
  overflow: hidden;
}
#topology-main #card-canvas {
  flex: 1 1 auto;
  min-width: 0;
}
#topology-main.has-path-panel #card-canvas {
  /* Shrink canvas to make room for sidebar */
  flex: 1 1 60%;
}

/* ── Path detail sidebar panel ─────────────────────────────────────── */
.path-detail-panel {
  width: 340px;
  min-width: 280px;
  max-width: 400px;
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  overflow: hidden;
}
.path-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 2;
}
.path-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.path-hop-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 0;
}
.path-panel-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}
.path-footer-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
}
.path-panel-footer .stat-warn { color: #b45309; }
.stat-verified.has-verified { color: #059669; font-weight: 700; }

/* Footer action buttons row */
.path-footer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.path-footer-actions .btn-ghost-sm {
  font-size: 10px;
  padding: 2px 7px;
  white-space: nowrap;
}

/* ── Hop items ──────────────────────────────────────────────────────── */
.path-hop-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,0.05));
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.15s;
}
.path-hop-item:hover { background: var(--bg-hover, rgba(0,0,0,0.04)); }
.path-hop-item.path-hop-logical { background: rgba(124,58,237,0.04); }
/* Verified state — green left stripe */
.path-hop-item.hop-verified {
  border-left-color: #059669;
  background: rgba(5,150,105,0.04);
}

/* Verify button (right-aligned ✓ toggle) */
.hop-verify-btn {
  flex-shrink: 0;
  margin-top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border, #e2e8f0);
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.hop-verify-btn:hover {
  border-color: #059669;
  color: #059669;
  background: rgba(5,150,105,0.08);
}
.hop-verify-btn.verified {
  border-color: #059669;
  background: #059669;
  color: #fff;
}

/* Print: show only the path panel content */
@media print {
  .top-bar, #card-canvas, .path-query-group,
  #path-panel-close, .path-footer-actions { display: none !important; }
  body { background: #fff !important; padding: 0 !important; }
  main.topology { display: block !important; }
  #path-detail-panel {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    border: none !important;
    flex: none !important;
  }
  .path-hop-item { page-break-inside: avoid; }
}
.hop-number {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--hop-color, #94a3b8);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.hop-body {
  flex: 1 1 auto;
  min-width: 0;
}
.hop-devices {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.hop-dev {
  cursor: default;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hop-connector {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 2px;
}
.hop-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.path-site-tag {
  background: var(--bg-alt, #f1f5f9);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.path-port { font-family: monospace; font-size: 11px; }
.path-port-missing { color: #b45309; font-style: italic; }
.path-cable { font-family: monospace; font-size: 10px; color: var(--text-muted); }
.path-cable-unknown { color: #b45309; }
.path-lan { font-size: 10px; font-weight: 700; }
.path-drawing-link {
  font-size: 10px;
  color: var(--accent, #2563eb);
  text-decoration: none;
  font-family: monospace;
}
.path-drawing-link:hover { text-decoration: underline; }
.path-drawing-unknown { font-size: 10px; color: var(--text-muted); }
.hop-medium {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
}

/* ── Path badges ─────────────────────────────────────────────────────── */
.path-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}
.path-badge-logical { background: #ede9fe; color: #5b21b6; }
.path-badge-warn    { background: #fef3c7; color: #92400e; cursor: help; }
@media (prefers-color-scheme: dark) {
  .path-badge-logical { background: #2e1065; color: #c4b5fd; }
  .path-badge-warn    { background: #451a03; color: #fcd34d; }
}

/* ── SVG node highlight + dim states ─────────────────────────────────── */
.rack-node.path-highlight rect {
  stroke: #e08c1a;
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(224,140,26,0.6));
}
.rack-node.path-dim rect {
  opacity: 0.25;
}
.rack-node.path-dim text {
  opacity: 0.25;
}

/* ── Responsive — narrow screens: stack sidebar below canvas ──────────── */
@media (max-width: 900px) {
  #topology-main {
    flex-direction: column;
  }
  .path-detail-panel {
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
