/* ==========================================================================
   PANELES LATERALES (OFF-CANVAS DRAWERS): FICHA TÉCNICA & DRILL-DOWN KPIS
   ========================================================================== */

/* ==========================================================================
   1. PANEL LATERAL IZQUIERDO: FICHA TÉCNICA & AYUDA
   ========================================================================== */

.left-backdrop, .left-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.left-backdrop.open, .left-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.left-info-drawer, .left-help-drawer {
    position: fixed;
    top: 0;
    left: -580px;
    width: 520px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.left-backdrop.open .left-info-drawer,
.left-backdrop.open .left-help-drawer,
.left-drawer-backdrop.open .left-info-drawer,
.left-drawer-backdrop.open .left-help-drawer {
    left: 0;
}

.left-drawer-header {
    padding: 22px 26px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.left-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-right: 36px;
}

.left-drawer-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.left-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 26px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.help-section-card, .help-section {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.help-section-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
}

.tech-specs-grid, .help-specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.spec-item, .spec-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.spec-item.full-width, .spec-card.full-width {
    grid-column: 1 / -1;
}

.spec-key, .spec-lbl {
    color: var(--text-dim);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.spec-val {
    color: var(--text-main);
    font-weight: 700;
    margin-top: 2px;
}

.help-text-block, .help-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-bottom: 12px;
}

.value-chain-flow {
    background: #ffffff;
    border: 1px dashed var(--border-subtle);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--cyan-accent);
    line-height: 1.4;
}

.escalation-rules-box {
    font-size: 0.76rem;
    color: #78350f;
    line-height: 1.4;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid var(--copper-primary);
    padding: 10px 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.superintendencies-list, .help-superintendencies-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.superintendencies-list li, .help-superintendencies-list li {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-main);
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
}

.left-drawer-footer {
    padding: 16px 26px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   2. PANEL LATERAL DERECHO: DESGLOSE DE KPIS (DRILL-DOWN)
   ========================================================================== */

.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.kpi-drawer {
    position: fixed;
    top: 0;
    right: -100vw;
    width: 98vw;
    max-width: 98vw;
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.drawer-backdrop.open .kpi-drawer {
    right: 0;
}

.drawer-header {
    padding: 20px 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.drawer-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: var(--transition-fast);
}

.drawer-close-btn:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.drawer-breadcrumbs {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.drawer-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    margin-bottom: 8px;
    padding-right: 32px;
}

.drawer-kpi-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
    margin: 0;
    flex: 1;
}

.drawer-title-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.drawer-impact-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #b45309;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.drawer-impact-icon-btn:hover {
    background: #fde68a;
    color: #78350f;
    transform: scale(1.15);
    box-shadow: 0 1px 4px rgba(217, 119, 6, 0.25);
}

.node-category-tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: #e2e8f0;
    color: var(--text-muted);
}

/* FÓRMULA MATEMÁTICA VISUAL ELEGANTE */
.breakdown-formula-section {
    margin-top: 20px;
    border-top: 1px dashed var(--border-color);
    padding-top: 14px;
}

/* CABECERA DE FÓRMULA Y SELECTOR DE MODO */
.breakdown-source-section {
    margin-top: 20px;
}

.drawer-components-heading { display:inline-flex; align-items:center; gap:8px; }
#drawerComponentsToggle { display:inline-flex; align-items:center; justify-content:center; width:24px; height:24px; padding:0; border:1px solid #dce5ef; border-radius:4px; background:transparent; color:inherit; font:inherit; font-size:12px; cursor:pointer; }
#drawerComponentsToggle:hover { background:#e2eaf4; }
#drawerComponentsToggle:focus-visible { outline:2px solid #008acb; outline-offset:2px; }
#breakdownTableBody[hidden] { display:none; }
#drawerComponentsTable[hidden] { display:none; }
#drawerComponentsTable { margin-bottom:0; flex-shrink:0; }

