/* ==========================================================================
   Árbol de Valor · Componentes base v3 (.ds-*)
   Usa solo variables de tokens.css. Ninguna regla toca clases existentes:
   una vista adopta el sistema usando estas clases.
   Reglas de la casa:
   - Botón principal en tinta; el cobre queda para datos y enlaces.
   - Bordes finos y filetes en vez de sombras y cajas dentro de cajas.
   - Pesos 400 a 600; títulos serif solo en página y sección.
   ========================================================================== */

/* ---------- Títulos ---------- */
.ds-page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--ds-space-4); }
.ds-page-title { font-family: var(--ds-font-display); font-size: var(--ds-fs-2xl); font-weight: var(--ds-fw-display); letter-spacing: var(--ds-tracking-display); line-height: 1.05; color: var(--ds-text); margin: 0; }
.ds-page-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: var(--ds-fs-sm); color: var(--ds-text-muted); }
.ds-section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--ds-space-3); }
.ds-section-title { font-family: var(--ds-font-display); font-size: var(--ds-fs-lg); font-weight: var(--ds-fw-display); letter-spacing: -0.01em; color: var(--ds-text); margin: 0; }
.ds-section-sub { font-size: var(--ds-fs-sm); color: var(--ds-text-muted); margin-top: 3px; }
.ds-muted { color: var(--ds-text-muted); }

/* Ayuda en (i): el método se esconde hasta que se pide */
.ds-info { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--ds-border-strong); display: inline-grid; place-items: center; font: 500 10px/1 var(--ds-font); font-style: normal; color: var(--ds-text-muted); background: transparent; padding: 0; cursor: help; }

/* ---------- Botones ---------- */
.ds-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--ds-radius-full); border: 1px solid var(--ds-border); background: var(--ds-surface); color: var(--ds-text); font: var(--ds-fw-medium) var(--ds-fs-sm)/1 var(--ds-font); white-space: nowrap; cursor: pointer; text-decoration: none; }
.ds-btn:hover { border-color: var(--ds-border-strong); background: var(--ds-surface-subtle); }
.ds-btn:focus-visible, .ds-seg button:focus-visible, .ds-link:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.ds-btn:disabled { opacity: .45; cursor: not-allowed; }
.ds-btn--primary { background: var(--ds-text); border-color: var(--ds-text); color: var(--ds-text-on-ink); }
.ds-btn--primary:hover { background: #000; border-color: #000; }
.ds-btn--quiet { border-color: transparent; background: transparent; color: var(--ds-text-body); }
.ds-btn--quiet:hover { background: var(--ds-surface-subtle); border-color: transparent; }
.ds-link { font: inherit; font-size: var(--ds-fs-sm); color: var(--ds-accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; white-space: nowrap; border-radius: 4px; }
.ds-link:hover { color: var(--ds-accent-strong); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Control segmentado (periodos, tipos) ---------- */
.ds-seg { display: inline-flex; align-items: center; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-full); background: var(--ds-surface); padding: 2px; gap: 0; }
.ds-seg button, .ds-seg a { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border: 0; border-radius: var(--ds-radius-full); background: transparent; color: var(--ds-text-body); font: var(--ds-fw-regular) var(--ds-fs-sm)/1 var(--ds-font); white-space: nowrap; cursor: pointer; text-decoration: none; }
.ds-seg button:hover, .ds-seg a:hover { color: var(--ds-text); }
.ds-seg .is-active, .ds-seg [aria-pressed="true"], .ds-seg [aria-selected="true"] { background: var(--ds-text); color: var(--ds-text-on-ink); }

/* ---------- Delta ---------- */
.ds-delta { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--ds-radius-xs); font-size: var(--ds-fs-xs); font-weight: var(--ds-fw-medium); background: var(--ds-surface-subtle); color: var(--ds-text-body); white-space: nowrap; }
.ds-delta--up { background: var(--ds-success-bg); color: var(--ds-success); }
.ds-delta--warn { background: var(--ds-warning-bg); color: var(--ds-warning); }
.ds-delta--down { background: var(--ds-danger-bg); color: var(--ds-danger); }

/* ---------- Punto de estado ---------- */
.ds-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ds-neutral-dot); flex: none; display: inline-block; }
.ds-dot--ok { background: var(--ds-success); }
.ds-dot--warn { background: var(--ds-warning); }
.ds-dot--bad { background: var(--ds-danger); }
.ds-dot--accent { background: var(--ds-accent); }

