/* ============================================================
   DASHBOARD STYLES (centralizado y gestionado desde un único archivo)
   - Todas las variables, tamaños y reglas principales se definen aquí.
   - Página con ancho estándar controlado por variable; contenido
     posicionado hacia la izquierda con margen configurable.
   - Gráficas y tablas responsivas; canvas controlado por JS.

   Migrada a web-dashboard/private/css (se sigue sirviendo en
   /dashboard/private/css). Al migrar:
   - .button pintaba linear-gradient(..., var(--accent-2)) y --accent-2 no
     existe: la declaracion entera quedaba invalida y "Agregar API" (y los
     demas .btn.button sin color propio) salian sin fondo. Ahora usa el
     fondo de .btn (--btn-bg / --btn-text).
   - La palabra de la columna Indicator (td.ok / .warn / .bad) salia en
     blanco en el tema oscuro: la tapaba el color !important de las celdas.
   - Modales .dmeter-info-modal en el tema claro: la X de cerrar se invertia
     a blanco sobre fondo claro (invisible) y el <code> salia en naranja
     claro sobre blanco.
============================================================ */

/* -----------------------
   Variables globales
   ----------------------- */
:root {
    /* Fondo general */
    --bg: #f5f7fa; /* blanco suave, más cálido que edf2f7 */
    --bg-accent: #f7f9fc;
    --bg-sheen: rgba(255, 255, 255, 0.18);

    /* Texto */
    --text: #0a0f1a; /* más profundo, mejor contraste */
    --text-light: #2a3344; /* gris azulado suave */
    --muted: #e9eef5;

    /* Tarjetas */
    --card: #ffffff; /* blanco puro para claridad */
    --card-header: #f2f5f9; /* sutil separación */
    --border: #d7dde6;
    --border-dark: #c2c9d4;

    /* Acentos */
    --accent: #4f8ef7; /* azul más profesional */
    --accent-strong: #6aa8ff;
    --accent-soft: rgba(79, 142, 247, 0.12);

    /* Estados */
    --ok: #2ecc71;
    --warn: #f1c40f;
    --bad: #e57373;

    /* Sidebar */
    --sidebar-bg: rgba(250, 252, 255, 0.96);
    --sidebar-border: var(--border);

    /* Inputs */
    --input-bg: #f9fbfe;
    --input-border: var(--border-dark);
    --input-text: var(--text);

    /* Botones */
    --btn-bg: linear-gradient(135deg, #5f9df5 0%, #3f82f0 100%);
    --btn-bg-hover: linear-gradient(135deg, #7ab3ff 0%, #5a9bff 100%);
    --btn-text: #ffffff;

    /* KPI / Paneles */
    --kpi-bg: var(--card);
    --kpi-text: var(--text);
    --log-bg: #eef3f8;
    --kpi-item-bg: #f4f7fb;
    --kpi-item-border: var(--border);
    --status-box-bg: rgba(240, 245, 252, 0.9);
    --chart-panel-bg: rgba(243, 248, 255, 0.9);

    /* Tablas API */
    --api-table-bg: rgba(245, 248, 255, 0.95);
    --api-table-row-odd-bg: rgba(240, 245, 255, 0.95);
    --api-table-row-even-bg: rgba(235, 240, 250, 0.95);
    --api-table-row-hover-bg: rgba(180, 205, 240, 0.55);

    /* Charts */
    --chart-legend-gap: 8px;
    --chart-axis-color: #1a1a1a;
    --chart-canvas-radius: 12px;
    --chart-max-width: 900px;
    --chart-default-height: 260px;

    /* Layout */
    --page-width: 1200px;
    --page-left-offset: 24px;
    --gutter: 16px;
    --card-radius: 16px;
    --card-padding: 18px;
    --transition-fast: 0.18s;
    --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body.dark-mode {
    --bg: #070d18;
    --bg-accent: rgba(96, 165, 250, 0.12);
    --bg-sheen: rgba(255, 255, 255, 0.06);
    --text: #edf4ff;
    --text-light: #d7e3f7;
    --muted: #a9b8d0;

    --card: rgba(11, 18, 31, 0.82);
    --card-header: rgba(17, 25, 40, 0.9);
    --border: #1d2f46;
    --border-dark: #274363;

    --accent: #7ab3ff;
    --accent-strong: #93c5fd;
    --accent-soft: rgba(122, 179, 255, 0.12);
    --ok: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;

    --sidebar-bg: rgba(11, 18, 31, 0.9);
    --sidebar-border: var(--border);

    --input-bg: rgba(15, 23, 42, 0.9);
    --input-border: var(--border-dark);
    --input-text: #edf4ff;

    --btn-bg: linear-gradient(135deg, #7ab3ff 0%, #4f8ef7 100%);
    --btn-bg-hover: linear-gradient(135deg, #93c5fd 0%, #6ba4ff 100%);
    --btn-text: #061321;

    --kpi-bg: rgba(17, 25, 40, 0.9);
    --kpi-text: #edf4ff;
    --log-bg: #020914;
    --kpi-item-bg: rgba(15, 23, 42, 0.92);
    --kpi-item-border: var(--border);
    --status-box-bg: rgba(15, 26, 45, 0.65);
    --chart-panel-bg: rgba(11, 20, 37, 0.65);
    --api-table-bg: rgba(11, 20, 37, 0.65);
    --api-table-row-odd-bg: rgba(11, 20, 37, 0.55);
    --api-table-row-even-bg: rgba(15, 26, 45, 0.75);
    --api-table-row-hover-bg: rgba(96, 165, 250, 0.12);

    --chart-axis-color: #d7e3f7;
    --shadow-soft: 0 18px 42px rgba(2, 6, 23, 0.52);
}

html, body {
    height: 100%;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    background: radial-gradient(circle at top left, var(--bg-accent), transparent 32%),
    linear-gradient(180deg, var(--bg-sheen), rgba(255, 255, 255, 0) 18%),
    var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.01em;
    transition: background var(--transition-fast) ease, color var(--transition-fast) ease;
}

body:not(.dark-mode),
body:not(.dark-mode) .small-muted,
body:not(.dark-mode) label,
body:not(.dark-mode) .form-check-label,
body:not(.dark-mode) .text-muted,
body:not(.dark-mode) .text-body-secondary,
body:not(.dark-mode) .kpi-title,
body:not(.dark-mode) .kpi-sub,
body:not(.dark-mode) .badge-files,
body:not(.dark-mode) .card h6,
body:not(.dark-mode) .card .fw-semibold {
    color: #111111 !important;
}

.app-wrapper {
    width: 100%;
    display: flex;
    justify-content: flex-start;
}

.dashboard {
    width: var(--page-width);
    max-width: calc(100% - var(--page-left-offset));
    margin-left: var(--page-left-offset);
    margin-right: auto;
    padding: calc(var(--gutter) * 1) 0;
}

.page {
    display: flex;
    gap: var(--gutter);
    align-items: flex-start;
    width: 100%;
}

.paper {
    width: 100%;
    display: flex;
    gap: var(--gutter);
    align-items: flex-start;
}

.sidebar {
    width: 320px;
    min-width: 240px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--card-radius);
    padding: var(--card-padding);
    box-shadow: var(--shadow-soft);
    transition: background var(--transition-fast), border var(--transition-fast), box-shadow var(--transition-fast);
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.sidebar > * {
    width: 100%;
    text-align: left;
    align-self: flex-start;
}

/* Exclusion TABs: estilo de texto claro (no modifica el card) */
.exclude-tabs-clear,
.exclude-tabs-clear .small-muted,
.exclude-tabs-clear .small,
.exclude-tabs-clear .form-check-label,
.exclude-tabs-clear label,
.exclude-tabs-clear .nav-link {
    color: var(--text) !important;
}

/* Un switch deshabilitado NO atenua su etiqueta.
 *
 * Aqui se atenuaba a 0.72 sobre --text-light, y sumado al `text-muted` que el
 * render anadia quedaba un gris sobre gris ilegible. El que mira este bloque
 * esta decidiendo que pestanas procesar: necesita leer los nombres aunque el
 * maestro este apagado. El estado inactivo lo comunica el switch, que el
 * navegador ya pinta distinto cuando esta deshabilitado. */
.exclude-tabs-clear .form-check-input:disabled + .form-check-label,
.exclude-tabs-clear .form-check-input[disabled] + .form-check-label {
    color: var(--text) !important;
}

/* Mantener el checkbox/switch con color de acento legible */
.exclude-tabs-clear .form-check-input {
    accent-color: var(--accent-strong);
}

/* Rango de tiempo (filtros avanzados): una pista con dos tiradores.
 *
 * Son los dos <input type=range> de siempre (#timeStartRange / #timeEndRange)
 * superpuestos sobre la misma pista: la pista no recibe el raton, solo los
 * tiradores. #timeRangeFill pinta el tramo elegido; lo coloca ui.js
 * (initTimeRangeControls). */
.time-range {
    position: relative;
    height: 28px;
    margin: 4px 0 2px;
}

.time-range__track {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 50%;
    height: 6px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: var(--border, #d6d9e0);
}

.time-range__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 999px;
    background: var(--accent-strong, #4f46e5);
}

.time-range__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.time-range__input:focus {
    outline: none;
}

.time-range__input::-webkit-slider-runnable-track {
    background: transparent;
    border: 0;
    height: 100%;
}

.time-range__input::-moz-range-track {
    background: transparent;
    border: 0;
}

.time-range__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    width: 16px;
    height: 16px;
    margin-top: 6px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--accent-strong, #4f46e5);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
    cursor: grab;
}

.time-range__input::-moz-range-thumb {
    pointer-events: auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--accent-strong, #4f46e5);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
    cursor: grab;
}

.time-range__input:active::-webkit-slider-thumb {
    cursor: grabbing;
}

.time-range__input:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

.time-range__input:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

.time-range__scale {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.72rem;
    color: var(--text-light, var(--text));
    opacity: 0.8;
}

.sidebar .mb-2,
.sidebar .file-list,
.sidebar .controls-row,
.sidebar .card {
    width: 100%;
}

/* El input nativo se oculta: el navegador fija su texto ("Elegir archivos") y no
   es traducible. La UI visible es .file-picker (label propio + nombre de archivo). */
#fileInput.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#fileInput:focus-visible + .file-picker #fileInputButton {
    outline: 2px solid var(--accent-strong, #2f6fed);
    outline-offset: 2px;
}

.main {
    flex: 1 1 auto;
    min-width: 0;
}

/* ============================================================
   TIPOGRAFÍA Y MICRO ESTILOS
============================================================ */
h1, h2, h3, h4, h5 {
    color: var(--text);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.small-muted {
    color: var(--muted);
    font-size: 0.85rem;
}

.badge-files {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid rgba(47, 111, 237, 0.2);
}

.file-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.file-picker-name {
    overflow-wrap: anywhere;
    flex: 1 1 auto;
    min-width: 0;
}

.input, .form-control, .form-select {
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--input-border);
    padding: 9px 12px;
    border-radius: 10px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    font-size: 0.95rem;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

.input:focus, .form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.16rem rgba(47, 111, 237, 0.14);
    outline: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, background .12s ease;
    border: 1px solid transparent;
    background: var(--btn-bg);
    color: var(--btn-text);
    box-shadow: 0 8px 16px rgba(47, 111, 237, 0.16);
}

.btn:hover {
    background: var(--btn-bg-hover);
    filter: saturate(1.08);
}

.btn:active {
    transform: translateY(1px);
}

.btn-outline-primary,
.btn-outline-secondary {
    background: transparent;
    box-shadow: none;
}

.btn-outline-primary {
    color: var(--accent);
    border-color: rgba(47, 111, 237, 0.4);
}

.btn-outline-primary:hover {
    background: var(--accent);
    color: #fff;
}

.btn-outline-secondary {
    color: var(--text);
    border-color: var(--border-dark);
}

.btn-outline-secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: var(--card-padding);
    box-shadow: var(--shadow-soft);
    transition: box-shadow var(--transition-fast), background var(--transition-fast), border var(--transition-fast), transform var(--transition-fast);
    overflow: hidden;
}

/* ============================================================
   GLOBAL TOGGLE CONTROL  (reusable enabled/disabled switch)
============================================================ */

.toggle-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: var(--text);
    font-size: 0.88rem;
}

.toggle-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.45);
    transition: background 0.2s ease, border-color 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.toggle-input:checked + .toggle-label .toggle-track {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-color: rgba(34, 197, 94, 0.75);
}

.toggle-input:checked + .toggle-label .toggle-thumb {
    transform: translateX(18px);
}

.toggle-input:focus-visible + .toggle-label .toggle-track {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* ── Exclude results sub-controls locked when master toggle is OFF ── */
#excludeResultsFields {
    transition: opacity 0.2s ease;
}

#excludeResultsFields.locked,
#thresholdsFields.locked {
    opacity: 0.4;
    pointer-events: none;
    user-select: none;
}

/* Valor de una regla que no se puede leer: esa regla no quita nada. */
#excludeResultsFields input[aria-invalid="true"] {
    border-color: var(--bad);
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--bad) 25%, transparent);
}