.drawer-detail-tabs {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    border-bottom: 1px solid #dbe4f0;
}
.drawer-detail-tabs button {
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    padding: 10px 14px;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    font: inherit;
}
.drawer-detail-tabs button[aria-selected="true"] {
    border-bottom-color: #0284c7;
    color: #0369a1;
    font-weight: 600;
}
.drawer-detail-tabs [hidden], #drawerFormulaPanel[hidden], #drawerSourcePanel[hidden] {
    display: none;
}
.formula-math-display { overflow-x: auto; min-width: 0; }
.formula-math-display .math-legend { overflow-wrap: anywhere; }

.drawer-source-box {
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    padding: 16px;
    background: var(--bg-card, #fff);
    color: var(--text-main, #334155);
    font: 400 0.8rem/1.6 var(--font-family, sans-serif);
    overflow-wrap: anywhere;
}

.source-detail-group + .source-detail-group { margin-top: 14px; }
.source-detail-group h4 { margin: 0 0 6px; font-size: 0.8rem; }
.source-detail-group ul { margin: 0; padding-left: 20px; }
.source-detail-group li + li { margin-top: 5px; }
.drawer-source-box p { margin: 12px 0 0; }

.drawer-formula-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 0 8px 0;
}

.formula-label-outside {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.formula-mode-switch {
    display: flex;
    align-items: center;
    background: #e2e8f0;
    border-radius: var(--radius-full);
    padding: 2px;
    gap: 2px;
}

.formula-tab-pill {
    background: transparent;
    border: none;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition-fast);
    line-height: 1.2;
}

.formula-tab-pill:hover {
    color: var(--text-main);
}

.formula-tab-pill.active {
    background: #ffffff;
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* FÓRMULA MATEMÁTICA ESTRUCTURADA */
.drawer-formula-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 4px 0 14px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    overflow-x: auto;
}

.formula-math-display {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    font-family: 'JetBrains Mono', var(--font-mono), monospace;
    font-size: 0.84rem;
    line-height: 1.4;
    min-height: 46px;
}

.math-fraction-expr {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.math-fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    padding: 2px 4px;
}

.math-numerator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding-bottom: 4px;
    border-bottom: 2px solid #334155;
    flex-wrap: wrap;
}

.math-denominator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding-top: 4px;
    flex-wrap: wrap;
}