/* ---------- Franja de KPI: sin cajas, separada por filetes ---------- */
.ds-strip { display: grid; grid-template-columns: repeat(var(--ds-strip-cols, 4), minmax(0, 1fr)); border-top: 1px solid var(--ds-border); border-bottom: 1px solid var(--ds-border); }
.ds-strip__item { padding: 16px 18px 14px; border-left: 1px solid var(--ds-border); min-width: 0; }
.ds-strip__item:first-child { border-left: 0; padding-left: 0; }
.ds-strip__label { font-size: var(--ds-fs-sm); color: var(--ds-text-muted); }
.ds-strip__value { font-size: var(--ds-fs-xl); font-weight: var(--ds-fw-semibold); letter-spacing: var(--ds-tracking-num); margin-top: 4px; white-space: nowrap; color: var(--ds-text); font-variant-numeric: tabular-nums; }
.ds-strip__value small { font-size: var(--ds-fs-sm); font-weight: var(--ds-fw-regular); letter-spacing: 0; color: var(--ds-text-muted); margin-left: 3px; }
.ds-strip__value--accent { color: var(--ds-accent); }
.ds-strip__note { font-size: var(--ds-fs-xs); color: var(--ds-text-muted); margin-top: 6px; }
@media (max-width: 860px) {
  .ds-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-strip__item:nth-child(odd) { border-left: 0; padding-left: 0; }
}

/* ---------- Barra fina con marca de meta ---------- */
.ds-meter { position: relative; height: 3px; border-radius: 2px; background: var(--ds-surface-subtle); }
.ds-meter__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--ds-text); max-width: 100%; }
.ds-meter__fill--ok { background: var(--ds-success); }
.ds-meter__fill--warn { background: var(--ds-warning); }
.ds-meter__fill--bad { background: var(--ds-danger); }
.ds-meter__fill--accent { background: var(--ds-accent); }
.ds-meter__mark { position: absolute; top: -3px; width: 1px; height: 9px; background: var(--ds-text); }

/* ---------- Deslizador ---------- */
.ds-range { -webkit-appearance: none; appearance: none; width: 100%; height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--ds-accent) var(--fill, 50%), var(--ds-border) var(--fill, 50%)); outline: none; }
.ds-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--ds-accent); border: 2px solid var(--ds-surface); box-shadow: 0 0 0 1px var(--ds-accent); cursor: grab; }
.ds-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ds-accent); border: 2px solid var(--ds-surface); box-shadow: 0 0 0 1px var(--ds-accent); cursor: grab; }
.ds-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--ds-accent), var(--ds-focus-ring); }

/* ---------- Campos ---------- */
.ds-input { height: 32px; border: 1px solid var(--ds-border-strong); border-radius: var(--ds-radius-sm); padding: 0 10px; background: var(--ds-surface); color: var(--ds-text); font: var(--ds-fw-regular) var(--ds-fs-sm) var(--ds-font); font-variant-numeric: tabular-nums; }
.ds-input:focus { outline: none; border-color: var(--ds-accent-border); box-shadow: var(--ds-focus-ring); }
.ds-input:disabled { background: var(--ds-surface-subtle); color: var(--ds-text-muted); }
.ds-input--search { border-color: var(--ds-border); border-radius: var(--ds-radius-full); padding: 0 14px; }
.ds-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--ds-fs-xs); color: var(--ds-text-muted); }