/* ============================================================
   EXCLUSION FILTER CARD  – light + dark mode
============================================================ */

#excludeCard {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 16px 16px;
    box-shadow: var(--shadow-soft, 0 4px 16px rgba(0, 0, 0, 0.06));
    color: var(--text);
    transition: background 0.2s, border 0.2s, color 0.2s;
}

#excludeCard h6 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}

#excludeCard .form-check-label,
#excludeCard .small-muted {
    color: var(--text-light, var(--text));
}

#excludeCard .form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 0.15rem;
    border-radius: 5px;
    border: 2px solid var(--border-dark, #60a5fa);
    background-color: var(--card);
    box-shadow: none;
}

/* ── List container ── */
#excludeCard #excludeList {
    max-height: 260px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--border);
    padding: 6px 4px;
    border-radius: 10px;
    background: var(--card-header, rgba(244, 247, 252, 0.9));
    transition: background 0.2s, border 0.2s;
}

/* dark-mode list */
body.dark-mode #excludeCard #excludeList {
    background: rgba(8, 14, 26, 0.72);
    border-color: rgba(148, 163, 184, 0.18);
}

/* ── Row (option) ── */
#excludeCard #excludeList .exclude-api-option {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

#excludeCard #excludeList .exclude-api-option:hover {
    background: var(--bg-accent, rgba(59, 130, 246, 0.08));
}