.math-linear-expr {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.math-pill {
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.math-pill.var {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}

.math-pill.val {
    background: rgba(194, 85, 37, 0.08);
    color: var(--copper-primary);
    border: 1px solid rgba(194, 85, 37, 0.25);
    font-weight: 700;
}

.math-pill.const {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    font-weight: 700;
}

.math-op {
    color: var(--cyan-accent);
    font-weight: 800;
    font-size: 0.95rem;
    padding: 0 2px;
}

.math-paren {
    color: #64748b;
    font-weight: 700;
    font-size: 1rem;
}

.math-equals {
    font-weight: 800;
    color: #0f172a;
    font-size: 1.1rem;
    margin: 0 4px;
}

.math-result {
    font-weight: 800;
    color: #0284c7;
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    white-space: nowrap;
}

/* Ecuaciones con tipografía matemática, sin cajas alrededor de cada término. */
.formula-math-display {
    display: block;
    font-family: var(--font-sans, sans-serif);
}

.formula-math-display .math-linear-expr,
.formula-math-display .math-fraction-expr {
    font-family: Cambria, 'Times New Roman', serif;
    font-size: 1.2rem;
    gap: 10px;
    padding: 10px 0;
}

.math-equation-scroll {
    max-width: 100%;
    overflow-x: auto;
}

.math-equation-scroll .math-linear-expr {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
}

.formula-math-display .math-pill {
    border: 0;
    background: none;
    box-shadow: none;
    padding: 2px;
    color: #1e293b;
    font-size: inherit;
    font-weight: 400;
}

.formula-math-display .math-pill.var {
    font-style: italic;
}

.formula-math-display .math-op {
    color: #475569;
    font-size: 1.1rem;
    font-weight: 400;
}

.formula-math-display .math-fraction {
    flex-shrink: 0;
}

.formula-math-display .math-numerator {
    border-bottom-width: 1px;
}

.formula-math-display .math-result {
    font-size: 1.1rem;
}

.math-legend {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px 18px;
    margin: 10px 0 4px;
    color: #475569;
    font-size: 0.73rem;
    line-height: 1.5;
}

.math-quality-note {
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px dashed #cbd5e1;
    font-family: var(--font-sans, sans-serif);
    font-size: 0.74rem;
    line-height: 1.65;
    color: #475569;
}

.math-legend i,
.math-legend strong {
    font-family: Cambria, 'Times New Roman', serif;
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 700;
}

.math-time-balance .math-pill:not(.const) {
    flex-direction: column;
    white-space: normal;
    text-align: center;
    max-width: 180px;
}

.math-time-balance .math-component-label,
.math-balance-row > strong {
    font-family: var(--font-sans, sans-serif);
    font-size: 0.74rem;
    font-style: normal;
    line-height: 1.4;
}

.math-balance-row { margin-top: 14px; }
.math-time-balance .math-quality-note { margin-top: 6px; padding-top: 6px; }
.math-labeled-value { display: inline-flex; flex-direction: column; align-items: center; max-width: 180px; text-align: center; }
.math-component-label { font-family: var(--font-sans, sans-serif); font-size: 0.74rem; line-height: 1.4; color: #475569; }

/* Stats Cards en Drawer (Valor, Referencia, Desviación) */
.drawer-kpi-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 14px;
}

@media (max-width: 650px) {
    .drawer-kpi-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.drawer-stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 10px;
    box-shadow: var(--shadow-sm);
}

.drawer-stat-card.card-real-db {
    background: #f0f9ff;
    border-color: #bae6fd;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
}

.stat-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    cursor: help;
    transition: transform 0.15s ease;
}

.stat-status-dot:hover {
    transform: scale(1.4);
}

.stat-status-dot.green {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.stat-status-dot.yellow {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.stat-status-dot.red {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.stat-status-dot.gray {
    background: #94a3b8;
    box-shadow: 0 0 6px rgba(148, 163, 184, 0.4);
}

.node-variance-pill.mock {
    color: #64748b;
}

.stat-value-big {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 2px;
}

.stat-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Tabs del Drawer */
.drawer-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.drawer-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 12px 14px;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
}

.drawer-tab-btn:hover {
    color: var(--text-main);
}

.drawer-tab-btn.active {
    color: var(--cyan-accent);
}

.drawer-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--cyan-accent);
}

/* Contenido del Drawer */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #f8fafc;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Tabla de Desglose */
.table-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.breakdown-table th {
    background: #f1f5f9;
    color: var(--text-dim);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.breakdown-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.breakdown-table th.col-component,
.breakdown-table td.col-component {
    width: 44%;
    text-align: left;
}

.breakdown-table th.col-num,
.breakdown-table td.col-num {
    width: 15%;
    text-align: left;
}

.breakdown-table th.col-status,
.breakdown-table td.col-status {
    width: 15%;
    text-align: left;
}

.breakdown-table th.col-resp,
.breakdown-table td.col-resp {
    width: 26%;
    text-align: left;
}

.breakdown-table tr:hover td {
    background: #f8fafc;
}

.subkpi-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.82rem;
    line-height: 1.35;
}

.table-num {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Gráfico de Tendencia */
.trend-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.trend-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.trend-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.trend-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-line {
    width: 14px;
    height: 3px;
    border-radius: 1px;
}

.legend-line.actual { background: var(--cyan-accent); }
.legend-line.target { background: var(--copper-primary); border-top: 1px dashed var(--copper-primary); }

.trend-chart-canvas {
    width: 100%;
    height: 150px;
}

/* Acciones Correctivas */
.action-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.action-id {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--cyan-accent);
}

.action-text {
    font-size: 0.78rem;
    color: var(--text-main);
    font-weight: 500;
    margin-top: 2px;
}

.badge-priority {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.badge-priority.Alta { background: #fee2e2; color: #dc2626; }
.badge-priority.Media { background: #fef3c7; color: #d97706; }
.badge-priority.Baja { background: #dcfce7; color: #16a34a; }

/* Footer del Drawer */
.drawer-footer {
    padding: 14px 24px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Floating Tooltip Personalizado de Alta Visibilidad */
.app-floating-tooltip {
    position: fixed;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.76rem;
    font-weight: 500;
    line-height: 1.4;
    padding: 8px 14px;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    pointer-events: none;
    max-width: 320px;
    white-space: normal;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: opacity 0.12s ease, transform 0.12s ease;
    opacity: 0;
    transform: translateY(4px);
}

.app-floating-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Glosario de Unidades con Hover */
.node-unit, .subkpi-unit, .unit-glossary {
    cursor: help;
    border-bottom: 1px dotted rgba(100, 116, 139, 0.5);
    transition: color 0.15s ease, border-color 0.15s ease;
}

.node-unit:hover, .subkpi-unit:hover, .unit-glossary:hover {
    color: var(--copper-primary) !important;
    border-color: var(--copper-primary) !important;
}

/* ==========================================================================
   TAB 3: ORIGEN DE DATOS EN BD MONGODB (REAL COLECCIÓN BD)
   ========================================================================== */
.drawer-db-source-container {
    padding: 4px 0 16px 0;
}

.db-spec-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.db-spec-header-card {
    border-radius: 8px;
    padding: 14px 16px;
    border: 1px solid;
    position: relative;
}

.db-spec-header-card.is-real {
    background: #f0f9ff;
    border-color: #bae6fd;
}

.db-spec-header-card.is-mock {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.db-spec-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.db-status-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.db-status-pill.real {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.db-status-pill.mock {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
}

.db-md-pill {
    font-size: 0.7rem;
    color: #0369a1;
    background: #e0f2fe;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #7dd3fc;
    font-weight: 600;
}

.db-md-pill code {
    font-family: monospace;
    font-weight: 700;
}

.db-spec-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.db-spec-subtitle {
    font-size: 0.78rem;
    color: #475569;
}

.db-code-inline {
    background: rgba(2, 132, 199, 0.1);
    color: #0284c7;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.75rem;
    font-weight: 600;
}

.db-spec-mock-notice {
    margin-top: 10px;
    font-size: 0.76rem;
    color: #64748b;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    line-height: 1.4;
}

.db-spec-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.db-metric-box {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
}

.db-metric-box.real-db {
    border-color: #7dd3fc;
    background: #f8fafc;
}

.db-metric-lbl {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
}

.db-metric-box.real-db .db-metric-lbl {
    color: #0284c7;
}

.db-metric-val {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
}

.db-metric-val.text-blue { color: #0284c7; }
.db-metric-val.text-slate { color: #0f172a; }
.db-metric-val.text-muted { color: #475569; }

.db-metric-sub {
    font-size: 0.68rem;
    color: #94a3b8;
    margin-top: 4px;
}

.db-spec-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.db-spec-sec-header {
    background: #f8fafc;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #1e293b;
}

.db-sec-icon {
    font-size: 0.95rem;
}

.db-spec-sec-body {
    padding: 12px 14px;
}

.db-spec-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.76rem;
    color: #475569;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.db-code-block-wrap {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #0f172a;
}

.db-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    padding: 5px 10px;
    font-size: 0.68rem;
    color: #94a3b8;
    font-family: monospace;
}

.db-code-tag {
    background: #0284c7;
    color: #ffffff;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 700;
}

.db-code-pre {
    margin: 0;
    padding: 10px 12px;
    color: #38bdf8;
    font-family: "JetBrains Mono", Consolas, Menlo, monospace;
    font-size: 0.74rem;
    line-height: 1.45;
    overflow-x: auto;
    white-space: pre-wrap;
}

.db-op-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.db-op-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.4;
}

.db-op-num {
    background: #e2e8f0;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.68rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.db-origin-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.db-origin-tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.db-origin-tag.real {
    color: #0284c7;
}

.db-origin-tag.target {
    color: #059669;
}

.db-origin-desc {
    margin: 0;
    font-size: 0.78rem;
    color: #334155;
    line-height: 1.45;
}

.db-spec-footer-note {
    font-size: 0.74rem;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
    line-height: 1.4;
}

/* Chronological evidence inside the KPI drawer. */
.drawer-states-toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin:20px 0 10px; }
.drawer-states-toolbar label { font-weight:600; }
.drawer-states-toolbar[hidden], .drawer-states-toolbar [hidden] { display:none; }
.drawer-daily-chart { overflow-x:auto; margin:16px 0; }
.drawer-daily-chart svg { width:100%; min-width:1200px; display:block; font:12px sans-serif; fill:var(--text-dim); }
.drawer-daily-chart .daily-hours-label { font-size:11px; font-weight:600; fill:var(--text-primary, #12304a); }
.drawer-daily-chart .daily-segment-label { font-size:10px; font-weight:600; }
.drawer-daily-legend { display:flex; flex-wrap:wrap; gap:10px 20px; margin:12px 0; }
.drawer-daily-legend-item { display:inline-flex; align-items:center; gap:6px; font-size:12px; }
.drawer-daily-swatch { width:12px; height:12px; border-radius:3px; display:inline-block; }
#drawerDailyContent details { margin-top:16px; }
.drawer-states-toolbar select { padding:7px 30px 7px 10px; border:1px solid #dce5ef; border-radius:8px; background:white; color:inherit; font:inherit; }
#drawerStatesSummary { color:var(--text-dim); font-size:12px; }
.drawer-states-info { color:#007eae; font-size:16px; cursor:help; margin-left:auto; }
.drawer-states-scroll { overflow:auto; max-height:62vh; border:1px solid #dce5ef; border-radius:8px; background:white; }
.drawer-states-table { width:100%; border-collapse:separate; border-spacing:0; font-size:12px; text-align:left; }
.drawer-states-table td, .drawer-states-table th { padding:10px; border-bottom:1px solid #edf1f6; vertical-align:top; }
.drawer-states-table thead th { position:sticky; top:0; background:#f1f5fa; z-index:1; color:var(--text-dim); white-space:nowrap; font-weight:600; }
.drawer-states-table .state-machine th { background:#f8fafd; color:#007eae; font-weight:600; }
.drawer-states-table .state-gap td { border-bottom:5px solid #f5f8fc; }
.state-time { min-width:120px; white-space:nowrap; }
.state-symbol { font-family:monospace; white-space:nowrap; }
.state-comment { min-width:120px; max-width:260px; white-space:pre-wrap; overflow-wrap:anywhere; }
.state-id small { display:block; color:var(--text-dim); font-size:10px; margin-top:4px; }
.state-hours { text-align:right; font-variant-numeric:tabular-nums; }
.drawer-maintenance-plan { margin-bottom:20px; padding:16px; background:#fff; border:1px solid #dce5ef; border-radius:8px; }
.maintenance-plan-title { font-weight:600; margin-bottom:12px; }
.maintenance-plan-values { display:flex; flex-wrap:wrap; gap:24px; }
.maintenance-plan-values span { display:block; color:var(--text-dim); font-size:11px; text-transform:uppercase; margin-bottom:4px; }
.maintenance-plan-values strong { font-size:18px; font-variant-numeric:tabular-nums; }
.maintenance-over-plan strong { color:#ed4245; }
.drawer-maintenance-plan p { font-size:12px; color:var(--text-dim); line-height:1.5; margin:12px 0 0; }
.drawer-states-table .state-before-period td { background:#fff7e8; }
.state-hours small { display:block; font-size:10px; color:var(--text-dim); margin-top:4px; white-space:nowrap; }
.kpi-drawer.showing-states .drawer-body { overflow:hidden; min-height:0; display:flex; flex-direction:column; }
.kpi-drawer.showing-states .drawer-detail-content { flex:1; min-height:0; display:flex; flex-direction:column; }
.kpi-drawer.showing-states .drawer-detail-tabs { flex-shrink:0; }
.kpi-drawer.showing-states #drawerStatesPanel:not([hidden]) { flex:1; min-height:0; display:flex; flex-direction:column; }
.kpi-drawer.showing-states .drawer-states-toolbar { flex-shrink:0; }
.kpi-drawer.showing-states #drawerStatesContent { flex:1; min-height:0; display:flex; flex-direction:column; }
.kpi-drawer.showing-states .drawer-states-scroll { flex:1; min-height:0; max-height:none; }
