/* SVG Viewer Engine CSS - Shared between CLI and React app */
/* Extracted from cadassure.Cli/Program.cs */

:root {
  --viewer-status-match: #0f8a2b;
  --viewer-status-probable: #4ade80;
  --viewer-status-possible: #84cc16;
  --viewer-status-ambiguous: #facc15;
  --viewer-status-nomatch: #d00000;
  --viewer-status-external: #475569;
  --viewer-status-pending: #64748b;
  --viewer-status-light-text: #ffffff;
  --viewer-status-dark-text: #0f172a;
}

.svg-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
  padding: 2px 0 0;
}

.svg-controls button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid #cbd5e1;
  border-radius: 0;
  background: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: #0f172a;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.svg-controls button:hover {
  background: #eff6ff;
  border-color: #94a3b8;
}

.svg-controls button:active {
  background: #dbeafe;
}

.svg-controls button:focus-visible,
.tab-button:focus-visible,
.svg-text-search-input:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 1px;
}

.svg-controls span {
  font-size: 12px;
  color: #475569;
  line-height: 1.2;
}

.svg-text-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.svg-text-search-mode {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  cursor: pointer;
}

.svg-text-search-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  box-shadow: none;
}

.svg-text-search-field:focus-within {
  border-color: #94a3b8;
}

.svg-text-search-input {
  width: 220px;
  max-width: min(32vw, 300px);
  min-height: 32px;
  padding: 6px 30px 6px 11px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.25;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
}

.svg-text-search-input:focus {
  background: transparent;
}

.svg-text-search-input:focus-visible {
  outline: none;
  box-shadow: none;
}

.svg-text-search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 20px;
  min-width: 20px;
  height: 20px;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: #64748b;
  font-size: 14px;
  line-height: 1;
}

.svg-text-search-clear:hover {
  background: rgba(148, 163, 184, 0.18) !important;
}

.svg-text-search-clear[hidden] {
  display: none !important;
}

.svg-text-search-count {
  min-width: 52px;
  padding: 0 2px;
  color: #475569 !important;
  white-space: nowrap;
  font-weight: 600;
}

.svg-viewer .svg-text-search-hit {
  fill: #fef08a;
  fill-opacity: 0.32;
  stroke: #facc15;
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
  filter: drop-shadow(0 0 2px rgba(250, 204, 21, 0.45));
}

.svg-viewer .svg-text-search-hit--metadata {
  fill-opacity: 0.20;
}

.tab-bar {
  display: flex;
  gap: 4px;
  padding: 2px;
  margin-bottom: 0;
  border: 1px solid #dbe3ec;
  border-radius: 0;
  background: #f8fafc;
}

.tab-button {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 0;
  background: #f8fafc;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.tab-button:hover {
  background: #ffffff;
  border-color: #cbd5e1;
}

.tab-button.active {
  background: #1d4ed8;
  color: #fff;
  border-color: #1e40af;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.svg-viewer {
  position: relative;
  border: 1px solid #d6dde6;
  border-radius: 0;
  overflow: hidden;
  width: 100%;
  height: 78vh;
  min-height: 540px;
  background: #ffffff;
  cursor: grab;
}

.svg-viewer:active {
  cursor: grabbing;
}

/* Hoverable SVG hits should read like info hotspots, not pan handles */
.svg-viewer [data-iec-level],
.svg-viewer [data-iec-level] *,
.svg-viewer [data-conductor-group],
.svg-viewer [data-conductor-group] *,
.svg-viewer [data-fence-handle],
.svg-viewer [data-fence-handle] * {
  cursor: help !important;
}

.svg-viewer .iec-fence-hover {
  stroke: #d7c600 !important;
  stroke-width: 2.2 !important;
  stroke-opacity: 1 !important;
}

.svg-viewer text.iec-fence-hover,
.svg-viewer text.iec-fence-source-hover {
  fill: #111 !important;
  stroke: #d7c600 !important;
  stroke-width: 0.9 !important;
  paint-order: stroke fill !important;
  stroke-linejoin: round !important;
}

.svg-viewer rect.iec-linked-hover,
.svg-viewer polygon.iec-linked-hover,
.svg-viewer line.iec-linked-hover,
.svg-viewer polyline.iec-linked-hover,
.svg-viewer path.iec-linked-hover {
  stroke: #d7c600 !important;
  stroke-width: 1.6 !important;
  stroke-opacity: 1 !important;
}

.svg-viewer rect.iec-linked-hover {
  fill-opacity: 0.16 !important;
}

.svg-viewer text.iec-linked-hover {
  fill: #111 !important;
  stroke: #d7c600 !important;
  stroke-width: 0.9 !important;
  paint-order: stroke fill !important;
  stroke-linejoin: round !important;
}

/* Per-ReferenceUnit glow highlighting */
@keyframes iec-ru-glow-pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.svg-viewer .iec-ru-glow {
  filter: none !important;
  stroke: #facc15 !important;
  stroke-width: 2.4px !important;
  stroke-opacity: 0.6 !important;
  stroke-dasharray: none !important;
  animation: iec-ru-glow-pulse 0.9s ease-out 4;
}