/* ── Label + toggle wrapper ── */
#excludeCard #excludeList .exclude-api-label-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
    cursor: pointer;
}

/* ── Text label ── */
#excludeCard #excludeList .exclude-api-label {
    display: inline-block;
    flex: 1 1 0;
    min-width: 0;
    color: var(--text);
    /* El tamaño y el peso de los demas filtros (los valores de Excluir
       resultados: 13 px, normal); antes 14 px seminegrita y parecia otro bloque. */
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.4;
    cursor: pointer;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

body.dark-mode #excludeCard #excludeList .exclude-api-label {
    color: #e2ecff;
}

/* ── Toggle container ── */
#excludeCard #excludeList .exclude-api-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* El tamaño de todos los interruptores de la barra lateral (.toggle-track:
       42 x 24, bola de 18); antes 38 x 22 con bola de 15. */
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

/* hidden real checkbox */
#excludeCard #excludeList .exclude-api-checkbox {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* ── Switch track – light mode ── */
#excludeCard #excludeList .exclude-api-switch {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: background 0.2s ease, border-color 0.2s ease;
}

body.dark-mode #excludeCard #excludeList .exclude-api-switch {
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* thumb */
#excludeCard #excludeList .exclude-api-switch::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

/* ── ON state ── */
/* El mismo azul que los demas interruptores (skin.css, --btn-bg): en verde
   el "Filtro de exclusion" parecia otro tipo de control. */
#excludeCard #excludeList .exclude-api-checkbox:checked + .exclude-api-switch {
    background: var(--btn-bg, #2563eb);
    border-color: var(--btn-bg, #2563eb);
}

#excludeCard #excludeList .exclude-api-checkbox:checked + .exclude-api-switch::before {
    transform: translateX(18px);
}

/* focus ring */
#excludeCard #excludeList .exclude-api-checkbox:focus-visible + .exclude-api-switch {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* scrollbar inside list */
#excludeCard #excludeList::-webkit-scrollbar {
    width: 5px;
}

#excludeCard #excludeList::-webkit-scrollbar-track {
    background: transparent;
}

#excludeCard #excludeList::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: var(--border-dark, rgba(148, 163, 184, 0.4));
}

.card:hover {
    box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
}

.card-header {
    background: var(--card-header);
    border-bottom: 1px solid var(--border-dark);
    color: var(--text-light);
    padding: 8px 0;
    margin-bottom: 12px;
}

/* ============================================================
   KPI GRID (homologado)
============================================================ */


/* Contenedor principal */
.kpi-section {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Bloque agrupador (cada tarjeta de grupo) */
.kpi-block {
    margin-bottom: 20px;
}

/* Título del bloque */
.kpi-block > h5 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    align-items: stretch;
}

.kpi-item {
    background: var(--kpi-item-bg);
    border: 1px solid var(--kpi-item-border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    min-height: 84px;
}

.kpi-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
    border-color: rgba(47, 111, 237, 0.3);
}

.kpi-title {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 8px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--kpi-text);
    line-height: 1.1;
    display: block;
    word-break: break-word;
}

.kpi-value.small {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
}

.kpi-value.ok {
    color: var(--ok);
}

.kpi-value.warn {
    color: var(--warn);
}

.kpi-value.bad {
    color: var(--bad);
}

.kpi-row {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

@media (max-width: 640px) {
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .kpi-item {
        padding: 14px;
        min-height: 72px;
    }

    .kpi-value {
        font-size: 1.05rem;
    }
}

.kpi-small-muted {
    font-size: 0.78rem;
    color: var(--muted);
}

.kpi-section .small {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 6px;
}

.kpi-item * {
    box-sizing: border-box;
}

body.dark-mode .small-muted,
body.dark-mode label,
body.dark-mode .kpi-title,
body.dark-mode .kpi-small-muted,
body.dark-mode .kpi-section .small,
body.dark-mode .kpi-advanced-summary,
body.dark-mode .kpi-card .small,
body.dark-mode .kpi-card .kpi-sub,
body.dark-mode .kpi-item .text-muted,
body.dark-mode .kpi-item .small,
body.dark-mode .kpi-item .small-muted,
body.dark-mode .kpi-section .text-muted,
body.dark-mode .table thead th,
body.dark-mode .badge-files,
body.dark-mode .chart-card .small,
body.dark-mode .chart-card .small-muted,
body.dark-mode .chart-card .text-muted,
body.dark-mode .chart-card .fw-semibold,
body.dark-mode .chart-card h6,
body.dark-mode .chart-card .mb-0,
body.dark-mode #summaryContent,
body.dark-mode [id$="Summary"],
body.dark-mode [id*="Analysis"],
body.dark-mode .summary-text,
body.dark-mode .ai-analysis-box,
body.dark-mode .card h6,
body.dark-mode .card .fw-semibold {
    color: rgba(255, 255, 255, 0.9) !important;
}

body.dark-mode .kpi-section .small-muted,
body.dark-mode .chart-card .small.fw-semibold,
body.dark-mode .chart-card .fw-semibold,
body.dark-mode .card .fw-semibold,
body.dark-mode .chart-card h6,
body.dark-mode .card h6 {
    color: #f5f7ff !important;
}

body.dark-mode .chart-card .bg-light {
    background: rgba(15, 23, 42, 0.55) !important;
    border-color: var(--border) !important;
}

body.dark-mode .kpi-section .small-muted {
    color: #ffffff !important;
}

body.dark-mode .kpi-advanced-summary,
body.dark-mode .kpi-item .text-muted,
body.dark-mode .kpi-item .small,
body.dark-mode .chart-card .text-muted,
body.dark-mode .chart-card .small,
body.dark-mode .ai-analysis-box,
body.dark-mode .summary-text {
    opacity: 1;
}

body.dark-mode .sidebar,
body.dark-mode .card,
body.dark-mode .table-card,
body.dark-mode .kpi-item,
body.dark-mode .chart-card {
    background: var(--card);
    border-color: var(--border);
    box-shadow: var(--shadow-soft);
}

body.dark-mode .kpi-item:hover {
    border-color: rgba(122, 179, 255, 0.5);
}

body.dark-mode .input,
body.dark-mode .form-control,
body.dark-mode .form-select,
body.dark-mode .form-range {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--input-text);
}

