/* ==========================================================================
   Product Assembly & n8n Flow Builder Stylesheet
   High-Density Enterprise Visual Manufacturing Architecture
   ========================================================================== */

#view-products.active {
  display: block !important;
  height: calc(100vh - 48px);
  overflow: hidden;
}

.products-wrapper {
  display: flex;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-main);
}

/* --------------------------------------------------------------------------
   1. Sub-Sidebar: Product Catalog & Selector
   -------------------------------------------------------------------------- */
.products-sub-sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 20;
}

.sub-sidebar-header {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.sub-sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.sub-sidebar-title {
  font-size: 0.785rem;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sub-sidebar-search-box {
  position: relative;
}

.sub-sidebar-search-box input {
  width: 100%;
  height: 28px;
  padding: 0.2rem 0.5rem 0.2rem 1.75rem;
  font-size: 0.725rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-alt);
}

.sub-sidebar-search-box svg {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  width: 12px;
  height: 12px;
}

.products-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.product-item-card {
  padding: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  position: relative;
}

.product-item-card:hover {
  border-color: #059669;
  background: #f0fdf4;
}

.product-item-card.active {
  border-color: #059669;
  background: #ecfdf5;
  box-shadow: 0 1px 3px rgba(5, 150, 105, 0.15);
}

.product-item-card.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3.5px;
  background: #059669;
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.product-item-thumb {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  object-fit: cover;
  flex-shrink: 0;
}

.product-item-info {
  flex: 1;
  min-width: 0;
}

.product-item-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.product-item-sku {
  font-size: 0.625rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 0.05rem;
}

.product-item-meta {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.product-stock-tag {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.08rem 0.3rem;
  border-radius: var(--radius-xs);
  background: #d1fae5;
  color: #065f46;
}

/* --------------------------------------------------------------------------
   2. Main Content Body: Header Banner & Interactive n8n Canvas
   -------------------------------------------------------------------------- */
.products-main-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Product Overview Banner - Compact Enterprise Density */
.product-banner-card {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.38rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  z-index: 15;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.product-banner-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  width: 100%;
}

.product-banner-bottom-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
}

.product-banner-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.product-banner-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  flex-shrink: 0;
}

.product-banner-details {
  min-width: 0;
}

.product-banner-title {
  font-size: 0.925rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.product-banner-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  font-size: 0.675rem;
  color: var(--text-muted);
}

.product-banner-sku-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  background: #f1f5f9;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  color: #334155;
  font-size: 0.675rem;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
}

/* KPI Badges on Banner */
.product-banner-metrics {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.metric-pill {
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-xs);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  text-align: right;
  min-width: 75px;
}

.metric-pill-label {
  font-size: 0.525rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-light);
  display: block;
}

.metric-pill-val {
  font-size: 0.785rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
}

.metric-pill.green {
  background: #ecfdf5;
  border-color: #a7f3d0;
}
.metric-pill.green .metric-pill-label {
  color: #065f46;
}
.metric-pill.green .metric-pill-val {
  color: #059669;
}

.metric-pill.blue {
  background: #f0f9ff;
  border-color: #bae6fd;
}
.metric-pill.blue .metric-pill-label {
  color: #0369a1;
}
.metric-pill.blue .metric-pill-val {
  color: #0284c7;
}

/* ==========================================================================
   Product Banner Actions Toolbar (Thematic Semantic Colors & Crisp Visibility)
   ========================================================================== */
.product-banner-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.product-banner-actions .btn {
  height: 25px;
  padding: 0 0.48rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

/* 1. Assemble Product: Vibrant Emerald Green */
#btnAssembleProduct {
  background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
  color: #ffffff !important;
  border: 1px solid #047857 !important;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.25) !important;
}
#btnAssembleProduct:hover {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(5, 150, 105, 0.35) !important;
}
#btnAssembleProduct svg {
  stroke: #ffffff;
  fill: #ffffff;
}

/* 2. Edit Product: Warm Golden Amber */
#btnEditProductModal {
  background: #fffbeb !important;
  color: #b45309 !important;
  border: 1.5px solid #fde68a !important;
  box-shadow: 0 1px 2px rgba(245, 158, 11, 0.1) !important;
}
#btnEditProductModal:hover {
  background: #fef3c7 !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(245, 158, 11, 0.2) !important;
}

/* 3. Add Node: Sky Blue / Cyan Accent */
#btnAddNodeModal {
  background: #f0f9ff !important;
  color: #0284c7 !important;
  border: 1.5px solid #bae6fd !important;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.1) !important;
}
#btnAddNodeModal:hover {
  background: #e0f2fe !important;
  border-color: #0284c7 !important;
  color: #0369a1 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(2, 132, 199, 0.2) !important;
}