.svg-viewer text.iec-ru-glow {
  fill: #111 !important;
  stroke: #facc15 !important;
  stroke-width: 0.42px !important;
  paint-order: stroke fill !important;
  filter: none !important;
  animation: none !important;
}

.svg-viewer rect.iec-ru-glow {
  fill: none !important;
  fill-opacity: 0 !important;
}

.svg-viewer circle.iec-ru-glow,
.svg-viewer ellipse.iec-ru-glow {
  fill: #fef08a !important;
  fill-opacity: 0.16 !important;
}

.svg-viewer .iec-fence-device-glow {
  filter: drop-shadow(0 0 1.4px rgba(37, 99, 235, 0.55));
  stroke: #2563EB !important;
  stroke-width: 1.5 !important;
  stroke-opacity: 0.32 !important;
}

.svg-viewer text.iec-fence-device-glow,
.svg-viewer text.iec-fence-device-glow-source {
  fill: #2563EB !important;
  stroke: #2563EB !important;
  stroke-width: 0.45 !important;
  stroke-opacity: 0.45 !important;
  paint-order: stroke fill !important;
  stroke-linejoin: round !important;
  filter: drop-shadow(0 0 0.5px rgba(37, 99, 235, 0.35));
}

.svg-viewer polygon.iec-synth-terminal-glow,
.svg-viewer circle.iec-synth-terminal-glow,
.svg-viewer ellipse.iec-synth-terminal-glow,
.svg-viewer line.iec-synth-terminal-glow,
.svg-viewer path.iec-synth-terminal-glow,
.svg-viewer polyline.iec-synth-terminal-glow,
.svg-viewer rect.iec-synth-terminal-glow {
  filter: drop-shadow(0 0 1.2px rgba(37, 99, 235, 0.7));
  stroke: #2563EB !important;
  stroke-width: 1.35 !important;
  stroke-opacity: 0.8 !important;
}

.svg-viewer polygon.iec-synth-terminal-glow,
.svg-viewer circle.iec-synth-terminal-glow,
.svg-viewer ellipse.iec-synth-terminal-glow {
  fill: #2563EB !important;
  fill-opacity: 0.12 !important;
}

.svg-viewer rect.iec-synth-terminal-glow {
  fill: #2563EB !important;
  fill-opacity: 0.12 !important;
}

.svg-viewer text.iec-synth-terminal-glow {
  fill: #2563EB !important;
  stroke: #2563EB !important;
  stroke-width: 0.3 !important;
  paint-order: stroke fill !important;
  filter: drop-shadow(0 0 0.7px rgba(37, 99, 235, 0.65));
}

/* Logical-children glow (click parent → children highlight) */
.svg-viewer .iec-children-glow {
  filter: drop-shadow(0 0 0.8px rgba(245, 158, 11, 0.5));
  stroke: #F59E0B !important;
  stroke-width: 1.2 !important;
  stroke-opacity: 0.75 !important;
}

.svg-viewer text.iec-children-glow {
  fill: #92400E !important;
  stroke: #F59E0B !important;
  stroke-width: 0.3 !important;
  paint-order: stroke fill !important;
  stroke-linejoin: round !important;
  filter: drop-shadow(0 0 0.5px rgba(245, 158, 11, 0.4));
}

.svg-viewer rect.iec-children-glow {
  fill: #F59E0B !important;
  fill-opacity: 0.08 !important;
}

.svg-viewer .iec-children-glow-source {
  filter: drop-shadow(0 0 1px rgba(245, 158, 11, 0.6));
  stroke: #D97706 !important;
  stroke-width: 1.5 !important;
  stroke-opacity: 0.9 !important;
}

.svg-viewer text.iec-children-glow-source {
  fill: #78350F !important;
  stroke: #D97706 !important;
  stroke-width: 0.4 !important;
  paint-order: stroke fill !important;
  stroke-linejoin: round !important;
  filter: drop-shadow(0 0 0.7px rgba(217, 119, 6, 0.5));
}

.svg-viewer rect.iec-children-glow-source {
  fill: #D97706 !important;
  fill-opacity: 0.1 !important;
}

/* Focused child highlight — bright red on click */
.svg-viewer .iec-child-focus {
  stroke: #DC2626 !important;
  stroke-opacity: 1 !important;
  stroke-width: 3.5px !important;
  filter: drop-shadow(0 0 3px rgba(220, 38, 38, 0.7)) !important;
  vector-effect: non-scaling-stroke;
}

.svg-viewer text.iec-child-focus {
  stroke: #FFF7ED !important;
  stroke-width: 1.1px !important;
  paint-order: stroke fill !important;
  fill: #DC2626 !important;
  fill-opacity: 1 !important;
  filter: drop-shadow(0 0 2px rgba(255, 247, 237, 0.9)) !important;
}

.svg-viewer rect.iec-child-focus {
  fill: #DC2626 !important;
  fill-opacity: 0.28 !important;
  stroke: #DC2626 !important;
  stroke-width: 2px !important;
}

.svg-viewer [data-entity-hover] {
  transition: stroke 0.12s ease, stroke-width 0.12s ease, stroke-opacity 0.12s ease, fill 0.12s ease, fill-opacity 0.12s ease;
}

