:root {
    --brand-green: #00923f;
    --brand-gold: #c59b27;
    --bg-dark: #0a0f1e;
    --card-bg: #161b2d;
    --text-main: #f8fafc;
    --text-dim: #64748b;
    --safe: #10b981;
    --warn: #f59e0b;
    --crit: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    display: flex;
}

/* --- ESTRUCTURA PRINCIPAL --- */
.dashboard-wrapper {
    display: flex;
    flex-direction: column; /* Apila el contenido principal arriba y el cronograma abajo */
    height: 100vh;
    width: 100%;
}

main {
    flex-grow: 1; /* Obliga al main a tomar todo el espacio vertical disponible */
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

/* --- CRONOGRAMA HORIZONTAL (PIE DE PÁGINA) --- */
.time-footer {
    background: #0f172a;
    border-top: 2px solid #1e293b;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 15px 30px;
    gap: 15px;
    flex-shrink: 0; /* Evita que el pie de página se aplaste */
    box-shadow: 0 -10px 20px rgba(0,0,0,0.2);
}

.filter-group {
    display: flex;
    gap: 10px;
    width: 250px; /* Ancho fijo para los filtros */
}

.slider-container {
    flex-grow: 1; /* El slider toma todo el espacio central sobrante */
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 20px;
}

.horizontal-slider {
    width: 100%;
    cursor: pointer;
    accent-color: var(--brand-green);
}

.total-badge {
    color: var(--text-dim); 
    font-size: 10px; 
    font-weight: bold; 
    text-align: center;
    min-width: 80px;
}

.sidebar-title {
    color: var(--brand-gold);
    font-weight: 900;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.vertical-slider {
    appearance: slider-vertical;
    width: 30px;
    height: 50%;
    cursor: pointer;
    accent-color: var(--brand-green);
}

.filter-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 10px 5px;
    border-top: 1px solid #2d3748;
}

.filter-container label {
    font-size: 9px;
    font-weight: bold;
    color: var(--text-dim);
    text-transform: uppercase;
    text-align: center;
}

.select-box {
    width: 100%;
    background: #161b2d;
    color: white;
    border: 1px solid var(--brand-green);
    padding: 6px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    text-align: center;
}

main {
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--brand-green);
    flex-shrink: 0;
}

.logo-area { display: flex; align-items: center; gap: 15px; }
.logo-area h1 { font-size: 22px; color: var(--brand-green); font-weight: 900; margin: 0; letter-spacing: 1px; }

.current-date-badge {
    background: var(--brand-gold);
    color: var(--bg-dark);
    padding: 8px 25px;
    border-radius: 6px;
    font-weight: 900;
    font-size: 15px;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(197, 155, 39, 0.3);
}

.tab-container {
    display: flex;
    gap: 15px;
    width: 100%;
}

.silo-tab {
    flex: 1;
    padding: 15px;
    background: var(--card-bg);
    color: var(--text-dim);
    border: 2px solid #1e293b;
    border-radius: 8px;
    font-weight: 900;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.silo-tab:hover {
    border-color: var(--brand-green);
    color: var(--text-main);
}

.silo-tab.active {
    background: var(--brand-green);
    color: white;
    border-color: var(--brand-green);
    box-shadow: 0 8px 20px rgba(0,146,63,0.4);
}

.active-silo-panel {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 25px;
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border-top: 6px solid var(--brand-green);
    flex-grow: 1;
}

.panel-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid rgba(255,255,255,0.05);
    padding-right: 20px;
}

.info-block h3 { color: var(--text-dim); font-size: 11px; text-transform: uppercase; margin-bottom: 5px; }
.info-block .main-val { color: var(--text-main); font-size: 28px; font-weight: 900; font-family: 'Consolas', monospace; }
.info-block .sub-val { color: var(--brand-gold); font-size: 14px; font-weight: bold; }

.status-badge {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 6px;
    font-weight: 900;
    font-size: 16px;
    text-align: center;
    width: 100%;
    margin-top: 10px;
}

.panel-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.kpi-card {
    background: #0f172a;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tooltip-icon {
    color: var(--brand-gold);
    cursor: help;
    position: relative;
    margin-left: 5px;
    font-size: 12px;
}

.tooltip-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Segoe UI', sans-serif;
    text-transform: none;
    white-space: normal;
    width: 220px;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border: 1px solid #334155;
    pointer-events: none;
}

.chart-container {
    width: 100%;
    height: 220px; 
    background: #0f172a;
    border-radius: 8px;
    padding: 10px;
    position: relative;
}

