@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

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

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
    width: 100vw;
    overflow-x: hidden;
    font-size: 16px;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ══ VARIABLES ══ */
:root {
    --bg: #0a0e1a;
    --card-bg: #111827;
    --nav-bg: rgba(10, 14, 26, 0.85);
    /* Couleurs Bel-Up Premium */
    --accent-mint: #4ade80; /* Solaire / Charge */
    --accent-cyan: #6366f1; /* Maison / Décharge (Updated to Indigo) */
    --accent-white: #f1f5f9; /* Réseau */
    /* Anciennes variables pour compatibilité */
    --accent-solar: #4ade80;
    --accent-battery: #4ade80;
    --accent-grid: #6366f1;
    --accent-consumption: #6366f1;
    --accent: #6366f1;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --border-hi: rgba(255, 255, 255, 0.15);
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --transition: 0.3s ease;
    
    color-scheme: dark;
}

select,
option {
    background-color: var(--card-bg);
    color: var(--text-primary);
}

select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' 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 1rem center;
    background-size: 1.1rem;
    padding-right: 2.5rem !important;
}

.light-mode select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.5)' 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");
}

select:focus {
    border-color: var(--accent-grid);
    outline: none;
}

.light-mode {
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --nav-bg: rgba(248, 250, 252, 0.9);
    --text-primary: #0f172a;
    --text-secondary: #475569; /* Darkened for better readability */
    --accent-mint: #16a34a; /* Deeper Emerald for light mode */
    --border: rgba(15, 23, 42, 0.05);
    --border-hi: rgba(15, 23, 42, 0.1);
    --shadow-soft: 0 4px 20px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.08);
    color-scheme: light;
}


/* ══ NAV ══ */
.main-nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 75px; 
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.nav-inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-col-left,
.nav-col-right {
    display: flex;
    align-items: center;
}

.nav-col-left {
    gap: 1.5rem; /* Espace entre le bouton menu et les liens */
}

.nav-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-toggle:hover {
    color: var(--text-primary);
    background: var(--border);
}

.nav-logo {
    display: none;
}

.nav-logo-img {
    height: 42px;
    width: auto;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.2));
    transition: var(--transition);
}

.nav-logo-img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.4));
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--border);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.nav-link.active svg {
    opacity: 1;
}

.container {
    width: 100%;
    min-height: calc(100vh - 75px);
    margin: 0;
    padding: 0; /* Suppression pour alignement précis des enfants */
    display: flex;
    flex-direction: column;
}

header {
    margin-bottom: 0;
    animation: fadeInDown 0.6s ease-out;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 5rem 0; /* Réduit à 5rem pour un décalage plus subtil */
    margin-bottom: 0.5rem;
}

.header-left,
.header-center,
.header-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.header-left {
    justify-content: flex-start;
}

.header-center {
    justify-content: center;
}

.header-logo-main {
    height: 60px;
    width: auto;
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.2));
    transition: transform var(--transition);
}

.header-logo-main:hover {
    transform: scale(1.05);
}

.header-right {
    justify-content: flex-end;
}

.header-right .flow-info {
    margin-right: 0;
}

.header-left .flow-info {
    margin-left: 0;
}

.history-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0;
}

.light-mode .history-title {
    color: #1e293b;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 0.5rem;
}

.light-mode h1 {
    color: #1e293b;
}

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

/* Dashboard Layout Adjustment - Unified Fluid App UI */
.dashboard-viewport {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    /* On reste centré pour la stabilité */
    overflow: hidden;
    position: relative;
    padding-bottom: 2rem;
}

.flow-dashboard {
    width: 1200px;
    height: 800px;
    position: relative;
    top: -65px;
    /* Ajusté de -40px à -65px pour réduire l'espace avec le header */
    flex-shrink: 0;

    /* Le scaling est désormais géré parfaitement par JavaScript */
    /* Cela évite les bugs CSS liés à `calc(length / length)` qui ignoraient les zooms */
    transform-origin: center center;
    transition: transform 0.2s ease-out;
}

.flow-info {
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    min-width: auto;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.v-val-small {
    font-size: 22px;
    /* Agrandi de 18px */
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.v-name-small {
    font-size: 12px;
    /* Agrandi de 10px */
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.label-weather {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.weather-text {
    text-align: left;
    display: flex;
    flex-direction: column;
}

#weatherIconWrap svg {
    transform: scale(1.3);
    /* Forcer une mise à l'échelle via transform au lieu de changer inline */
    transform-origin: center center;
}



.grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Ligne 1 : Consommation (gauche) | Production Solaire (droite) */
.grid-top {
    grid-template-columns: 1fr 1fr;
}

/* Ligne 2 : Maison + Voiture (gauche) | Batterie (droite) */
.grid-bottom-new {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
}

.left-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.left-stack .card {
    flex: 1;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem 1.5rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.6s ease-out both;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--card-accent), transparent);
    opacity: 0.5;
}

.card-consumption {
    --card-accent: var(--accent-grid);
    animation-delay: 0.1s;
}

.card-solar {
    --card-accent: var(--accent-solar);
    animation-delay: 0.2s;
}

.card-house {
    --card-accent: #a855f7;
    animation-delay: 0.3s;
}

.card-car {
    --card-accent: #f97316;
    animation-delay: 0.35s;
}

/* ── Voiture non branchée ── */
.car-disconnected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    gap: 0.5rem;
    flex: 1;
}

