:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --danger: #ef4444;
    --success: #22c55e;
    --warn: #f59e0b;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    --mode-on: #ef4444;       /* Rosso */
    --mode-home: #fbbf24;    /* Giallo */
    --mode-area: #38bdf8;     /* Azzurro */
    --mode-perim: #818cf8;     /* Indaco */
    --mode-off: #22c55e;      /* Verde */
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* =========================================
   Typography & Utils
   ========================================= */
a { text-decoration: none; color: inherit; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mr-1 { margin-right: 0.5rem; }
.d-flex { display: flex; }
.row { display: flex; flex-direction: row; }
.h-align-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.ml-auto { margin-left: auto; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 1rem; }
.gap-05 { gap: 0.5rem; }


/* =========================================
   Buttons & Inputs
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    gap: 0.5rem;
}
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.btn-primary { background: var(--accent); color: #0f172a; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 0 15px rgba(56, 189, 248, 0.3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: rgba(255,255,255,0.05); border-color: var(--text-secondary); }

.btn-cmd { color: #fff; font-weight: 700; padding: 1.2rem; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 10px; }
.btn-on { background: linear-gradient(135deg, #ef4444, #991b1b); }
.btn-home { background: linear-gradient(135deg, #fbbf24, #92400e); color: #000; }
.btn-area { background: linear-gradient(135deg, #38bdf8, #075985); }
.btn-perim { background: linear-gradient(135deg, #818cf8, #3730a3); }
.btn-off { background: linear-gradient(135deg, #22c55e, #166534); }

/* Blocco comandi quando la centrale è offline: si applica atomicamente a TUTTI i .cmd-btn */
body.central-offline .cmd-btn {
    opacity: 0.4 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
    filter: grayscale(60%) !important;
}


.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: var(--text-secondary); }
input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    background: #0f172a;
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input.input-sm { width: auto; display: inline-block; padding: 0.5rem 0.8rem; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2); }

/* =========================================
   Cards & Layouts
   ========================================= */
.container { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid > * { min-width: 0; } /* Prevent grid items from overflowing */
.layout-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1200px) { .layout-1-2 { grid-template-columns: 1fr; } }
.layout-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1.5px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.card-header {
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border);
}
.card-body { padding: 1rem; }

/* =========================================
   Login & Admin Auth
   ========================================= */
.login-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 400px; padding: 1rem; }
.login-card { background: var(--bg-card); padding: 2rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.login-header { text-align: center; margin-bottom: 2rem; }
.alert { padding: 1rem; border-radius: 4px; margin-bottom: 1rem; }
.alert.error { background: rgba(255,0,110,0.1); border: 1px solid var(--danger); color: var(--danger); }

.navbar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; background: var(--bg-card); border-bottom: 1.5px solid var(--border); }
.nav-brand { font-weight: 700; font-size: 1.25rem; letter-spacing: -0.5px; }
.user-pill { padding: 0.3rem 1rem; background: rgba(56, 189, 248, 0.1); color: var(--accent); border-radius: 20px; margin-right: 1rem; font-size: 0.9rem; font-weight: 600; }

@media (max-width: 600px) {
    .navbar { padding: 0.8rem 1rem; }
    .nav-brand { font-size: 1rem; }
    .user-pill { padding: 0.2rem 0.6rem; margin-right: 0.5rem; font-size: 0.8rem; }
}

.data-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; table-layout: auto; word-wrap: break-word; }
.data-table th, .data-table td { padding: 0.4rem 0.3rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: rgba(0, 0, 0, 0.15); color: var(--text-secondary); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; white-space: normal; word-break: break-word; }
.data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.data-table td { font-size: 0.85rem; vertical-align: middle; }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card-hover) transparent;
}
.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--bg-card-hover); border-radius: 10px; }

/* =========================================
   Dashboard App Layout
   ========================================= */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 250px; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { color: var(--accent); margin-bottom: 0.3rem; }
