:root {
    --bg-main: #111;
    --bg-card: #1a1a1a;
    --color-text: #fff;
    --color-muted: #999;
    --color-success: #00c853;
    --color-error: #ff5252;
    --shadow: 0 4px 6px rgba(0,0,0,0.3);
    --radius: 12px;
    --header-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg-main);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Qualité de l'air: valeurs en rouge dans les cards */
.air-quality-page .error {
    color: var(--color-error);
}




.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    opacity: 0;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.footer {
    height: var(--header-height);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    opacity: 0;
    color:white;
    flex-flow: column;
    gap:10px;
    padding: 15px;
    height: auto;;
}

.footer-version {
    font-size: 0.875rem;
    color: var(--color-muted);
    font-weight: 500;
}

.footer-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.footer a {
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.footer-nav a:hover {
    background: rgba(255,255,255,0.1);
}

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

.table td { border:1px solid white; margin:3px; }

.container {
    max-width: 90%;
    margin: 0 auto;
    padding: calc(var(--header-height) + 1rem) 1rem calc(var(--footer-height, 50px) + 2rem);
    opacity:0;
}

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

}

.grid-indicators {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.grid-full {
  display:block;
  gap: 1rem;

}

/* Cards compactes pour indicateurs */
.card-compact {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    min-height: 80px;
    display: flex;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.5s ease;
    position: relative;
    overflow: hidden;
}

.card-compact:hover {
    
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

/* Card batterie avec fond coloré progressif */
.card-battery {
    background-size: 200% 100%;
}

.battery-content {
    position: relative;
    z-index: 1;
}

.compact-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.compact-icon {
    font-size: 1.2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.compact-icon-large {
    font-size: 2rem;
    line-height: 1;
}

.compact-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.compact-label {
    font-size: 0.75rem;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.compact-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.compact-value-small {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}

.compact-status {
    font-size: 0.7rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Jauge semi-circulaire */
.semi-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.semi-gauge {
    width: 100%;
    max-width: 120px;
    height: auto;
}

.gauge-value-text {
    font-size: 18px;
    font-weight: 700;
    fill: var(--color-text);
}

/* Carte Optimisme - Design flat moderne et visible */
.card-optimism {
    position: relative;
    transition: all 0.3s ease;
}

.pointer {     cursor: pointer; }

.mppt-leds {
    display: block;
    align-items: center;
    gap: 6px;
    padding-left: 8px;
    padding-right: 0px;
}

.mppt-led {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    opacity: 0.22;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
    transition: opacity 0.2s ease, box-shadow 0.2s ease;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;

}

.mppt-led.active {
    opacity: 1;
    box-shadow: 0 0 10px currentColor;
}

.mppt-led-blue {
    background: #3fa7ff;
    color: #3fa7ff;
}

.mppt-led-orange {
    background: #ff9800;
    color: #ff9800;
}

.mppt-led-green {
    background: #3bd16f;
    color: #3bd16f;
}

/* Arrière-plan avec dégradé selon l'état */
.card-optimism.optimism-good {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.15) 0%, rgba(0, 200, 83, 0.05) 100%);
    border-color: rgba(0, 200, 83, 0.3);
}

.card-optimism.optimism-warning {
    background: linear-gradient(135deg, rgba(255, 167, 38, 0.15) 0%, rgba(255, 167, 38, 0.05) 100%);
    border-color: rgba(255, 167, 38, 0.3);
}

.label-up { background-color: var(--color-success); color:white!important; border-radius: 20px; padding:2px 14px; }

.label-down { background-color: var(--color-error); color:white!important; border-radius: 20px; padding:2px 14px; }

.card-optimism.optimism-critical {
    background: linear-gradient(135deg, rgba(255, 82, 82, 0.15) 0%, rgba(255, 82, 82, 0.05) 100%);
    border-color: rgba(255, 82, 82, 0.3);
    color:#ff5252
}

.card-optimism.optimism-unknown {
    background: linear-gradient(135deg, rgba(128, 128, 128, 0.15) 0%, rgba(128, 128, 128, 0.05) 100%);
    border-color: rgba(128, 128, 128, 0.3);
}

/* Icône emoji en arrière-plan */
.optimism-background {
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.optimism-icon {
    font-size: 90px;
    line-height: 1;
    filter: blur(0.5px);
}

/* Texte de statut stylisé */
.optimism-status-text {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

.card-optimism.optimism-good .optimism-status-text {
    color: #00e676;
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.3);
}

.card-optimism.optimism-warning .optimism-status-text {
    color: #ffb74d;
    text-shadow: 0 0 10px rgba(255, 183, 77, 0.3);
}

.card-optimism.optimism-critical .optimism-status-text {
    color: #ff5252;
    text-shadow: 0 0 10px rgba(255, 82, 82, 0.3);
}

.card-optimism.optimism-unknown .optimism-status-text {
    color: #9e9e9e;
}




/* Ancienne classe - conservée pour compatibilité mais non utilisée */
.optimism-indicator-compact {
    display: none;
}


.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.grid .card-transparent button {
    display:block;
    width: 100%;
        padding: 22px 10px;
    font-size: 17px;
    margin-bottom:10px;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.status {
    display: inline-block;
    padding: 0.15rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.675rem;
    margin-bottom: 1rem;
}

.status.online {
    background: var(--color-success);
    color: #000;
}

.status.offline {
    background: var(--color-error);
    color: #fff;
}

.measures {
    display: grid;
    gap: 0.75rem;
}

.measure {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    
    transition: all 0.3s ease-in-out;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.measure-label {
    color: var(--color-muted);
    font-size: 1rem;
    padding-left: 7px;
}

.measure-value {
    font-variant-numeric: tabular-nums;
    font-size: 1.75rem;
    font-weight: bold;
}

.measure.warning {
    background: rgba(255,152,0,0.15);
}

.measure.danger {
    background: rgba(255,82,82,0.15);
}

.gauge {
    width: 100%;
    height: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    margin-top: 0.5rem;
    margin-bottom:10px;
    
}

.gauge-fill {
    height: 100%;
    transition: width 0.3s ease-in-out;

}
.solar-fill {
    height: 100%;
    background: linear-gradient(90deg,#ffcc33,#00c853);
    transition: width 0.4s ease-in-out;
}
.solar-fill-alt {
    height: 100%;
    background: linear-gradient(90deg,#a38bff,#4e54c8);
    transition: width 0.4s ease-in-out;
}
.rain-fill {
    height: 100%;
    background: linear-gradient(90deg,#66b3ff,#0077cc);
    transition: width 0.4s ease-in-out;
}
.hydro-canvas {
    width: 100%;
    height: 240px;
    border-radius: 8px;
}
.battery-gauge {
    background: linear-gradient(90deg, var(--color-error) 0%, var(--color-success) 100%)!important;
}


.voltage-gauge {
    background: linear-gradient(90deg, var(--color-error) 0%, var(--color-success) 50%, var(--color-error) 100%)!important;
}

.battery-gauge .gauge-fill {
    border-right: 8px solid white;
}

.voltage-gauge .gauge-fill {
    border-right: 8px solid white;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-transform:uppercase;
}

.card-header .gauge {
    margin-left:20px;
}

.card-header h2 {
    margin: 0;
}

.status {
    margin: 0;
}

.settings-btn {
    background: transparent;
    border: none;
    color: var(--color-text);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: opacity 0.2s;
}

.settings-btn:hover {
    opacity: 0.7;
}

.settings-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.settings-btn .spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.settings-btn svg {
    display: block;
}

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


.general-btn {
    background: #ff5252;
    color: #fff;
    border: 2px solid transparent;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.general-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    transition: left 0.5s ease;
}

.general-btn:hover::before {
    left: 100%;
}

.general-btn.alert-btn {
    background: var(--bg-card);
    color: #ff5252;
    border: 2px solid #ff5252;
}

.general-btn.success-btn {
    color: #00c853;
    border: 2px solid #00c853;
    background: var(--bg-card);
        padding: 0px 6px;
}

.general-btn.alert-btn:hover {
    background: #ff5252;
    color: white;
}

.general-btn.success-btn:hover {
    background: #00c853;
    color: white;
}

.general-btn:focus {
    outline: none;
}

.header h1 { cursor: pointer; }

.general-btn.success-btn:focus {
    box-shadow: 0 0 0 3px rgba(0, 200, 83, 0.4), 0 2px 8px rgba(0, 200, 83, 0.3);
}

.general-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.card-settings {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255,255,255,0.02);
    border-radius: 6px;
}


.card-settings label {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    margin-right: 0.75rem;
}

.error {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255,82,82,0.1);
    border-radius: 6px;
    border: 1px solid var(--color-error);
    color: var(--color-error);
    font-size: 0.875rem;
}

.endCard { display:flex; justify-content:space-between; align-items:center; }

.update-time {
    margin-top: 1rem;
    color: var(--color-muted);
    font-size: 0.75rem;
    text-align: right;
}

.details {
    margin-top: 1rem;
    color: var(--color-muted);
    font-size: 0.75rem;
    text-align: left;
}

/* Utility classes */
.row { display: flex; }
.column { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.text-right { text-align: right; }
.ml-auto { margin-left: auto; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.my-2 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.p-1 { padding: 0.4rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.w-100 { width: 100%; }
.w-50 { width: 50%; }
.w-90 { width: 90px; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xs { font-size: 0.7rem; }
.text-muted { color: var(--color-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-error); }
.text-info { color: #29b6f6; }
.text-warning { color: #ffa726; }
.text-dim { opacity: 0.7; }
.link-icon { display: flex; align-items: center; text-decoration: none; }
.divider { margin: 1.5rem 0; border: none; border-top: 1px solid rgba(255,255,255,0.1); }
.box { background: rgba(255,255,255,0.03); border-radius: 6px; }
.box-thin { background: rgba(255,255,255,0.02); border-radius: 6px; }
.progress-box { flex: 1; background: rgba(255,255,255,0.06); border-radius: 6px; overflow: hidden; height: 28px; position: relative; }
.progress-label { position: absolute; left: 8px; right: 8px; top: 53%; transform: translateY(-50%); font-weight: 700; color: white; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: clamp(0.8rem, 2.8vw, 0.95rem); }
.scroll-320 { max-height: 320px; overflow: auto; }
.font-bold { font-weight:700; }
.font-semibold { font-weight:600; }
.device-title { font-size:1.1rem; font-weight:600; }
.mt-5 { margin-top:20px; }
.mb-3 { margin-bottom: 0.75rem; }
.mt-10 { margin-top: 10px; }


.loader-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-main);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
  pointer-events: auto;
}

/* Désactiver les interactions quand le loader est affiché */
.body-disabled {
  pointer-events: none;
}
.loader-sun {
  position: relative;
  width: 80px;
  height: 80px;
  animation: spin 1.2s linear infinite;
}
.sun-core {
  width: 48px;
  height: 48px;
  background: radial-gradient(circle at 30% 30%, #64b5f6 80%, #2196f3 100%);
  border-radius: 50%;
  box-shadow: 0 0 30px 10px #64b5f6;
  position: absolute;
  top: 16px; left: 16px;
}
.sun-rays {
  position: absolute;
  top: 0; left: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  box-shadow:
    0 -40px 0 -20px #2196f3,
    0 40px 0 -20px #2196f3,
    40px 0 0 -20px #2196f3,
    -40px 0 0 -20px #2196f3,
    28px 28px 0 -20px #2196f3,
    -28px 28px 0 -20px #2196f3,
    28px -28px 0 -20px #2196f3,
    -28px -28px 0 -20px #2196f3;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Contenu du loader pour les actions */
.action-loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: white;
  text-align: center;
  max-width: 300px;
}

.action-loader-icon {
  font-size: 48px;
  animation: pulse 2s ease-in-out infinite;
}

.action-loader-text {
  font-size: 18px;
  font-weight: 500;
}

.action-loader-subtitle {
  font-size: 14px;
  opacity: 0.8;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Styles pour les boutons de période de tendance */
.trend-period-buttons .period-btn {
    transition: all 0.2s ease;
}

.trend-period-buttons .period-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #777;
}

.trend-period-buttons .period-btn.active {
    background: rgba(33, 150, 243, 0.2);
    border-color: #2196f3;
    color: #2196f3;
}

.trend-period-buttons .period-btn
{
padding: 2px 6px; font-size: 13px; border: 1px solid transparent; background: transparent; color: #ccc; border-radius: 3px;
}

/* Styles pour les couleurs de tendance */
.trend-period-buttons .period-btn.trend-up {
    background: rgba(76, 175, 80, 0.3)!important;
   
}

.trend-period-buttons .period-btn.trend-down {
    background: rgba(244, 67, 54, 0.3)!important;
   
}

.trend-period-buttons .period-btn.trend-flat {
    background: rgba(255, 152, 0, 0.3)!important;
  
}

/* Le bouton actif prend le dessus sur les couleurs de tendance */
.trend-period-buttons .period-btn.active.trend-up,
.trend-period-buttons .period-btn.active.trend-down,
.trend-period-buttons .period-btn.active.trend-flat {
    background: rgba(33, 150, 243, 0.4);
    border-color: #2196f3;
    color: #2196f3;
}

/* Message d'action temporaire */
.action-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 8px;
  padding: 16px 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.3s ease-out;
}

.action-message-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-message-text {
  color: white;
  font-size: 16px;
  font-weight: 500;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Forecast specific */
.forecast-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.forecast-table-header {
    display: grid;
    grid-template-columns: 90px 1fr 1fr;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.forecast-table-row {
    display: grid;
    grid-template-columns: 90px 1fr 1fr;
    gap: 12px;
    align-items: center;
    padding: 4px 0;
}

.forecast-date-col {
    text-align: right;
    padding-right: 8px;
}

.forecast-data-col {
    display: flex;
    align-items: center;
}

.forecast-column-title {
    font-size: 14px;
    margin: 0;
}

.forecast-detail-title {
    font-size: 14px;
    margin-bottom: 20px;
}

/* Container du graphique forecast avec hauteur responsive */
.forecast-chart-container {
    position: relative;
    width: 100%;
    height: 400px;
    margin-top: 1rem;
}

/* Mode responsive : chaque jour devient une carte avec date + 2 jauges */
@media (max-width: 768px) {

    .card-battery { width: 100%; }
    .forecast-table-header { display: none; }

    /* Empiler chaque jour sur une seule colonne */
    .forecast-table-row {
        grid-template-columns: 1fr;
        row-gap: 6px;
        padding: 8px 0;
        display:flex;
    }

    .forecast-date-col {
        text-align: left;
        padding-right: 0;
        font-weight: 600;
    }
    .forecast-date-col.date {
        display:none;
    }

    .forecast-data-col {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    /* Afficher les labels des colonnes (kWh / mm) au-dessus des jauges */
    .forecast-data-col::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        color: var(--color-muted);
        margin-bottom: 4px;
    }

    .progress-box { height: 26px; display: list-item;
        width: 100%; }

        .solar-fill, .rain-fill { display: list-item; }
    
    /* Graphique forecast : hauteur réduite sur mobile */
    .forecast-chart-container {
        height: 150px;
    }
}

/* Documentation specific */
.doc-content {
    padding: 0.5rem 0;
    max-height: 320px;
    overflow: auto;
}
.doc-pre {
    white-space: pre-wrap;
    font-size: 0.85rem;
    color: var(--color-muted);
}

/* Optimism indicator (colored circle) */
.optimism-indicator {
    display: inline-block;
    font-size: 3rem;
    line-height: 1;
    /* text-shadow: 0 0 10px currentColor, 0 0 20px currentColor; */
    animation: pulse 2s ease-in-out infinite;
}

.optimism-good {
    color: var(--color-success);
}

.optimism-warning {
    color: #ffa726;
}

.optimism-critical {
    color: var(--color-error);
}

.optimism-unknown {
    color: var(--color-muted);
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}



/* ========== Custom Tooltips (Infobulles personnalisées) ========== */
.tooltip-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

/* Ancienne infobulle hover remplacée par overlays modales au clic */
.custom-tooltip { display:none; }

.custom-tooltip-wide {
    min-width: 380px;
    max-width: 450px;
}

/* ===== Overlay plein écran pour détails (click) ===== */
.tooltip-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 2rem 1rem;
    opacity: 0;
}

.tooltip-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
    width: 100%;
    max-width: 700px;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55);
    overflow-y: auto;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalFade 0.25s ease;
}

@keyframes modalFade {
    from { opacity:0; transform: translateY(12px) scale(.96); }
    to { opacity:1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg,#0f3460 0%, #16213e 100%);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.modal-header h3 { margin:0; font-size:1.1rem; font-weight:600; flex:1; }
.modal-close-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color:#fff;
    border-radius: 40px;
    width:36px; height:36px;
    cursor:pointer;
    font-size:1rem;
    display:flex; align-items:center; justify-content:center;
    transition: background .2s, color .2s;
}
.modal-close-btn:hover { background:#ff5252; border-color:#ff5252; }

.modal-body { padding: 12px 20px 20px; overflow-y:auto; }
.modal-sections { display:grid; gap:14px; }

.modal-section { background: rgba(255,255,255,0.03); padding:12px 14px; border-radius:10px; border:1px solid rgba(255,255,255,0.05); }
.modal-section h4 { margin:0 0 8px; font-size:.85rem; text-transform:uppercase; letter-spacing:.5px; color:#64b5f6; }
.modal-items { display:flex; flex-direction:column; gap:6px; }
.modal-item { display:flex; justify-content:space-between; font-size:.85rem; }
.modal-item .label { color:#b0b0b0; }
.modal-item .value { font-family: 'Courier New', monospace; font-weight:600; }

.modal-footer { margin-top:4px; padding:7px 20px; background: linear-gradient(135deg,#0a1929 0%, #0f3460 100%); border-top:1px solid rgba(255,255,255,0.08); display:flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px; }
.modal-balance { font-size:1.05rem; font-weight:700; }
.modal-footer-score { 
    font-size:1.1rem; 
    font-weight:700; 
    padding: 6px 16px;
    border-radius: 20px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.score-up { 
    background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 200, 83, 0.4);
}

.score-down { 
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.4);
}

.score-good { 
    background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 200, 83, 0.4);
}

.score-warning { 
    background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
}

.score-critical { 
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.4);
}

.score-neutral { 
    background: linear-gradient(135deg, #616161 0%, #757575 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(97, 97, 97, 0.4);
}

.value-positive { color:#00e676 !important; }
.value-negative { color:#ff5252 !important; }

@media (max-width: 768px){

   .card-header.automations-header {display: block;}

    .tooltip-overlay { 
        padding:0; 
        align-items: stretch;
    }
    .tooltip-modal { 
        border-radius:0; 
        max-height:100vh; 
        height: 100vh;
        max-width: 100%;
        width: 100%;
    }
    .modal-body { 
        padding:14px 16px 24px; 
        flex: 1;
        overflow-y: auto;
    }
    .modal-header {
        padding: 20px;
        min-height: 60px;
    }
    .modal-header h3 {
        font-size: 1.2rem;
    }
    .modal-close-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    .modal-footer {
        padding: 7px 20px;
    }

     .header h1 {
        font-size: 1.125rem;
    }
    .card {
        padding: 1rem;
    }
    .card h2 {
        font-size: 1.25rem;
    }
    .measure {
        padding: 0.375rem;
    }
    .grid {
  column-count: 1;
  column-gap: 1rem;
    }

    .automations-header .row.gap-2.align-center {
        width: 100%;
    }

    /* Mini-cartes indicateurs: 2 colonnes en responsive */
    .grid-indicators {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* La carte Batterie occupe toute la largeur en mobile */
    .grid-indicators .card-battery {
        grid-column: 1 / -1;
    }

    /* Bloc Automatisations : mettre les contrôles sous le titre sur mobile */
    .automations-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .automations-header .row.gap-2.w-100 {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .automations-header code {
        font-size: 0.75rem;
    }
}

/* Flèche de l'infobulle */
.custom-tooltip::after {
    content: "";
    
    border: 8px solid transparent;
    border-top-color: #1a1a2e;
}

/* En-tête de l'infobulle */
.tooltip-header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.tooltip-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.tooltip-title {
    font-weight: 600;
    font-size: 1rem;
    flex: 1;
    color: #ffffff;
}

.tooltip-score {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.score-positive {
    background: linear-gradient(135deg, #00c853 0%, #00e676 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 200, 83, 0.3);
}

.score-negative {
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.score-neutral {
    background: linear-gradient(135deg, #ff9800 0%, #ffa726 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

/* Sections de l'infobulle */
.tooltip-section {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tooltip-section:last-child {
    border-bottom: none;
}

.tooltip-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #64b5f6;
    font-weight: 600;
    font-size: 0.9rem;
}

.section-icon {
    font-size: 1.2rem;
}

.section-title {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
}

/* Items de données */
.tooltip-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0px 0;
    gap: 0px;
}

.item-label {
    color: #b0b0b0;
    font-size: 0.85rem;
    flex: 1;
}

.item-value {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: right;
    font-family: 'Courier New', monospace;
}

.value-positive {
    color: #00e676 !important;
}

.value-negative {
    color: #ff5252 !important;
}

/* Footer de l'infobulle */
.tooltip-footer {
    background: linear-gradient(135deg, #0a1929 0%, #0f3460 100%);
    padding: 12px 16px;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.tooltip-footer .tooltip-item {
    padding: 0;
    font-size: 0.95rem;
}

.tooltip-footer .item-label {
    color: #ffffff;
    font-weight: 600;
}

.tooltip-footer .item-value {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Animation d'apparition */
@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(0%) translateY(5px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(-87%) translateY(-80%) scale(1);
    }
}

/* Mode hover legacy supprimé */

/* Responsive : ajuster la position sur mobile */
@media (max-width: 768px) { .container {max-width: 100%;} }


.special {    box-shadow: none!important;  border-color: silver!important; color: silver!important; }

.special:hover {  box-shadow: none!important;  background-color: silver!important;    border-color: silver!important; color: black!important; }


.success-btn.special:hover {  box-shadow: none!important;  background-color: var(--color-success)!important;    border-color: var(--color-success)!important; color: white!important; });    border-color: silver!important; color: black!important; }
.alert-btn.special:hover { box-shadow: none!important;   background-color: var(--color-error)!important;    border-color: var(--color-error)!important; color: white!important; }

/* Styles pour la card d'erreurs système */
.error-card {
    background: transparent;
    border: 0px solid var(--color-error);
    border-radius: var(--radius);
    padding: 0rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
   
}

.error-card-single {
    margin-left: auto;
    margin-right: auto;
}

.error-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: var(--color-error);
    font-weight: 600;
}

.error-header svg {
    flex-shrink: 0;
}

.error-title {
    font-size: 1.1rem;
}

.error-list {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
        display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.tooltip-overlay .special { 
    padding: 0px 6px;
}
.tooltip-overlay .special.active, .tooltip-overlay .special:hover { 
    background-color: black!important;    
    color: white!important; 
}
.error-item {
    padding: 0.5rem;
    border-radius: 6px;
    border-left: 3px solid;
}

.error-critical {
    background: rgba(255, 82, 82, 0.1);
    border-left-color: var(--color-error);
}

.error-warning {
    background: rgba(255, 152, 0, 0.1);
    border-left-color: #ff9800;
}

.error-message {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Responsive pour la card d'erreur */
@media (max-width: 768px) {
    .error-card {
        margin: 0 1rem 1rem 1rem;
    }
    
    .error-card-single {
        margin: 0 1rem 1rem 1rem;
        max-width: none;
    }
}

/* Air Quality Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.period-selector {
    color: var(--color-text);
    border-radius: 8px;
    padding: 0px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}



.badge-error {
    background: var(--color-error);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.period-selector:focus {
    outline: none;
    border-color: var(--color-success);
}

/* Barre de progression perpétuelle en bas de l'écran */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: white;
    border-top: 3px solid black;
    transform-origin: left;
    animation: progress 30s linear infinite;
    display:none;
}

@keyframes progress {
    0% {
        transform: scaleX(0);
    }
    100% {
        transform: scaleX(1);
    }
}