/* 4. Save Layout: Royal Purple / Violet Accent */
#btnSaveCanvasLayout {
  background: #faf5ff !important;
  color: #7c3aed !important;
  border: 1.5px solid #ddd6fe !important;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.1) !important;
}
#btnSaveCanvasLayout:hover {
  background: #f3e8ff !important;
  border-color: #7c3aed !important;
  color: #5b21b6 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(124, 58, 237, 0.2) !important;
}

/* 4.5. Auto-Arrange: Indigo / Deep Blue Accent */
#btnBannerAutoArrange,
#btnAutoArrangeFlow {
  background: #eef2ff !important;
  color: #4f46e5 !important;
  border: 1.5px solid #c7d2fe !important;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.1) !important;
}
#btnBannerAutoArrange:hover,
#btnAutoArrangeFlow:hover {
  background: #e0e7ff !important;
  border-color: #4f46e5 !important;
  color: #3730a3 !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(79, 70, 229, 0.2) !important;
}

/* 5. Fullscreen: Modern Clean Slate */
#btnBannerFullscreen {
  background: #f8fafc !important;
  color: #334155 !important;
  border: 1.5px solid #cbd5e1 !important;
  box-shadow: 0 1px 2px rgba(51, 65, 85, 0.08) !important;
}
#btnBannerFullscreen:hover {
  background: #f1f5f9 !important;
  border-color: #94a3b8 !important;
  color: #0f172a !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(51, 65, 85, 0.15) !important;
}

/* 6. Sync / Refresh: Vibrant Fresh Teal */
#btnRefreshFlow {
  background: #f0fdfa !important;
  color: #0d9488 !important;
  border: 1.5px solid #99f6e4 !important;
  box-shadow: 0 1px 2px rgba(13, 148, 136, 0.1) !important;
}
#btnRefreshFlow:hover {
  background: #ccfbf1 !important;
  border-color: #0d9488 !important;
  color: #0f766e !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(13, 148, 136, 0.2) !important;
}

/* --------------------------------------------------------------------------
   3. n8n Node Flow Canvas
   -------------------------------------------------------------------------- */
.n8n-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #f8fafc;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  cursor: grab;
  user-select: none;
}

.n8n-canvas-container.is-panning {
  cursor: grabbing !important;
  user-select: none;
}

.n8n-canvas-workspace {
  position: relative;
  min-width: 2800px;
  min-height: 2200px;
  width: 3800px;
  height: 3000px;
  overflow: visible !important;
}

/* SVG Connection Cables Layer */
.n8n-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible !important;
  pointer-events: none;
  z-index: 5;
}

.n8n-cable-group {
  cursor: pointer;
}

.n8n-cable-path {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2.2px;
  cursor: pointer;
  pointer-events: stroke;
  transition: stroke 0.15s, stroke-width 0.15s, filter 0.15s;
}

.n8n-cable-group:hover .n8n-cable-path {
  stroke: #10b981 !important;
  stroke-width: 3.2px !important;
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.4));
}

.n8n-cable-group.is-selected .n8n-cable-path {
  stroke: #059669 !important;
  stroke-width: 3.8px !important;
  filter: drop-shadow(0 0 8px rgba(5, 150, 105, 0.55));
}

.n8n-cable-flow {
  fill: none;
  stroke: #10b981;
  stroke-width: 1.8px;
  stroke-dasharray: 6 5;
  animation: cableFlowAnim 1.2s linear infinite;
  pointer-events: none;
}

/* Midpoint Interactive Live Dynamic Wire Requirement Badge (Requested by User) */
.n8n-cable-badge-wrap {
  cursor: pointer;
  pointer-events: all;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.n8n-cable-badge-pill {
  fill: #ffffff;
  stroke: #059669;
  stroke-width: 1.6px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.12));
  transition: fill 0.15s, stroke 0.15s, filter 0.15s;
}

.n8n-cable-badge-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 800;
  fill: #065f46;
  pointer-events: none;
}

.n8n-cable-badge-icon {
  fill: #10b981;
  pointer-events: none;
}

.n8n-cable-badge-wrap:hover .n8n-cable-badge-pill,
.n8n-cable-group:hover .n8n-cable-badge-pill {
  fill: #f0fdf4;
  stroke: #047857;
  stroke-width: 2px;
  filter: drop-shadow(0 3px 8px rgba(5, 150, 105, 0.28));
}

.n8n-cable-group.is-selected .n8n-cable-badge-pill {
  fill: #ecfdf5;
  stroke: #059669;
  stroke-width: 2.2px;
  filter: drop-shadow(0 0 10px rgba(5, 150, 105, 0.45));
}