.svg-hover-layer {
  pointer-events: none;
}

.svg-hover-terminal-ring {
  display: none;
  fill: #ffff00;
  fill-opacity: 0.4;
  stroke: #ffe100;
  stroke-opacity: 0.9;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 1;
  vector-effect: non-scaling-stroke;
}

.svg-hover-info-panel {
  min-height: 58px;
  max-height: 58px;
  padding: 6px 10px;
  border: 1px solid #d6dde6;
  border-radius: 6px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f7fb 100%);
  color: #0f172a;
  font: 12px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow: auto;
}

.svg-hover-info-panel.is-active {
  background: #fff;
}

.svg-hover-info-panel-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 6px 10px;
  min-width: 0;
}

.svg-hover-placeholder {
  color: #64748b;
  font-style: italic;
}

.svg-hover-panel-section {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  align-content: stretch;
  min-width: 0;
}

.svg-hover-section-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  align-content: flex-start;
  gap: 4px 8px;
  width: 100%;
  min-width: 0;
}

.svg-hover-panel-section--compact .svg-hover-section-body {
  gap: 3px 6px;
}

.svg-hover-panel-section + .svg-hover-panel-section {
  padding-left: 10px;
  border-left: 1px solid #e2e8f0;
}

.svg-hover-panel-section--list {
  flex-direction: column;
  align-items: stretch;
}

.svg-hover-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.svg-hover-section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.svg-hover-section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

.svg-hover-help-anchor {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.svg-hover-help-anchor--floating {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.svg-hover-help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #64748b;
  font: 600 10px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.8;
}

.svg-hover-help-button:hover,
.svg-hover-help-button:focus-visible {
  color: #334155;
  border-color: #94a3b8;
  background: #fff;
  opacity: 1;
  outline: none;
}

.svg-hover-help-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 4;
  width: min(300px, calc(100vw - 48px));
  max-height: 240px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  color: #1e293b;
  font: 11px/1.4 ui-sans-serif, system-ui, sans-serif;
}