.badge { font-size: 0.75rem; background: rgba(255,255,255,0.1); padding: 0.2rem 0.5rem; border-radius: 4px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.nav-item { display: block; padding: 0.8rem 1.5rem; color: var(--text-secondary); transition: all 0.2s; border-left: 3px solid transparent; margin-bottom: 0.2rem; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.05); color: var(--text-primary); border-left-color: var(--accent); }
.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-dark); transition: margin-left 0.3s; }
.top-bar { padding: 1rem 1.5rem; background: var(--bg-card); border-bottom: 1.5px solid var(--border); display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.content-area { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1.5rem; }

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    margin-right: 1rem;
    line-height: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        bottom: 0;
        z-index: 1001;
        transition: left 0.3s ease;
        box-shadow: 10px 0 20px rgba(0,0,0,0.5);
    }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-overlay.active { display: block; }
    .content-area { padding: 1rem; }
}

.tab-pane { display: none; animation: fadeIn 0.3s ease; }
.tab-pane.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   Item Cards (Settori, Zone, Domotica)
   ========================================= */
.item-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.2rem;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.item-card:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); border-color: rgba(255,255,255,0.2); }
.border-danger { border-color: var(--danger) !important; box-shadow: 0 0 10px rgba(239, 68, 68, 0.4) !important; }

.item-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.item-title { font-size: 1.1rem; font-weight: 600; }
.item-num { font-size: 0.8rem; color: var(--text-secondary); }

.status-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: none;
}

/* Modi per i settori */
.st-s-on { background: rgba(239, 68, 68, 0.15); color: var(--mode-on); border: 1.5px solid rgba(239, 68, 68, 0.25); }
.st-s-home { background: rgba(251, 191, 36, 0.15); color: var(--mode-home); border: 1.5px solid rgba(251, 191, 36, 0.25); }
.st-s-area { background: rgba(56, 189, 248, 0.15); color: var(--mode-area); border: 1.5px solid rgba(56, 189, 248, 0.25); }
.st-s-perim { background: rgba(129, 140, 248, 0.15); color: var(--mode-perim); border: 1.5px solid rgba(129, 140, 248, 0.25); }
.st-s-off { background: rgba(34, 197, 94, 0.1); color: var(--mode-off); border: 1.5px solid rgba(34, 197, 94, 0.2); }

/* Modi per zone/uscite */
.st-z-ok { color: var(--success); }
.st-z-alarm { color: var(--danger); font-weight: bold; animation: pulse 1s infinite alternate; }
.st-z-escl { color: var(--warn); }
.st-o-on { background: rgba(239, 68, 68, 0.15); color: var(--mode-on); border: 1.5px solid rgba(239, 68, 68, 0.25); }
.st-o-off { background: rgba(34, 197, 94, 0.1); color: var(--mode-off); border: 1.5px solid rgba(34, 197, 94, 0.2); }

@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

.item-footer { margin-top: auto; padding-top: 1rem; border-top: 1px dashed var(--border); }

/* =========================================
   Modal
   ========================================= */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.7); backdrop-filter: blur(3px); }
