/* Nexus Relations — standalone styling (.nx- prefix). Independent of Maestro. */
#tp-nexus {
  --nx-bg: #f7f7fb;
  --nx-card: #ffffff;
  --nx-line: rgba(15, 23, 42, .10);
  --nx-text: #0f172a;
  --nx-muted: #64748b;
  --nx-accent: #6d28d9;       /* indigo/violet — distinct from Maestro blue */
  --nx-accent2: #4f46e5;
  --nx-green: #16a34a;
  --nx-amber: #d97706;
  --nx-red: #dc2626;
  color: var(--nx-text);
}

.nx-shell { padding: 18px; max-width: 1540px; margin: 0 auto; }

.nx-header {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  padding: 18px; border-radius: 10px; color: #f8fafc;
  background: linear-gradient(135deg, #1e1b4b, #312e81 55%, #4c1d95);
  box-shadow: 0 16px 36px rgba(30, 27, 75, .22);
}
.nx-kicker { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #c4b5fd; font-weight: 800; }
.nx-title { margin: 3px 0 4px; font-size: 28px; line-height: 1.1; }
.nx-sub { margin: 0; color: #ddd6fe; font-size: 13px; max-width: 640px; }

.nx-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; min-width: 460px; }
.nx-toggle { display: inline-flex; align-items: center; gap: 6px; color: #ede9fe; font-size: 12px; font-weight: 700; cursor: pointer; user-select: none; }
.nx-toggle input { accent-color: #a78bfa; }

.nx-btn {
  border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .08);
  color: #f8fafc; border-radius: 7px; padding: 9px 12px; font-size: 12px; font-weight: 800; cursor: pointer;
}
.nx-btn.primary { background: var(--nx-accent2); border-color: var(--nx-accent2); min-width: 150px; }
.nx-btn.success { background: var(--nx-green); border-color: var(--nx-green); }
.nx-btn.xs { padding: 4px 9px; min-width: 0; font-size: 11px; }
.nx-btn:hover { filter: brightness(1.08); }
.nx-btn:disabled { opacity: .45; cursor: not-allowed; }

.nx-notice {
  margin: 14px 0; padding: 11px 13px; border-radius: 8px; font-size: 12px; font-weight: 700;
  border: 1px solid rgba(109, 40, 217, .18); background: rgba(109, 40, 217, .06); color: #5b21b6;
}
.nx-notice.warn { border-color: rgba(217, 119, 6, .24); background: rgba(217, 119, 6, .08); color: #92400e; }
.nx-notice.fail { border-color: rgba(220, 38, 38, .24); background: rgba(220, 38, 38, .08); color: #991b1b; }

.nx-health { display: grid; grid-template-columns: 170px 1fr; gap: 12px; margin-bottom: 14px; }
.nx-score, .nx-kpis > div, .nx-panel {
  background: var(--nx-card); border: 1px solid var(--nx-line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}
.nx-score { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px; }
.nx-score span { font-size: 40px; font-weight: 900; color: var(--nx-accent); line-height: 1; }
.nx-score small { color: var(--nx-muted); font-size: 11px; font-weight: 700; margin-top: 4px; }
.nx-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.nx-kpis > div { padding: 10px; text-align: center; }
.nx-kpis b { display: block; font-size: 20px; font-weight: 900; color: var(--nx-text); }
.nx-kpis span { font-size: 10px; color: var(--nx-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }

.nx-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.nx-panel { padding: 14px; overflow: hidden; }
.nx-panel.full { grid-column: 1 / -1; }
.nx-panel.wide { grid-column: 1 / -1; }
.nx-panel.priority { border-color: rgba(109, 40, 217, .35); box-shadow: 0 12px 30px rgba(109, 40, 217, .12); }
@media (min-width: 1180px) { .nx-panel.wide { grid-column: auto; } }

.nx-panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 10px; }
.nx-panel-head h3 { margin: 0; font-size: 14px; font-weight: 800; }
.nx-panel-head span { font-size: 11px; color: var(--nx-muted); font-weight: 700; }

.nx-empty { color: var(--nx-muted); font-size: 12px; font-style: italic; padding: 10px 2px; }
.nx-muted { color: var(--nx-muted); }

.nx-tree { max-height: 320px; overflow: auto; font-size: 12px; }
.nx-tree-row { padding: 3px 6px; border-bottom: 1px dashed var(--nx-line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nx-table-wrap { max-height: 420px; overflow: auto; }
.nx-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nx-table th { position: sticky; top: 0; background: #f1f0fa; text-align: left; padding: 7px 8px; font-weight: 800; border-bottom: 1px solid var(--nx-line); white-space: nowrap; }
.nx-table td { padding: 6px 8px; border-bottom: 1px solid var(--nx-line); vertical-align: top; }
.nx-table tbody tr:hover { background: rgba(109, 40, 217, .05); cursor: default; }
#nexusRelationships .nx-table tbody tr { cursor: pointer; }

.nx-pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; background: #eef2ff; color: #3730a3; white-space: nowrap; }
.nx-pill.high { background: rgba(22, 163, 74, .12); color: #166534; }
.nx-pill.mid { background: rgba(217, 119, 6, .12); color: #92400e; }
.nx-pill.low { background: rgba(220, 38, 38, .12); color: #991b1b; }

.nx-list { max-height: 360px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.nx-list-item { padding: 8px 10px; border-radius: 8px; border-left: 3px solid var(--nx-line); background: #fafafe; font-size: 12px; }
.nx-list-item b { display: block; font-weight: 800; margin-bottom: 2px; }
.nx-list-item span { color: var(--nx-muted); }
.nx-list-item.warn { border-left-color: var(--nx-amber); background: rgba(217, 119, 6, .05); }
.nx-list-item.fail { border-left-color: var(--nx-red); background: rgba(220, 38, 38, .05); }
.nx-list-item.pass { border-left-color: var(--nx-green); background: rgba(22, 163, 74, .05); }
.nx-learn-actions { display: flex; gap: 6px; margin-top: 6px; }
.nx-learn-actions .nx-btn { color: #1e1b4b; background: #ede9fe; border-color: #ddd6fe; }
.nx-learn-actions .nx-btn.success { color: #fff; background: var(--nx-green); border-color: var(--nx-green); }

.nx-explain { font-size: 12px; }
.nx-explain-block > div { padding: 7px 0; border-bottom: 1px dashed var(--nx-line); }
.nx-explain-block b { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--nx-accent); margin-bottom: 2px; }

/* Gantt preview */
.nx-gantt { max-height: 460px; overflow: auto; }
.nx-gantt-group { margin-bottom: 10px; }
.nx-gantt-group-head { font-size: 11px; font-weight: 800; color: #312e81; background: #f1f0fa; padding: 4px 8px; border-radius: 6px; position: sticky; left: 0; }
.nx-gantt-row { display: grid; grid-template-columns: 340px 1fr; gap: 8px; align-items: center; padding: 2px 0; }
.nx-gantt-name { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-gantt-track { position: relative; height: 16px; background: repeating-linear-gradient(90deg, #f3f4f6, #f3f4f6 9.9%, #e9e9f3 10%); border-radius: 4px; }
.nx-gantt-bar { position: absolute; top: 2px; height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--nx-accent2), var(--nx-accent)); box-shadow: 0 1px 3px rgba(49, 46, 129, .3); }
.nx-gantt-bar.warn { background: linear-gradient(90deg, #f59e0b, #d97706); }
.nx-gantt-bar.crit { background: linear-gradient(90deg, #ef4444, #b91c1c); }
.nx-gantt-bar.bottleneck { outline: 2px solid #1e1b4b; outline-offset: 1px; }
.nx-tag { display: inline-block; font-size: 9px; font-weight: 800; padding: 0 5px; border-radius: 999px; margin-left: 4px; }
.nx-tag.crit { background: rgba(220, 38, 38, .14); color: #991b1b; }
.nx-tag.bn { background: rgba(30, 27, 75, .12); color: #1e1b4b; }

/* Test harness */
.nx-test-table td { font-size: 12px; }
.nx-test-head td { background: #f1f0fa; padding-top: 9px; }
