/* Árbol de valor · v3: encabezado de página, vista "Camino" y panel de detalle. */

/* ---------- Modo: Camino o Árbol completo ---------- */
body[data-tree-mode="canvas"] .ds-tree { display: none; }
body:not([data-tree-mode="canvas"]) .cp-canvas-viewport { display: none; }
body:not([data-tree-mode="canvas"]) .cp-level-slider-wrap,
body:not([data-tree-mode="canvas"]) #btnExpandToggle { display: none; }

/* ---------- Encabezado de página con horizontes ---------- */
body.ds-v3 .ds-tree-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; min-height: 0; padding: 26px 32px 18px; background: var(--ds-bg-app); border-bottom: 1px solid var(--ds-border); }
.ds-tree-heading { min-width: 0; }
.ds-tree-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
body.ds-v3 .cp-horizon-switcher { display: inline-flex; gap: 0; padding: 2px; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-full); background: var(--ds-surface); box-shadow: none; }
body.ds-v3 .cp-horizon-btn, body.ds-v3 .cp-horizon-btn.horizon-custom { height: 26px; padding: 0 12px; gap: 0; border: 0; border-radius: var(--ds-radius-full); background: transparent; color: var(--ds-text-body); font-size: var(--ds-fs-sm); font-weight: var(--ds-fw-regular); box-shadow: none; }
body.ds-v3 .cp-horizon-btn:hover { color: var(--ds-text); background: var(--ds-surface-subtle); }
body.ds-v3 .cp-horizon-btn.active, body.ds-v3 .cp-horizon-btn.active.horizon-forecast, body.ds-v3 .cp-horizon-btn.horizon-custom.active { background: var(--ds-text); color: var(--ds-text-on-ink); border: 0; box-shadow: none; }
body.ds-v3 .cp-horizon-btn .horizon-tag { display: none; }
body.ds-v3 .cp-horizon-btn:focus-visible, body.ds-v3 .cp-btn-filter-icon:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
body.ds-v3 .cp-btn-filter-icon { position: relative; width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--ds-border); border-radius: 50%; background: var(--ds-surface); color: var(--ds-text-body); box-shadow: none; }
body.ds-v3 .cp-btn-filter-icon:hover, body.ds-v3 .cp-btn-filter-icon.active { border-color: var(--ds-border-strong); background: var(--ds-surface-subtle); color: var(--ds-text); }

/* Barra de filtros: una línea tranquila bajo el encabezado */
body.ds-v3 .cp-filter-toolbar { padding: 10px 32px; background: var(--ds-bg-app); border-bottom: 1px solid var(--ds-border); box-shadow: none; }
body.ds-v3 .cp-filter-toolbar * { font-family: var(--ds-font); }
body.ds-v3 .cp-hidden-nodes-toggle { font-size: var(--ds-fs-sm); font-weight: var(--ds-fw-regular); color: var(--ds-text-body); }
body.ds-v3 .cp-hidden-nodes-toggle input { accent-color: var(--ds-text); }
body.ds-v3 .cp-filter-search-box { border: 1px solid var(--ds-border); border-radius: var(--ds-radius-full); background: var(--ds-surface); box-shadow: none; }

/* ---------- Vista "Camino" ---------- */
.ds-tree { flex: 1; min-height: 0; overflow: auto; background: var(--ds-bg-app); }
.ds-tree-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: 100%; }
.ds-tree-canvas { position: relative; overflow-x: auto; padding: 28px 24px 40px 32px; }
.ds-tree-cols { position: relative; display: grid; grid-template-columns: repeat(var(--ds-cols, 3), 228px); gap: 44px; align-items: center; width: max-content; }
.ds-tree-col { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; }
.ds-tree-wires { position: absolute; inset: 0; z-index: 0; overflow: visible; pointer-events: none; }
.ds-tree-wires path { fill: none; stroke: var(--ds-border-strong); stroke-width: 1; }
.ds-tree-wires path.is-hot { stroke: var(--ds-accent); stroke-width: 1.5; }