body.dark-mode .btn-outline-primary {
    color: var(--accent-strong);
}

body.dark-mode .chart-container {
    background: rgba(10, 14, 24, 0.55);
    border: 1px solid var(--border);
}

/* ============================================================
   CARDS
============================================================ */

/* Asegura que cada chart-card ocupe 100% y se apilen verticalmente en móviles y escritorio */
.chart-card {
    display: block;
    width: 100%;
    margin-bottom: 18px;
    box-sizing: border-box;
}

/* Si usas grid/row de bootstrap, forzar columna completa en pantallas pequeñas */
@media (min-width: 992px) {
    /* en desktop puedes mantener 2 columnas si lo deseas; para vertical forzar col-12 */
    .chartsArea .col-12 {
        width: 100%;
    }
}

/* Si quieres forzar siempre vertical (una por fila) */
#chartsArea > .col-12, #chartsArea > .col-12 .chart-card {
    width: 100% !important;
    max-width: 100%;
}

/* Canvas responsive */
.chart-card canvas {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* ============================================================
   TABLAS (homologadas)
   Oxford grey striped rows — light & dark mode
   Bootstrap 5.3 uses box-shadow (not background-color) for stripes.
   We must neutralise that shadow and own both background-color and
   box-shadow on every cell with !important.
============================================================ */

/* --- Bootstrap 5 CSS variable overrides (fallback) --- */
table,
.table,
.table-striped {
    --bs-table-bg: #f4f5f6;
    --bs-table-striped-bg: #eaecee;
    --bs-table-color: #1e2430;
    --bs-table-striped-color: #1e2430;
    --bs-table-border-color: #b0b8c1;
    --bs-table-hover-bg: #d8dce2;
    --bs-table-hover-color: #1e2430;
    --bs-table-accent-bg: transparent;
}

body.dark-mode table,
body.dark-mode .table,
body.dark-mode .table-striped {
    --bs-table-bg: #2d3541;
    --bs-table-striped-bg: #353e4d;
    --bs-table-color: rgba(234, 242, 255, 0.9);
    --bs-table-striped-color: rgba(234, 242, 255, 0.9);
    --bs-table-border-color: #2d3541;
    --bs-table-hover-bg: #3e4858;
    --bs-table-hover-color: rgba(234, 242, 255, 0.9);
    --bs-table-accent-bg: transparent;
}

/* --- Table card wrapper --- */
.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    padding: var(--card-padding);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Base table layout --- */
table,
.table {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    margin-top: 12px;
    color: var(--text);
    font-size: 0.88rem;
    background: transparent !important;
}

/* ----------------------------------------------------------------
   CRITICAL: Bootstrap 5.3 paints stripes via
   box-shadow: inset 0 0 0 9999px var(--bs-table-bg-type).
   We must zero that out on EVERY cell so our background-color wins.
---------------------------------------------------------------- */
table > :not(caption) > * > *,
.table > :not(caption) > * > * {
    box-shadow: none !important;
}

/* --- Cell base --- */
table th, table td,
.table th, .table td {
    padding: 9px 12px !important;
    border-bottom: 1px solid var(--border-dark) !important;
    border-top: none !important;
    text-align: left;
    vertical-align: middle !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- Row hover transition --- */
table tbody tr,
.table tbody tr {
    transition: background-color 0.12s ease;
}

/* ================================================================
   LIGHT MODE — Oxford grey rows
================================================================ */

/* Odd rows */
table > tbody > tr:nth-child(odd) > td,
table > tbody > tr:nth-child(odd) > th,
.table > tbody > tr:nth-child(odd) > td,
.table > tbody > tr:nth-child(odd) > th {
    background-color: #f4f5f6 !important;
}

/* Even rows */
table > tbody > tr:nth-child(even) > td,
table > tbody > tr:nth-child(even) > th,
.table > tbody > tr:nth-child(even) > td,
.table > tbody > tr:nth-child(even) > th {
    background-color: #eaecee !important;
}

/* Hover */
table > tbody > tr:hover > td,
table > tbody > tr:hover > th,
.table > tbody > tr:hover > td,
.table > tbody > tr:hover > th {
    background-color: #d8dce2 !important;
}

/* Headers — light */
table > thead > tr > th,
.table > thead > tr > th {
    background-color: #d1d5db !important;
    color: #1e2430 !important;
    border-bottom: 2px solid #b0b8c1 !important;
    font-size: 0.78rem !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
}

/* ================================================================
   DARK MODE — Oxford grey dark rows
================================================================ */

/* Odd rows */
body.dark-mode table > tbody > tr:nth-child(odd) > td,
body.dark-mode table > tbody > tr:nth-child(odd) > th,
body.dark-mode .table > tbody > tr:nth-child(odd) > td,
body.dark-mode .table > tbody > tr:nth-child(odd) > th {
    background-color: #2d3541 !important;
}

/* Even rows */
body.dark-mode table > tbody > tr:nth-child(even) > td,
body.dark-mode table > tbody > tr:nth-child(even) > th,
body.dark-mode .table > tbody > tr:nth-child(even) > td,
body.dark-mode .table > tbody > tr:nth-child(even) > th {
    background-color: #353e4d !important;
}

/* Hover */
body.dark-mode table > tbody > tr:hover > td,
body.dark-mode table > tbody > tr:hover > th,
body.dark-mode .table > tbody > tr:hover > td,
body.dark-mode .table > tbody > tr:hover > th {
    background-color: #3e4858 !important;
}

/* Headers — dark */
body.dark-mode table > thead > tr > th,
body.dark-mode .table > thead > tr > th {
    background-color: #1a2130 !important;
    color: rgba(234, 242, 255, 0.95) !important;
    border-bottom: 2px solid #2d3541 !important;
    box-shadow: none !important;
}

/* Text & border color — dark */
body.dark-mode table,
body.dark-mode .table {
    color: rgba(234, 242, 255, 0.9) !important;
}

body.dark-mode table td,
body.dark-mode table th,
body.dark-mode .table td,
body.dark-mode .table th {
    color: rgba(234, 242, 255, 0.9) !important;
    border-color: #2d3541 !important;
}

/* --- Numeric column helper --- */
.num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Status row indicators */
body.dark-mode .row-ok {
    border-left: 3px solid #22c55e;
}

body.dark-mode .row-error {
    border-left: 3px solid #ef4444;
}


/* ============================================================
   GRÁFICAS: contenedor y canvas (control centralizado)
   - JS debe usar Support.ensureCanvasSize(canvas, heightPx)
   - CSS evita que el canvas crezca fuera del contenedor
============================================================ */

.chart-legend {
    display: flex;
    gap: var(--chart-legend-gap);
    align-items: center;
    margin-bottom: 8px;
}

.chart-axis-label {
    font-size: 12px;
    color: var(--chart-axis-color);
}

/* Contenedor visual de la gráfica: controla ancho y layout */
.chart-container {
    width: 100%;
    max-width: var(--chart-max-width);
    height: var(--chart-default-height); /* valor visual por defecto; JS puede sobrescribir */
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    border-radius: var(--chart-canvas-radius);
}

/* Forzamos que el canvas ocupe el ancho del contenedor.
   La altura real la controla JS mediante canvas.width/canvas.height
   para respetar devicePixelRatio y evitar pixelación. */
.chart-container canvas,
canvas {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box;
    height: auto !important;
    max-height: none !important;
    border-radius: var(--chart-canvas-radius);
}

/* Si se necesita un layout de múltiples columnas para charts */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gutter);
}

