/* ============================================ */
/* ENERGYTRACKER — Professional Redesign        */
/* ============================================ */

:root {
    /* Couleurs mode clair — palette raffinée */
    --bg-primary: #f4f6f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf0f5;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --text-primary: #1a1f36;
    --text-secondary: #6b7594;
    --text-muted: #9aa2b8;
    --border-color: #e1e5ee;
    --border-light: rgba(0, 0, 0, 0.04);
    
    /* Accent palette */
    --color-primary: #0dac72;
    --color-primary-rgb: 13, 172, 114;
    --color-primary-light: rgba(13, 172, 114, 0.08);
    --color-primary-glow: rgba(13, 172, 114, 0.2);
    --color-secondary: #4f6ef7;
    --color-secondary-light: rgba(79, 110, 247, 0.08);
    --color-danger: #e5484d;
    --color-warning: #f0a400;
    --color-success: #0dac72;
    
    /* Indicateurs consommation */
    --color-negative: #0dac72;
    --color-low: #f0a400;
    --color-high: #e5484d;
    
    /* Ombres raffinées */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.03);
    --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    
    /* Tailles */
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --border-radius: 10px;
    --border-radius-lg: 14px;
    --border-radius-sm: 6px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
    --bg-primary: #0c111d;
    --bg-secondary: #151b2b;
    --bg-tertiary: #1e2740;
    --bg-glass: rgba(21, 27, 43, 0.8);
    --text-primary: #eef1f8;
    --text-secondary: #8b95b0;
    --text-muted: #5a647e;
    --border-color: #252f47;
    --border-light: rgba(255, 255, 255, 0.04);
    
    --color-primary-light: rgba(13, 172, 114, 0.12);
    --color-secondary-light: rgba(79, 110, 247, 0.12);
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* ── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ── NAVIGATION ────────────────────────────── */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background-color: var(--bg-glass);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 1.75rem;
    max-width: 100%;
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

.nav-menu-btn:hover {
    background-color: var(--bg-tertiary);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.nav-brand i {
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--color-primary), #06d6a0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 1.15rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ── SIDEBAR ───────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1rem 0;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}

.nav-menu {
    list-style: none;
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.92rem;
    position: relative;
}

.nav-item:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
    border-right: none;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    opacity: 0.85;
}

.nav-item.active i {
    opacity: 1;
}

/* ── MAIN CONTENT ──────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--navbar-height);
    padding: 2rem 2.5rem;
    min-height: calc(100vh - var(--navbar-height));
}

.tab-content {
    display: none;
    animation: fadeIn 0.35s ease-out;
}

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

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

h1 {
    font-size: 1.75rem;
    margin-bottom: 1.75rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

/* ── STATS GRID ────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.stat-header i {
    font-size: 1.25rem;
    color: var(--color-primary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-light);
    border-radius: 8px;
}

.stat-header h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.power-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    font-family: 'DM Sans', sans-serif;
    line-height: 1.1;
}

.unit {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-secondary {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.stat-indicator {
    height: 3px;
    border-radius: 2px;
    margin-top: 1rem;
    background-color: var(--color-low);
    transition: background-color var(--transition-smooth);
}

.stat-indicator.negative {
    background-color: var(--color-negative);
}

.stat-indicator.high {
    background-color: var(--color-high);
}

/* Battery */
.battery-bar {
    height: 6px;
    background-color: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1rem;
}

.battery-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-success), #06d6a0);
    transition: width 0.5s ease;
    border-radius: 3px;
}

/* Comparisons */
.stat-comparison {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.comparison-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
}

.comparison-item small {
    color: var(--text-muted);
    font-weight: 400;
}

.trend-up {
    color: var(--color-success);
    font-weight: 600;
}

.trend-down {
    color: var(--color-danger);
    font-weight: 600;
}

/* Autoconsommation */
.autoconso-details {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.autoconso-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
}

.autoconso-item span:first-child {
    color: var(--text-secondary);
}