.svg-hover-help-popover-header {
  margin-bottom: 6px;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.svg-hover-help-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.svg-hover-help-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.svg-hover-help-item-label {
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
}

.svg-hover-help-item-text,
.svg-hover-help-empty {
  color: #475569;
  font-size: 11px;
}

.svg-hover-section-toggle {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.svg-hover-section-toggle:hover {
  background: #f8fafc;
}

.svg-hover-list-container {
  width: 100%;
  min-width: 0;
}

.svg-hover-collapsed-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}

.svg-hover-collapsed-indicator:hover {
  background: #f1f5f9;
}

.svg-hover-collapsed-indicator:hover .svg-hover-collapsed-indicator-text {
  color: #3b82f6;
}

.svg-hover-collapsed-indicator-line {
  flex: 1 1 auto;
  min-width: 12px;
  border-top: 1px dashed #cbd5e1;
}

.svg-hover-collapsed-indicator-text {
  flex: 0 0 auto;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.svg-hover-panel-section--collapsible:not(.is-collapsed) .svg-hover-collapsed-indicator {
  display: none;
}

.svg-hover-section-tag,
.svg-hover-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.svg-hover-section-tag {
  background: #475569;
}

.svg-hover-badge--terminal {
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.svg-hover-badge--terminal-regular {
  background: #7c3aed;
}

.svg-hover-badge--terminal-boundary {
  background: #f97316;
}

.svg-hover-badge--terminal-plugsocket {
  background: #0891b2;
}

.svg-hover-source {
  color: #4f46e5;
  font-weight: 700;
  white-space: nowrap;
}

/* Termination conductor-group list (Phase 7) */
.svg-hover-tcg-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.svg-hover-tcg-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.svg-hover-tcg-row:hover {
  background: rgba(0, 172, 193, 0.12);
}

.svg-hover-tcg-row.is-focused {
  background: rgba(0, 172, 193, 0.22);
  outline: 1px solid #00ACC1;
}

.svg-hover-tcg-header {
  cursor: pointer;
}

.svg-hover-tcg-members {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding-left: 30px;
}

.svg-hover-tcg-member {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.svg-hover-tcg-member-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  padding-left: 30px;
  border-radius: 4px;
}

.svg-hover-tcg-id {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: auto;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #64748b;
  white-space: normal;
  word-break: break-all;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.svg-hover-tcg-lozenge {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 172, 193, 0.16);
  border: 1px solid rgba(0, 172, 193, 0.45);
  color: #045863;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.svg-hover-tcg-lozenge--cable {
  background: rgba(33, 150, 243, 0.16);
  border-color: rgba(33, 150, 243, 0.45);
  color: #1565c0;
}

.svg-hover-tcg-lozenge--wire {
  background: rgba(76, 175, 80, 0.16);
  border-color: rgba(76, 175, 80, 0.45);
  color: #2e7d32;
}

.svg-hover-field {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.svg-hover-field--wide {
  flex: 1 1 280px;
}

.svg-hover-field--full {
  flex: 1 1 100%;
}

.svg-hover-label {
  color: #475569;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}

.svg-hover-value {
  color: #0f172a;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.svg-hover-copyable-value {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.svg-hover-copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #fff;
  color: #475569;
  font: 700 10px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  vertical-align: baseline;
}

.svg-hover-copy-button:hover,
.svg-hover-copy-button:focus-visible {
  border-color: #60a5fa;
  color: #1d4ed8;
  outline: none;
}

.svg-hover-copy-button.is-copied {
  border-color: #22c55e;
  color: #15803d;
}

.svg-hover-copy-button.is-copy-failed {
  border-color: #ef4444;
  color: #b91c1c;
}

.svg-hover-inline-note {
  color: #334155;
  font-weight: 600;
  white-space: nowrap;
}

.svg-hover-target-cr-text {
  color: #0f172a;
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
  line-height: 1.25;
}

.svg-hover-target-cr-text--none {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.16);
}

.svg-hover-target-cr-text--single {
  color: #166534;
  background: rgba(34, 197, 94, 0.18);
}

.svg-hover-target-cr-text--multiple {
  color: #854d0e;
  background: rgba(250, 204, 21, 0.22);
}

.svg-hover-target-cr-text--external {
  color: #0c4a6e;
  background: rgba(125, 211, 252, 0.28);
}

.svg-hover-target-cr-text--rejected {
  color: #7c2d12;
  background: rgba(251, 146, 60, 0.18);
}

.svg-hover-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Children list in info panel */
.svg-hover-children-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 4px;
  max-height: 280px;
  overflow-x: hidden;
  overflow-y: auto;
}

.svg-hover-child-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  padding: 2px 3px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  line-height: 1.4;
}

.svg-hover-child-row:last-child {
  border-bottom: none;
}

.svg-hover-child-row:hover {
  background: rgba(245, 158, 11, 0.08);
  cursor: pointer;
}

.svg-hover-same-contact-group {
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  background: #eef2ff;
  padding: 4px;
}

.svg-hover-same-contact-group + .svg-hover-child-row,
.svg-hover-child-row + .svg-hover-same-contact-group,
.svg-hover-same-contact-group + .svg-hover-same-contact-group {
  margin-top: 4px;
}

.svg-hover-same-contact-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.svg-hover-same-contact-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #4f46e5;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  text-transform: uppercase;
}

.svg-hover-child-row.is-focused {
  background: rgba(245, 158, 11, 0.18);
  outline: 1px solid #F59E0B;
  outline-offset: -1px;
  border-radius: 3px;
}

.svg-hover-search-result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.svg-hover-search-result-card {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 7px;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  background: #f8fbff;
}

.svg-hover-search-result-card.is-clickable {
  cursor: pointer;
}

.svg-hover-search-result-card.is-clickable:hover,
.svg-hover-search-result-card.is-clickable:focus-visible {
  border-color: #93c5fd;
  background: #eff6ff;
  outline: none;
}

.svg-hover-search-result-card.is-focused {
  border-color: #93c5fd;
  background: #eff6ff;
  outline: none;
}

.svg-hover-search-result-title,
.svg-hover-search-result-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.svg-hover-search-result-title {
  justify-content: space-between;
  margin-bottom: 4px;
}

.svg-hover-badge--sm {
  font-size: 9px;
  padding: 0 5px;
  flex-shrink: 0;
}

.svg-hover-child-des {
  flex: 1 1 auto;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
}

.svg-hover-child-meta {
  color: #64748b;
  font-size: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.svg-hover-child-handle {
  color: #94a3b8;
  font-size: 10px;
  font-family: monospace;
  flex-shrink: 0;
  margin-left: auto;
  white-space: nowrap;
}

/* ReferenceUnit subpanel cards */
.svg-hover-ru-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  flex-basis: 100%;
  min-width: 0;
}

.svg-hover-device-group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  min-width: 0;
}