/* Centered Interactive Disconnect Button on Wire */
.n8n-cable-disconnect-pill {
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: all;
  cursor: pointer;
}

.n8n-cable-group:hover .n8n-cable-disconnect-pill {
  opacity: 1;
}

.n8n-disconnect-circle {
  fill: #ef4444;
  stroke: #ffffff;
  stroke-width: 2px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
  transition: fill 0.15s, transform 0.15s;
}

.n8n-cable-disconnect-pill:hover .n8n-disconnect-circle {
  fill: #dc2626;
  transform: scale(1.18);
}

@keyframes cableFlowAnim {
  from {
    stroke-dashoffset: 22;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.n8n-cable-drawing {
  fill: none;
  stroke: #2563eb;
  stroke-width: 3.2px;
  stroke-dasharray: 6 5;
  filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.75));
  pointer-events: none;
  animation: cableFlowAnim 0.9s linear infinite;
}

.n8n-cable-drawing.drawing-normal {
  stroke: #059669;
  filter: drop-shadow(0 0 6px rgba(5, 150, 105, 0.5));
}

.n8n-cable-drawing.drawing-blue {
  stroke: #2563eb;
  filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.85));
}

.n8n-cable-drawing.drawing-yellow {
  stroke: #f59e0b;
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.85));
}

/* ==========================================================================
   Live Dynamic Blue Wire (Gram to Piece Conversion Mode)
   ========================================================================== */
.n8n-cable-group.cable-gram-to-piece .n8n-cable-path {
  stroke: #2563eb !important;
  stroke-width: 2.8px !important;
}

.n8n-cable-group.cable-gram-to-piece:hover .n8n-cable-path {
  stroke: #1d4ed8 !important;
  stroke-width: 3.8px !important;
  filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.55)) !important;
}

.n8n-cable-group.cable-gram-to-piece.is-selected .n8n-cable-path {
  stroke: #1e40af !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 12px rgba(30, 64, 175, 0.7)) !important;
}

.n8n-cable-group.cable-gram-to-piece .n8n-cable-flow {
  stroke: #60a5fa !important;
  stroke-width: 2.2px !important;
  stroke-dasharray: 6 5;
  animation: cableFlowAnim 1.1s linear infinite;
}

.n8n-cable-group.cable-gram-to-piece .n8n-cable-badge-pill {
  fill: #eff6ff !important;
  stroke: #2563eb !important;
  stroke-width: 1.8px !important;
  filter: drop-shadow(0 2px 6px rgba(37, 99, 235, 0.25)) !important;
}

.n8n-cable-group.cable-gram-to-piece .n8n-cable-badge-text {
  fill: #1e40af !important;
  font-weight: 800 !important;
}

.n8n-cable-group.cable-gram-to-piece .n8n-cable-badge-icon {
  fill: #2563eb !important;
}

.n8n-cable-group.cable-gram-to-piece:hover .n8n-cable-badge-pill,
.n8n-cable-group.cable-gram-to-piece.is-selected .n8n-cable-badge-pill {
  fill: #dbeafe !important;
  stroke: #1d4ed8 !important;
  stroke-width: 2.2px !important;
  filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.45)) !important;
}

/* ==========================================================================
   Yellow Conversion Box Wire (Raw Material KG ➔ Empty Yellow Box ➔ Pcs)
   ========================================================================== */
.n8n-cable-group.cable-conversion .n8n-cable-path {
  stroke: #f59e0b !important;
  stroke-width: 2.8px !important;
}

.n8n-cable-group.cable-conversion:hover .n8n-cable-path {
  stroke: #d97706 !important;
  stroke-width: 3.8px !important;
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.55)) !important;
}

.n8n-cable-group.cable-conversion.is-selected .n8n-cable-path {
  stroke: #b45309 !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 12px rgba(180, 83, 9, 0.7)) !important;
}

.n8n-cable-group.cable-conversion .n8n-cable-flow {
  stroke: #fbbf24 !important;
  stroke-width: 2.2px !important;
  stroke-dasharray: 6 5;
  animation: cableFlowAnim 1.1s linear infinite;
}

.n8n-cable-group.cable-conversion .n8n-cable-badge-pill {
  fill: #fffbeb !important;
  stroke: #f59e0b !important;
  stroke-width: 1.8px !important;
  filter: drop-shadow(0 2px 6px rgba(245, 158, 11, 0.25)) !important;
}

.n8n-cable-group.cable-conversion .n8n-cable-badge-text {
  fill: #92400e !important;
  font-weight: 800 !important;
}

.n8n-cable-group.cable-conversion .n8n-cable-badge-icon {
  fill: #f59e0b !important;
}