.modal-content { 
    background-color: var(--bg-card); 
    margin: 5vh auto; 
    padding: 0; 
    border: 1px solid var(--border); 
    border-radius: 12px; 
    width: 90%; 
    max-width: 500px; 
    max-height: 90vh; /* Prevents overflow of viewport */
    display: flex; 
    flex-direction: column;
    animation: scaleIn 0.3s ease; 
    overflow: hidden; 
}
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header { padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.close { color: var(--text-secondary); font-size: 28px; font-weight: bold; cursor: pointer; }
.close:hover { color: #fff; }
.modal-body { padding: 1.5rem; overflow-y: auto; flex-grow: 1; }
.command-grid { display: grid; gap: 0.8rem; grid-template-columns: 1fr; }

.loader { text-align: center; padding: 2rem; color: var(--text-secondary); font-style: italic; display: flex; align-items: center; justify-content: center; }
.log-viewer { 
    background: var(--bg-dark); 
    padding: 0; 
    border-radius: 8px; 
    font-family: inherit; 
    max-height: 600px; 
    overflow-y: auto; 
    color: var(--text-primary); 
    border: 1px solid var(--border);
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
    margin-right: 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}
.status-online { background-color: var(--success); box-shadow: 0 0 5px var(--success); }
.status-offline { background-color: #666; }

.badge-info { background: rgba(58,134,255,0.2); color: var(--accent); border: 1px solid rgba(58,134,255,0.3); }
.badge-success { background: rgba(56,176,0,0.2); color: var(--success); border: 1px solid rgba(56,176,0,0.3); }

.row-disabled { opacity: 0.6; filter: grayscale(100%); }

.col-riga { width: 80px; text-align: center !important; }
.col-date { width: 110px; }
.col-time { width: 90px; }
.col-event { width: auto; }

/* Custom styles for Thermostats and Energy */
.thermostat-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.thermostat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.thermostat-header {
    width: 100%;
    text-align: center;
}

.thermostat-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f8fafc;
    margin-bottom: 5px;
}

.thermostat-status {
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 500;
}

.status-off {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.status-inverno {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.status-estate {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.thermostat-temp-display {
    font-size: 2.2rem;
    font-weight: 700;
    color: #f8fafc;
}

.thermostat-setpoint-label {
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Vertical Slider Container */
.slider-container {
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
}

/* Vertical range slider styling */
.vertical-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 130px;
    outline: none;
    border-radius: 4px;
    writing-mode: vertical-lr; /* WebKit/Standard moderno per slider verticale */
}

/* Rende trasparente il track per mostrare il gradiente lineare inline */
.vertical-slider::-webkit-slider-runnable-track {
    background: transparent !important;
    border: none !important;
}
.vertical-slider::-moz-range-track {
    background: transparent !important;
    border: none !important;
}

/* Custom thumb styling per slider verticale */
.vertical-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 18px !important;
    height: 18px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: none !important;
    transition: background-color 0.2s ease;
}

.vertical-slider::-moz-range-thumb {
    width: 18px !important;
    height: 18px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: none !important;
    transition: background-color 0.2s ease;
}

/* Specifici colori del thumb basati sulla stagione e sullo stato */
.vertical-slider.inverno::-webkit-slider-thumb {
    background: #f59e0b !important;
}
.vertical-slider.estate::-webkit-slider-thumb {
    background: #3b82f6 !important;
}
.vertical-slider.off::-webkit-slider-thumb {
    background: #64748b !important;
}

.vertical-slider.inverno::-moz-range-thumb {
    background: #f59e0b !important;
}
.vertical-slider.estate::-moz-range-thumb {
    background: #3b82f6 !important;
}
.vertical-slider.off::-moz-range-thumb {
    background: #64748b !important;
}

/* Power dashboard and cards */
.energy-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.energy-name {
    font-weight: 500;
    color: #f8fafc;
}

.energy-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #f59e0b;
}

#energy-grid .item-card, .item-card.mdc-card {
    min-height: 160px;
    justify-content: space-between;
    position: relative;
}

.energy-mod-power, .domo-mod-power {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
    margin: auto 0;
}

/* Il banner potenza totale è nascosto di default: il JS lo mostra SOLO con 2+ controlli carichi */
#total-power-card {
    display: none !important;
}
/* Classe aggiunta via JS per mostrarlo quando ci sono 2+ load controls */
#total-power-card.visible {
    display: block !important;
}

/* ============================================================================
   Thermostat Advanced Styling
   ============================================================================ */
.vertical-slider.inverno::-webkit-slider-thumb {
    background: #f59e0b !important;
}
.vertical-slider.estate::-webkit-slider-thumb {
    background: #3b82f6 !important;
}
.vertical-slider.inverno::-moz-range-thumb {
    background: #f59e0b !important;
}
.vertical-slider.estate::-moz-range-thumb {
    background: #3b82f6 !important;
}