.heatmap-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.grid-title-meta {
    font-size: 12px;
    color: var(--brand-green);
    font-weight: 900;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- REDISEÑO EN EL DASHBOARD: SILO REALISTA A GRAN ESCALA --- */
.silo-grid {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 0 !important; /* Cero separación para fundir los mapas de calor continuos */
    
    /* Fondo industrial de acero corrugado ajustado a escala mayor */
    background: repeating-linear-gradient(180deg, #cbd5e1, #cbd5e1 6px, #94a3b8 7px, #94a3b8 8px);
    
    padding: 45px 0 0 0; /* Relleno superior para dar espacio a la curvatura del domo */
    border: 6px solid #475569;
    border-bottom: 18px solid #334155; /* Base sólida de cimentación negra */
    border-radius: 120px 120px 10px 10px; /* Techo curvo realista proporcional al ancho */
    
    width: 100%;
    max-width: 920px; /* Aprovechamos al máximo el ancho del panel derecho */
    box-shadow: inset 0 0 30px rgba(0,0,0,0.4), 0 15px 35px rgba(0,0,0,0.3);
    overflow: hidden; /* Corta los "píxeles" térmicos para que respeten las curvas del tanque */
    position: relative;
}

.cell-unit {
    width: 100%;
    aspect-ratio: 1/1;
    background: transparent; /* Si no hay datos, se ve la lámina corrugada de fondo (Silo Vacío) */
    cursor: crosshair;
    transition: all 0.3s ease;
    
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px; /* Tamaño ideal para lectura clara en pantallas de monitoreo */
    font-weight: bold;
    /* Sombra de texto reforzada para ser legible sobre verde, naranja o rojo */
    text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 2px rgba(0,0,0,1);
    position: relative;
}

/* Efecto lupa al inspeccionar con el mouse manteniendo el orden de capas */
.cell-unit:hover {
    transform: scale(1.3);
    box-shadow: 0 0 12px rgba(255,255,255,0.8) !important;
    z-index: 10 !important;
}

/* --- MOTOR DE DIFUMINACIÓN TÉRMICA EN DASHBOARD --- */
.cell-unit.seg-safe { 
    background-color: rgba(16, 185, 129, 0.85) !important; 
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.9); 
    z-index: 1; 
}
.cell-unit.seg-warn { 
    background-color: rgba(245, 158, 11, 0.85) !important; 
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.9); 
    z-index: 2; /* Alerta sobresale por encima de lo normal */
}
.cell-unit.seg-crit { 
    background-color: rgba(239, 68, 68, 0.85) !important; 
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.9); 
    z-index: 3; /* Puntos críticos siempre al frente */
}

.loading-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, #161b2d 0%, #0a0f1e 100%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#error-log-display { color: #ef4444; font-weight: bold; margin-top: 15px; font-size: 14px; text-transform: uppercase; }

.btn-start {
    background: var(--brand-green);
    color: white;
    padding: 15px 40px;
    border-radius: 6px;
    font-weight: 900;
    cursor: pointer;
    font-size: 18px;
    border: none;
    box-shadow: 0 10px 20px rgba(0, 146, 63, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* --- GUIAS DE EJES (CABLES Y NIVELES) --- */
.radiograph-layout {
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 950px;
    gap: 8px; /* Separación entre los Ns y la pared del silo */
}

.y-axis-labels {
    display: flex;
    flex-direction: column;
    /* Padding top de 51px compensa exacto el domo (45px) + el borde (6px) */
    padding-top: 51px; 
    /* Padding bottom compensa la cimentación negra del tanque */
    padding-bottom: 18px; 
}

.y-label {
    flex: 1; /* Se estira como liga para igualar la altura de las filas del silo */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 11px;
    font-weight: 900;
    color: #64748b;
}

.silo-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Separación entre la base del silo y los Cs */
}

.x-axis-labels {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    /* Margen lateral de 6px compensa el grosor de las paredes del tanque */
    margin: 0 6px; 
}

.x-label {
    text-align: center;
    font-size: 10px;
    font-weight: 900;
    color: #64748b;
}

/* --- COMPONENTE DE EXPORTACIÓN EXCEL EN CABECERA --- */
.report-export-container {
    display: flex;
    align-items: center;
    background: #1e293b; /* Color un poco más claro que el fondo para que resalte */
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #334155;
    gap: 15px;
    margin-left: auto; /* Empuja el módulo hacia la derecha */
    margin-right: 20px; /* Separación con el badge de fecha */
}

.export-input-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.export-input-group label {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
}

.export-input-group input[type="date"] {
    background: #0f172a;
    border: 1px solid #475569;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.export-input-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1); /* Hace que el icono del calendario sea blanco */
    cursor: pointer;
}

.btn-export-excel {
    background: #10b981; /* Verde Excel / Seguro */
    color: white;
    border: none;
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}

.btn-export-excel:hover {
    background: #059669;
    transform: translateY(-1px);
}
.btn-export-excel:active {
    transform: translateY(0);
}