.car-disconnected-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px dashed rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.2);
    margin-bottom: 0.4rem;
}

.car-disconnected-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.03em;
}

.car-disconnected-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.18);
}

.card-battery {
    --card-accent: var(--accent-battery);
    animation-delay: 0.4s;
}

/* ══ JAUGE CIRCULAIRE BATTERIE ══ */
.battery-gauge-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.4rem 0 0.3rem;
    flex: 1;
}

.battery-gauge-svg {
    width: 100%;
    max-width: 220px;
    height: auto;
    filter: drop-shadow(0 0 24px rgba(16, 185, 129, 0.3));
}

.gauge-track {
    transition: stroke 0.3s;
}

.gauge-fill {
    transition: stroke-dashoffset 1s ease-out, stroke 0.3s ease;
}

.gauge-soc-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.9rem;
    font-weight: 700;
    fill: var(--text-primary);
}

.gauge-power-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    fill: var(--accent-battery);
}

.gauge-label-text {
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    fill: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.house-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.battery-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-top: 0.6rem;
}

.data-item {
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
}

.data-item-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.data-item-value {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

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

.card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: var(--border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-value {
    font-size: 2.2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 0.3rem;
    color: var(--card-accent);
    display: inline-block;
}

.metric-unit-inline {
    font-size: 2.2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--card-accent);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.progress-bar {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    height: 12px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--card-accent), rgba(255, 255, 255, 0.6));
    transition: width 1s ease-out;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

.metric-unit {
    font-size: 1.5rem;
    font-weight: 400;
    opacity: 0.7;
}

.metric-label-unit {
    display: none;
}

.status-item-small {
    flex: 0 0 auto;
    min-width: 160px;
    max-width: 180px;
}

/* ── Météo ── */
.weather-item {
    flex: 0 0 auto;
    min-width: 160px;
    max-width: 200px;
}

.weather-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.weather-emoji {
    font-size: 1.4rem;
    line-height: 1;
}

.weather-item .status-content h3 {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 2px;
}

.weather-item #weatherTemp {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.global-toggle-btn {
    background: none;
    border: none;
    color: var(--accent-grid);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.2s;
    text-align: left;
}

.global-toggle-btn:hover {
    opacity: 0.7;
}

.toggle-icon {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.1));
    color: #818cf8;
}

.card-details {
    overflow: hidden;
    max-height: 600px;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.card-details.hidden {
    max-height: 0;
    opacity: 0;
}

.card-header-power {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.simple-phase-list {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.simple-phase-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.simple-phase-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.phase-table {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.phase-row {
    display: grid;
    grid-template-columns: 2rem 1fr 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.phase-row:not(.phase-header) {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.2s;
}

.phase-row:not(.phase-header):hover {
    background: rgba(255, 255, 255, 0.08);
}

.phase-header {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    padding-left: 0.8rem;
    letter-spacing: 0.04em;
}

.phase-label {
    font-weight: 600;
    color: var(--card-accent);
    font-size: 0.85rem;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Responsive */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .logo {
        height: 60px;
        align-self: center;
    }

    .status-bar {
        flex-direction: column;
    }

    .grid-top {
        grid-template-columns: 1fr;
    }

    .grid-bottom-new {
        grid-template-columns: 1fr;
    }

    .metric-value {
        font-size: 2.5rem;
    }
}


/* ══ BODY ADJUSTMENT ══ */
body {
    padding-top: 0 !important;
}



/* Unified Node Position Rules */
.flow-dashboard {
    background: transparent;
    border-radius: 12px;
    overflow: visible;
    /* Let scale work without clipping */
}

.flow-lines-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Trace grise (le "tuyau") */
.flow-track {
    stroke: rgba(255, 255, 255, 0.1);
    /* Ligne pleine (non pointillée) */
    stroke-width: 2;
    stroke-linecap: round;
    fill: none;
}

/* Segment animé (le "flux") */
.flow-line {
    stroke-width: 3.5; /* Plus fin pour plus d'élégance */
    stroke-linecap: round;
    fill: none;
    stroke-dasharray: 25, 60;
    /* Bâtonnets longs et espacés */
    animation: flowMove 2.5s linear infinite; /* Vitesse ajustée (2.5s) */
    opacity: 1;
}

.solar-flow {
    stroke: #10b981 !important;
    filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.6));
}

.grid-flow {
    stroke: #ffffff !important;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
}

.house-flow {
    stroke: #38bdf8 !important; /* Bleu Clair pour la Maison */
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.6));
}

.car-flow {
    stroke: #38bdf8 !important;
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.6));
}