/* ============================================================
   FOOTER
============================================================ */
.agp-footer {
    text-align: center;
    padding: 12px 0;
    margin-top: 40px;
    font-size: 0.9rem;
    color: var(--muted);
    border-top: 1px solid var(--border-dark);
    opacity: 0.9;
}

/* ============================================================
   RESPONSIVE RULES (homologadas)
   - Todos los ajustes de tamaño y columnas se controlan aquí.
   - Las gráficas se re-renderizan desde JS en resize para recalcular pixel ratio.
============================================================ */

/* Page width adaptativo: si la ventana es más pequeña que --page-width,
   el dashboard se ajusta y mantiene margen izquierdo mínimo. */
@media (max-width: 1280px) {
    :root {
        --page-width: 100%;
        --chart-max-width: 100%;
    }

    .dashboard {
        margin-left: calc(var(--page-left-offset) / 2);
        padding: 8px 12px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(4, minmax(140px, 1fr));
    }

    .sidebar {
        width: 100%;
        order: 1;
    }

    .main {
        order: 2;
    }

    .page {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 900px) {
    .kpi-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }

    :root {
        --chart-default-height: 260px;
    }
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .card {
        padding: 12px;
        border-radius: 8px;
    }

    .dashboard {
        margin-left: 12px;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: repeat(1, minmax(120px, 1fr));
    }

    :root {
        --chart-default-height: 200px;
    }

    .sidebar {
        display: none;
    }

    /* opcional: ocultar sidebar en móviles */
}

/* ============================================================
   UTILIDADES
============================================================ */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.center {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.p-2 {
    padding: 8px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mt-1 {
    margin-top: 4px;
}

.gap-2 {
    gap: 8px;
}

/* ============================================================
   NOTAS DE INTEGRACIÓN
*/

/* Backwards-compatible KPI-card styling used by some tabs */
.kpi-card {
    background: var(--kpi-item-bg);
    border: 1px solid var(--kpi-item-border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 160px;
    max-width: 320px;
    text-align: center;
}

.kpi-card .small {
    color: var(--muted);
    font-size: 0.78rem;
    margin: 0;
}

.kpi-card .h5 {
    margin: 0;
    font-weight: 800;
    color: var(--kpi-text);
    font-size: 1.15rem
}

.kpi-card .kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.kpi-card .kpi-icon.warn {
    background: linear-gradient(180deg, #ffd6a8, #f59e0b);
    color: #fff
}

.kpi-card .kpi-icon.ok {
    background: linear-gradient(180deg, #9ff5c9, #19b36b);
    color: #fff
}

.kpi-card .kpi-icon.bad {
    background: linear-gradient(180deg, #ffd6d6, #ef4444);
    color: #fff
}

.kpi-card .kpi-sub {
    color: var(--muted);
    font-size: 0.78rem
}

/* KPI "Test duration" del Runner (hybrid-ui.js -> renderDurationKpi).
   La barra avanza con el tiempo efectivo; el color dice como acabo. */
.kpi-duration__track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.kpi-duration__fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.45s linear;
}

.kpi-duration[data-phase="paused"] .kpi-duration__fill {
    background: var(--warn);
}

.kpi-duration[data-phase="finished"] .kpi-duration__fill {
    background: var(--ok);
}

.kpi-duration[data-phase="stopped"] .kpi-duration__fill,
.kpi-duration[data-phase="limit"] .kpi-duration__fill {
    background: var(--warn);
}

.kpi-duration .kpi-value {
    font-variant-numeric: tabular-nums;
}

/* ensure mobile flow keeps cards neat */
@media (max-width: 900px) {
    .kpi-card {
        min-width: 140px;
        padding: 8px 10px
    }

    .kpi-card .h5 {
        font-size: 1rem
    }
}

/* KPIs propios de cada grafica (core/chart-kpis.js), entre el analisis y el canvas */
.chart-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin: 8px 0 10px;
}

.chart-kpis:empty {
    display: none;
}

.chart-kpi {
    background: var(--kpi-item-bg);
    border: 1px solid var(--kpi-item-border);
    border-left: 3px solid var(--kpi-item-border);
    border-radius: 10px;
    padding: 8px 10px;
    min-width: 0;
}

.chart-kpi.is-ok {
    border-left-color: var(--ok);
}

.chart-kpi.is-warn {
    border-left-color: var(--warn);
}

.chart-kpi.is-bad {
    border-left-color: var(--bad);
}

.chart-kpi-label,
.chart-kpi-sub {
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-kpi-label {
    font-size: 0.72rem;
}

.chart-kpi-sub {
    font-size: 0.7rem;
    opacity: 0.75;
}

.chart-kpi-value {
    color: var(--kpi-text);
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.chart-kpis-empty {
    grid-column: 1 / -1;
    color: var(--text-light);
    font-size: 0.8rem;
    opacity: 0.75;
}

/* ============================================================
   NOTAS DE INTEGRACIÓN
   - Quitar estilos duplicados de otros .js/.css y usar únicamente
     este archivo como fuente de verdad para tamaños y colores.
   - Asegurarse de que los componentes HTML usen las clases:
     .app-wrapper > .dashboard > .page > .sidebar + .main
     y que los charts estén dentro de .chart-container.
   - JavaScript debe llamar Support.ensureCanvasSize(canvas, heightPx)
     antes de crear/actualizar cada Chart.js instance.
============================================================ */

/* --- Added missing rules merged from public/css/style.css (no duplicates) --- */

/* Siempre va con .btn (runner, tabla de APIs): mismo fondo que .btn. */
.button {
    background: var(--btn-bg);
    border: 0;
    color: var(--btn-text);
    font-weight: 600;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
}

.button.ghost {
    background: transparent;
    border: 1px solid var(--line, var(--border));
    color: var(--text);
}

.button.warn {
    background: rgba(239, 68, 68, .2);
    border: 1px solid rgba(239, 68, 68, .45);
    color: #fee2e2;
}

body:not(.dark-mode) .button,
body:not(.dark-mode) .button.warn,
body:not(.dark-mode) #btnRun {
    color: #111111 !important;
}

#btnRun {
    background: #16a34a !important;
    border: 1px solid #15803d !important;
    color: #fff !important;
}

#btnRun:hover {
    filter: brightness(1.08);
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.toolbar .toolbar-wide {
    grid-column: 1 / -1;
}

.toolbar .button[disabled],
.toolbar .button:disabled {
    opacity: .45;
    cursor: not-allowed;
    filter: grayscale(35%);
}

.status-box {
    margin-top: 10px;
    border: 1px solid rgba(148, 163, 184, .1);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--status-box-bg);
}

.chart-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--chart-panel-bg);
    padding: 10px;
    height: 320px;
    min-height: 320px;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    /* El resumen y el boton de insights que anade chart-insights.js son hijos
       de este panel, y con el canvas clavado a 250px no les quedaban mas que
       ~20px de los 320: se salian por debajo del borde. Ahora el canvas cede
       el sitio (ver .chart-panel__canvas) y la fila cae dentro del recuadro. */
    overflow: hidden;
}

/* Caja de la grafica.
 *
 * Chart.js dimensiona el canvas contra su contenedor, no contra el panel, asi
 * que este hueco flexible es lo que convierte "lo que sobre" en espacio para la
 * fila de insights en lugar de empujarla fuera. Es el patron que la propia
 * documentacion de Chart.js recomienda: un contenedor relativo con la altura
 * que manda. */
.chart-panel__canvas {
    position: relative;
    flex: 1 1 auto;
    /* Sin esto un hijo flex no baja de su contenido y el canvas volveria a
       desbordar el panel. */
    min-height: 0;
}

.chart-panel canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
}

