:root {
    /* --- TEMA DARK (Por defecto) --- */
    --bg-main: radial-gradient(circle at top center, #1e2030 0%, #0c0e14 80%);
    --text-main: #d3d7e6;
    --text-title: #ffffff;
    --text-muted: #9fa4bc;
    --text-subtitle: rgba(255, 255, 255, 0.5);

    /* Tarjetas */
    --card-bg: rgba(26, 29, 44, 0.85);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: rgba(0, 0, 0, 0.45);

    /* Colores del V2L */
    --v2l-cyan: #00e5ff;
    --v2l-cyan-glow: rgba(0, 229, 255, 0.45);
    --v2l-cyan-bg: rgba(0, 229, 255, 0.12);

    --v2l-amber: #ffb300;
    --v2l-amber-glow: rgba(255, 179, 0, 0.45);
    --v2l-amber-bg: rgba(255, 179, 0, 0.12);

    --v2l-red: #ff3366;
    --v2l-red-glow: rgba(255, 51, 102, 0.45);
    --v2l-red-bg: rgba(255, 51, 102, 0.12);

    --v2l-green: #00e676;
    --v2l-green-glow: rgba(0, 230, 118, 0.45);
    --v2l-green-bg: rgba(0, 230, 118, 0.12);

    --separator-color: rgba(255, 255, 255, 0.15);
    --shadow-color: rgba(0, 0, 0, 0.5);
}

[data-theme='light'] {
    /* --- TEMA LIGHT --- */
    --bg-main: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
    --text-main: #333a4d;
    --text-title: #1a1e29;
    --text-muted: #656d82;
    --text-subtitle: #7c859b;

    /* Tarjetas */
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.12);
    --card-shadow: rgba(0, 0, 0, 0.12);

    /* Colores adaptados a claridad */
    --v2l-cyan: #0097a7;
    --v2l-cyan-glow: rgba(0, 151, 167, 0.25);
    --v2l-cyan-bg: rgba(0, 151, 167, 0.08);

    --v2l-amber: #e65100;
    --v2l-amber-glow: rgba(230, 81, 0, 0.25);
    --v2l-amber-bg: rgba(230, 81, 0, 0.08);

    --v2l-red: #d50000;
    --v2l-red-glow: rgba(213, 0, 0, 0.25);
    --v2l-red-bg: rgba(213, 0, 0, 0.08);

    --v2l-green: #2e7d32;
    --v2l-green-glow: rgba(46, 125, 50, 0.25);
    --v2l-green-bg: rgba(46, 125, 50, 0.08);

    --separator-color: rgba(0, 0, 0, 0.12);
    --shadow-color: rgba(0, 0, 0, 0.12);
}

/* ========== GENERAL ========== */
body {
    background: var(--bg-main) !important;
    color: var(--text-main);
    font-family: 'Outfit', 'Inter', sans-serif;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== THEME TOGGLE (Alineación requerida) ========== */
.theme-toggle {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 45px;
    height: 45px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle i {
    font-size: 1.25rem;
    color: var(--v2l-amber);
}

/* ========== TEXTOS Y LEGIBILIDAD ========== */
.text-white-custom {
    color: var(--text-title) !important;
}

.text-light-custom {
    color: var(--text-main) !important;
}

.text-white-50-custom {
    color: var(--text-subtitle) !important;
}

/* Blindaje de pequeños y mutados */
.text-muted, .small-muted, .small, .form-text {
    color: var(--text-muted) !important;
}

.main-title {
    color: var(--v2l-cyan);
    text-shadow: 0 0 20px var(--v2l-cyan-glow);
    font-weight: 800;
    letter-spacing: -0.5px;
}

.main-subtitle {
    color: var(--text-subtitle);
}

/* ========== TARJETAS ========== */
.card-clean {
    border: 1px solid var(--card-border);
    border-radius: 1.25rem;
    box-shadow: 0 8px 24px var(--card-shadow);
    background-color: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: 100%;
    color: var(--text-main);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* ========== PESTAÑAS (NAVS) ========== */
.nav-tabs-custom {
    border-bottom: 2px solid var(--separator-color);
    margin-bottom: 2rem;
}

.nav-tabs-custom .nav-link {
    color: var(--text-subtitle);
    border: none;
    background: transparent;
    padding: 0.9rem 1.8rem;
    font-weight: 700;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.nav-tabs-custom .nav-link:hover {
    color: var(--text-title);
    border-bottom: 3px solid var(--separator-color);
}

.nav-tabs-custom .nav-link.active {
    color: var(--v2l-cyan);
    background: transparent;
    border: none;
    border-bottom: 3px solid var(--v2l-cyan);
    text-shadow: 0 0 12px var(--v2l-cyan-glow);
}

/* ========== SLIDERS ELEGANTES ========== */
.range-slider-container {
    position: relative;
    padding-bottom: 12px;
}

.custom-range {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--separator-color);
    outline: none;
}

.custom-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--v2l-cyan);
    cursor: pointer;
    box-shadow: 0 0 12px var(--v2l-cyan-glow);
    transition: transform 0.1s ease;
}

.custom-range::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.custom-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--v2l-cyan);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 12px var(--v2l-cyan-glow);
    transition: transform 0.1s ease;
}