.total-savings {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* ── ADVICE CARD ───────────────────────────── */
.advice-card {
    background: linear-gradient(135deg, #0dac72, #4f6ef7);
    color: white;
    border-radius: var(--border-radius-lg);
    padding: 1.5rem 1.75rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 24px rgba(13, 172, 114, 0.2);
    position: relative;
    overflow: hidden;
}

.advice-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    pointer-events: none;
}

.advice-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.advice-header i {
    font-size: 1.35rem;
    opacity: 0.9;
}

.advice-header h3 {
    font-size: 1.1rem;
    margin: 0;
    color: white;
    font-weight: 600;
}

.advice-content p {
    margin: 0.4rem 0;
    opacity: 0.95;
    line-height: 1.55;
    font-size: 0.95rem;
}

/* ── CHARTS ────────────────────────────────── */
.charts-section {
    margin-top: 2rem;
}

.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.controls-group {
    display: flex;
    gap: 0.6rem;
}

.control-select {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.88rem;
    font-family: inherit;
    font-weight: 500;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7594' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

.control-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.chart-container {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

#mainChart {
    height: 400px !important;
    max-height: 400px;
}

.charts-section > .chart-container:first-of-type {
    height: auto;
}

.charts-section > .chart-container:first-of-type canvas {
    height: 400px !important;
}

@media (max-width: 768px) {
    #mainChart {
        height: 250px !important;
        max-height: 250px;
    }
    .charts-section > .chart-container:first-of-type canvas {
        height: 250px !important;
    }
}

/* ── PIE CHARTS ────────────────────────────── */
.pie-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.pie-container {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-card);
    min-height: 420px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light);
}

.pie-container h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.pie-container canvas {
    max-height: 320px;
    flex: 1;
}

/* ── HISTORY ───────────────────────────────── */
.history-controls {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

.controls-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.control-group {
    flex: 1;
    min-width: 200px;
}

.control-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.control-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.control-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Period stats */
.period-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.period-stat-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1.1rem;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid var(--border-light);
}

.period-stat-card i {
    font-size: 1.5rem;
    color: var(--color-primary);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-light);
    border-radius: 10px;
    flex-shrink: 0;
}

.period-stat-content {
    display: flex;
    flex-direction: column;
}