.svg-hover-ru-card {
  border-left: 3px solid var(--ru-card-color, #475569);
  background: rgba(0, 0, 0, 0.04);
  padding: 4px 6px;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.svg-hover-ru-card:hover {
  background: rgba(0, 0, 0, 0.08);
}

.svg-hover-ru-card-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.svg-hover-ru-card-details {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 46px;
}

.svg-hover-ru-close-button {
  position: absolute;
  top: 0;
  right: 22px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #475569;
  font: 700 12px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.svg-hover-ru-close-button:hover,
.svg-hover-ru-close-button:focus-visible {
  border-color: #94a3b8;
  background: #fff;
  color: #0f172a;
  outline: none;
}

.svg-hover-ru-card.is-focused {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 4px var(--ru-card-color, #475569);
}

.svg-hover-panel-section--collapsible.is-collapsed .svg-hover-list-item:nth-child(n+13) {
  display: none;
}

.svg-hover-ru-card.is-dimmed {
  border-left-color: #475569;
}

.svg-hover-ru-card-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--ru-card-color, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.svg-hover-ru-card-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  font-size: 11px;
  line-height: 1.4;
  justify-content: flex-start;
}

.svg-hover-ru-card-row .svg-hover-label {
  color: #334155;
  flex-shrink: 0;
  min-width: 55px;
}

.svg-hover-ru-card-row .svg-hover-value {
  color: #1e293b;
  font-weight: 500;
  text-align: left;
  min-width: 0;
  overflow-wrap: anywhere;
}

.svg-hover-ru-card-summary {
  min-width: 0;
  color: #1e293b;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svg-hover-ru-card-summary-index {
  color: var(--ru-card-color, #64748b);
  font-weight: 700;
}

.svg-hover-ru-card-summary-warning {
  color: #b45309;
  font-weight: 600;
}

/* Connections (group-device links) — one expandable card per link */
.svg-hover-connection-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  margin: 3px 0;
  padding: 0;
  overflow: hidden;
}

.svg-hover-connection-summary {
  list-style: none;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svg-hover-connection-summary::-webkit-details-marker { display: none; }

.svg-hover-connection-summary::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 6px;
  font-size: 9px;
  color: #94a3b8;
  transition: transform 0.12s ease;
}

.svg-hover-connection-card[open] > .svg-hover-connection-summary::before {
  transform: rotate(90deg);
}

.svg-hover-connection-card[open] > .svg-hover-connection-summary {
  border-bottom: 1px solid #eef2f7;
}

.svg-hover-connection-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 8px 8px 20px;
}

.svg-hover-connection-part {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
}

.svg-hover-connection-part-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  margin-bottom: 1px;
}

.svg-hover-connection-body .svg-hover-field {
  width: auto;
  justify-content: flex-start;
}


.svg-hover-ru-card-warning {
  color: #b45309;
  font-size: 11px;
  font-weight: 600;
}

.svg-hover-ru-match-badge {
  margin-left: 4px;
  vertical-align: middle;
}

.svg-hover-ru-match-badge--matched {
  background: var(--viewer-status-match);
}

.svg-hover-ru-match-badge--unmatched {
  background: var(--viewer-status-nomatch);
}

.svg-hover-ru-location-match-badge {
  margin-left: 4px;
  vertical-align: middle;
}

.svg-hover-ru-location-match-badge--match {
  background: var(--viewer-status-match);
}

.svg-hover-ru-location-match-badge--nomatch {
  background: var(--viewer-status-nomatch);
}

.svg-hover-ru-location-match-badge--ambiguous {
  background: var(--viewer-status-ambiguous);
  color: var(--viewer-status-dark-text);
}

.svg-hover-v2-match-badge {
  margin-left: 4px;
  vertical-align: middle;
  color: var(--viewer-status-light-text);
}
.svg-hover-v2-match-badge--matched { background: var(--viewer-status-match); }
.svg-hover-v2-match-badge--probable {
  background: var(--viewer-status-probable);
  color: var(--viewer-status-dark-text);
}
.svg-hover-v2-match-badge--possible {
  background: var(--viewer-status-possible);
  color: var(--viewer-status-dark-text);
}
.svg-hover-v2-match-badge--ambiguous {
  background: var(--viewer-status-ambiguous);
  color: var(--viewer-status-dark-text);
}
.svg-hover-v2-match-badge--nomatch { background: var(--viewer-status-nomatch); }
.svg-hover-v2-match-badge--external { background: var(--viewer-status-external); }
.svg-hover-v2-match-badge--pending { background: var(--viewer-status-pending); }
.svg-hover-v2-match-badge--deferred { background: var(--viewer-status-pending); }
.svg-hover-v2-match-badge--invalid {
  background: #B71C1C;
  color: #ffffff;
}
.svg-hover-v2-match-badge--tbd {
  background: #A78BFA;
  color: #1f2937;
}

.svg-hover-tcg-match {
  padding-left: 30px;
  align-items: baseline;
}
.svg-hover-tcg-match-reason {
  font-size: 10px;
  color: #64748b;
  white-space: normal;
  overflow-wrap: anywhere;
}
.svg-termcg-status-marker {
  cursor: pointer;
  /* `all` makes the marker's painted children clickable in every browser AND overrides any inherited
     pointer-events:none from an overlay ancestor. `bounding-box` (Chrome/WebKit only; ignored by
     Firefox) then widens the hit area to the whole marker box. Order matters: Firefox keeps `all`. */
  pointer-events: all;
  pointer-events: bounding-box;
}
.svg-ru-status-marker {
  cursor: pointer;
  pointer-events: all;
  pointer-events: bounding-box;
}
.svg-ru-status-marker:hover circle {
  stroke-width: 1.6;
  opacity: 1;
}
.svg-ru-status-marker.match-marker-selected,
.svg-termcg-status-marker.match-marker-selected {
  filter: none;
}
.svg-ru-status-marker.match-marker-selected circle,
.svg-termcg-status-marker.match-marker-selected circle,
.svg-termcg-status-marker.match-marker-selected polygon,
.svg-termcg-status-marker.match-marker-selected rect {
  fill: #fef08a;
  fill-opacity: 0.95;
  stroke: #facc15;
  stroke-width: 2.8;
  paint-order: stroke fill;
}
.svg-ru-legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
  line-height: 1.55;
  color: #1f2937;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}
.svg-ru-legend-title {
  font-weight: 600;
  margin-bottom: 3px;
}
.svg-ru-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.svg-ru-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #1f2937;
}