.n8n-cable-group.cable-conversion:hover .n8n-cable-badge-pill,
.n8n-cable-group.cable-conversion.is-selected .n8n-cable-badge-pill {
  fill: #fef3c7 !important;
  stroke: #d97706 !important;
  stroke-width: 2.2px !important;
  filter: drop-shadow(0 0 10px rgba(245, 158, 11, 0.45)) !important;
}

/* Wire Mode Selector (Normal vs Gram to Piece) */
.wire-mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.wire-mode-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  position: relative;
  transition: all 0.18s ease;
  user-select: none;
}

.wire-mode-card:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.wire-mode-card.active.normal {
  border-color: #10b981;
  background: #ecfdf5;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.wire-mode-card.active.gram {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.wire-mode-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.wire-mode-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wire-mode-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #0f172a;
}

.wire-mode-sub {
  font-size: 0.65rem;
  color: #64748b;
  line-height: 1.2;
}

.wire-mode-check {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  align-items: center;
  justify-content: center;
}

.wire-mode-card.active.normal .wire-mode-check {
  display: flex;
  background: #059669;
}

.wire-mode-card.active.gram .wire-mode-check {
  display: flex;
  background: #2563eb;
}

/* KG to Gram and Gram to Piece Calculator Box */
.kg-gram-calc-box {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1.5px solid #93c5fd;
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.kg-gram-calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(37, 99, 235, 0.25);
  padding-bottom: 0.4rem;
}

.kg-gram-calc-title {
  font-size: 0.775rem;
  font-weight: 800;
  color: #1e40af;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.kg-gram-calc-badge {
  font-size: 0.65rem;
  font-weight: 800;
  background: #2563eb;
  color: #ffffff;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.kg-gram-quick-ref {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  color: #1e3a8a;
  font-weight: 700;
}

.calc-ratio-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.55rem;
}

.calc-ratio-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.calc-ratio-field label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #1e40af;
}

.calc-ratio-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.calc-ratio-input {
  width: 100%;
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e3a8a;
  background: #ffffff;
  border: 1.5px solid #93c5fd;
  border-radius: 7px;
  padding: 0.4rem 2.2rem 0.4rem 0.65rem;
  outline: none;
  transition: border-color 0.15s;
}

.calc-ratio-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.calc-ratio-unit {
  position: absolute;
  right: 0.55rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: #3b82f6;
  pointer-events: none;
}

.calc-ratio-arrow {
  font-size: 1.15rem;
  font-weight: 900;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.9rem;
}

.calc-summary-card {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.calc-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
}

.calc-summary-label {
  color: #475569;
  font-weight: 600;
}

.calc-summary-val {
  color: #1e40af;
  font-weight: 800;
}

/* Focus and pulse effects */
.wire-glow-pulse {
  animation: bluePulseGlow 1.5s infinite;
}

@keyframes bluePulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* ==========================================================================
   n8n Wireframe Node Design (Redesigned with Full Material Name Box)
   ========================================================================== */
.n8n-node {
  position: absolute;
  width: 240px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  user-select: none;
  z-index: 10;
  cursor: grab;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.12s;
  box-sizing: border-box;
}

.n8n-node:hover {
  box-shadow: 0 10px 22px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

.n8n-node.is-dragging {
  cursor: grabbing !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.22), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 50;
  opacity: 0.95;
  transform: scale(1.02);
}

.n8n-node.is-selected {
  border-color: #059669;
  outline: 2.5px solid rgba(5, 150, 105, 0.4);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15), 0 10px 20px -3px rgba(0, 0, 0, 0.1);
}

/* Node Types Theming & Border Accents */
.n8n-node.node-type-raw_material {
  border-color: #a7f3d0;
}
.n8n-node.node-type-raw_material.is-selected {
  border-color: #10b981;
  outline-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2), 0 10px 20px -3px rgba(0, 0, 0, 0.1);
}

.n8n-node.node-type-sub_assembly {
  border-color: #bae6fd;
}
.n8n-node.node-type-sub_assembly.is-selected {
  border-color: #0284c7;
  outline-color: rgba(2, 132, 199, 0.45);
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.2), 0 10px 20px -3px rgba(0, 0, 0, 0.1);
}

.n8n-node.node-type-final_output {
  border-color: #ddd6fe;
}
.n8n-node.node-type-final_output.is-selected {
  border-color: #8b5cf6;
  outline-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2), 0 10px 20px -3px rgba(0, 0, 0, 0.1);
}

.n8n-node.has-zero-stock {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35), 0 6px 14px -2px rgba(239, 68, 68, 0.15) !important;
}

/* --------------------------------------------------------------------------
   Tier 1: Top Row (Type Badge on Left, SKU/Stage Tag on Right)
   -------------------------------------------------------------------------- */