/* On force l'affichage de tous les chemins */
.solar-flow,
.grid-flow,
.house-flow,
.car-flow {
    display: block !important;
}

.reverse-flow {
    animation-direction: reverse !important;
}

@keyframes flowMove {
    from {
        stroke-dashoffset: 85;
        /* Ajusté pour le nouveau dasharray */
    }

    to {
        stroke-dashoffset: 0;
    }
}

/* Animations de Cadre Batterie */
@keyframes pulse-green {
    0% { border-color: rgba(74, 222, 128, 0.3); box-shadow: 0 0 5px rgba(74, 222, 128, 0.2); }
    50% { border-color: rgba(74, 222, 128, 1); box-shadow: 0 0 15px rgba(74, 222, 128, 0.6); }
    100% { border-color: rgba(74, 222, 128, 0.3); box-shadow: 0 0 5px rgba(74, 222, 128, 0.2); }
}

@keyframes pulse-blue {
    0% { border-color: rgba(56, 189, 248, 0.3); box-shadow: 0 0 5px rgba(56, 189, 248, 0.2); }
    50% { border-color: rgba(56, 189, 248, 1); box-shadow: 0 0 15px rgba(56, 189, 248, 0.6); }
    100% { border-color: rgba(56, 189, 248, 0.3); box-shadow: 0 0 5px rgba(56, 189, 248, 0.2); }
}

/* Nœuds */
.node {
    position: absolute;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.node img {
    height: 150px;
    width: auto;
    object-fit: contain;
}

/* Nœud Central Batterie */
.node-center {
    top: 450px;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}

/* Ombre portée détachée sous la batterie (Ellipse) */
.battery-shadow {
    position: absolute;
    top: 540px; /* Légèrement ajusté de 525px pour la v4 */
    left: 50%;
    transform: translate(-50%, -50%);
    width: 240px; /* Plus large pour la v4 */
    height: 35px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: 5;
    border-radius: 50%;
}

#batteryHub {
    height: 170px; /* Plus grand pour l'effet 3D */
    width: auto;
    object-fit: contain;
    transition: filter 0.5s ease;
}

.battery-hub.idle {
    filter: brightness(0.85);
}

/* Anciens styles du hub SVG masqués/désactivés */
.battery-hub:not(img) {
    display: none !important;
}

/* ÉTATS DYNAMIQUES */
.battery-hub.idle .battery-u-logo {
    color: #94a3b8;
    animation: none;
}

.battery-hub.charging .battery-u-logo {
    color: #10b981;
    /* Vert plus vif */
    animation: battery-blink 1.5s infinite ease-in-out;
}

.battery-hub.discharging .battery-u-logo {
    color: #3b82f6;
    /* Bleu vif */
    animation: battery-blink 1.5s infinite ease-in-out;
}

.battery-power-display {
    font-size: 12px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.battery-hub.charging .battery-power-display {
    color: #10b981;
}

.battery-hub.discharging .battery-power-display {
    color: #3b82f6;
}

/* Styles LCD supprimés car déplacés vers flow-label */

.soc-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Espace entre l'icône et le texte % */
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 17px;
    font-weight: 600;
    line-height: 1;
}

/* Icône de batterie style GSM */
.battery-icon {
    width: 24px;
    height: 12px;
    border: 1.5px solid #475569;
    border-radius: 2px;
    position: relative;
    padding: 1px;
}

/* Le petit connecteur "+" de la batterie */
.battery-icon::after {
    content: '';
    position: absolute;
    right: -3.5px;
    top: 3px;
    width: 2px;
    height: 4px;
    background: #475569;
    border-radius: 0 1px 1px 0;
}

.battery-level {
    height: 100%;
    background: #10b981;
    border-radius: 1px;
    transition: width 0.5s ease, background-color 0.5s ease;
}

#batterySoc {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.light-mode .grid-flow path {
    stroke: var(--accent) !important; /* Rétabli en Indigo */
    filter: drop-shadow(0 0 5px rgba(99, 102, 241, 0.6));
}

.light-mode .flow-track path {
    stroke: rgba(15, 23, 42, 0.04); /* Subtle track in light mode */
}


.light-mode .label-solar .v-val {
    color: var(--accent); /* Coordination avec le flux (Indigo) */
}

.light-mode .label-house .v-val {
    color: #0284c7; /* Bleu Azur plus soutenu pour la lisibilité en mode clair */
}