/* La fila de resumen y acciones no se encoge: es lo ultimo que se ve y lo que
   el cliente pulsa. */
.chart-panel .dm-insights-summary,
.chart-panel .dm-insights-actions {
    flex: 0 0 auto;
    margin-top: 6px !important;
}

/* ============================================================
   EXECUTION SUMMARY: LECTURA EJECUTIVA + LECTURA TECNICA
   Dos columnas en pantalla ancha y una debajo de otra en estrecha. El bloque
   ejecutivo va primero a proposito: es el que se lee de pie.
============================================================ */
.exec-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: var(--gutter);
}

@media (max-width: 1100px) {
    .exec-summary {
        grid-template-columns: 1fr;
    }
}

.exec-summary__block {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--chart-panel-bg);
}

.exec-summary__title {
    margin: 0 0 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
}

.exec-summary__verdict {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
}

.exec-summary__verdict--ok {
    color: var(--ok);
}

.exec-summary__verdict--warn {
    color: var(--warn);
}

.exec-summary__verdict--bad {
    color: var(--bad);
}

.exec-summary__headline {
    margin-top: 6px;
    font-size: 0.95rem;
}

/* El aviso que invalida la lectura. Se ve, no se insinua. */
.exec-summary__caveat {
    margin-top: 10px;
    padding: 8px 10px;
    border-left: 3px solid var(--warn);
    background: rgba(241, 196, 15, 0.12);
    font-size: 0.85rem;
}

.exec-summary__group {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    margin-bottom: 4px;
}

.exec-summary__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
    font-size: 0.88rem;
}

.exec-summary__label {
    color: var(--text-light);
}

.exec-summary__value {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ============================================================
   SEMAFORO DEL ESCENARIO DE CARGA
   La barra es un degradado fijo verde -> amarillo -> rojo y lo que se mueve es
   el marcador. Es deliberado: el cliente ve el RANGO completo y donde cae lo
   suyo dentro de el, que es la pregunta ("¿voy bien?"). Una barra que se
   rellena solo dice cuanto, no respecto a que.
============================================================ */
.scenario-risk {
    grid-column: 1 / -1;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--chart-panel-bg);
}

.scenario-risk__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.scenario-risk__level {
    font-size: 0.82rem;
    font-weight: 600;
}

.scenario-risk__track {
    position: relative;
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg,
    var(--ok) 0%,
    var(--ok) 45%,
    var(--warn) 62%,
    var(--bad) 85%,
    var(--bad) 100%);
    /* El degradado se atenua hasta que el marcador dice donde estas: asi la
       barra no grita rojo cuando el escenario es pequeno. */
    opacity: 0.45;
}

.scenario-risk__marker {
    position: absolute;
    top: -4px;
    left: 0;
    width: 4px;
    height: 18px;
    border-radius: 2px;
    background: var(--text);
    box-shadow: 0 0 0 2px var(--card);
    transition: left var(--transition-fast, 0.18s) ease-out;
}

.scenario-risk__note {
    margin-top: 6px;
    min-height: 1.2em;
}

.scenario-risk__caution {
    margin-top: 4px;
    font-size: 0.78rem;
}

.scenario-risk--safe .scenario-risk__level {
    color: var(--ok);
}

.scenario-risk--caution .scenario-risk__level {
    color: var(--warn);
}

.scenario-risk--danger .scenario-risk__level {
    color: var(--bad);
}

/* En rojo la barra deja de estar atenuada: a partir de aqui el aviso ES el
   mensaje, no un adorno. */
.scenario-risk--danger .scenario-risk__track {
    opacity: 1;
}

.scenario-risk--danger {
    border-color: var(--bad);
}

/* ============================================================
   TIPOS DE PRUEBA (presets) Y FORMA DE LA CARGA
   - Los botones los construye hybrid-ui.js -> renderShapeButtons().
   - La curva la calcula scenario-shapes.js con el plan real.
   El color de la curva es el del semaforo a proposito: los dos paneles hablan
   del mismo escenario y discrepar visualmente seria mentir a medias.
   ============================================================ */

.scenario-presets {
    margin-bottom: 10px;
}

.scenario-presets__row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.scenario-presets__btn.active {
    border-color: var(--accent, var(--text));
    font-weight: 600;
}

.scenario-presets__note {
    margin-top: 4px;
    min-height: 1.1em;
}

.scenario-shape {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--chart-panel-bg);
}

.scenario-shape__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.scenario-shape__peak {
    font-size: 0.82rem;
    font-weight: 600;
}

/* El SVG se estira a lo ancho (preserveAspectRatio="none"), asi que la altura
   la fija el contenedor y no la relacion de aspecto. */
.scenario-shape__canvas {
    height: 120px;
    overflow: hidden;
}

.scenario-shape__svg {
    display: block;
    width: 100%;
    height: 120px;
}

.scenario-shape__axis {
    stroke: var(--border);
    stroke-width: 1;
}

.scenario-shape__line {
    fill: none;
    stroke: var(--ok);
    stroke-width: 2;
}

.scenario-shape__area {
    fill: var(--ok);
    opacity: 0.14;
    stroke: none;
}

.scenario-shape__ramp {
    stroke: var(--text);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.45;
}

.scenario-shape__svg--caution .scenario-shape__line {
    stroke: var(--warn);
}

.scenario-shape__svg--caution .scenario-shape__area {
    fill: var(--warn);
}

.scenario-shape__svg--danger .scenario-shape__line {
    stroke: var(--bad);
}

.scenario-shape__svg--danger .scenario-shape__area {
    fill: var(--bad);
}

.scenario-shape__ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.74rem;
}

.scenario-shape__note {
    margin-top: 4px;
    min-height: 1.2em;
}