.n8n-node-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 6px;
}

.n8n-pill-badge {
  flex-shrink: 0;
  height: 22px;
  border-radius: 9999px;
  padding: 0 8px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.n8n-pill-badge.badge-raw_material,
.node-type-raw_material .n8n-pill-badge {
  background: #10b981;
}

.n8n-pill-badge.badge-sub_assembly,
.node-type-sub_assembly .n8n-pill-badge {
  background: #0284c7;
}

.n8n-pill-badge.badge-final_output,
.node-type-final_output .n8n-pill-badge {
  background: #8b5cf6;
}

/* Clean Monospace SKU Tag */
.n8n-node-sku-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.625rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Tier 2: Center Row (Central Hub Avatar + Left/Right Ports)
   -------------------------------------------------------------------------- */
.n8n-node-center-row {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 94px;
  padding: 4px 0;
}

.n8n-node-hub {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  transition: transform 0.15s, border-color 0.15s;
}

.node-type-raw_material .n8n-node-hub {
  border: 3.5px solid #10b981;
  background: #f0fdf4;
}

.node-type-sub_assembly .n8n-node-hub {
  border: 3.5px solid #0284c7;
  background: #f0f9ff;
}

.node-type-final_output .n8n-node-hub {
  border: 3.5px solid #8b5cf6;
  background: #f5f3ff;
}

.n8n-node.has-zero-stock .n8n-node-hub {
  border: 3.5px solid #ef4444 !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.35) !important;
}

.n8n-node-hub-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.n8n-node-hub-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

.n8n-node-hub-fallback svg {
  width: 38px;
  height: 38px;
}

.node-type-raw_material .n8n-node-hub-fallback {
  color: #059669;
}

.node-type-sub_assembly .n8n-node-hub-fallback {
  color: #0284c7;
}

.node-type-final_output .n8n-node-hub-fallback {
  color: #8b5cf6;
}

/* --------------------------------------------------------------------------
   Material Name Box (Full Un-Truncated Name Display requested by User)
   -------------------------------------------------------------------------- */
.n8n-material-info-box {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  text-align: center;
  box-sizing: border-box;
}

.node-type-raw_material .n8n-material-info-box {
  background: #f0fdf4;
  border-color: #d1fae5;
}

.node-type-sub_assembly .n8n-material-info-box {
  background: #f0f9ff;
  border-color: #e0f2fe;
}

.node-type-final_output .n8n-material-info-box {
  background: #faf5ff;
  border-color: #f3e8ff;
}

.n8n-material-main-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  word-break: break-word;
}

.node-type-raw_material .n8n-material-main-name {
  color: #064e3b;
}

.node-type-sub_assembly .n8n-material-main-name {
  color: #0369a1;
}

.node-type-final_output .n8n-material-main-name {
  color: #581c87;
}

.n8n-material-sub-name {
  font-size: 0.675rem;
  font-weight: 500;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Connector Ports with Extra Large 36px Invisible Hit Targets
   (Effortless dragging & dropping without having to zoom in!)
   -------------------------------------------------------------------------- */
.n8n-port {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  cursor: crosshair;
  z-index: 30;
  transition: transform 0.15s, box-shadow 0.15s;
}

/* 36px Hit Target around port for easy connecting */
.n8n-port::before {
  content: "";
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 50%;
  cursor: crosshair;
}

.n8n-port:hover {
  transform: translateY(-50%) scale(1.35);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.7);
}

.n8n-port-in {
  left: -19px;
  border: 3px solid #0284c7;
}

.n8n-port-out {
  right: -19px;
  border: 3px solid #10b981;
}

/* --------------------------------------------------------------------------
   Tier 3: Bottom Row Wide Pill
   -------------------------------------------------------------------------- */
.n8n-node-bottom-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.n8n-pill-bottom {
  width: 100%;
  height: 26px;
  border-radius: 9999px;
  padding: 0 8px;
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-sizing: border-box;
}