.period-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.period-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.compare-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    margin-top: 3px;
}
.compare-badge.up-bad   { background: #fee2e2; color: #b91c1c; }
.compare-badge.down-good { background: #dcfce7; color: #15803d; }
.compare-badge.up-good  { background: #dcfce7; color: #15803d; }
.compare-badge.down-bad { background: #fee2e2; color: #b91c1c; }
.compare-badge.neutral  { background: #f1f5f9; color: #64748b; }

[data-theme="dark"] .compare-badge.up-bad    { background: rgba(239,68,68,.15); color: #f87171; }
[data-theme="dark"] .compare-badge.down-good { background: rgba(34,197,94,.15); color: #4ade80; }
[data-theme="dark"] .compare-badge.up-good   { background: rgba(34,197,94,.15); color: #4ade80; }
[data-theme="dark"] .compare-badge.down-bad  { background: rgba(239,68,68,.15); color: #f87171; }

#histElecCompareControls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Top cards */
.top-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.top-card {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.top-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.top-list {
    list-style: none;
    counter-reset: top-counter;
}

.top-list li {
    counter-increment: top-counter;
    display: flex;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.4rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    position: relative;
    padding-left: 2.75rem;
    font-size: 0.9rem;
    transition: background-color var(--transition-fast);
}

.top-list li:hover {
    background-color: var(--bg-primary);
}

.top-list li::before {
    content: counter(top-counter);
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.1rem;
}

.top-date {
    color: var(--text-primary);
}

.top-value {
    font-weight: 700;
    color: var(--color-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

/* ── CONFIGURATION ─────────────────────────── */
.config-section {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 0.45rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    line-height: 1.45;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-primary);
    border-radius: 4px;
}

/* Time slots */
.time-slots {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.time-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-slot input {
    flex: 1;
}

/* Sources */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.source-item {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1.15rem;
    border: 1px solid var(--border-light);
}

.source-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.source-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.source-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ── COLOR PICKER ─────────────────────────── */
.color-picker-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.color-picker-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.color-picker-wrap input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 2.4rem;
    height: 2.4rem;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.color-picker-wrap input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 5px;
}

.color-picker-wrap input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}

.color-picker-wrap input[type="color"]:hover {
    border-color: var(--primary);
    transform: scale(1.08);
}

.color-picker-label {
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    letter-spacing: 0.04em;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

/* Alerts */
.alerts-config {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.alert-item {
    padding: 0.5rem 0;
}

/* ── BUTTONS ───────────────────────────────── */
.btn {
    padding: 0.65rem 1.35rem;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #06c47d);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(var(--color-primary-rgb), 0.35);
    filter: brightness(1.05);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-small {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.45rem;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background-color: rgba(229, 72, 77, 0.08);
    color: var(--color-danger);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.75rem;
}

/* ── TOAST NOTIFICATIONS ───────────────────── */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.9rem 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    animation: slideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.toast.success {
    border-left: 3px solid var(--color-success);
}

.toast.error {
    border-left: 3px solid var(--color-danger);
}

.toast.warning {
    border-left: 3px solid var(--color-warning);
}

@keyframes slideIn {
    from {
        transform: translateX(120%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .nav-menu-btn {
        display: block;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.4rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .controls-row {
        flex-direction: column;
    }
    
    .control-group {
        min-width: 100%;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    .top-cards {
        grid-template-columns: 1fr;
    }
    
    .toast-container {
        left: 1rem;
        right: 1rem;
    }
    
    .toast {
        min-width: auto;
    }
    
    .pie-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .nav-brand span {
        display: none;
    }
    
    .power-value {
        font-size: 1.85rem;
    }
    
    .stat-comparison {
        flex-direction: column;
        gap: 0.35rem;
    }
}

/* PWA specific */
@media (display-mode: standalone) {
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
    
    .main-content {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

/* ── DEVICES ───────────────────────────────── */
.devices-title {
    grid-column: 1 / -1;
    margin: 1.75rem 0 1rem 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.015em;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.device-card {
    background: var(--bg-secondary);
    border-left: 3px solid #f0a400;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
}

.device-card .stat-header i {
    color: #f0a400;
    background: rgba(240, 164, 0, 0.08);
}

/* ── NAV ACTIONS / LOGOUT ──────────────────── */
.nav-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-logout {
    background: transparent;
    border: 1.5px solid var(--color-danger);
    color: var(--color-danger);
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-logout:hover {
    background: var(--color-danger);
    color: white;
}

/* ============================================ */
/* EAU & GAZ — Styles spécifiques              */
/* ============================================ */

.water-card .stat-header i,
.water-meter-badge .stat-header i {
    color: #4f6ef7 !important;
    background: rgba(79, 110, 247, 0.08) !important;
}

.water-card {
    border-top: none;
}
.water-card::before {
    background: linear-gradient(90deg, #4f6ef7, #60a5fa) !important;
    opacity: 1 !important;
}

.water-meter-badge {
    border-left: 3px solid #4f6ef7;
}

.gas-card .stat-header i,
.gas-meter-badge .stat-header i {
    color: #f0a400 !important;
    background: rgba(240, 164, 0, 0.08) !important;
}

.gas-card {
    border-top: none;
}
.gas-card::before {
    background: linear-gradient(90deg, #f0a400, #fbbf24) !important;
    opacity: 1 !important;
}

.gas-meter-badge {
    border-left: 3px solid #f0a400;
}

#waterChart {
    height: 400px !important;
    max-height: 400px;
}

#gasChart {
    height: 400px !important;
    max-height: 400px;
}

@media (max-width: 768px) {
    #waterChart,
    #gasChart {
        height: 250px !important;
        max-height: 250px;
    }
}

.config-section h2 i.fa-tint {
    color: #4f6ef7;
}

.config-section h2 i.fa-fire {
    color: #f0a400;
}

/* ============================================ */
/* HISTORY SUB-TABS                             */
/* ============================================ */
.history-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.history-tab {
    padding: 0.65rem 1.35rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.history-tab:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.history-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.history-tab[data-history-tab="water"] { color: #4f6ef7; }
.history-tab[data-history-tab="water"].active { border-bottom-color: #4f6ef7; }
.history-tab[data-history-tab="gas"] { color: #f0a400; }
.history-tab[data-history-tab="gas"].active { border-bottom-color: #f0a400; }

.history-panel {
    display: none;
    animation: fadeIn 0.3s;
}

.history-panel.active {
    display: block;
}

#histElecChart, #histWaterChart, #histGasChart {
    height: 400px !important;
    max-height: 400px;
}

@media (max-width: 768px) {
    #histElecChart, #histWaterChart, #histGasChart {
        height: 250px !important;
        max-height: 250px;
    }
    .history-tabs {
        flex-wrap: wrap;
    }
    .history-tab {
        flex: 1;
        justify-content: center;
        padding: 0.55rem 0.6rem;
        font-size: 0.82rem;
    }
}

/* ============================================ */
/* SOLAR FORECAST                               */
/* ============================================ */
.forecast-section {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    margin-top: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-light);
    border-left: 3px solid #f0a400;
    position: relative;
}

.forecast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.forecast-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--text-primary);
}

.forecast-header h2 i { color: #f0a400; }

.forecast-day-tabs {
    display: flex;
    gap: 0;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    padding: 3px;
}

.forecast-day-tab {
    padding: 0.35rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.forecast-day-tab:hover {
    color: var(--text-primary);
}

.forecast-day-tab.active {
    background: var(--bg-secondary);
    color: #f0a400;
    box-shadow: var(--shadow-xs);
}

.forecast-quality {
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.quality-excellente { background: #dcfce7; color: #166534; }
.quality-bonne { background: #fef9c3; color: #854d0e; }
.quality-moyenne { background: #ffedd5; color: #9a3412; }
.quality-mauvaise { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .quality-excellente { background: #166534; color: #dcfce7; }
[data-theme="dark"] .quality-bonne { background: #854d0e; color: #fef9c3; }
[data-theme="dark"] .quality-moyenne { background: #9a3412; color: #ffedd5; }
[data-theme="dark"] .quality-mauvaise { background: #991b1b; color: #fee2e2; }

.forecast-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.forecast-stat {
    display: flex;
    flex-direction: column;
}

.forecast-stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.forecast-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.forecast-best-windows h3 {
    font-size: 0.95rem;
    margin-bottom: 0.65rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.windows-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.window-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

.window-item:hover {
    background: var(--bg-primary);
}

.window-rank { font-size: 1.15rem; }
.window-time { 
    font-weight: 600; 
    font-size: 0.9rem; 
    color: var(--text-primary); 
    min-width: 120px;
    font-family: 'JetBrains Mono', monospace;
}

.window-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge-offpeak { background: #dbeafe; color: #1e40af; }
.badge-solar { background: #fef3c7; color: #92400e; }
.badge-solar-low { background: #f1f5f9; color: #64748b; }
[data-theme="dark"] .badge-offpeak { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-solar { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-solar-low { background: #334155; color: #94a3b8; }

.window-advice {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(13, 172, 114, 0.06), rgba(79, 110, 247, 0.06));
    border-radius: var(--border-radius-sm);
    font-size: 0.88rem;
    color: var(--text-primary);
    border: 1px solid rgba(13, 172, 114, 0.1);
}

.window-advice i { color: #f0a400; margin-right: 0.25rem; }

#forecastChart {
    height: 250px !important;
    max-height: 250px;
}

@media (max-width: 768px) {
    .forecast-stats { flex-direction: column; gap: 0.75rem; }
    #forecastChart { height: 180px !important; max-height: 180px; }
}

/* ============================================ */
/* TEMPO / EJP TARIFF CONFIG                    */
/* ============================================ */
.tempo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.tempo-color {
    padding: 1.15rem;
    border-radius: var(--border-radius);
    border: 1.5px solid var(--border-color);
    transition: border-color var(--transition-fast);
}

.tempo-color:hover {
    border-color: var(--text-muted);
}

.tempo-blue { border-color: #4f6ef7; background: rgba(79, 110, 247, 0.04); }
.tempo-white { border-color: #94a3b8; background: rgba(148, 163, 184, 0.04); }
.tempo-red { border-color: #e5484d; background: rgba(229, 72, 77, 0.04); }
[data-theme="dark"] .tempo-blue { background: rgba(79, 110, 247, 0.08); }
[data-theme="dark"] .tempo-white { background: rgba(148, 163, 184, 0.08); }
[data-theme="dark"] .tempo-red { background: rgba(229, 72, 77, 0.08); }

.tempo-color-label {
    display: block;
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.tempo-color-label small {
    font-weight: 400;
    color: var(--text-muted);
}

.tempo-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tempo-prices .form-group {
    margin: 0;
}

.tempo-prices label {
    font-size: 0.78rem;
}

/* Tempo day badge */
.tempo-day-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 700;
}
.tempo-day-blue { background: #dbeafe; color: #1e40af; }
.tempo-day-white { background: #f1f5f9; color: #475569; }
.tempo-day-red { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .tempo-day-blue { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .tempo-day-white { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .tempo-day-red { background: #7f1d1d; color: #fca5a5; }

/* ============================================ */
/* SIMULATION                                   */
/* ============================================ */
.sim-section {
    border-left: 3px solid #8b5cf6;
}

.sim-intro {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-bottom: 1.5rem;
    line-height: 1.55;
}

/* Range slider */
.form-range {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    margin-top: 0.5rem;
    cursor: pointer;
}
.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
    transition: box-shadow var(--transition-fast);
}
.form-range::-webkit-slider-thumb:hover {
    box-shadow: 0 3px 12px rgba(139, 92, 246, 0.45);
}
.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #8b5cf6;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.sim-range-value {
    display: inline-block;
    margin-top: 0.5rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #8b5cf6;
    font-family: 'JetBrains Mono', monospace;
}

/* Résultats simulation */
.sim-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sim-result-card {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: transform var(--transition-fast);
    border: 1px solid var(--border-light);
}
.sim-result-card:hover {
    transform: translateY(-2px);
}

.sim-result-savings {
    background: linear-gradient(135deg, rgba(13, 172, 114, 0.08), rgba(79, 110, 247, 0.05));
    border: 1px solid rgba(13, 172, 114, 0.15);
}

.sim-result-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sim-result-icon i {
    font-size: 1.15rem;
    color: #8b5cf6;
}
.sim-result-savings .sim-result-icon i {
    color: #0dac72;
}

.sim-result-content {
    display: flex;
    flex-direction: column;
}
.sim-result-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.sim-result-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* Comparaison */
.sim-comparison {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-light);
}
.sim-comparison h3 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}
.sim-comparison-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.sim-comp-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.sim-comp-label {
    font-size: 0.88rem;
    color: var(--text-secondary);
    min-width: 200px;
}
.sim-comp-values {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sim-comp-without {
    color: #e5484d;
    font-weight: 600;
    text-decoration: line-through;
    opacity: 0.7;
    font-size: 0.9rem;
}
.sim-comp-arrow {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.sim-comp-with {
    color: #0dac72;
    font-weight: 700;
    font-size: 0.9rem;
}
.sim-comp-badge {
    background: #dcfce7;
    color: #166534;
    padding: 0.12rem 0.45rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
}
[data-theme="dark"] .sim-comp-badge {
    background: #166534;
    color: #dcfce7;
}

/* Note investissement */
.sim-invest-note {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.06), rgba(79, 110, 247, 0.04));
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: var(--border-radius);
    padding: 1rem 1.15rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.sim-invest-note i {
    color: #8b5cf6;
    margin-right: 0.25rem;
}
.sim-profit-positive {
    color: #0dac72;
}
.sim-profit-negative {
    color: #e5484d;
}

/* Détails installation */
.sim-details-section {
    margin-bottom: 1.5rem;
}
.sim-details-section h3 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}
.sim-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.65rem;
}
.sim-detail {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}
.sim-detail-label {
    color: var(--text-muted);
    font-size: 0.82rem;
}
.sim-detail-value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: 'JetBrains Mono', monospace;
}

/* Projection note */
.sim-projection-note {
    background: linear-gradient(135deg, rgba(240, 164, 0, 0.06), rgba(13, 172, 114, 0.04));
    border: 1px solid rgba(240, 164, 0, 0.15);
    border-radius: var(--border-radius);
    padding: 1.15rem;
    margin-bottom: 1.5rem;
}
.sim-projection-note h3 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}
.sim-projection-note p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0.3rem 0;
}

/* Charts row */
.sim-charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.25rem;
}

#batterySimChart {
    height: 300px !important;
    max-height: 300px;
}
#batteryAmortChart {
    height: 300px !important;
    max-height: 300px;
}
#roiChart {
    height: 300px !important;
    max-height: 300px;
}
#monthlyProductionChart {
    height: 300px !important;
    max-height: 300px;
}

@media (max-width: 768px) {
    .sim-results-grid {
        grid-template-columns: 1fr;
    }
    .sim-comp-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .sim-charts-row {
        grid-template-columns: 1fr;
    }
    #batterySimChart, #batteryAmortChart, #roiChart, #monthlyProductionChart {
        height: 220px !important;
        max-height: 220px;
    }
    .sim-details-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================ */
/* LOADING PLACEHOLDERS                         */
/* ============================================ */
@keyframes loadingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.loading-placeholder {
    animation: loadingPulse 1.5s ease-in-out infinite;
    color: var(--text-muted) !important;
}

.loading-placeholder.loaded {
    animation: none;
    color: inherit !important;
}

/* ============================================ */
/* TEMPO / EJP BANNER                           */
/* ============================================ */
.tempo-ejp-banner {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tempo-ejp-today,
.tempo-ejp-tomorrow {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.tempo-ejp-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tempo-ejp-color {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.tempo-ejp-color.tempo-bleu {
    background: #3b82f620;
    color: #2563eb;
    border: 1px solid #3b82f640;
}
.tempo-ejp-color.tempo-blanc {
    background: #94a3b818;
    color: #64748b;
    border: 1px solid #94a3b840;
}
.tempo-ejp-color.tempo-rouge,
.tempo-ejp-color.ejp-peak {
    background: #ef444420;
    color: #dc2626;
    border: 1px solid #ef444440;
    animation: tempoPulseRed 2s ease-in-out infinite;
}
.tempo-ejp-color.ejp-normal {
    background: #0dac7220;
    color: #059669;
    border: 1px solid #0dac7240;
}
.tempo-ejp-color.tempo-unknown,
.tempo-ejp-color.ejp-unknown {
    background: #94a3b812;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
}

@keyframes tempoPulseRed {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 8px 2px rgba(239, 68, 68, 0.15); }
}

/* Masquage prévisions solaires (prioritaire sur forecast.js) */
.forecast-hidden {
    display: none !important;
}

.tempo-ejp-tariff {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tempo-ejp-separator {
    width: 1px;
    height: 1.8rem;
    background: var(--border-color);
}

.tempo-ejp-stats {
    display: flex;
    gap: 0.8rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-left: auto;
    flex-wrap: wrap;
}

.tempo-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.tempo-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.tempo-stat-dot.blue { background: #3b82f6; }
.tempo-stat-dot.white { background: #94a3b8; }
.tempo-stat-dot.red { background: #ef4444; }

@media (max-width: 640px) {
    .tempo-ejp-banner {
        gap: 0.6rem;
        padding: 0.6rem 0.8rem;
    }
    .tempo-ejp-separator {
        display: none;
    }
    .tempo-ejp-stats {
        margin-left: 0;
        width: 100%;
        padding-top: 0.4rem;
        border-top: 1px solid var(--border-color);
    }
}

/* ============================================ */
/* TEMPO / EJP BANNER                           */
/* ============================================ */
.tempo-ejp-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.tempo-ejp-today,
.tempo-ejp-tomorrow {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    min-width: 160px;
}

.tempo-day-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.8;
}

.tempo-day-color {
    font-size: 1rem;
    font-weight: 700;
    padding: 0.2rem 0.8rem;
    border-radius: 6px;
}

/* Couleurs Tempo */
.tempo-blue {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.tempo-blue .tempo-day-color {
    background: #3b82f6;
    color: white;
}
.tempo-white {
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.3);
}
.tempo-white .tempo-day-color {
    background: #e2e8f0;
    color: #1e293b;
}
.tempo-red {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.tempo-red .tempo-day-color {
    background: #ef4444;
    color: white;
}

/* EJP */
.tempo-ejp-peak {
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.tempo-ejp-peak .tempo-day-color {
    background: #ef4444;
    color: white;
}
.tempo-ejp-normal {
    background: rgba(13, 172, 114, 0.10);
    border: 1px solid rgba(13, 172, 114, 0.3);
}
.tempo-ejp-normal .tempo-day-color {
    background: #0dac72;
    color: white;
}
.tempo-ejp-unknown {
    background: rgba(148, 163, 184, 0.10);
    border: 1px solid rgba(148, 163, 184, 0.25);
}
.tempo-ejp-unknown .tempo-day-color {
    background: #94a3b8;
    color: white;
}

.tempo-ejp-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 150px;
}

.tempo-now {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tempo-stats {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

@media (max-width: 640px) {
    .tempo-ejp-banner {
        flex-direction: column;
        align-items: stretch;
    }
    .tempo-ejp-today,
    .tempo-ejp-tomorrow {
        min-width: auto;
        justify-content: space-between;
    }
}