.scenario-shape__flag {
    margin-top: 2px;
    font-size: 0.78rem;
}

/* ============================================================
   ESTADO EN LAS TABLAS: CIRCULO + PALABRA
   - La columna Status pinta el circulo (ui.js -> statusDotCell).
   - La columna Indicator pinta la palabra, con el mismo color.
   El color no es el unico canal: el circulo lleva aria-label y title, y la
   palabra esta en la columna de al lado.
============================================================ */
.status-dot-cell {
    text-align: center;
    /* Que la columna no se encoja al ancho del punto y quede ilegible el
       encabezado. */
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    /* El borde es lo que lo separa del fondo de la fila en el tema claro, donde
       el verde sobre blanco pierde contorno. */
    border: 1px solid rgba(15, 23, 42, 0.25);
    vertical-align: middle;
    background: var(--text-light);
}

.status-dot--ok {
    background: var(--ok);
}

.status-dot--warn {
    background: var(--warn);
}

.status-dot--bad {
    background: var(--bad);
}

/* La palabra de la columna Indicator, en el mismo tono que su circulo.
   !important porque las celdas del tema oscuro (body.dark-mode table td) y de
   .analysis-surface fijan su color y la dejaban en blanco. */
td.ok {
    color: var(--ok) !important;
}

td.warn {
    color: var(--warn) !important;
}

td.bad {
    color: var(--bad) !important;
}

.api-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--api-table-bg);
}

.api-table thead th {
    background: var(--card-header);
    color: var(--text);
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
}

.api-table tbody td {
    background: var(--api-table-row-odd-bg);
    color: var(--text);
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    padding: 12px 14px;
    vertical-align: middle;
}

.api-table tbody tr:nth-child(even) td {
    background: var(--api-table-row-even-bg);
}

.api-table tbody tr:hover td {
    background: var(--api-table-row-hover-bg);
}

.api-table .api-id {
    width: 64px;
    font-weight: 700;
    text-align: center;
}

.api-table .api-url {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.api-table .api-actions {
    white-space: nowrap;
}

.api-table .btn.small {
    width: 32px;
    height: 32px;
    padding: 0;
    margin-right: 4px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(122, 179, 255, 0.22);
    color: var(--text);
    box-shadow: none;
}

.api-table .btn.small:hover {
    background: rgba(96, 165, 250, 0.22);
}

.api-table th:last-child,
.api-table td:last-child {
    text-align: center;
}

/* --- End merged-from-public --- */

/* ============================================================
   INFO MODALS (KPI definitions / Execution method definitions)
   Llevan data-bs-theme="dark", pero el fondo y el texto salen de las
   variables del tema: en el tema claro el modal es claro.
============================================================ */
.dmeter-info-modal .modal-content {
    background: var(--card-header);
    border: 1px solid var(--border-dark);
    color: var(--text);
    box-shadow: var(--shadow-soft);
}

.dmeter-info-modal .modal-header,
.dmeter-info-modal .modal-footer {
    border-color: var(--border-dark);
}

.dmeter-info-modal .modal-title,
.dmeter-info-modal strong,
.dmeter-info-modal b {
    color: var(--text);
}

.dmeter-info-modal h6 {
    color: var(--text-light);
    letter-spacing: 0.04em;
}

.dmeter-info-modal,
.dmeter-info-modal .modal-body {
    color: var(--text);
}

.dmeter-info-modal .text-body-secondary {
    color: var(--text-light) !important;
}

.dmeter-info-modal code {
    color: #ffd6a8;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
}

body:not(.dark-mode) .dmeter-info-modal code {
    color: #9a3412;
    background: rgba(15, 23, 42, 0.05);
}

.dmeter-info-modal .border {
    border-color: var(--border) !important;
}

.dmeter-info-modal .border-primary {
    border-color: var(--accent) !important;
}

.dmeter-info-modal .bg-body-tertiary {
    background: var(--accent-soft) !important;
}

.dmeter-info-modal .table {
    --bs-table-color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    color: var(--text);
    margin-bottom: 0;
}

.dmeter-info-modal .table > :not(caption) > * > * {
    background: transparent;
    color: var(--text);
}

.dmeter-info-modal .badge.text-bg-light {
    background: rgba(255, 255, 255, 0.12) !important;
    color: var(--text-light) !important;
    border-color: var(--border-dark) !important;
}

.dmeter-info-modal .badge.text-bg-secondary {
    background: rgba(255, 255, 255, 0.18) !important;
    color: var(--text) !important;
}

/* La X se invierte a blanco solo sobre el fondo oscuro. En el claro hay que
   anular tambien el filtro que Bootstrap aplica bajo [data-bs-theme=dark]. */
body.dark-mode .dmeter-info-modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(220%);
}

body:not(.dark-mode) .dmeter-info-modal .btn-close {
    filter: none;
}

.dmeter-info-modal .btn-secondary {
    background: var(--accent-soft);
    border-color: var(--border-dark);
    color: var(--text);
}

.dmeter-info-modal .btn-secondary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #061321;
}

/* ============================================================
   HISTORY MODAL (home/history.js)
   Sin estilos propios era el modal blanco de Bootstrap: en el tema oscuro
   el texto secundario (.small-muted, blanco !important) no se veia sobre el
   fondo blanco y las tablas oscuras quedaban encima. Ahora el fondo y el
   texto salen de las variables del tema, como en .dmeter-info-modal.
============================================================ */
.history-modal {
    /* --muted es un fondo en el tema claro; el texto secundario necesita el suyo. */
    --history-muted: #4b5567;
    --history-better: #15803d;
    --history-worse: #b91c1c;
}

body.dark-mode .history-modal {
    --history-muted: #a9b8d0;
    --history-better: #34d399;
    --history-worse: #f87171;
}

.history-modal .modal-content {
    background: var(--card-header);
    border: 1px solid var(--border-dark);
    color: var(--text);
    box-shadow: var(--shadow-soft);
}

.history-modal .modal-header {
    border-color: var(--border-dark);
}

.history-modal .modal-title {
    color: var(--text);
    font-weight: 700;
}

.history-modal .modal-title i {
    color: var(--accent);
}

body.dark-mode .history-modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(220%);
}

/* Gana a las reglas !important de .small-muted / .text-muted de cada tema. */
.history-modal .modal-body .small-muted,
.history-modal .modal-body .text-muted {
    color: var(--history-muted) !important;
}

.history-modal .modal-body h6 {
    color: var(--text);
}

/* Nombre de la ejecucion: los de fichero no tienen espacios y no partian. */
.history-modal .history-name-cell {
    min-width: 220px;
    max-width: 360px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.history-modal .history-name-cell strong {
    color: var(--text);
}

#historyDetail:not(:empty) {
    margin-top: 20px !important;
    padding-top: 16px;
    border-top: 1px solid var(--border-dark);
}

.history-run-head {
    margin-bottom: 4px;
}

