:root {
    --bg: #03060a;
    --card-bg: rgba(6, 12, 20, 0.85);
    --border: #102a3f;
    --cyan: #00f3ff;
    --magenta: #ff0055;
    --amber: #ffb700;
    --red: #ff2a2a;
    --green: #00ff66;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    color: var(--cyan);
    font-family: 'Share Tech Mono', monospace;
    padding: 1.5rem;
}

/* Adaptación fluida para tablets y laptops compactas */
@media (max-width: 1024px) {
    .summary-grid {
        grid-template-columns: 1fr 1fr; /* Pasa el sidebar de KPIs abajo en pantallas medianas */
    }
    
    .kpi-column {
        grid-column: span 2;
        flex-direction: row;
    }

    .telemetry-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columnas en lugar de 3 */
    }
}

.vfd-frame {
    max-width: 1400px;
    margin: 0 auto;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    background: #050a10;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.05);
    position: relative;
}

.vfd-frame::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.3) 50%);
    background-size: 100% 4px;
    pointer-events: none;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.drop-zone {
    border: 1.5px dashed var(--cyan);
    background: rgba(0, 243, 255, 0.05);
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1.5rem;
    border-radius: 4px;
}

input[type="file"] {
    display: none !important;
}

/* Hero Summary Layout */
.summary-grid {
    display: grid;
    grid-template-columns: 2.2fr 2.2fr 1.6fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.hero-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hero-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.hero-value {
    font-family: 'VT323', monospace;
    font-size: 3.5rem;
    line-height: 1;
}

.hero-chart {
    width: 100%;
    height: 120px;
}

/* KPI Column Layout */
.kpi-column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.5rem;
}

.kpi-row {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-metrics {
    text-align: right;
}

.kpi-value {
    font-family: 'VT323', monospace;
    font-size: 2.2rem;
    line-height: 1;
}

.kpi-sub {
    font-size: 0.75rem;
    color: rgba(0, 243, 255, 0.6);
}

/* Matrix 3x4 Grid */
.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.grid-column-title {
    font-size: 0.9rem;
    color: rgba(0, 243, 255, 0.7);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25rem;
}

.chart-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.5rem;
    height: 120px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chart-box:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.2);
}

.loss-bar-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.loss-progress {
    display: flex;
    height: 20px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-top: 0.5rem;
}

.loss-pass {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
}

.loss-fail {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

/* Modal Styling */
/* Modal Styling */
.vfd-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(4px); /* Aumenta el contraste VFD */
    z-index: 99;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    overflow-y: auto;
}

.vfd-modal {
    width: 80%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    background: #08101a;
    border: 2px solid var(--cyan);
    box-shadow: 0 0 35px rgba(0, 243, 255, 0.3), inset 0 0 15px rgba(0, 243, 255, 0.05);
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
}

/* Personalización de la barra de desplazamiento retro VFD */
.vfd-modal::-webkit-scrollbar {
    width: 8px;
}

.vfd-modal::-webkit-scrollbar-track {
    background: #050a10;
    border-left: 1px solid var(--border);
}

.vfd-modal::-webkit-scrollbar-thumb {
    background: var(--cyan);
    border-radius: 2px;
    box-shadow: 0 0 8px var(--cyan);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    position: sticky;
    top: -1.5rem;
    background: #08101a;
    padding-top: 0.5rem;
    z-index: 20;
}

.close-btn {
    color: var(--magenta);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.close-btn:hover {
    text-shadow: 0 0 10px var(--magenta);
}

#modal-chart {
    width: 100%;
    height: 280px;
    margin-bottom: 1rem;
    position: relative;
}

/* Capa de scanlines VFD sobre el gráfico del modal */
#modal-chart::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.4) 50%);
    background-size: 100% 4px;
    pointer-events: none; /* Permite interactuar con los tooltips de ECharts */
    z-index: 2;
}

.modal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    font-family: 'Share Tech Mono', monospace;
}

.modal-table th,
.modal-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 0.6rem;
    text-align: center;
}

.modal-table th:first-child,
.modal-table td:first-child {
    border-left: 1px solid var(--border);
}

/* Fijado de encabezados de tabla SIN empalmes */
.modal-table th {
    background: #0d1926; /* Fondo SÓLIDO para tapar el texto al scrollear */
    color: var(--cyan);
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    letter-spacing: 1px;
    text-shadow: 0 0 5px var(--cyan);
    position: sticky;
    top: 2.2rem; /* Se posiciona justo debajo del header sticky */
    z-index: 10;
    border-top: 1px solid var(--cyan);
    border-bottom: 2px solid var(--cyan);
}

.cyan-glow {
    color: var(--cyan);
    text-shadow: 0 0 10px var(--cyan);
}

.magenta-glow {
    color: var(--magenta);
    text-shadow: 0 0 10px var(--magenta);
}

.amber-glow {
    color: var(--amber);
    text-shadow: 0 0 10px var(--amber);
}

.red-glow {
    color: var(--red);
    text-shadow: 0 0 10px var(--red);
}

/* Celdas de tabla: texto nítido con lectura clara */
.modal-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 0.6rem;
    text-align: center;
    font-size: 0.9rem;
    text-shadow: none; /* Eliminamos el brillo difuso de fondo */
}

/* Glow sutil para los valores dentro de la tabla */
.table-val-glow {
    text-shadow: 0 0 1px currentColor; /* Un brillo mínimo que no distorsiona el texto */
}