.custom-range::-moz-range-thumb:hover {
    transform: scale(1.25);
}

.slider-value-badge {
    background: var(--v2l-cyan-bg);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: var(--v2l-cyan);
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
}

/* ========== GRID DE SELECCIÓN DE ELECTRODOMÉSTICOS ========== */
.appliance-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.appliance-card {
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.18);
    border-radius: 14px;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.appliance-card:hover {
    border-color: var(--v2l-cyan);
    background: rgba(0, 229, 255, 0.05);
}

.appliance-card.active {
    border-color: var(--v2l-cyan);
    background: var(--v2l-cyan-bg);
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.2);
}

.appliance-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.appliance-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: all 0.25s ease;
}

.appliance-card.active .appliance-icon-wrapper {
    background: var(--v2l-cyan);
    color: #1a1d29;
    box-shadow: 0 0 10px var(--v2l-cyan-glow);
}

.appliance-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-main);
    display: block;
}

.appliance-power {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Selector numérico de cantidad */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--card-border);
}

.quantity-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.06);
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quantity-btn:hover {
    background: var(--v2l-cyan);
    color: #161824;
}

.quantity-val {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 14px;
    text-align: center;
}

/* ========== DISPLAYS ========== */
.display-result-wrapper {
    text-align: center;
    padding: 1.3rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 14px;
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
    height: 100%;
}

.display-result {
    font-size: 2.3rem;
    font-weight: 800;
    margin-bottom: 2px;
    line-height: 1.2;
}

.display-label {
    font-size: 0.8rem;
    color: var(--text-subtitle);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* ========== BARRA LED DE CONSUMO TOTAL ========== */
.led-bar-container {
    background: rgba(0,0,0,0.22);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--card-border);
    margin-bottom: 1rem;
}

.led-bar-label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 700;
}

.led-bar-track {
    height: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.led-bar-fill {
    height: 100%;
    width: 0%; /* Dinámico */
    background: linear-gradient(to right, var(--v2l-green), var(--v2l-amber), var(--v2l-red));
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
}

.led-bar-limits {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 600;
}

/* ========== DIAGNÓSTICOS BMS V2L ========== */
.diagnostic-alert {
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 0;
    border-left: 5px solid transparent;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.4s ease-out;
}

.diagnostic-alert i {
    font-size: 1.7rem;
    margin-right: 15px;
    margin-top: 3px;
}

.diagnostic-alert h5 {
    font-weight: 800;
    margin-bottom: 6px;
    font-size: 1.1rem;
}

.diagnostic-alert p {
    margin-bottom: 0;
    font-size: 0.92rem;
    line-height: 1.55;
}

/* Clases de estado V2L */
.status-ok {
    background: var(--v2l-green-bg);
    border: 1px solid rgba(0, 230, 118, 0.22);
    border-left: 5px solid var(--v2l-green);
    color: var(--text-main);
}
.status-ok i, .status-ok h5 { color: var(--v2l-green); }

.status-warning {
    background: var(--v2l-amber-bg);
    border: 1px solid rgba(255, 179, 0, 0.22);
    border-left: 5px solid var(--v2l-amber);
    color: var(--text-main);
}
.status-warning i, .status-warning h5 { color: var(--v2l-amber); }

.status-danger {
    background: var(--v2l-red-bg);
    border: 1px solid rgba(255, 51, 102, 0.22);
    border-left: 5px solid var(--v2l-red);
    color: var(--text-main);
}
.status-danger i, .status-danger h5 { color: var(--v2l-red); }

/* ========== SECCIÓN DE FUNDAMENTOS ========== */
.theory-intro-card {
    border-bottom: 3px solid var(--v2l-cyan);
    margin-bottom: 2rem;
}

.theory-block {
    padding: 1.5rem;
    border-radius: 14px;
    height: 100%;
    border: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease;
}

.theory-block:hover {
    transform: translateY(-4px);
}

.theory-block i {
    font-size: 2rem;
    margin-bottom: 12px;
}

.theory-block h5 {
    font-weight: 800;
    margin-bottom: 10px;
    font-size: 1.15rem;
}

.theory-block p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0;
}

.block-cyan i, .block-cyan h5 { color: var(--v2l-cyan); }
.block-green i, .block-green h5 { color: var(--v2l-green); }
.block-amber i, .block-amber h5 { color: var(--v2l-amber); }
.block-purple i, .block-purple h5 { color: #b794f6; }

/* ========== ANIMACIONES ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 991px) {
    .theme-toggle {
        top: auto;
        bottom: 20px;
        right: 20px;
    }
    .appliance-grid {
        grid-template-columns: 1fr;
    }
    .display-result {
        font-size: 2rem;
    }
}