.light-mode .house-flow path {
    stroke: #0284c7 !important;
    filter: drop-shadow(0 0 5px rgba(2, 132, 199, 0.4));
}

/* Libellés de flux */
.flow-label {
    position: absolute;
    z-index: 5;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border: none;
    /* Le SVG tracé agit comme bordure maintenant ! */
    border-radius: 22px;
    /* Moitié de 44px */
    width: 120px;
    height: 44px;
    padding: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    line-height: 1.1;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flow-label:hover {
    box-shadow: var(--shadow-lg);
    /* Retiré le transform translateY(-5px) pour que le label ne se détache pas de sa "bordure" SVG au hover */
    transform: translate(-50%, -50%);
}

.v-val {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

.v-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 2px;
}

/* Positions des nœuds (Totalement centrés par rapport à l'axe) */
.node-grid {
    top: 675px; /* Bas Gauche */
    left: 250px;
    transform: translate(-50%, -50%);
}

.node-grid img {
    height: 155px;
    /* Réduit d'environ 20% */
}

.node-solar {
    top: 225px; /* Haut Gauche */
    left: 250px;
    transform: translate(-50%, -50%);
}

.node-solar img {
    height: 150px;
}

.node-house {
    top: 225px;
    left: 950px;
    width: 200px; /* Largeur fixe pour alignement avec la voiture */
    transform: translate(-50%, -50%);
}

.node-house img {
    height: 145px;
}

.node-car {
    top: 675px;
    left: 950px;
    width: 200px; /* Largeur fixe identique à la maison */
    transform: translate(-50%, -50%);
}

.node-car img {
    height: 180px;
}

/* Positions des labels (Totalement centrés sur les axes verticaux/horizontaux) */

.label-grid {
    top: 400px;
    left: 380px;
    transform: translate(-50%, -50%);
}

.label-grid .v-val {
    color: var(--accent-mint); /* Solaire en haut */
}

.label-solar {
    top: 500px;
    left: 380px;
    transform: translate(-50%, -50%);
}

.label-solar .v-val {
    color: var(--text-primary); /* Réseau en bas - Visible in both modes */
}

.label-house {
    top: 400px;
    left: 820px;
    transform: translate(-50%, -50%);
}

.label-house .v-val {
    color: #38bdf8; /* Bleu Clair pour la maison (Sombre & Clair) */
}

.label-car {
    top: 500px;
    left: 820px;
    transform: translate(-50%, -50%);
}

.label-car .v-val {
    color: var(--text-primary); /* Invisible white text replaced by primary text */
}

/* Position Label Batterie */
.label-battery {
    top: 590px;
    left: 600px;
    transform: translate(-50%, -50%);
    height: auto;
    min-height: 60px;
    padding: 10px 15px;
    width: 125px; /* Plus étroit pour plus d'élégance */
    border: 2px solid rgba(255, 255, 255, 0.1); /* Bordure de base */
    transition: all 0.5s ease;
}

/* États dynamiques du cadre batterie */
.label-battery.state-charging {
    animation: pulse-green 2s infinite ease-in-out;
    background: rgba(74, 222, 128, 0.05); /* Teinte légère verte */
}

.label-battery.state-discharging {
    animation: pulse-blue 2s infinite ease-in-out;
    background: rgba(56, 189, 248, 0.05); /* Teinte légère bleue */
}

.label-battery.state-idle {
    border-color: var(--border-hi);
    box-shadow: none;
    background: var(--card-bg);
}

.label-battery .v-val-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.battery-icon-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.v-val-sub {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-battery);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.label-battery .v-name {
    margin-top: 4px;
}

/* Responsive Dash */
@media screen and (max-width: 768px) {

    /* NAVIGATION MOBILE */
    .nav-inner {
        padding: 0 1rem !important;
    }

    .nav-link {
        padding: 0.6rem 0.5rem !important;
        font-size: 0.85rem !important;
    }

    .user-name {
        display: none !important;
    }

    /* HEADER MOBILE */
    .header-content {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    /* SCALE ADJUSTMENT FOR MOBILE */
    .flow-dashboard {
        /* On narrow screens, allow a bit more space */
        --scale-w: calc((100vw - 1rem) / 1200);
        --scale-h: calc((100vh - 300px) / 800);
    }
}

/* Modales de Détails (Bulles d'infos) */
.details-modal {
    display: none;
    position: absolute;
    left: 50%;
    transform: translateX(-20%);
    width: 320px;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    z-index: 200;
    flex-direction: column;
}

.house-details-modal {
    top: 130px; /* Retour au dessus de la batterie */
}

.car-details-modal {
    top: 540px; /* Retour en dessous de la batterie */
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-icon-wrap {
    background: var(--border);
    padding: 8px;
    border-radius: 10px;
}

.modal-title-wrap h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-row {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-row-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.modal-row-value {
    font-size: 1.1rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}