.svg-hover-v2-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 260px;
}

.svg-hover-v2-detail-row {
  display: grid;
  grid-template-columns: 56px auto 1fr;
  align-items: start;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.svg-hover-v2-detail-label {
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.svg-hover-v2-detail-status {
  border-radius: 999px;
  color: var(--viewer-status-light-text);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
}

.svg-hover-v2-detail-status--matched { background: var(--viewer-status-match); }
.svg-hover-v2-detail-status--probable {
  background: var(--viewer-status-probable);
  color: var(--viewer-status-dark-text);
}
.svg-hover-v2-detail-status--possible {
  background: var(--viewer-status-possible);
  color: var(--viewer-status-dark-text);
}
.svg-hover-v2-detail-status--ambiguous {
  background: var(--viewer-status-ambiguous);
  color: var(--viewer-status-dark-text);
}
.svg-hover-v2-detail-status--nomatch { background: var(--viewer-status-nomatch); }
.svg-hover-v2-detail-status--external,
.svg-hover-v2-detail-status--pending,
.svg-hover-v2-detail-status--na,
.svg-hover-v2-detail-status--deferred { background: var(--viewer-status-pending); }

.svg-hover-v2-detail-row--deferred-return .svg-hover-v2-detail-text a {
  color: #334155;
  font-weight: 700;
  text-decoration: underline;
}

.svg-hover-v2-detail-reason {
  color: #334155;
  font-size: 10px;
  font-weight: 700;
}

.svg-hover-v2-detail-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.svg-hover-v2-detail-text {
  color: #475569;
  font-size: 11px;
  line-height: 1.25;
}

.svg-hover-v2-structured {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.svg-hover-v2-structured-group {
  border-left: 2px solid rgba(148, 163, 184, 0.35);
  padding-left: 6px;
}

.svg-hover-v2-structured-title {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 2px;
}

.svg-hover-v2-structured-list {
  list-style: disc;
  margin: 0;
  padding: 0 0 0 14px;
}

.svg-hover-v2-structured-item {
  color: #475569;
  display: list-item;
  font-size: 11px;
  line-height: 1.35;
  margin: 0;
}

.svg-hover-v2-structured-key {
  color: #334155;
  font-weight: 700;
  margin-right: 4px;
}

.svg-hover-v2-structured-value {
  color: #475569;
}

.svg-hover-ru-group-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.svg-hover-ru-card-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.svg-hover-ru-cg-definition {
  display: grid;
  gap: 6px;
}

.svg-hover-ru-member-list {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0 0 0 16px;
}

.svg-hover-ru-member-list li {
  padding-left: 2px;
}

.svg-hover-ru-member-handle {
  display: inline-block;
  margin-left: 6px;
  color: #64748b;
  font-size: 10px;
}

.svg-hover-ru-match-divider {
  grid-column: 1 / -1;
  height: 1px;
  margin: 8px 0 6px;
  background: linear-gradient(to right, rgba(124, 58, 237, 0.55), rgba(148, 163, 184, 0.25));
}

.svg-hover-ru-card-block-label {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.svg-hover-ru-group-members {
  margin-top: 0;
  max-height: 220px;
}

.svg-hover-ru-empty {
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
  padding: 4px 0;
}

.svg-viewer.svg-hover-panel-enabled .iec-annotation,
.svg-viewer.svg-hover-panel-enabled .iec-ann-overlay .iec-annotation,
.svg-viewer.svg-hover-panel-enabled .iec-entity-group:hover .iec-annotation {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Entity label texts can be offset from their hit rects (e.g. -C1 block insert vs label position).
   Override the SVG-inline pointer-events:none so clicking the visible text also resolves the entity. */
.svg-viewer.svg-hover-panel-enabled text[data-source-entity-handle] {
  pointer-events: all;
}

@media (prefers-color-scheme: dark) {
  .svg-hover-info-panel {
    border-color: #334155;
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    color: #e5e7eb;
  }

  .svg-hover-info-panel.is-active {
    background: #111827;
  }

  .svg-hover-placeholder {
    color: #94a3b8;
  }

  .svg-hover-panel-section + .svg-hover-panel-section {
    border-left-color: #334155;
  }

  .svg-hover-label {
    color: #93c5fd;
  }

  .svg-hover-value,
  .svg-hover-inline-note {
    color: #e5e7eb;
  }

  .svg-hover-search-result-card {
    border-color: #334155;
    background: #1e293b;
    color: #e5e7eb;
  }

  .svg-hover-search-result-card.is-clickable:hover,
  .svg-hover-search-result-card.is-clickable:focus-visible,
  .svg-hover-search-result-card.is-focused {
    border-color: #facc15;
    background: #25344a;
  }

  .svg-hover-search-result-card .svg-hover-label {
    color: #93c5fd;
  }

  .svg-hover-search-result-card .svg-hover-value {
    color: #f8fafc;
  }

  .svg-hover-target-cr-text {
    color: #e5e7eb;
  }

  .svg-hover-target-cr-text--none {
    color: #fecaca;
    background: rgba(127, 29, 29, 0.55);
  }

  .svg-hover-target-cr-text--single {
    color: #bbf7d0;
    background: rgba(20, 83, 45, 0.55);
  }

  .svg-hover-target-cr-text--multiple {
    color: #fde68a;
    background: rgba(133, 77, 14, 0.52);
  }

  .svg-hover-target-cr-text--external {
    color: #dbeafe;
    background: rgba(14, 116, 144, 0.5);
  }

  .svg-hover-target-cr-text--rejected {
    color: #fed7aa;
    background: rgba(154, 52, 18, 0.48);
  }

  .svg-hover-source {
    color: #a5b4fc;
  }

  .svg-hover-child-row {
    border-bottom-color: #334155;
  }

  .svg-hover-child-des {
    color: #e5e7eb;
  }

  .svg-hover-child-meta {
    color: #94a3b8;
  }

  .svg-hover-same-contact-group {
    border-color: #3730a3;
    background: rgba(49, 46, 129, 0.35);
  }

  .svg-hover-same-contact-badge {
    background: #6366f1;
  }

  .svg-hover-child-handle {
    color: #94a3b8;
  }

  .svg-hover-ru-card {
    background: rgba(255, 255, 255, 0.06);
  }

  .svg-hover-ru-card:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  .svg-hover-ru-card-summary {
    color: #e2e8f0;
  }

  .svg-hover-ru-card-summary-index {
    color: var(--ru-card-color, #cbd5e1);
  }

  .svg-hover-ru-card-summary-warning {
    color: #fbbf24;
  }

  .svg-hover-ru-card-warning {
    color: #fbbf24;
  }

  .svg-hover-ru-group-details {
    border-top-color: rgba(148, 163, 184, 0.28);
  }

  .svg-hover-ru-card-block-label {
    color: #cbd5e1;
  }

  .svg-hover-ru-card-row .svg-hover-label {
    color: #93c5fd;
  }

  .svg-hover-ru-card-row .svg-hover-value {
    color: #e2e8f0;
  }

  .svg-hover-v2-detail-label {
    color: #93c5fd;
  }

  .svg-hover-v2-detail-reason,
  .svg-hover-v2-detail-text {
    color: #cbd5e1;
  }

  .svg-hover-v2-detail-row--deferred-return .svg-hover-v2-detail-text a {
    color: #93c5fd;
  }

  .svg-hover-v2-structured-title,
  .svg-hover-v2-structured-item,
  .svg-hover-v2-structured-value {
    color: #cbd5e1;
  }

  .svg-hover-v2-structured-key {
    color: #e2e8f0;
  }
}

.svg-inner, .pdf-inner {
  transform-origin: 0 0;
}

.svg-inner svg {
  display: block;
}

.pdf-inner canvas {
  display: block;
}

.pdf-error {
  padding: 20px;
  color: #999;
  text-align: center;
  font-size: 0.9em;
}


/* Search debug overlay (cross-reference directional rectangles) */
.svg-search-debug-rect {
  fill: rgba(59, 130, 246, 0.08);
  stroke: #3b82f6;
  stroke-width: 1;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.svg-viewer .iec-entity-group.cr-match-status-nomatch rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-nomatch rect.iec-source-attr {
  stroke: var(--viewer-status-nomatch) !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-nomatch rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-nomatch rect.iec-source-attr-double {
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-matched rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-matched rect.iec-source-attr {
  stroke: var(--viewer-status-match) !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-matched rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-matched rect.iec-source-attr-double {
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-probable rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-probable rect.iec-source-attr {
  stroke: var(--viewer-status-probable) !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-probable rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-probable rect.iec-source-attr-double {
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-possible rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-possible rect.iec-source-attr {
  stroke: var(--viewer-status-possible) !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-possible rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-possible rect.iec-source-attr-double {
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-ambiguous rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-ambiguous rect.iec-source-attr {
  stroke: var(--viewer-status-ambiguous) !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-ambiguous rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-ambiguous rect.iec-source-attr-double {
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-external rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-external rect.iec-source-attr {
  stroke: #7dd3fc !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-external rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-external rect.iec-source-attr-double {
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-pending rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-match-status-pending rect.iec-source-attr {
  stroke: #94a3b8 !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  fill-opacity: 0 !important;
  opacity: 1 !important;
  filter: none !important;
}

.svg-viewer .iec-entity-group.cr-match-status-pending rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-pending rect.iec-source-attr-double {
  stroke: #64748b !important;
  stroke-width: 1 !important;
  opacity: 1 !important;
  filter: none !important;
}

/* Outer rect: match status is the primary state indicator; keep the stroke crisp. */
.svg-viewer .iec-entity-group.cr-ref-type-wire rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-ref-type-wire rect.iec-source-attr,
.svg-viewer .iec-entity-group.cr-ref-type-device rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-ref-type-device rect.iec-source-attr,
.svg-viewer .iec-entity-group.cr-ref-type-fence rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-ref-type-fence rect.iec-source-attr,
.svg-viewer .iec-entity-group.cr-ref-type-block rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-ref-type-block rect.iec-source-attr,
.svg-viewer .iec-entity-group.cr-ref-type-terminal rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-ref-type-terminal rect.iec-source-attr,
.svg-viewer .iec-entity-group.cr-ref-type-ambiguous rect.iec-source-pattern,
.svg-viewer .iec-entity-group.cr-ref-type-ambiguous rect.iec-source-attr {
  filter: none !important;
  opacity: 1 !important;
}

/* Match status owns the source box color; suppress the separate ref-type ring. */
.svg-viewer .iec-entity-group.cr-ref-type-wire rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-ref-type-wire rect.iec-source-attr-double {
  stroke: none !important;
  stroke-width: 0 !important;
  stroke-dasharray: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-ref-type-device rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-ref-type-device rect.iec-source-attr-double,
.svg-viewer .iec-entity-group.cr-ref-type-fence rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-ref-type-fence rect.iec-source-attr-double,
.svg-viewer .iec-entity-group.cr-ref-type-block rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-ref-type-block rect.iec-source-attr-double {
  stroke: none !important;
  stroke-width: 0 !important;
  stroke-dasharray: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-ref-type-terminal rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-ref-type-terminal rect.iec-source-attr-double {
  stroke: none !important;
  stroke-width: 0 !important;
  stroke-dasharray: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-ref-type-ambiguous rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-ref-type-ambiguous rect.iec-source-attr-double {
  stroke: none !important;
  stroke-width: 0 !important;
  stroke-dasharray: none !important;
  opacity: 0 !important;
}

/* Keep the inner ring disabled even when match-status classes are applied. */
.svg-viewer .iec-entity-group.cr-match-status-matched rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-matched rect.iec-source-attr-double {
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-match-status-probable rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-probable rect.iec-source-attr-double {
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-match-status-possible rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-possible rect.iec-source-attr-double {
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-match-status-ambiguous rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-ambiguous rect.iec-source-attr-double {
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-match-status-nomatch rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-nomatch rect.iec-source-attr-double {
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-match-status-external rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-external rect.iec-source-attr-double {
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-viewer .iec-entity-group.cr-match-status-pending rect.iec-source-pattern-inner,
.svg-viewer .iec-entity-group.cr-match-status-pending rect.iec-source-attr-double {
  stroke: #64748b !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  filter: none !important;
  opacity: 0 !important;
}

.svg-hover-ref-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.svg-hover-ref-type-badge--wire {
  background: #ea580c;
}

.svg-hover-ref-type-badge--device {
  background: #2563eb;
}

.svg-hover-ref-type-badge--fence {
  background: #2563eb;
}

.svg-hover-ref-type-badge--block {
  background: #0891b2;
}

.svg-hover-ref-type-badge--terminal {
  background: #7c3aed;
}

.svg-hover-ref-type-badge--ambiguous {
  background: #dc2626;
}

.svg-hover-ref-type-badge--unknown {
  background: #475569;
}

.svg-hover-ref-type-device-name {
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  white-space: nowrap;
}

.svg-hover-search-debug-section {
  border-top: 1px solid #e0e0e0;
  padding-top: 6px;
  margin-top: 2px;
}

.svg-hover-search-debug-section .svg-hover-source {
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.svg-hover-search-debug-body {
  font-size: 11px;
  color: #475569;
  line-height: 1.5;
}

.svg-hover-search-debug-body p {
  margin: 0 0 4px 0;
}

.svg-hover-search-debug-body strong {
  color: #1e293b;
}

.svg-hover-search-debug-hint {
  color: #3b82f6;
  font-style: italic;
}

@media (max-width: 960px) {
  .svg-text-search {
    width: 100%;
    margin-left: 0;
  }

  .svg-text-search-field {
    flex: 1 1 auto;
  }

  .svg-text-search-input {
    width: 100%;
    max-width: none;
  }
}

@media (prefers-color-scheme: dark) {
  .svg-text-search-mode,
  .svg-text-search-field {
    border-color: #475569;
    background: #0f172a;
    color: #e5e7eb;
  }

  .svg-text-search-input {
    border-color: #475569;
    background: #0f172a !important;
    color: #e5e7eb;
    caret-color: #93c5fd;
  }

  .svg-text-search-input:focus,
  .svg-text-search-input:focus-visible {
    background: #0f172a !important;
    color: #e5e7eb;
  }

  .svg-text-search-input::selection {
    background: #2563eb;
    color: #ffffff;
  }

  .svg-text-search-clear {
    color: #94a3b8;
  }

  .svg-text-search-count {
    color: #cbd5e1 !important;
  }

  .svg-viewer .svg-text-search-hit {
    fill: #fde047;
    fill-opacity: 0.96;
    stroke: #facc15;
  }

  .svg-hover-search-debug-section { border-top-color: #334155; }
  .svg-hover-search-debug-section .svg-hover-source { color: #a5b4fc; }
  .svg-hover-search-debug-body { color: #cbd5e1; }
  .svg-hover-search-debug-body strong { color: #f1f5f9; }
  .svg-hover-search-debug-hint { color: #60a5fa; }
  .svg-hover-ref-type-device-name { color: #e2e8f0; }
}