/* Nodo: nombre, cifra grande, meta en una línea, barra fina */
.ds-node { position: relative; display: block; width: 100%; padding: 12px 14px; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); background: var(--ds-surface); color: var(--ds-text); font: inherit; text-align: left; cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease; }
.ds-node:hover { border-color: var(--ds-border-strong); }
.ds-node:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.ds-node.is-on-path { border-color: var(--ds-accent-border); }
.ds-node.is-selected { border-color: var(--ds-accent); box-shadow: 0 0 0 3px var(--ds-accent-soft); }
.ds-node.is-dimmed { opacity: .35; }
.ds-node__name { display: flex; align-items: center; gap: 7px; font-size: var(--ds-fs-sm); color: var(--ds-text-body); line-height: 1.3; }
.ds-node__name span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ds-node__value { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 6px; }
.ds-node__value b { font-size: 20px; font-weight: var(--ds-fw-semibold); letter-spacing: var(--ds-tracking-num); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ds-node__value b small { font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-regular); color: var(--ds-text-muted); margin-left: 3px; letter-spacing: 0; }
.ds-node__value .ds-delta { height: 20px; font-size: 11px; padding: 0 7px; }
.ds-node__empty { font-size: var(--ds-fs-md); font-weight: var(--ds-fw-regular); color: var(--ds-text-muted); }
.ds-node__target { margin-top: 2px; font-size: var(--ds-fs-xs); color: var(--ds-text-muted); line-height: 1.35; }
.ds-node .ds-meter { margin-top: 10px; }
.ds-node__kids { position: absolute; right: -12px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--ds-border); background: var(--ds-surface); display: grid; place-items: center; font-size: 10.5px; color: var(--ds-text-muted); }
.ds-node--root { padding: 16px 18px; }
.ds-node--root .ds-node__value b { font-size: 28px; }

/* ---------- Panel de detalle ---------- */
.ds-tree-inspector { border-left: 1px solid var(--ds-border); padding: 28px 28px 40px 24px; background: var(--ds-bg-app); }
.ds-insp__kicker { font-size: var(--ds-fs-xs); color: var(--ds-text-muted); }
.ds-insp__title { font-family: var(--ds-font-display); font-weight: var(--ds-fw-display); font-size: 22px; letter-spacing: -0.01em; line-height: 1.15; margin: 4px 0 0; color: var(--ds-text); }
.ds-insp__value { font-size: var(--ds-fs-3xl); font-weight: var(--ds-fw-medium); letter-spacing: -0.03em; line-height: 1; margin: 12px 0 10px; font-variant-numeric: tabular-nums; }
.ds-insp__value small { font-size: 15px; color: var(--ds-text-muted); margin-left: 4px; letter-spacing: 0; }
.ds-insp__value .ds-node__empty { font-size: 20px; }
.ds-insp__meta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: var(--ds-fs-sm); color: var(--ds-text-muted); }
.ds-insp__rows { margin-top: 22px; }
.ds-insp__rows > .ds-insp__kicker { margin-bottom: 6px; }
.ds-insp__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; width: 100%; padding: 9px 0; border: 0; border-top: 1px solid var(--ds-border); background: transparent; font: inherit; font-size: var(--ds-fs-sm); color: var(--ds-text-body); text-align: left; cursor: pointer; }
.ds-insp__row:hover .ds-insp__label { color: var(--ds-text); }
.ds-insp__row:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); border-radius: 4px; }
.ds-insp__label { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ds-insp__num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ds-text); }
.ds-insp__row .ds-meter { grid-column: 1 / -1; }
.ds-insp__note { margin: 18px 0 0; font-size: var(--ds-fs-sm); color: var(--ds-text-muted); }
.ds-insp__how { margin-top: 18px; font-size: var(--ds-fs-sm); color: var(--ds-text-body); }
.ds-insp__how summary { cursor: pointer; color: var(--ds-accent); width: max-content; }
.ds-insp__how p { margin: 8px 0 0; font-size: var(--ds-fs-xs); line-height: 1.5; color: var(--ds-text-muted); }
.ds-insp__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

@media (max-width: 1180px) {
  .ds-tree-split { grid-template-columns: minmax(0, 1fr); }
  .ds-tree-inspector { border-left: 0; border-top: 1px solid var(--ds-border); padding: 24px 32px 40px; }
}
@media (max-width: 700px) {
  body.ds-v3 .ds-tree-toolbar { padding: 20px 16px 14px; }
  .ds-tree-canvas { padding: 20px 16px 28px; }
  .ds-tree-cols { grid-template-columns: repeat(var(--ds-cols, 3), 200px); gap: 32px; }
  .ds-tree-inspector { padding: 20px 16px 32px; }
}

/* ---------- Tarjetas sobre el fondo gris (v3d) ---------- */
.ds-tree-inspector { margin: 20px 24px 24px 0; padding: 24px; align-self: start; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); background: var(--ds-surface); box-shadow: var(--ds-shadow-card); }
.ds-node { box-shadow: var(--ds-shadow-card); }
@media (max-width: 1180px) {
  .ds-tree-inspector { margin: 0 24px 24px; border-top: 1px solid var(--ds-border); padding: 24px; }
}