.thermostat-setpoint-label {
    font-size: 1.05rem !important; /* Ingrandito */
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px; /* Spazio per l'icona */
    margin: 4px 0;
}

.thermostat-icon {
    width: 2.2rem !important; /* Raddoppiata la grandezza */
    height: 2.2rem !important;
    stroke-width: 2.2 !important; /* Spessore proporzionato */
    display: inline-block;
    vertical-align: middle;
}

.thermostat-mode-text {
    font-size: 0.82rem;
    font-weight: 500;
    color: #94a3b8 !important; /* Mantiene la colorazione dell'automatica */
    text-align: center;
    margin-top: 4px;
}

.thermostat-time-highlight {
    font-weight: 700;
}
.inverno .thermostat-time-highlight {
    color: #f59e0b; /* Arancione per inverno */
}
.estate .thermostat-time-highlight {
    color: #3b82f6; /* Celeste/blu per estate */
}

.thermostat-manual-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.btn-restore {
    background: transparent;
    border: 1.5px solid currentColor;
    font-size: 0.76rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-restore:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.05);
}

.horizontal-slider-container {
    width: 100%;
    max-width: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 5px;
}

.horizontal-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: #475569;
    border-radius: 3px;
    outline: none;
}

.horizontal-slider-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 5px;
    font-size: 0.64rem;
    color: #64748b;
    padding: 0 2px;
}

/* Colori in base a inverno (arancione) / estate (celeste-blu) */
.inverno .btn-restore {
    color: #f59e0b;
}
.inverno .horizontal-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f59e0b;
}
.inverno .horizontal-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: #f59e0b;
}

.estate .btn-restore {
    color: #3b82f6;
}
.estate .horizontal-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
}
.estate .horizontal-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: #3b82f6;
}

/* ============================================================================
   Global Thermostat Control Icons (SVGs)
   ============================================================================ */
.global-control-icon {
    cursor: pointer !important;
    pointer-events: auto !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    vertical-align: middle;
    user-select: none;
}
.global-control-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}
.global-control-icon:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.08);
}
.btn-off-all {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.25);
}
.btn-off-all:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}
.btn-auto-all {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.25);
}
.btn-auto-all:hover {
    background: rgba(34, 197, 94, 0.12) !important;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.25);
}
.btn-season-winter {
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.25);
}
.btn-season-winter:hover {
    background: rgba(245, 158, 11, 0.12) !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
}
.btn-season-summer {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.25);
}
.btn-season-summer:hover {
    background: rgba(59, 130, 246, 0.12) !important;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.25);
}

/* ============================================================================
   New UI Enhancements (Thermostats & Energy)
   ============================================================================ */
.thermostat-card {
    position: relative; /* Ensure card actions are relative to this */
}

.thermostat-card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.thermostat-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
}

.thermostat-card-action:hover {
    color: var(--accent);
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.3);
    transform: scale(1.1);
}

/* Weekly Program Styles */
.program-slider-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.temp-slider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.temp-slider-label {
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 140px;
}

