/* ── EMIS Setup & Configuration Module ──────────────────────────────────────── */

/* ── Page wrapper ────────────────────────────────────────────────────────── */
#setupConfig { padding: 0; }

.cfg-shell {
  background: #f0f4f8;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(20,48,68,.10);
  box-shadow: 0 2px 16px rgba(20,48,68,.06);
}

/* ── Active Site Selector ────────────────────────────────────────────────── */
.cfg-site-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 12px;
  background: linear-gradient(180deg, #0d2233 0%, #143044 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.cfg-site-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
}
.cfg-site-selector select {
  padding: 6px 32px 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.10);
  color: #e7f3f8;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0bfce' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 180px;
  transition: border-color .15s, background-color .15s;
}
.cfg-site-selector select:hover,
.cfg-site-selector select:focus {
  border-color: rgba(255,255,255,.35);
  background-color: rgba(255,255,255,.16);
  outline: none;
}
.cfg-site-selector select option {
  background: #143044;
  color: #e7f3f8;
}

/* ── Tab Bar ─────────────────────────────────────────────────────────────── */
.cfg-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 20px 0;
  background: linear-gradient(180deg, #143044 0%, #1a3d55 100%);
  overflow-x: auto;
  scrollbar-width: none;
}
.cfg-tabs::-webkit-scrollbar { display: none; }

.cfg-tab {
  padding: 10px 18px 12px;
  font-size: 12.5px;
  font-weight: 700;
  color: rgba(255,255,255,.55);
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 10px 10px 0 0;
  white-space: nowrap;
  letter-spacing: .03em;
  transition: color .15s, background .15s;
  position: relative;
}
.cfg-tab:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.08); }
.cfg-tab.active {
  color: #143044;
  background: #f0f4f8;
  font-weight: 800;
}

.cfg-tab-panel { display: none; padding: 20px; }
.cfg-tab-panel.active { display: block; }

/* ── Split Pane (Hierarchy tab) ──────────────────────────────────────────── */
.cfg-split {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
  min-height: 560px;
}
@media (max-width: 768px) { .cfg-split { grid-template-columns: 1fr; } }