/* ---------- Tabla y lista con filetes ---------- */
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--ds-fs-sm); }
.ds-table th { text-align: left; font-weight: var(--ds-fw-regular); font-size: var(--ds-fs-xs); color: var(--ds-text-muted); padding: 8px 10px; border-bottom: 1px solid var(--ds-border); white-space: nowrap; }
.ds-table td { padding: 12px 10px; border-bottom: 1px solid var(--ds-border); color: var(--ds-text); vertical-align: middle; }
.ds-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Tarjeta (solo cuando un bloque debe separarse del papel) ---------- */
.ds-card { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); padding: var(--ds-space-5) var(--ds-space-6); box-shadow: var(--ds-shadow-card); }

/* Tarjeta de sección: agrupa un bloque de la vista sobre el fondo gris de la app.
   Úsala para cada bloque que se lee por separado (filtros, una lista, un gráfico, un panel de detalle). */
.ds-panel { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); padding: 22px; box-shadow: var(--ds-shadow-card); }
.ds-panel + .ds-panel { margin-top: var(--ds-space-5); }
.ds-panel--flush { padding: 0; overflow: hidden; }
.ds-panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--ds-space-3); margin: 0 0 var(--ds-space-4); }
.ds-panel__title { margin: 0; font-family: var(--ds-font-display); font-size: 16px; font-weight: var(--ds-fw-display); letter-spacing: -0.01em; color: var(--ds-text); }
.ds-panel__sub { margin: 2px 0 0; font-size: var(--ds-fs-sm); color: var(--ds-text-muted); }

/* ---------- Estado vacío, carga y error ---------- */
.ds-status { font-size: var(--ds-fs-sm); color: var(--ds-text-muted); padding: var(--ds-space-4) 0; }
.ds-status[data-error="true"] { color: var(--ds-danger); }

/* ---------- Tooltip de gráficos (static/js/common/chart_tip.js) ----------
   Tarjeta blanca con borde fino y sombra suave, título en tinta y filas clave · etiqueta · valor con cifras
   tabulares. Reemplaza el <title> nativo de SVG. */
.ds-chart-tip { position: fixed; top: 0; left: 0; z-index: 30000; min-width: 160px; max-width: 300px; padding: 10px 12px; border: 1px solid var(--ds-border, #e5e7eb); border-radius: 10px; background: var(--ds-surface, #fff); color: var(--ds-text-body, #374151); box-shadow: 0 8px 24px rgba(16, 24, 40, .12), 0 1px 3px rgba(16, 24, 40, .06); font: 400 12px/1.4 var(--ds-font, 'Inter', system-ui, sans-serif); font-variant-numeric: tabular-nums; pointer-events: none; }
.ds-chart-tip[hidden] { display: none; }
.ds-chart-tip__title { margin: 0 0 6px; color: var(--ds-text, #111827); font-size: 12.5px; font-weight: 600; }
.ds-chart-tip ul { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ds-chart-tip li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.ds-chart-tip li.is-strong .ds-chart-tip__value { color: var(--ds-text, #111827); font-weight: 600; }
.ds-chart-tip__key { width: 10px; height: 10px; border-radius: 3px; background: var(--k); }
.ds-chart-tip__key.is-dashed { width: 12px; height: 0; border-top: 2px dashed var(--k); border-radius: 0; background: none; }
.ds-chart-tip__key[hidden] { display: block; visibility: hidden; }
.ds-chart-tip__label { color: var(--ds-text-muted, #6b7280); }
.ds-chart-tip__value { color: var(--ds-text-body, #374151); font-weight: 500; text-align: right; white-space: nowrap; }
.ds-chart-tip__foot { margin: 8px 0 0; padding-top: 6px; border-top: 1px solid var(--ds-border, #e5e7eb); color: var(--ds-text-muted, #6b7280); }