.n8n-pill-bottom.in-stock {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.n8n-pill-bottom.low-stock {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.n8n-pill-bottom.out-of-stock {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.n8n-pill-bottom.final-stock {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  color: #5b21b6;
}

.n8n-pill-sep {
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1;
}

.n8n-mini-action-btn {
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 2px 7px;
  font-size: 0.6rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: background 0.15s, transform 0.1s;
  line-height: 1.2;
}

.n8n-mini-action-btn:hover {
  background: #0369a1;
  transform: scale(1.05);
}

.n8n-mini-action-btn.assemble {
  background: #8b5cf6;
}

.n8n-mini-action-btn.assemble:hover {
  background: #7c3aed;
}

/* Floating Right-Click Context Menu */
.n8n-context-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 0.35rem 0;
  min-width: 170px;
  z-index: 1000;
  display: none;
}

.n8n-context-menu.show {
  display: block;
  animation: menuFade 0.1s ease-out;
}

@keyframes menuFade {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.n8n-context-item {
  padding: 0.38rem 0.75rem;
  font-size: 0.725rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.1s, color 0.1s;
}

.n8n-context-item:hover {
  background: #f1f5f9;
  color: #059669;
}

.n8n-context-item.danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.n8n-context-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.25rem 0;
}

/* Image Upload Dropzone */
.image-upload-dropzone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.image-upload-dropzone:hover {
  border-color: #059669;
  background: #f0fdf4;
}

.image-upload-dropzone-preview {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  margin: 0 auto 0.35rem;
  display: block;
}

/* ==========================================================================
   Top Legend & Canvas Controls Bar (Dedicated Top Bar Toolbar above Canvas)
   ========================================================================== */
.n8n-canvas-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.n8n-canvas-unified-bar {
  position: relative;
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 10;
  flex-shrink: 0;
  user-select: none;
}

.n8n-canvas-unified-bar .n8n-canvas-legend {
  position: static;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
}

.n8n-canvas-unified-bar .legend-hint {
  color: #64748b;
  font-size: 0.625rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 550px;
}

.n8n-canvas-unified-bar .n8n-canvas-toolbar {
  position: static;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

@media (max-width: 1100px) {
  .n8n-canvas-unified-bar .legend-hint {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   4. Sub-Sidebar Tabs: Products vs Drag & Drop Component Palette
   -------------------------------------------------------------------------- */
.sub-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
}

.sub-tab-btn {
  flex: 1;
  padding: 0.5rem 0.4rem;
  border: none;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.sub-tab-btn:hover {
  color: var(--text-main);
  background: #f1f5f9;
}

.sub-tab-btn.active {
  color: #059669;
  background: #ffffff;
  border-bottom-color: #059669;
}

/* Palette Items List */
.palette-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.palette-section-title {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.35rem 0.25rem 0.15rem;
}

.palette-item {
  padding: 0.45rem 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.15s ease;
  user-select: none;
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item:hover {
  border-color: #059669;
  background: #f0fdf4;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.12);
  transform: translateY(-1px);
}

.palette-item.is-template {
  border-left: 3.5px solid #0284c7;
}

.palette-item.is-template.final {
  border-left: 3.5px solid #8b5cf6;
}

.palette-item-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  flex-shrink: 0;
}

.palette-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: #f1f5f9;
}

.palette-item-info {
  flex: 1;
  min-width: 0;
}

.palette-item-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.palette-item-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  font-size: 0.6rem;
}

.palette-item-grip {
  color: #cbd5e1;
  font-size: 0.85rem;
  letter-spacing: -2px;
  padding-left: 0.2rem;
}

/* Fullscreen Canvas Mode (Includes Products & Raw Materials Sidebar Docked on the Left) */
.products-wrapper.canvas-fullscreen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  background: #f8fafc !important;
  display: flex !important;
  flex-direction: row !important;
  overflow: hidden !important;
}

.products-wrapper.canvas-fullscreen-mode .products-sub-sidebar {
  width: 260px !important;
  min-width: 260px !important;
  max-width: 260px !important;
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: 100vh !important;
  z-index: 1000000 !important;
  background: #ffffff !important;
  border-right: 1.5px solid #e2e8f0 !important;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.06) !important;
  display: flex !important;
  flex-direction: column !important;
  flex-shrink: 0 !important;
  transition: margin-left 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.18s ease;
}

.products-sub-sidebar.collapsed {
  margin-left: -260px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
}

.products-wrapper.canvas-fullscreen-mode .products-main-body {
  flex: 1 !important;
  min-width: 0 !important;
  height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  background: #f8fafc !important;
}

.products-wrapper.canvas-fullscreen-mode .product-banner-card {
  padding: 0.45rem 1rem !important;
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  border-top: none !important;
  margin-bottom: 0 !important;
  flex-shrink: 0 !important;
}

.products-wrapper.canvas-fullscreen-mode .canvas-inspector-layout {
  flex: 1 !important;
  min-height: 0 !important;
  height: calc(100vh - 58px) !important;
}

.products-wrapper.canvas-fullscreen-mode .n8n-canvas-container {
  height: auto !important;
  flex: 1 !important;
}

.products-main-body.canvas-fullscreen-mode {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Stock Alert Notification Banner */
.n8n-stock-alert-banner {
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  z-index: 16;
}

.n8n-stock-alert-banner strong {
  font-weight: 800;
}

/* Empty Canvas Guidance State */
.n8n-empty-state {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 2rem 2.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  max-width: 480px;
  z-index: 12;
  pointer-events: auto;
}

.n8n-empty-state-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.n8n-empty-state-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.n8n-empty-state-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1rem;
}

.n8n-empty-state-actions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
}

/* --------------------------------------------------------------------------
   5. Canvas Inspector Layout & Right-Side Details Sub-Sidebar
   -------------------------------------------------------------------------- */
.canvas-inspector-layout {
  display: flex;
  flex: 1 1 0%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  max-height: 100%;
}

.products-main-body.canvas-fullscreen-mode .canvas-inspector-layout {
  height: calc(100vh - 58px) !important;
}

/* Right-Side Sub-Sidebar / Inspector Panel */
.node-inspector-sidebar {
  width: 320px;
  min-width: 320px;
  max-width: 340px;
  background: #ffffff;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  box-shadow: -4px 0 15px rgba(0, 0, 0, 0.04);
  z-index: 25;
  animation: slideInRight 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#inspectorNodeView,
#inspectorWireView {
  display: none;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  flex: 1 1 0%;
  overflow: hidden;
}

#inspectorNodeView.active,
#inspectorWireView.active {
  display: flex !important;
}