/* ── Tree Panel ──────────────────────────────────────────────────────────── */
.tree-panel {
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(20,48,68,.09);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(20,48,68,.06);
}
.tree-panel-header {
  padding: 12px 14px;
  background: linear-gradient(135deg,#f7fbff,#eef4fb);
  border-bottom: 1px solid rgba(20,48,68,.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tree-panel-header h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #607588;
}
.tree-scroll { overflow-y: auto; max-height: 580px; }
.tree-root { list-style: none; margin: 0; padding: 6px 0; }
.tree-item { list-style: none; }
.tree-item-row {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  padding: 7px 10px 7px 12px;
  cursor: pointer;
  transition: background .12s;
  min-height: 36px;
  user-select: none;
  border-left: 3px solid transparent;
}
.tree-item-row:hover {
  background: linear-gradient(90deg, rgba(21,94,159,.06), transparent);
  border-left-color: rgba(21,94,159,.2);
}
.tree-item-row.selected {
  background: linear-gradient(90deg, rgba(21,94,159,.12), rgba(21,94,159,.04));
  border-left-color: var(--blue,#155e9f);
}
.tree-item-row.selected .tree-label { font-weight: 700; color: var(--blue,#155e9f); }
.tree-item-row[draggable] { cursor: grab; }
.tree-item-row.drag-over { background: rgba(0,176,80,.1); border-left-color: var(--se,#00b050); }

.tree-toggle {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: #a3b8c8; font-size: 9px; flex-shrink: 0;
  transition: transform .2s;
  border-radius: 4px;
}
.tree-toggle:hover { background: rgba(20,48,68,.08); }
.tree-toggle.open { transform: rotate(90deg); }
.tree-icon { font-size: 13px; flex-shrink: 0; }
.tree-label {
  font-size: 12.5px;
  color: #2d4a5e;
  flex: 1;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  min-width: 0;
}
.tree-code {
  font-size: 10px;
  color: #8fa8b8;
  font-family: 'Courier New', monospace;
  background: rgba(20,48,68,.06);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: .03em;
}
.tree-children { list-style: none; padding: 0; overflow: hidden; }
.tree-children.collapsed { display: none; }
.tree-children.expanded { display: block; }
.tree-add-btn {
  opacity: 0;
  transition: opacity .15s;
  background: rgba(0,176,80,.1);
  border: none;
  color: var(--se,#00b050);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  flex-shrink: 0;
}
.tree-item-row:hover .tree-add-btn { opacity: 1; }

/* ── Detail Panel ────────────────────────────────────────────────────────── */
.detail-panel {
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(20,48,68,.09);
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(20,48,68,.06);
}
.detail-panel-header {
  padding: 18px 22px 16px;
  background: linear-gradient(135deg,#f7fbff,#eef4fb);
  border-bottom: 1px solid rgba(20,48,68,.09);
}
.detail-panel-header h3 { margin: 0 0 3px; font-size: 17px; font-weight: 800; color: #143044; }
.detail-panel-header .detail-meta {
  font-size: 12px;
  color: #607588;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.detail-panel-header .detail-meta .breadcrumb { color: #8fa8b8; }
.detail-panel-header .detail-meta .sep { color: #c5d5df; }
.detail-type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(21,94,159,.1);
  color: var(--blue,#155e9f);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.detail-panel-body { padding: 18px 22px; }
.detail-panel-body .detail-desc {
  font-size: 13px;
  color: #607588;
  line-height: 1.6;
  padding: 10px 14px;
  background: rgba(20,48,68,.03);
  border-radius: 8px;
  border-left: 3px solid rgba(21,94,159,.25);
  margin-bottom: 16px;
}
.detail-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.detail-section-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #a3b8c8;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(20,48,68,.08);
}
.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 260px;
  color: #a3b8c8;
  text-align: center;
  gap: 10px;
  font-size: 13px;
}
.detail-empty-icon { font-size: 44px; opacity: .6; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg,#1a6fc4,#155e9f);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(21,94,159,.28);
  transition: filter .15s, box-shadow .15s;
  white-space: nowrap;
  letter-spacing: .02em;
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 12px rgba(21,94,159,.38); }

.btn-secondary {
  background: #fff;
  color: #2d4a5e;
  border: 1px solid rgba(20,48,68,.18);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn-secondary:hover { background: #f0f4f8; border-color: rgba(20,48,68,.3); }

.btn-danger {
  background: linear-gradient(135deg,#e53e3e,#c53030);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(197,48,48,.25);
  transition: filter .15s;
  white-space: nowrap;
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-success {
  background: linear-gradient(135deg,#00c060,#00904a);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,176,80,.25);
  transition: filter .15s;
  white-space: nowrap;
}
.btn-success:hover { filter: brightness(1.08); }

.btn-sm { padding: 5px 12px; font-size: 11.5px; }

.btn-icon {
  background: #f0f4f8;
  border: 1px solid rgba(20,48,68,.12);
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  color: #607588;
  font-size: 13px;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-icon:hover {
  background: rgba(21,94,159,.08);
  color: var(--blue,#155e9f);
  border-color: rgba(21,94,159,.25);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.cfg-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.cfg-form.single-col { grid-template-columns: 1fr; }
.cfg-field { display: flex; flex-direction: column; gap: 5px; }
.cfg-field.full { grid-column: 1 / -1; }
.cfg-field label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #8090a0;
}
.cfg-field input, .cfg-field select, .cfg-field textarea {
  border: 1.5px solid rgba(20,48,68,.13);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: #143044;
  background: #fff;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.cfg-field input:focus, .cfg-field select:focus, .cfg-field textarea:focus {
  outline: none;
  border-color: var(--blue,#155e9f);
  box-shadow: 0 0 0 3px rgba(21,94,159,.1);
}
.cfg-field textarea { min-height: 72px; resize: vertical; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.cfg-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(20,48,68,.09);
  margin-top: 14px;
  box-shadow: 0 1px 6px rgba(20,48,68,.04);
}
.cfg-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.cfg-table thead tr { background: linear-gradient(135deg,#f7fbff,#eef4fb); }
.cfg-table th {
  padding: 11px 16px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #607588;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1.5px solid rgba(20,48,68,.1);
}
.cfg-table td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(20,48,68,.06);
  vertical-align: middle;
  color: #2d4a5e;
}
.cfg-table tr:last-child td { border-bottom: none; }
.cfg-table tbody tr:hover td { background: rgba(21,94,159,.03); }
.cfg-table-actions { display: flex; gap: 5px; }
.tag-row-highlight td { background: rgba(245,158,11,.12) !important; transition: background .5s; }

/* ── Toolbar / filter row ────────────────────────────────────────────────── */
.cfg-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.cfg-search {
  flex: 1;
  min-width: 180px;
  border: 1.5px solid rgba(20,48,68,.13);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: #143044;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.cfg-search:focus {
  outline: none;
  border-color: var(--blue,#155e9f);
  box-shadow: 0 0 0 3px rgba(21,94,159,.1);
}
.cfg-filter-sel {
  border: 1.5px solid rgba(20,48,68,.13);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #143044;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s;
}
.cfg-filter-sel:focus { outline: none; border-color: var(--blue,#155e9f); }

/* ── Status / type pills ─────────────────────────────────────────────────── */
.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: .02em;
}
.conn-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: conn-pulse 2s ease-in-out infinite;
}
@keyframes conn-pulse {
  0%,100% { opacity:1; }
  50% { opacity:.5; }
}
.conn-status.connected { background: rgba(0,176,80,.1); color: #007a38; }
.conn-status.connected::before { background: #00b050; animation: conn-pulse 2s ease-in-out infinite; }
.conn-status.simulated { background: rgba(21,94,159,.1); color: var(--blue,#155e9f); }
.conn-status.simulated::before { background: var(--blue,#155e9f); animation: none; }
.conn-status.error { background: rgba(220,38,38,.1); color: #c53030; }
.conn-status.error::before { background: #e53e3e; animation: none; }
.conn-status.unconfigured { background: rgba(156,163,175,.15); color: #8090a0; }
.conn-status.unconfigured::before { background: #a3b8c8; animation: none; }

.conn-type-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(20,48,68,.07);
  color: #607588;
  white-space: nowrap;
  letter-spacing: .02em;
}
.conn-type-pill.plc    { background: rgba(21,94,159,.1);  color: #155e9f; }
.conn-type-pill.pi     { background: rgba(0,176,80,.1);   color: #007a38; }
.conn-type-pill.db     { background: rgba(124,58,237,.1); color: #6d28d9; }
.conn-type-pill.file   { background: rgba(245,158,11,.1); color: #92400e; }
.conn-type-pill.api    { background: rgba(14,165,233,.1); color: #0369a1; }
.conn-type-pill.manual { background: rgba(156,163,175,.1); color: #8090a0; }

.tag-cat-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(20,48,68,.07);
  color: #607588;
  letter-spacing: .02em;
}
.tag-cat-pill.energy     { background: rgba(21,94,159,.1);  color: #155e9f; }
.tag-cat-pill.power      { background: rgba(245,158,11,.1); color: #92400e; }
.tag-cat-pill.production { background: rgba(0,176,80,.1);   color: #007a38; }
.tag-cat-pill.cost       { background: rgba(124,58,237,.1); color: #6d28d9; }
.tag-cat-pill.flow       { background: rgba(14,165,233,.1); color: #0369a1; }
.tag-cat-pill.other      { background: rgba(156,163,175,.1); color: #8090a0; }

/* ── Bindings ─────────────────────────────────────────────────────────────── */
.binding-tag-list { display: flex; flex-direction: column; gap: 7px; }
.binding-tag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: linear-gradient(135deg,rgba(21,94,159,.04),rgba(21,94,159,.02));
  border-radius: 10px;
  border: 1px solid rgba(21,94,159,.12);
  font-size: 13px;
  transition: box-shadow .15s;
}
.binding-tag-row:hover { box-shadow: 0 2px 8px rgba(21,94,159,.12); }
.binding-tag-name { font-weight: 600; flex: 1; color: #143044; }
.binding-role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(0,176,80,.1);
  color: #007a38;
  letter-spacing: .03em;
}
.unbound-tag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #f9fafb;
  border-radius: 10px;
  border: 1px solid rgba(20,48,68,.08);
  font-size: 13px;
  transition: background .15s;
}
.unbound-tag-row:hover { background: #f0f4f8; }

/* ── Product Cards ───────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px,1fr));
  gap: 14px;
  margin-top: 14px;
}
.product-card {
  background: #fff;
  border: 1.5px solid rgba(20,48,68,.09);
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.product-card:hover {
  box-shadow: 0 6px 20px rgba(20,48,68,.12);
  border-color: var(--blue,#155e9f);
  transform: translateY(-2px);
}
.product-card-name { font-size: 14px; font-weight: 700; color: #143044; margin-bottom: 8px; }
.product-card-meta { font-size: 12px; color: #8090a0; display: flex; flex-wrap: wrap; gap: 5px; }
.product-card-tag {
  background: rgba(20,48,68,.06);
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  color: #607588;
}

/* ── Baseline Variables ──────────────────────────────────────────────────── */
.bl-var-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.bl-var-row {
  display: grid;
  grid-template-columns: 1fr 1fr 80px auto;
  gap: 8px;
  align-items: center;
  padding: 9px 14px;
  background: #f7fbff;
  border: 1px solid rgba(20,48,68,.09);
  border-radius: 10px;
}
.bl-var-row input, .bl-var-row select {
  font-size: 12px;
  padding: 6px 9px;
  border: 1.5px solid rgba(20,48,68,.12);
  border-radius: 7px;
  color: #143044;
  background: #fff;
}

/* ── Shed Profile ────────────────────────────────────────────────────────── */
.shed-profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px,1fr));
  gap: 16px;
  margin-top: 14px;
}
.shed-profile-card {
  background: #fff;
  border: 1.5px solid rgba(20,48,68,.09);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(20,48,68,.05);
}
.shed-profile-header {
  padding: 14px 16px;
  background: linear-gradient(135deg,#f7fbff,#eef4fb);
  border-bottom: 1px solid rgba(20,48,68,.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.shed-profile-name { font-size: 14px; font-weight: 800; color: #143044; }
.shed-priority-list { list-style: none; padding: 10px; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.shed-priority-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f7fbff;
  border: 1px solid rgba(20,48,68,.08);
  border-radius: 10px;
  font-size: 12.5px;
  cursor: grab;
  transition: background .12s, box-shadow .12s;
}
.shed-priority-item:hover { background: #eef4fb; box-shadow: 0 2px 8px rgba(20,48,68,.08); }
.shed-priority-item.dragging { opacity: .4; }
.shed-priority-item.drag-over { border-color: var(--se,#00b050); background: rgba(0,176,80,.06); }
.shed-item-order {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg,#1a6fc4,#155e9f);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(21,94,159,.3);
}
.shed-item-name { flex: 1; font-weight: 600; color: #143044; }
.shed-item-kw { font-size: 11.5px; color: #8090a0; white-space: nowrap; font-weight: 600; }

/* ── KPI Bar ─────────────────────────────────────────────────────────────── */
.cfg-kpi-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.cfg-kpi {
  background: #fff;
  border: 1px solid rgba(20,48,68,.09);
  border-radius: 12px;
  padding: 14px 18px;
  flex: 1;
  min-width: 120px;
  box-shadow: 0 1px 6px rgba(20,48,68,.05);
  transition: box-shadow .15s;
}
.cfg-kpi:hover { box-shadow: 0 4px 14px rgba(20,48,68,.1); }
.cfg-kpi-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #8090a0;
  margin-bottom: 5px;
}
.cfg-kpi-val { font-size: 26px; font-weight: 900; color: #143044; line-height: 1.1; }
.cfg-kpi-sub { font-size: 11px; color: #a3b8c8; margin-top: 2px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.cfg-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #143044;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .22s cubic-bezier(.4,0,.2,1), transform .22s cubic-bezier(.4,0,.2,1);
  max-width: 340px;
  letter-spacing: .02em;
}
.cfg-toast.show { opacity: 1; transform: translateY(0); }
.cfg-toast.success { background: linear-gradient(135deg,#00c060,#008a3e); }
.cfg-toast.error   { background: linear-gradient(135deg,#e53e3e,#c53030); }
.cfg-toast.warn    { background: linear-gradient(135deg,#f59e0b,#d97706); }

/* ── Modal overrides for cfg modals ──────────────────────────────────────── */
.cfg-modal-body .cfg-form { margin-top: 14px; }
.cfg-modal-body h3 { margin: 0 0 16px; font-size: 16px; font-weight: 800; color: #143044; }
.modal-btn-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(20,48,68,.09);
}

/* ── Node detail info grid ───────────────────────────────────────────────── */
.node-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.node-info-cell {
  background: #f7fbff;
  border: 1px solid rgba(20,48,68,.08);
  border-radius: 10px;
  padding: 10px 14px;
}
.node-info-cell .nic-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #a3b8c8;
  margin-bottom: 3px;
}
.node-info-cell .nic-val { font-size: 13px; font-weight: 700; color: #143044; }

/* ═══════════════════════════════════════════════════════════════════════════
   HIERARCHY — FULL-WIDTH TREE + NODE POPUP OVERLAY
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Full-width tree panel ───────────────────────────────────────────────── */
.hv-tree-full {
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 500px;
}
.hv-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(20,48,68,.09);
  background: linear-gradient(135deg,#f0f4f8,#e8f0f7);
  flex-shrink: 0;
}
.hv-tree-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #607588;
}
.hv-tree-body {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.hv-tree-body::-webkit-scrollbar { width: 5px; }
.hv-tree-body::-webkit-scrollbar-thumb { background: rgba(20,48,68,.15); border-radius: 10px; }

/* ── Tree Row ────────────────────────────────────────────────────────────── */
.hvt-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px 6px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
  user-select: none;
  min-height: 36px;
}
.hvt-row:hover { background: rgba(21,94,159,.05); }
.hvt-row.selected {
  background: linear-gradient(90deg, rgba(21,94,159,.1), rgba(21,94,159,.03));
}
.hvt-row.selected .hvt-name { font-weight: 800; color: #143044; }
.hvt-row { cursor: grab; }
.hvt-row:active { cursor: grabbing; }
.hvt-row.hvt-dragging { opacity: .4; pointer-events: none; }
.hvt-row.hvt-drop-target {
  background: rgba(0,176,80,.1);
  border-left: 3px solid #00b050;
  outline: 1.5px dashed rgba(0,176,80,.5);
  outline-offset: -2px;
}
.hvt-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: #143044;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  white-space: nowrap;
  opacity: .92;
}

.hvt-toggle {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #607588; flex-shrink: 0;
  border-radius: 6px; border: none; background: transparent;
  cursor: pointer; padding: 0;
  transition: background .12s, color .12s;
}
.hvt-toggle:hover { background: rgba(20,48,68,.1); color: #143044; }
button.hvt-toggle { draggable: false; }
.hvt-invisible { visibility: hidden; pointer-events: none; }
.hvt-icon { font-size: 14px; flex-shrink: 0; line-height: 1; }

/* Label group: name + type/code chips */
.hvt-label-group { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hvt-name {
  font-size: 12.5px; color: #2d4a5e; font-weight: 600;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.hvt-meta-row { display: flex; align-items: center; gap: 4px; }
.hvt-type-chip {
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; padding: 1px 5px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0;
}
.hvt-code {
  font-size: 9.5px; font-family: 'Courier New', monospace;
  color: #a3b8c8; background: rgba(20,48,68,.06);
  padding: 1px 5px; border-radius: 4px; flex-shrink: 0;
  letter-spacing: .03em; white-space: nowrap;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis;
}

/* Tag count toggle button */
.hvt-tags-toggle {
  display: flex; align-items: center; gap: 3px;
  padding: 2px 7px; background: rgba(0,176,80,.08);
  border: 1px solid rgba(0,176,80,.2); border-radius: 20px;
  cursor: pointer; flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.hvt-tags-toggle:hover { background: rgba(0,176,80,.16); border-color: rgba(0,176,80,.35); }
.hvt-tag-dot-sm { width: 5px; height: 5px; border-radius: 50%; background: #00b050; flex-shrink: 0; }
.hvt-tags-cnt { font-size: 10px; font-weight: 800; color: #007a38; line-height: 1; }
.hvt-tags-chevron { font-size: 9px; color: #007a38; line-height: 1; }

.hvt-add {
  opacity: 0; width: 20px; height: 20px; border-radius: 5px;
  border: none; background: rgba(0,176,80,.12); color: #007a38;
  font-size: 14px; font-weight: 700; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity .12s, background .12s;
}
.hvt-row:hover .hvt-add { opacity: 1; }
.hvt-add:hover { background: rgba(0,176,80,.22); }

.hvt-children { display: block; }
.hvt-children.hvt-collapsed { display: none; }

/* ── Inline tag chips ────────────────────────────────────────────────────── */
.hvt-inline-tags {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 2px 12px 6px;
}
.hvt-inline-tags.hvt-collapsed { display: none; }

.hvt-tag-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 600;
  border: 1px solid;
  border-radius: 20px; padding: 2px 8px;
  white-space: nowrap; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis;
  cursor: default; transition: opacity .12s;
}
.hvt-tag-chip:hover { opacity: .8; }
.hvt-tag-chip-unit { font-size: 9.5px; font-weight: 500; opacity: .7; }

/* ══════════════════════════════════════════════════════════════════════════
   NODE POPUP OVERLAY
   ══════════════════════════════════════════════════════════════════════════ */
.np-overlay {
  position: fixed; inset: 0;
  background: rgba(10,28,44,.55);
  backdrop-filter: blur(3px);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: np-fade-in .18s ease;
}
@keyframes np-fade-in { from { opacity:0; } to { opacity:1; } }

.np-popup {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.28), 0 4px 20px rgba(0,0,0,.12);
  width: 100%;
  max-width: 920px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: np-slide-up .2s cubic-bezier(.4,0,.2,1);
}
@keyframes np-slide-up { from { transform: translateY(16px); opacity:.6; } to { transform: translateY(0); opacity:1; } }

/* Popup header */
.np-header {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 20px 14px;
  background: linear-gradient(135deg,#f7fbff,#eef4fb);
  border-bottom: 1px solid rgba(20,48,68,.09);
  flex-shrink: 0; flex-wrap: wrap;
}
.np-icon {
  width: 46px; height: 46px; border-radius: 13px;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.np-title-group { flex: 1; min-width: 0; }
.np-name { font-size: 20px; font-weight: 900; color: #143044; line-height: 1.15; margin-bottom: 5px; }
.np-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.np-type-badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; padding: 3px 10px; border-radius: 20px;
}
.np-crumb { font-size: 11.5px; color: #a3b8c8; }
.np-actions {
  display: flex; gap: 7px; flex-wrap: wrap;
  flex-shrink: 0; align-items: flex-start;
}
.np-close-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: rgba(20,48,68,.08); color: #607588;
  font-size: 18px; font-weight: 300; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s; flex-shrink: 0;
}
.np-close-btn:hover { background: rgba(229,62,62,.1); color: #c53030; }

/* Stats row */
.np-stats {
  display: flex; gap: 0;
  border-bottom: 1px solid rgba(20,48,68,.07);
  flex-shrink: 0;
}
.np-stat {
  flex: 1; padding: 10px 16px; text-align: center;
  border-right: 1px solid rgba(20,48,68,.07);
}
.np-stat:last-child { border-right: none; }
.np-stat-val { font-size: 15px; font-weight: 800; color: #143044; line-height: 1.2; margin-bottom: 1px; }
.np-stat-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #a3b8c8; }

/* Description */
.np-desc {
  padding: 10px 20px; font-size: 13px; color: #607588;
  line-height: 1.6; border-bottom: 1px solid rgba(20,48,68,.07);
  background: rgba(20,48,68,.02); flex-shrink: 0;
}

/* Color legend */
.np-legend {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(20,48,68,.07);
  background: #fafcff;
  flex-shrink: 0;
}
.np-legend-label {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .06em; color: #a3b8c8; white-space: nowrap; flex-shrink: 0;
}
.np-legend-chip {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; padding: 2px 8px; border-radius: 20px;
  border: 1px solid; white-space: nowrap;
}

/* Body split */
.np-body-split {
  display: grid; grid-template-columns: 1fr 1.4fr;
  flex: 1; min-height: 0; overflow: hidden;
}
@media (max-width: 640px) { .np-body-split { grid-template-columns: 1fr; } }

.np-bound-col {
  border-right: 1px solid rgba(20,48,68,.07);
  display: flex; flex-direction: column; overflow: hidden;
}
.np-lib-col {
  display: flex; flex-direction: column; overflow: hidden;
}

/* Section headers */
.np-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(20,48,68,.07);
  background: linear-gradient(135deg,#f7fbff,#f0f4f8);
  flex-shrink: 0;
}
.np-section-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: #607588;
}
.npb-count-badge {
  font-size: 10px; font-weight: 800;
  background: rgba(21,94,159,.1); color: #155e9f;
  padding: 2px 8px; border-radius: 20px;
}

/* Bound tag list */
.np-bound-list {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 120px; transition: background .15s;
}
.np-bound-list::-webkit-scrollbar { width: 5px; }
.np-bound-list::-webkit-scrollbar-thumb { background: rgba(20,48,68,.15); border-radius: 10px; }
.np-bound-list.np-drop-active {
  background: rgba(21,94,159,.04); outline: 2px dashed rgba(21,94,159,.3);
  outline-offset: -4px;
}
.np-bound-empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 80px; color: #c0d0dc; font-size: 12.5px;
  font-style: italic; text-align: center; padding: 12px;
}

/* Bound tag row */
.npb-tag-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(135deg,rgba(21,94,159,.05),rgba(21,94,159,.02));
  border: 1px solid rgba(21,94,159,.12); border-radius: 10px;
  transition: box-shadow .15s;
}
.npb-tag-row:hover { box-shadow: 0 2px 8px rgba(21,94,159,.1); }

/* Category chip (reused in popup and tree) */
.npb-cat-chip {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; padding: 2px 7px; border-radius: 20px;
  border: 1px solid; white-space: nowrap; flex-shrink: 0;
  min-width: 52px; text-align: center;
}
.npb-tag-info { flex: 1; min-width: 0; }
.npb-tag-name {
  font-size: 12px; font-weight: 700; color: #143044;
  display: block; word-break: break-all; line-height: 1.4;
}
.npb-tag-path {
  font-size: 10.5px; color: #a3b8c8;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.npb-tag-unit {
  font-size: 11px; color: #8090a0; flex-shrink: 0; white-space: nowrap;
}

/* Tag library filters */
.np-lib-filters {
  display: flex; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid rgba(20,48,68,.07);
  background: #fff; flex-wrap: wrap; flex-shrink: 0;
}
.np-cat-sel { font-size: 12px; padding: 5px 9px; }

/* Available tag list */
.np-avail-list {
  flex: 1; overflow-y: auto; padding: 6px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.np-avail-list::-webkit-scrollbar { width: 5px; }
.np-avail-list::-webkit-scrollbar-thumb { background: rgba(20,48,68,.15); border-radius: 10px; }

.npb-avail-tag {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; background: #fff;
  border: 1px solid rgba(20,48,68,.09); border-radius: 8px;
  transition: background .12s, border-color .12s; cursor: grab;
}
.npb-avail-tag:hover { background: rgba(21,94,159,.04); border-color: rgba(21,94,159,.18); }
.npb-avail-tag.dragging { opacity: .5; cursor: grabbing; }
.npb-avail-tag.npb-avail-bound { opacity: .65; cursor: default; background: rgba(0,176,80,.03); border-color: rgba(0,176,80,.15); }

/* Keep compat classes for existing binding HTML if still referenced */
.hv-split { display: block; }
.hv-detail-panel { display: none; }
.hvc-type-badge {
  font-size: 10px; font-weight: 800; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap; letter-spacing: .04em;
  text-transform: uppercase; flex-shrink: 0;
}
.detail-code-badge {
  font-size: 11px; font-weight: 800; font-family: 'Courier New', monospace;
  letter-spacing: .04em; padding: 3px 10px; border-radius: 20px;
  background: rgba(20,48,68,.08); color: #607588;
}

/* ── Drop Zone (legacy, kept for binding drag compat) ────────────────────── */
.binding-dropzone { background: #fafcff; border: 2px dashed rgba(21,94,159,.2); border-radius: 10px; min-height: 100px; transition: border-color .18s, background .18s; }
.binding-dropzone.drop-active { border-color: var(--blue,#155e9f); background: rgba(21,94,159,.05); }
.bdz-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 8px; flex-wrap: wrap; gap: 4px; }
.bdz-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: #607588; display: flex; align-items: center; gap: 5px; }
.bdz-count { background: rgba(21,94,159,.12); color: var(--blue,#155e9f); font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 20px; }
.bdz-hint { font-size: 11px; color: #a3b8c8; font-style: italic; }
.bdz-empty { display: flex; align-items: center; justify-content: center; min-height: 60px; color: #c0d0dc; font-size: 12.5px; font-style: italic; padding: 12px; text-align: center; }

/* ── Bound Tag Items (legacy) ────────────────────────────────────────────── */
.bound-tag-list { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 10px; }
.bound-tag-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: linear-gradient(135deg,rgba(21,94,159,.06),rgba(21,94,159,.02)); border: 1px solid rgba(21,94,159,.14); border-radius: 9px; transition: box-shadow .15s; }
.bound-tag-item:hover { box-shadow: 0 2px 8px rgba(21,94,159,.12); }
.bti-left { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bti-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.bti-icon { font-size: 14px; flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; background: rgba(21,94,159,.1); display: flex; align-items: center; justify-content: center; }
.bti-info { min-width: 0; }
.bti-name { font-size: 12px; font-weight: 700; color: #143044; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.bti-unit { font-size: 11px; color: #8090a0; }
.bti-role-sel { font-size: 11px; font-weight: 600; padding: 3px 7px; border: 1.5px solid rgba(20,48,68,.13); border-radius: 7px; background: #fff; color: #2d4a5e; cursor: pointer; max-width: 130px; }
.bti-role-sel:focus { outline: none; border-color: var(--blue,#155e9f); }
.btn-icon-danger { background: rgba(229,62,62,.08); border: 1px solid rgba(229,62,62,.18); border-radius: 7px; padding: 3px 7px; cursor: pointer; color: #c53030; font-size: 12px; line-height: 1; transition: background .15s, border-color .15s; }
.btn-icon-danger:hover { background: rgba(229,62,62,.18); border-color: rgba(229,62,62,.35); }

/* ── Tag Library Panel (legacy) ──────────────────────────────────────────── */
.tag-library-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; border-bottom: 1px solid rgba(20,48,68,.08); background: linear-gradient(135deg,#f7fbff,#eef4fb); flex-shrink: 0; }
.tlh-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: #607588; }
.tlh-count { font-size: 11px; font-weight: 700; color: #a3b8c8; background: rgba(20,48,68,.06); padding: 2px 8px; border-radius: 20px; }
.tag-lib-filters { display: flex; gap: 8px; padding: 7px 10px; border-bottom: 1px solid rgba(20,48,68,.07); background: #fff; flex-wrap: wrap; flex-shrink: 0; }
.tag-lib-search { flex: 1; min-width: 90px; border: 1.5px solid rgba(20,48,68,.12); border-radius: 7px; padding: 6px 10px; font-size: 12px; color: #143044; background: #f7fbff; transition: border-color .15s, box-shadow .15s; }
.tag-lib-search:focus { outline: none; border-color: var(--blue,#155e9f); box-shadow: 0 0 0 3px rgba(21,94,159,.08); }
.tag-lib-filters .cfg-filter-sel { font-size: 12px; padding: 6px 9px; }
.avail-tag-list { display: flex; flex-direction: column; gap: 4px; padding: 7px 10px; overflow-y: auto; }
.avail-tag-list::-webkit-scrollbar { width: 5px; }
.avail-tag-list::-webkit-scrollbar-thumb { background: rgba(20,48,68,.15); border-radius: 10px; }
.avail-tag-item { display: flex; align-items: center; gap: 7px; padding: 7px 9px; background: #fff; border: 1px solid rgba(20,48,68,.09); border-radius: 8px; transition: background .12s, border-color .12s; cursor: grab; }
.avail-tag-item:hover { background: rgba(21,94,159,.04); border-color: rgba(21,94,159,.18); }
.avail-tag-item.dragging { opacity: .5; cursor: grabbing; }
.avail-tag-item.tag-already-bound { background: rgba(0,176,80,.04); border-color: rgba(0,176,80,.18); cursor: default; opacity: .75; }
.ati-icon { font-size: 13px; flex-shrink: 0; width: 24px; height: 24px; border-radius: 6px; background: rgba(20,48,68,.06); display: flex; align-items: center; justify-content: center; }
.ati-info { flex: 1; min-width: 0; }
.ati-name { font-size: 12px; font-weight: 700; color: #143044; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ati-path { font-size: 10px; color: #a3b8c8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ati-pills { display: flex; gap: 3px; margin-top: 2px; flex-wrap: wrap; }
.ati-bind-btn { font-size: 11px; font-weight: 700; padding: 3px 9px; border: 1.5px solid rgba(21,94,159,.25); border-radius: 6px; background: rgba(21,94,159,.06); color: var(--blue,#155e9f); cursor: pointer; flex-shrink: 0; white-space: nowrap; transition: background .12s, border-color .12s; }
.ati-bind-btn:hover { background: rgba(21,94,159,.14); border-color: rgba(21,94,159,.4); }
.ati-bound-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: rgba(0,176,80,.1); color: #007a38; flex-shrink: 0; white-space: nowrap; pointer-events: none; }