.temp-slider-label.eco { color: #38bdf8; }
.temp-slider-label.normal { color: #10b981; }
.temp-slider-label.comfort { color: #f97316; }

.temp-slider-control {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.temp-slider-control input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    outline: none;
    background: #475569;
}

.temp-slider-control input[type="range"].eco::-webkit-slider-thumb { background: #38bdf8; }
.temp-slider-control input[type="range"].normal::-webkit-slider-thumb { background: #10b981; }
.temp-slider-control input[type="range"].comfort::-webkit-slider-thumb { background: #f97316; }

.temp-slider-val {
    font-family: monospace;
    font-size: 0.95rem;
    font-weight: bold;
    min-width: 45px;
    text-align: right;
}

/* Schedule Paint Brush Selector */
.schedule-brush-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
}

.brush-chip {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
    user-select: none;
}

.brush-chip.eco { background: rgba(56, 189, 248, 0.1); color: #38bdf8; border-color: rgba(56, 189, 248, 0.2); }
.brush-chip.normal { background: rgba(16, 185, 129, 0.1); color: #10b981; border-color: rgba(16, 185, 129, 0.2); }
.brush-chip.comfort { background: rgba(249, 115, 22, 0.1); color: #f97316; border-color: rgba(249, 115, 22, 0.2); }
.brush-chip.off { background: rgba(100, 116, 139, 0.1); color: #94a3b8; border-color: rgba(100, 116, 139, 0.2); }

.brush-chip.eco.active { background: #38bdf8; color: #0f172a; border-color: #38bdf8; box-shadow: 0 0 10px rgba(56, 189, 248, 0.4); }
.brush-chip.normal.active { background: #10b981; color: #0f172a; border-color: #10b981; box-shadow: 0 0 10px rgba(16, 185, 129, 0.4); }
.brush-chip.comfort.active { background: #f97316; color: #0f172a; border-color: #f97316; box-shadow: 0 0 10px rgba(249, 115, 22, 0.4); }
.brush-chip.off.active { background: #64748b; color: #0f172a; border-color: #64748b; box-shadow: 0 0 10px rgba(100, 116, 139, 0.4); }

/* Weekly Grid Bars */
.weekly-schedule-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.schedule-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.schedule-day-label {
    width: 75px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.schedule-bar-grid {
    flex: 1;
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    background: #475569;
    border: 1px solid rgba(255,255,255,0.05);
}

.hour-block {
    flex: 1;
    height: 22px;
    border-right: 1px solid rgba(0, 0, 0, 0.15);
    cursor: crosshair;
    transition: background-color 0.1s ease;
}

.hour-block:last-child {
    border-right: none;
}

.hour-block.level-0 { background-color: #38bdf8; } /* Eco */
.hour-block.level-1 { background-color: #10b981; } /* Normal */
.hour-block.level-2 { background-color: #f97316; } /* Comfort */
.hour-block.level-3 { background-color: #475569; } /* OFF */

/* Graph Styles */
.chart-dot {
    transition: r 0.15s ease, stroke-width 0.15s ease;
    cursor: pointer;
}
.chart-dot:hover {
    r: 6;
    stroke-width: 2.5;
}

/* Info Modal Date Header */
.info-date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    background: rgba(255,255,255,0.02);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.info-date-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.info-date-btn:hover {
    background: var(--accent);
    color: #0f172a;
    border-color: var(--accent);
}

.info-date-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

/* Consumption Panel */
.lc-consumption-panel {
    background: rgba(30, 41, 59, 0.4) !important;
}

.period-btn-group .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.period-btn-group .btn.active {
    background: var(--accent);
    color: #0f172a;
    border-color: var(--accent);
}

.period-btn-group .btn:hover:not(.active) {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.period-navigator .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
}

.period-navigator .btn:hover {
    background: var(--accent);
    color: #0f172a;
    border-color: var(--accent);
}

.lc-consumption-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1.5px solid rgba(255,255,255,0.1);
}

.lc-consumption-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.lc-consumption-table tr.total-row {
    font-weight: bold;
    border-top: 1.5px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.02);
}

.lc-consumption-table tr.total-row td {
    border-bottom: none;
}

/* Tab Buttons for PO Day Header */
.day-tabs-header .btn-tab {
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border, #334155);
    color: var(--text-secondary, #94a3b8);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.day-tabs-header .btn-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #f8fafc);
}

.day-tabs-header .btn-tab.active {
    background: var(--accent, #3b82f6);
    color: #0f172a;
    border-color: var(--accent, #3b82f6);
}

.badge-info {
    background: rgba(14, 165, 233, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.overflow-x-auto {
    overflow-x: auto;
    scrollbar-width: thin;
}