/* Side-Wise Inspector Navigation Tabs */
.inspector-tabs-nav {
  display: flex;
  background: #f8fafc;
  border-bottom: 1.5px solid var(--border-color);
  padding: 0.35rem 0.65rem;
  gap: 0.35rem;
  flex-shrink: 0;
}

.inspector-tab-pill {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.725rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.inspector-tab-pill:hover {
  background: #ffffff;
  color: #0f172a;
}

.inspector-tab-pill.active {
  background: #ffffff;
  color: #059669;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.inspector-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #ffffff;
  flex-shrink: 0;
  z-index: 2;
}

.inspector-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.inspector-thumb-wrap {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.inspector-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.inspector-thumb-wrap .inspector-icon-fallback {
  font-size: 1.1rem;
}

.inspector-title-wrap {
  min-width: 0;
}

.inspector-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
  word-break: break-word;
  margin: 0 0 0.2rem 0;
  line-height: 1.35;
}

.inspector-type-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: #ecfdf5;
  color: #059669;
}

.inspector-type-badge.sub-assembly {
  background: #e0f2fe;
  color: #0284c7;
}

.inspector-type-badge.final-output {
  background: #f5f3ff;
  color: #8b5cf6;
}

.inspector-type-badge.wire-badge {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* Wire Inspector Flow Card & Details */
.wire-inspector-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1.5px solid #a7f3d0;
  color: #059669;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.wire-path-flow-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
}

.wire-node-card {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

.wire-node-card.source-box {
  border-left: 3.5px solid #059669;
}

.wire-node-card.target-box {
  border-left: 3.5px solid #7c3aed;
}

.wire-node-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.wire-node-tag {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #64748b;
  text-transform: uppercase;
}

.wire-node-name {
  font-size: 0.825rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wire-node-sku {
  font-size: 0.68rem;
  color: #64748b;
  font-family: monospace;
}

.wire-flow-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.1rem 0;
}

.wire-flow-line {
  flex: 1;
  height: 1px;
  background: #cbd5e1;
}

.wire-flow-pill {
  font-size: 0.65rem;
  font-weight: 700;
  color: #059669;
  background: #ecfdf5;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  border: 1px solid #a7f3d0;
  white-space: nowrap;
}

.wire-inspector-top-tag {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 700;
}

/* Connect Dynamic Wire In-App Modal Dialog */
.connect-wire-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #059669;
  border: 1.5px solid #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.connect-wire-diagram-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.connect-wire-node-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
}