.history-modal .history-run-title {
    margin: 0 0 4px;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.history-run-meta {
    color: var(--history-muted);
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

.history-modal .history-section-title {
    margin: 18px 0 0;
    font-size: 0.95rem;
    font-weight: 700;
}

/* Cabecera de la comparacion: el nombre y la fecha, sin mayusculas forzadas. */
.history-modal .table > thead > tr > th.history-col-run {
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.85rem !important;
    white-space: normal;
    overflow-wrap: anywhere;
    min-width: 160px;
}

.history-modal th.history-col-run .small-muted {
    font-weight: 400;
    font-size: 0.78rem;
}

/* Mejora / empeora: el color !important de las celdas del tema oscuro lo tapaba. */
.history-modal .table td.text-success {
    color: var(--history-better) !important;
    font-weight: 600;
}

.history-modal .table td.text-danger {
    color: var(--history-worse) !important;
    font-weight: 600;
}

/* ============================================================
   analysis-surface
   Mismo lenguaje visual que los modales de modalAnalysis.js.
   Se aplica a las pestanas de analisis (gantt, threads,
   complements, tabla API) y funciona en tema claro y oscuro.
   ============================================================ */
.analysis-surface {
    color: var(--text, #0a0f1a);
}

.analysis-surface .card {
    background: var(--card, #ffffff);
    color: var(--text, #0a0f1a);
    border: 1px solid var(--border, #d7dde6);
    border-radius: 10px;
}

.analysis-surface .card-header {
    background: var(--card-header, #f2f5f9);
    color: var(--text, #0a0f1a);
    border-bottom: 1px solid var(--border, #d7dde6);
}

.analysis-surface .table-responsive {
    background: var(--card, #ffffff);
    color: var(--text, #0a0f1a);
}

.analysis-surface .table {
    --bs-table-color: var(--text, #0a0f1a);
    --bs-table-bg: transparent;
    --bs-table-striped-color: var(--text, #0a0f1a);
    --bs-table-striped-bg: var(--card-header, #f2f5f9);
    --bs-table-hover-color: var(--text, #0a0f1a);
    --bs-table-hover-bg: rgba(59, 130, 246, 0.12);
    --bs-table-border-color: var(--border, #d7dde6);
    background: transparent;
    color: var(--text, #0a0f1a);
}

.analysis-surface .table thead th,
.analysis-surface .table-dark th {
    background: var(--card-header, #f2f5f9);
    color: var(--text, #0a0f1a);
    border-color: var(--border, #d7dde6);
    text-transform: uppercase;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    font-weight: 700;
    white-space: nowrap;
}

.analysis-surface .table td,
.analysis-surface .table th {
    color: var(--text, #0a0f1a);
    border-color: var(--border, #d7dde6);
    vertical-align: middle;
}

.analysis-surface .small-muted,
.analysis-surface .text-muted {
    color: var(--text-light, #2a3344) !important;
    opacity: 0.85;
}

body.dark-mode .analysis-surface .small-muted,
body.dark-mode .analysis-surface .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
    opacity: 1;
}
/* ============================================================
   Encabezado de marca (i9x / Hybrid Performance)
   Antes era un SVG con fondo #030C23 fijo: en modo claro quedaba
   una banda negra pegada al resto del dashboard. Ahora usa las
   variables de tema para verse bien en claro y oscuro.
   ============================================================ */
.app-header {
    display: flex;
    align-items: center;
    padding: 18px 24px;
    border: 1px solid var(--border, #d7dde6);
    /* Esquinas rectas: la banda de marca va de lado a lado, no es una tarjeta. */
    border-radius: 0;
    background: linear-gradient(135deg,
    var(--accent-soft, rgba(79, 142, 247, 0.12)) 0%,
    var(--card, #ffffff) 55%,
    var(--card, #ffffff) 100%);
    box-shadow: 0 6px 18px rgba(10, 15, 26, 0.06);
}

body.dark-mode .app-header {
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.app-header__mark {
    width: 78px;
    height: 78px;
    flex: 0 0 auto;
    color: var(--accent, #4f8ef7);
}

.app-header__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.12;
}

.app-header__title {
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text, #0a0f1a);
}

.app-header__subtitle {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent-strong, #2f6fed);
}

.app-header__tagline {
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-light, #5a6477);
}

@media (max-width: 575.98px) {
    .app-header {
        padding: 14px 16px;
    }

    .app-header__mark {
        width: 56px;
        height: 56px;
    }

    .app-header__title {
        font-size: 2rem;
    }

    .app-header__subtitle {
        font-size: 0.95rem;
        letter-spacing: 2px;
    }
}

/* ============================================================
   CHART INSIGHTS — fila "Summary" + boton "View Insights"
   El bloque se inyecta desde core/chart-insights.js al final de cada
   tarjeta; estas reglas evitan que se recorte o se salga del borde.
============================================================ */

.chart-card:has(.dm-insights-summary),
.card:has(> .dm-insights-summary) {
    overflow: visible !important;
    padding-bottom: 10px !important;
}

.dm-insights-summary {
    width: 100%;
    margin-top: 10px !important;
    padding-top: 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    line-height: 1.35;
}

.dm-insights-summary-label {
    flex: 1 1 200px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.dm-insights-actions {
    display: flex;
    justify-content: flex-end;
}

.dm-insights-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    border-radius: 999px;
    padding: 3px 14px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ============================================================
   LISTA DE ARCHIVOS CARGADOS (sidebar)
============================================================ */

.file-item {
    padding: 8px 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 10px;
    margin-bottom: 6px;
    transition: border-color .15s ease, background-color .15s ease;
}

.file-item:hover {
    border-color: rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.06);
}

.file-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.file-item-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: transparent;
    color: var(--text-light, #94a3b8);
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: all .15s ease;
}

.file-item-btn:hover {
    transform: translateY(-1px);
}

.file-item-btn:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.6);
    outline-offset: 1px;
}

.file-item-btn--edit:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
}

.file-item-btn--remove:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.14);
    color: #f87171;
}

/* ============================================================
   i9x Performance Web (core/platform.js)
   La app de Next de la web pinta <html data-i9x-platform="web">. Lo
   que es solo de escritorio (runner, agente, recordar el dispositivo)
   no se ve en la web, y lo que es solo de la web (el aviso de
   privacidad, borrar los datos del navegador) no se ve en escritorio.
============================================================ */

html[data-i9x-platform="web"] .i9x-desktop-only {
    display: none !important;
}

html:not([data-i9x-platform="web"]) .i9x-web-only {
    display: none !important;
}

.i9x-web-note {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--text-light, #5a6477);
}

.i9x-web-note .bi {
    margin-right: 0.35rem;
}

/* Fase 1: solo Chrome y Edge de escritorio (core/platform.js#isSupportedBrowser). */
.i9x-web-browser-note {
    position: relative;
    z-index: 2000;
    padding: 6px 16px;
    font-size: 0.8rem;
    text-align: center;
    background: #fff7e6;
    color: #7a4b00;
    border-bottom: 1px solid #f3d7a0;
}