.connect-wire-node-badge {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.connect-wire-node-badge.source {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.connect-wire-node-badge.target {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.connect-wire-node-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.connect-wire-arrow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.connect-wire-line {
  flex: 1;
  height: 1px;
  background: #cbd5e1;
}

.connect-wire-arrow-pill {
  font-size: 0.625rem;
  font-weight: 700;
  color: #059669;
  background: #ecfdf5;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  border: 1px solid #a7f3d0;
  white-space: nowrap;
}

.inspector-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.inspector-close-btn:hover {
  color: #1e293b;
  background: #f1f5f9;
}

.inspector-body {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 0.85rem 1rem 3.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f8fafc;
}

.inspector-body::-webkit-scrollbar {
  width: 7px;
}
.inspector-body::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 4px;
}
.inspector-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.inspector-body::-webkit-scrollbar-thumb:hover {
  background: #059669;
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.inspector-section-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.inspector-stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.inspector-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.inspector-stat-key {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.inspector-stat-val {
  font-weight: 700;
  color: var(--text-main);
}

.inspector-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.inspector-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
}

.inspector-input-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.inspector-input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.775rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  background: #ffffff;
}

.inspector-input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

.inspector-unit-badge {
  font-size: 0.68rem;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
}

.inspector-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.inspector-connections-list {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 48px;
  max-height: 160px;
  overflow-y: auto;
}

.inspector-conn-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.45rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.7rem;
}

.inspector-conn-tag {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.inspector-conn-tag.in {
  background: #e0f2fe;
  color: #0284c7;
}

.inspector-conn-tag.out {
  background: #ecfdf5;
  color: #059669;
}

.inspector-conn-disconnect-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  font-size: 0.75rem;
  border-radius: 3px;
}

.inspector-conn-disconnect-btn:hover {
  background: #fee2e2;
}

.inspector-button-row {
  display: flex;
  gap: 0.5rem;
}

/* Selected Node on Canvas */
.n8n-node.is-selected {
  border-color: #059669 !important;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.28), 0 10px 25px -5px rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-1px);
}

/* ==========================================================================
   Worker Profile & Output Tracking Overlay Styles
   ========================================================================== */
.n8n-node-hub.is-worker-hub {
  border-color: #10b981 !important;
  background: #f0fdf4 !important;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25) !important;
}

.n8n-worker-dp-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  user-select: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
}

.n8n-worker-dp-box {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.n8n-worker-dp-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   YELLOW CONVERSION BOX (KG ➔ PCS FORMULA ARCHITECTURE)
   Excel Formula: In pcs = Input in KG [H10] / Weight in KG [G10]
   ========================================================================== */
.n8n-node.node-type-conversion {
  border-color: #f59e0b !important;
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%) !important;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.15) !important;
}

.n8n-node.node-type-conversion:hover {
  border-color: #d97706 !important;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25) !important;
}

.n8n-node.node-type-conversion.is-selected {
  border-color: #d97706 !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35), 0 8px 24px rgba(245, 158, 11, 0.22) !important;
}

.n8n-type-badge.badge-conversion {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  letter-spacing: 0.03em !important;
  border-radius: 4px;
}

.n8n-node.node-type-conversion .n8n-node-hub {
  border-color: #fbbf24 !important;
  background: #fef3c7 !important;
  color: #d97706 !important;
}

.n8n-pill-bottom.conversion-stock {
  background: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #fde68a !important;
  font-weight: 800 !important;
}

/* White Storage Box (Converted PCS Buffer Node) */
.n8n-node.node-type-storage_box {
  background: #ffffff !important;
  border: 2px solid #cbd5e1 !important;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08) !important;
}

.n8n-node.node-type-storage_box .n8n-node-hub {
  border-color: #94a3b8 !important;
  background: #f8fafc !important;
  color: #334155 !important;
}

.n8n-type-badge.badge-storage_box {
  background: #f1f5f9 !important;
  color: #334155 !important;
  border: 1px solid #cbd5e1 !important;
  font-weight: 800 !important;
  border-radius: 4px;
}

.n8n-pill-bottom.storage-box-stock {
  background: #f8fafc !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  font-weight: 800 !important;
}

/* Dedicated Conversion Palette & Inspector Styles */
.conversion-calc-card {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
}

.conversion-formula-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid #fde68a;
  margin-bottom: 0.65rem;
  width: 100%;
}

.palette-item-card.conversion-card {
  border-color: #fde68a;
  background: #fffbeb;
}

.palette-item-card.conversion-card:hover {
  border-color: #f59e0b;
  background: #fef3c7;
}

.palette-item-card.conversion-card .palette-item-icon {
  background: #fef3c7;
  border-color: #fde68a;
  color: #d97706;
}

.n8n-worker-badge-pin {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #064e3b;
  color: #ffffff;
  font-size: 0.75rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.n8n-worker-name-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.685rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.n8n-worker-pill-role {
  font-size: 0.575rem;
  background: #059669;
  color: #ffffff;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-weight: 800;
}

.n8n-pill-bottom.has-extra-production {
  background: #ecfdf5 !important;
  border-color: #6ee7b7 !important;
  color: #065f46 !important;
}

.n8n-pill-bottom.target-achieved {
  background: #f0fdf4 !important;
  border-color: #bbf7d0 !important;
  color: #166534 !important;
}

.n8n-pill-bottom.target-pending {
  background: #f0f9ff !important;
  border-color: #bae6fd !important;
  color: #0369a1 !important;
}

.n8n-extra-pill {
  animation: pulseExtra 1.8s infinite;
}

@keyframes pulseExtra {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

