/* =================================================================
   Smooth scroll (style index.olution.info) — ancres fluides
================================================================= */
html {
    scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* =================================================================
   Barre de progression au scroll (style index.olution.info)
================================================================= */
#scroll-progress.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary, #008B74), var(--accent-primary-hover, #00A896));
    z-index: 9999;
    transition: width 0.1s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    #scroll-progress.scroll-progress { display: none !important; }
}

[data-theme="dark"] .value-updated {
    animation: glowValueDark 0.8s ease-in-out;
}

@keyframes glowValueDark {
    0%, 100% { box-shadow: 0 0 0 rgba(0, 255, 200, 0); }
    50% { box-shadow: 0 0 14px rgba(0, 255, 200, 0.4); }
}

/* =================================================================
   TYPOGRAPHIE n³ — Raleway (titres), Cabin (corps)
================================================================= */
body,
body input,
body select,
body textarea {
    font-family: 'Cabin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

body h1,
body h2,
body h3,
body h4,
body h5,
body h6,
#header .logo,
#nav ul.links,
button,
.button,
label {
    font-family: 'Raleway', Helvetica, sans-serif !important;
}

/* Labels checkbox/radio : Cabin (corps) pour cohérence */
input[type="checkbox"] + label,
input[type="radio"] + label {
    font-family: 'Cabin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* =================================================================
   HERO UNIFIÉ (aquaponie, MSP1, N3PP)
   Style moderne commun : gradient, motif, titre orange, synthèse centrée
================================================================= */
.modern-header {
    background: linear-gradient(145deg, #008B74 0%, #007A61 25%, #00B794 50%, #008B74 100%);
    color: white;
    padding: 58px 0;
    margin: -20px -20px 0 -20px;
    position: relative;
    overflow: hidden;
    border-radius: 0 0 16px 16px;
}
.modern-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="g" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="0.5"/></pattern></defs><rect width="100" height="100" fill="url(%23g)"/></svg>');
    opacity: 0.2;
}
.header-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}
.header-title {
    font-family: "Raleway", "Source Sans Pro", Helvetica, sans-serif;
    font-size: 3.5em;
    font-weight: bold;
    margin: 0 0 15px 0;
    color: #FF6300 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}
.header-title i {
    font-size: 0.8em;
}
.header-title i.header-icon-float {
    animation: heroIconFloat 3s ease-in-out infinite;
}
@keyframes heroIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.header-subtitle {
    font-size: 1.3em;
    margin: 0 0 1.25rem 0;
    opacity: 0.9;
    font-weight: 300;
    line-height: 1.6;
    text-align: center;
}
.header-synthesis {
    margin: 0 0 1rem 0;
    font-size: 0.95em;
    padding: 10px 18px;
    background: rgba(255,255,255,0.18);
    border-radius: 12px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    backdrop-filter: blur(6px);
}
.header-more {
    margin-top: 1rem;
    opacity: 0.95;
    text-align: center;
}
.header-more a {
    display: inline-block;
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.header-more a:hover {
    color: #FF6300 !important;
    background: rgba(255,255,255,0.2);
    border-color: #FF6300;
    opacity: 1;
}
article.post.featured > h2:first-of-type,
.synthesis-title {
    text-align: center;
}
/* Réduire l'espace entre hero et premier bloc de contenu */
.modern-header + article.post.featured > .section-header:first-of-type,
.modern-header + article.post.featured > .alt-section-title-full:first-of-type {
    margin-top: 0 !important;
}
@media (max-width: 768px) {
    .modern-header { padding: 40px 0; margin: -20px -10px 0 -10px; }
    .header-title { font-size: 2.2em; gap: 12px; }
}
@media (max-width: 480px) {
    .modern-header { padding: 32px 0; margin: -20px -10px 0 -10px; }
    .header-title { font-size: 1.8em; }
}

/* Mode clair : titres hero, principaux et sections restent orange (surcharge main.css h1..h6 #212931) */
body:not([data-theme="dark"]) .modern-header .header-title,
body:not([data-theme="dark"]) .header-title {
    color: #FF6300 !important;
}
body:not([data-theme="dark"]) header.major h1,
body:not([data-theme="dark"]) header.major h2,
body:not([data-theme="dark"]) .section-header h2,
body:not([data-theme="dark"]) .section-header h3,
body:not([data-theme="dark"]) .home-section-header h2,
body:not([data-theme="dark"]) .filter-header h3,
body:not([data-theme="dark"]) .system-health-panel h3 {
    color: #FF6300 !important;
}

/* =================================================================
   FOND DE PAGE : IMAGE AQUAPONIE AVEC APPARITION EN FONDU
   Remplace le fond noir (main.css externe) sur toutes les pages.
   Regles renforcees pour aquaponie, aquaponie-alt, control, etc.
================================================================= */
html {
    min-height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
body {
    position: relative;
    background: transparent !important;
    min-height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Calque de fond en element reel (#page-bg) : non affecte par body.is-preload * { animation: none } de main.css */
#page-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--page-bg-color, #e8f4f2);
    background-image: url('../bg-aquaponie.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0;
    animation: bgFadeIn 1.2s ease-out forwards !important;
    pointer-events: none;
    transition: background-color 0.4s ease;
}
/* Overlay fondu mode sombre : transition en fondu au lieu d'un changement brutal */
#page-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.75) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
[data-theme="dark"] #page-bg {
    background-color: var(--page-bg-color);
}
[data-theme="dark"] #page-bg::after {
    opacity: 1;
}
@keyframes bgFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fallback body::before si #page-bg absent */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--page-bg-color, #e8f4f2);
    background-image: url('../bg-aquaponie.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -2;
    opacity: 0;
    animation: bgFadeIn 1.2s ease-out forwards !important;
    transition: background-color 0.4s ease;
}
body.is-preload::before {
    animation: bgFadeIn 1.2s ease-out forwards !important;
}

/* Mode sombre : photo de fond avec fondu noir (fallback) */
[data-theme="dark"] body::before {
    background-color: var(--page-bg-color);
    background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.75) 100%), url('../bg-aquaponie.png');
}

/* Wrapper semi-transparent pour laisser voir l'image de fond (fondu) sur les pages type controle */
/* Neutraliser le fond opaque et le calque sombre de main.css (#wrapper.fade-in:before { background: #1e252d }) */
#wrapper > .bg {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
}
#wrapper.fade-in::before,
body.is-preload #wrapper.fade-in::before {
    background: transparent !important;
    background-color: transparent !important;
}

/* Overlay léger pour lisibilité du contenu, sans masquer la photo de fond */
#wrapper.control-wrapper {
    background: var(--wrapper-control-bg, linear-gradient(180deg, rgba(248, 250, 252, 0.35) 0%, rgba(238, 242, 246, 0.4) 100%)) !important;
}

/**
 * Styles pour syst├¿me temps r├®el et PWA
 */

/* Logo header (image + IOT) */
#header .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
}
#header .logo img {
    height: 2rem;
    width: auto;
    display: block;
    vertical-align: middle;
}
#header .logo .logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.05em;
}

/* =================================================================
   TOAST NOTIFICATIONS
================================================================= */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    border-left: 4px solid #ccc;
}

.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    color: var(--footer-color, #6b7280);
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Types de toasts */
.toast-info {
    border-left-color: #3498db;
}

.toast-info .toast-icon {
    color: #3498db;
}

.toast-success {
    border-left-color: #27ae60;
}

.toast-success .toast-icon {
    color: #27ae60;
}

.toast-warning {
    border-left-color: #f39c12;
}

.toast-warning .toast-icon {
    color: #f39c12;
}

.toast-error {
    border-left-color: #e74c3c;
}

.toast-error .toast-icon {
    color: #e74c3c;
}

/* =================================================================
   BADGE LIVE - En haut à droite, sans chevaucher le menu dépliant
================================================================= */
#live-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
}

/* Sur mobile : décaler le badge à gauche du bouton Menu pour éviter le chevauchement */
@media screen and (max-width: 980px) {
    #live-badge {
        top: 12px;
        right: 100px;
    }
}

#live-badge i {
    font-size: 10px;
}

.badge-success {
    background: #27ae60;
    color: white;
}

.badge-warning {
    background: #f39c12;
    color: white;
}

.badge-danger {
    background: #e74c3c;
    color: white;
}

.badge-secondary {
    background: #95a5a6;
    color: white;
}

/* Animation pulse pour LIVE */
.badge-success {
    animation: pulse 2s infinite;
}

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

/* =================================================================
   DASHBOARD SYST├êME
================================================================= */
.system-health-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 139, 116, 0.15);
    border: 1px solid rgba(0, 139, 116, 0.1);
}

/* Titres de section « État du système » et « Filtrage des données » : style identique sur toutes les pages */
.system-health-panel h3,
.system-health-panel h4,
.system-health-panel .system-health-panel-title,
.filter-header h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.15em;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid #008B74;
    padding-bottom: 10px;
}
.system-health-panel h3 i,
.system-health-panel h4 i,
.system-health-panel .system-health-panel-title i,
.filter-header h3 i {
    color: #008B74;
}

/* Boutons « Afficher les mesures » et « Télécharger CSV » : toujours sur la même ligne, toutes pages */
.action-buttons {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}
/* Même style que « En savoir plus » (balance-reveal-btn) sur toutes les pages */
.action-buttons button {
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.9em;
    font-weight: 600;
    color: #008B74;
    background: rgba(0, 139, 116, 0.08);
    border: 1px solid rgba(0, 139, 116, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.action-buttons button:hover {
    background: rgba(0, 139, 116, 0.15);
    border-color: #008B74;
}

/* Presets de période (1h, 3h, 1j…) : centrés horizontalement dans le bloc */
.quick-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 12px;
    margin-top: 12px;
}

/* Durée de la fenêtre / Mesures chargées / Lectures live reçues : centrés horizontalement */
.period-info-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    margin-top: 12px;
}

.health-items {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-top: 12px;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.health-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #008B74;
}

.health-item-label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

.health-item-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #2c3e50;
}

.health-item-value .reading-ago {
    font-size: 1.1em;
    font-weight: 700;
    color: inherit;
}

.health-item-value .reading-timestamp {
    font-size: 0.6em;
    color: rgba(44, 62, 80, 0.7);
    display: block;
    margin-top: 4px;
    letter-spacing: 0.05em;
}

.health-item-value .reading-count {
    font-size: 1.2em;
}

.health-item-value .reading-hint {
    font-size: 0.6em;
    color: rgba(44, 62, 80, 0.6);
    margin-left: 6px;
}

.health-item-value .reading-none {
    font-size: 0.75em;
    font-weight: 500;
    color: rgba(114, 28, 36, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.95em;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.status-indicator i {
    font-size: 0.9em;
}

.status-indicator strong {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.8em;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: inherit;
    backdrop-filter: blur(6px);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: inherit;
}

.status-text span {
    font-size: 0.9em;
}

.status-online {
    background: #d4edda;
    color: #155724;
    box-shadow: 0 3px 10px rgba(21, 87, 36, 0.15);
}

.status-online i {
    color: #1d7a2c;
}

.status-offline {
    background: #f8d7da;
    color: #721c24;
    box-shadow: 0 3px 10px rgba(114, 28, 36, 0.15);
}

.status-offline i {
    color: #b02a37;
}

.status-warning {
    background: #fff4e5;
    color: #a05a00;
    box-shadow: 0 3px 10px rgba(160, 90, 0, 0.15);
}

.status-warning i {
    color: #ff8800;
}

.status-paused {
    background: #e2e3e5;
    color: #383d41;
    box-shadow: 0 3px 10px rgba(56, 61, 65, 0.15);
}

.status-paused i {
    color: #6c757d;
}

.status-error {
    background: #fbeaec;
    color: #b02a37;
    box-shadow: 0 3px 10px rgba(176, 42, 55, 0.2);
}

.status-error i {
    color: #dc3545;
}

.status-indicator.is-animated {
    animation: pulse-status 2.5s ease-in-out infinite;
}

@keyframes pulse-status {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

/* =================================================================
   COUNTDOWN NEXT UPDATE
================================================================= */
.next-update-countdown {
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

.next-update-countdown strong {
    color: #008B74;
}

/* =================================================================
   SPINNER DE RAFRA├ÄCHISSEMENT
================================================================= */
.refresh-spinner {
    display: inline-block;
    margin-left: 10px;
    color: #008B74;
    opacity: 0;
    transition: opacity 0.3s;
}

.refresh-spinner.active {
    opacity: 1;
    animation: spin 1s linear infinite;
}

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

/* =================================================================
   TOGGLE POLLING CONTROLS
================================================================= */
.polling-controls {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logs-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.logs-counter {
    font-size: 0.8em;
    font-weight: 600;
    background: rgba(0, 139, 116, 0.1);
    color: #006653;
    padding: 4px 10px;
    border-radius: 999px;
}

.log-entry {
    display: grid;
    grid-template-columns: 70px 26px 80px 1fr;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #f8f9fa;
    font-size: 0.85em;
    border: 1px solid #eef2f3;
}

.log-entry .log-time {
    font-family: 'Fira Mono', Consolas, monospace;
    color: var(--text-secondary, #6b7280);
    font-size: 0.8em;
}

.log-entry .log-icon {
    text-align: center;
    color: #008b74;
}

.log-entry .log-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #34495e;
}

.log-entry .log-message {
    color: #2c3e50;
    line-height: 1.3;
}

.log-entry.log-sync {
    border-left: 3px solid #3498db;
}

.log-entry.log-gpio {
    border-left: 3px solid #16a085;
}

.log-entry.log-error {
    border-left: 3px solid #e74c3c;
    background: #fbeaea;
}

.log-entry.log-warning {
    border-left: 3px solid #f39c12;
    background: #fff6e6;
}

.log-entry.log-info {
    border-left: 3px solid #2980b9;
}

.log-entry.log-status {
    border-left: 3px solid var(--text-secondary, #6b7280);
    font-style: italic;
}

.polling-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.polling-toggle label {
    margin: 0;
    cursor: pointer;
}


/* =================================================================
   SAVE INDICATORS (AUTO-SAVE FORM FIELDS)
================================================================= */
.save-indicator {
    display: block;
    min-height: 1.2em;
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text-secondary, #6b7280);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.save-indicator[data-state="saving"] {
    opacity: 1;
    transform: translateY(0);
    color: #2980b9;
}

.save-indicator[data-state="success"] {
    opacity: 1;
    transform: translateY(0);
    color: #27ae60;
}

.save-indicator[data-state="error"] {
    opacity: 1;
    transform: translateY(0);
    color: #c0392b;
}

.save-indicator.state-changed {
    animation: saveIndicatorPulse 0.45s ease;
}

@keyframes saveIndicatorPulse {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.polling-toggle input[type="checkbox"] {
    width: 40px;
    height: 20px;
    cursor: pointer;
}

.polling-interval-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.polling-interval-selector select {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* =================================================================
   RESPONSIVE MOBILE
================================================================= */
@media (max-width: 768px) {
    .toast-container {
        top: 60px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        font-size: 13px;
    }
    
    #live-badge {
        top: 10px;
        right: 95px; /* à gauche du bouton Menu */
        font-size: 10px;
        padding: 6px 12px;
    }
    
    .health-grid {
        grid-template-columns: 1fr;
    }
    
    .polling-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* =================================================================
   MODE SOMBRE (data-theme="dark")
================================================================= */
[data-theme="dark"] .toast {
    background: var(--toast-bg);
    color: var(--toast-text);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .toast-message {
    color: var(--toast-text, #ecf0f1);
}

[data-theme="dark"] .toast-close {
    color: #94a3b8;
}

[data-theme="dark"] .toast-close:hover {
    background: #334155;
    color: var(--toast-text);
}

[data-theme="dark"] .system-health-panel {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .system-health-panel h3,
[data-theme="dark"] .system-health-panel h4,
[data-theme="dark"] .system-health-panel .system-health-panel-title,
[data-theme="dark"] .filter-header h3 {
    color: var(--text-primary);
    border-bottom-color: var(--accent-primary);
}
[data-theme="dark"] .system-health-panel h3 i,
[data-theme="dark"] .system-health-panel h4 i,
[data-theme="dark"] .filter-header h3 i {
    color: var(--accent-primary);
}

[data-theme="dark"] .health-item {
    background: var(--bg-secondary);
    border-left-color: var(--accent-primary);
}

[data-theme="dark"] .health-item-label {
    color: var(--text-secondary);
}

[data-theme="dark"] .health-item-value {
    color: var(--text-primary);
}

[data-theme="dark"] .health-item-value .reading-timestamp,
[data-theme="dark"] .health-item-value .reading-hint {
    color: var(--text-secondary);
}

[data-theme="dark"] .health-item-value .reading-none {
    color: var(--text-muted);
}

[data-theme="dark"] .action-buttons button {
    color: var(--accent-primary);
    background: var(--accent-muted);
    border-color: var(--accent-border);
}
[data-theme="dark"] .action-buttons button:hover {
    background: var(--accent-muted);
    border-color: var(--accent-primary);
}

[data-theme="dark"] .next-update-countdown {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

[data-theme="dark"] .next-update-countdown strong {
    color: var(--accent-primary);
}

[data-theme="dark"] .refresh-spinner {
    color: var(--accent-primary);
}

/* Indicateurs de statut (En ligne, Hors ligne, etc.) — variantes mode sombre */
[data-theme="dark"] .status-online {
    background: rgba(45, 212, 191, 0.2);
    color: #5eead4;
    box-shadow: 0 3px 10px rgba(45, 212, 191, 0.2);
}

[data-theme="dark"] .status-online i {
    color: #2dd4bf;
}

[data-theme="dark"] .status-offline {
    background: rgba(248, 113, 113, 0.2);
    color: #fca5a5;
    box-shadow: 0 3px 10px rgba(248, 113, 113, 0.2);
}

[data-theme="dark"] .status-offline i {
    color: #f87171;
}

[data-theme="dark"] .status-warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fcd34d;
    box-shadow: 0 3px 10px rgba(251, 191, 36, 0.2);
}

[data-theme="dark"] .status-warning i {
    color: #fbbf24;
}

[data-theme="dark"] .status-paused {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .status-paused i {
    color: var(--text-muted);
}

[data-theme="dark"] .status-error {
    background: rgba(248, 113, 113, 0.2);
    color: #fca5a5;
    box-shadow: 0 3px 10px rgba(248, 113, 113, 0.2);
}

[data-theme="dark"] .status-error i {
    color: #f87171;
}

/* =================================================================
   ANIMATIONS MISE ├Ç JOUR TEMPS R├ëEL
================================================================= */
.value-updated {
    animation: glowValue 0.9s ease-in-out;
    background: linear-gradient(90deg, rgba(0, 139, 116, 0.12), rgba(0, 139, 116, 0));
}

@keyframes glowValue {
    0%, 100% { box-shadow: 0 0 0 rgba(0, 139, 116, 0); }
    50% { box-shadow: 0 0 22px rgba(0, 139, 116, 0.45); }
}

[data-theme="dark"] .value-updated {
    animation: glowValueDark 0.9s ease-in-out;
    background: linear-gradient(90deg, rgba(0, 255, 200, 0.15), rgba(0, 255, 200, 0));
}

@keyframes glowValueDark {
    0%, 100% { box-shadow: 0 0 0 rgba(0, 255, 200, 0); }
    50% { box-shadow: 0 0 22px rgba(0, 255, 200, 0.4); }
}

.progress-updated {
    transition: width 0.6s ease-out;
}

/* =================================================================
   CONTR├öLES MODE LIVE INT├ëGR├ëS (dans ├ëtat du syst├¿me)
================================================================= */
.live-controls-integrated {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.live-control-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    justify-content: space-around;
}

.live-control-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.live-control-item:last-child {
    border-right: none;
}

.live-control-label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

.live-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.live-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.live-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.live-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.live-toggle-switch input:checked + .live-toggle-slider {
    background-color: #008B74;
}

.live-toggle-switch input:checked + .live-toggle-slider:before {
    transform: translateX(20px);
}

.live-interval-selector {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85em;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.live-interval-selector:hover {
    border-color: #008B74;
}

.live-interval-selector:focus {
    outline: none;
    border-color: #008B74;
    box-shadow: 0 0 0 2px rgba(0, 139, 116, 0.1);
}

.live-refresh-button {
    padding: 6px 12px;
    background: #008B74;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.live-refresh-button:hover {
    background: #00B794;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 139, 116, 0.3);
}

.live-refresh-button:active {
    transform: translateY(0);
}

.live-stats-display {
    font-size: 0.85em;
    color: #666;
    display: flex;
    align-items: center;
    gap: 5px;
}

.live-stats-display i {
    color: #008B74;
}

.live-stats-value {
    font-weight: bold;
    color: #008B74;
}

.live-collapse-toggle {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    transition: all 0.2s;
}

.live-collapse-toggle:hover {
    color: #008B74;
}

/* Responsive */
@media (max-width: 768px) {
    .live-control-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .live-control-item {
        width: 100%;
        justify-content: space-between;
        padding: 10px 12px;
    }
    
    .live-control-label {
        font-size: 0.85em;
    }
    
    .live-toggle-switch {
        width: 40px;
        height: 22px;
    }
    
    .live-toggle-slider:before {
        height: 16px;
        width: 16px;
    }
    
    .live-toggle-switch input:checked + .live-toggle-slider:before {
        transform: translateX(18px);
    }
}

/* =================================================================
   Surcharges main.css pour dark mode
   (realtime-styles chargé après main.css)
================================================================= */
/* Body reste transparent pour laisser voir #page-bg (photo + fondu noir) en mode sombre */
[data-theme="dark"] body {
    background: transparent !important;
    color: var(--text-primary);
}

[data-theme="dark"] body a {
    color: var(--accent-primary) !important;
    border-bottom-color: var(--accent-border);
}

[data-theme="dark"] body a:hover {
    color: var(--accent-primary-hover) !important;
}

[data-theme="dark"] body strong,
[data-theme="dark"] body b {
    color: var(--text-primary);
}

[data-theme="dark"] body h1,
[data-theme="dark"] body h2 {
    color: var(--accent-secondary) !important;
}

[data-theme="dark"] body h3,
[data-theme="dark"] body h4,
[data-theme="dark"] body h5,
[data-theme="dark"] body h6 {
    color: var(--accent-primary) !important;
}

[data-theme="dark"] body input,
[data-theme="dark"] body select,
[data-theme="dark"] body textarea {
    color: var(--text-primary) !important;
}

[data-theme="dark"] body blockquote {
    border-left-color: var(--border-color) !important;
}

[data-theme="dark"] body code {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] body hr {
    border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] #main {
    background-color: var(--bg-main) !important;
}

[data-theme="dark"] #main > * {
    border-top-color: var(--border-color) !important;
}

[data-theme="dark"] #header,
[data-theme="dark"] #nav {
    color: var(--header-nav-text);
}
[data-theme="dark"] #header {
    /* Transparent : photo visible via #page-bg, comme en mode clair */
    background: transparent !important;
    background-image: none !important;
}
[data-theme="dark"] #nav {
    /* Barre opaque pour le menu uniquement */
    background: var(--header-nav-bg) !important;
    background-image: none !important;
    border-bottom: 1px solid var(--accent-border);
}

[data-theme="dark"] #header a,
[data-theme="dark"] #nav a {
    color: var(--header-nav-text) !important;
}

[data-theme="dark"] #header a:hover,
[data-theme="dark"] #nav a:hover {
    color: var(--header-nav-hover) !important;
}

[data-theme="dark"] #nav ul.links li.active {
    background-color: var(--header-nav-active-bg) !important;
}

[data-theme="dark"] #nav ul.links li.active a {
    color: var(--header-nav-active-text) !important;
}

[data-theme="dark"] #header .logo {
    border-color: var(--header-nav-text) !important;
}

[data-theme="dark"] #header .logo:hover {
    border-color: var(--header-nav-hover) !important;
    color: var(--header-nav-hover) !important;
}

[data-theme="dark"] #footer {
    color: var(--footer-color) !important;
}

/* Footer applicatif N3 IoT — override Massively, styles unifiés */
#footer.app-footer {
    display: block;
    text-align: center;
    padding: 20px 0;
    color: var(--footer-color, #6b7280);
    font-size: 0.9em;
    background: transparent;
    width: 100%;
    max-width: none;
    margin: 0 auto;
    cursor: default;
}
#footer.app-footer--elevated {
    padding: 1.5rem 2rem;
    margin-top: 2rem;
    border-top: 1px solid var(--footer-border-elevated, rgba(0, 139, 116, 0.15));
    background: var(--footer-bg-elevated, rgba(255, 255, 255, 0.92));
}

/* Espacement réduit entre les lignes du footer */
#footer.app-footer p,
#footer.app-footer--elevated p {
    margin: 2px 0;
    line-height: 1.4;
}

[data-theme="dark"] .live-controls-integrated {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .live-control-item {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .live-control-label {
    color: var(--text-secondary);
}

[data-theme="dark"] .live-stats-display {
    color: var(--text-secondary);
}

[data-theme="dark"] .live-interval-selector {
    background: var(--bg-input, var(--bg-secondary));
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .live-interval-selector:hover,
[data-theme="dark"] .live-interval-selector:focus {
    border-color: var(--accent-primary);
}

[data-theme="dark"] .live-collapse-toggle {
    color: var(--text-secondary);
}

[data-theme="dark"] .live-collapse-toggle:hover {
    color: var(--accent-primary);
}

[data-theme="dark"] .live-stats-display i,
[data-theme="dark"] .live-stats-value {
    color: var(--accent-primary);
}

[data-theme="dark"] .live-toggle-slider {
    background-color: var(--bg-secondary);
}

[data-theme="dark"] .live-toggle-slider:before {
    background-color: var(--text-primary);
}

[data-theme="dark"] .live-toggle-switch input:checked + .live-toggle-slider {
    background-color: var(--accent-primary);
}

[data-theme="dark"] .live-refresh-button {
    background: var(--accent-primary);
    color: var(--bg-card);
}

[data-theme="dark"] .live-refresh-button:hover {
    background: var(--accent-primary-hover, #34d399);
}

/* =================================================================
   Highcharts navigator — correctifs bugs connus
   (Highcharts issue #16901 : parent visibility:hidden non respecté)
================================================================= */
.highcharts-navigator {
    visibility: inherit !important;
}

/* =================================================================
   Scroll Reveal — animations d'apparition au défilement (remplace AOS)
   Implémentation native : Intersection Observer + CSS, pas de dépendance externe
   Sans JS : éléments visibles (pas de .js-scroll-reveal)
================================================================= */
.js-scroll-reveal [data-aos] {
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}
.js-scroll-reveal [data-aos="fade-up"] { opacity: 0; transform: translateY(40px); }
.js-scroll-reveal [data-aos="fade-up"].sr-visible { opacity: 1; transform: translateY(0); }
.js-scroll-reveal [data-aos="fade-down"] { opacity: 0; transform: translateY(-40px); }
.js-scroll-reveal [data-aos="fade-down"].sr-visible { opacity: 1; transform: translateY(0); }
.js-scroll-reveal [data-aos="fade-left"] { opacity: 0; transform: translateX(40px); }
.js-scroll-reveal [data-aos="fade-left"].sr-visible { opacity: 1; transform: translateX(0); }
.js-scroll-reveal [data-aos="fade-right"] { opacity: 0; transform: translateX(-40px); }
.js-scroll-reveal [data-aos="fade-right"].sr-visible { opacity: 1; transform: translateX(0); }
.js-scroll-reveal [data-aos="zoom-in"] { opacity: 0; transform: scale(0.92); }
.js-scroll-reveal [data-aos="zoom-in"].sr-visible { opacity: 1; transform: scale(1); }
.js-scroll-reveal [data-aos="fade-up"].sr-visible,
.js-scroll-reveal [data-aos="fade-down"].sr-visible,
.js-scroll-reveal [data-aos="fade-left"].sr-visible,
.js-scroll-reveal [data-aos="fade-right"].sr-visible,
.js-scroll-reveal [data-aos="zoom-in"].sr-visible {
    opacity: 1 !important;
}
/* Override is-preload pour [data-aos] — permet les transitions */
body.is-preload [data-aos] {
    transition: opacity 0.8s ease, transform 0.8s ease !important;
}
/* prefers-reduced-motion : pas d'animation, affichage direct */
@media (prefers-reduced-motion: reduce) {
    [data-aos] { opacity: 1 !important; transform: none !important; transition: none !important; }
    [data-aos].sr-visible { opacity: 1 !important; transform: none !important; }
}
/* Sans JS : pas de .js-scroll-reveal, donc [data-aos] garde le style par défaut (visible) */

/* =================================================================
   Back-to-top (fiche 03, ameliorations visuelles)
================================================================= */
.back-to-top {
    position: fixed;
    visibility: hidden;
    opacity: 0;
    right: 15px;
    bottom: 15px;
    z-index: 996;
    background: var(--accent-primary, #008B74);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: opacity 0.4s, visibility 0.4s, background 0.2s;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.back-to-top i {
    font-size: 1.25rem;
    line-height: 0;
}
.back-to-top:hover {
    background: var(--accent-primary-hover, #00A896);
    color: #fff;
}
.back-to-top.active {
    visibility: visible;
    opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
    .back-to-top { transition: none; }
}

/* =================================================================
   Liens underline animé (fiche 04) — contenu principal et footer, hors nav
================================================================= */
.header-content a,
.section-header a,
#main .post a,
#footer a {
    position: relative;
}
.header-content a::after,
.section-header a::after,
#main .post a::after,
#footer a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease-out;
}
.header-content a:hover::after,
.section-header a:hover::after,
#main .post a:hover::after,
#footer a:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}
@media (prefers-reduced-motion: reduce) {
    .header-content a::after,
    .section-header a::after,
    #main .post a::after,
    #footer a::after {
        transition: none;
    }
}

/* =================================================================
   Header au scroll — blur et fond semi-transparent (fiche 09)
================================================================= */
#header {
    transition: background 0.3s ease, backdrop-filter 0.3s ease;
}
#header.header-scrolled {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(30, 37, 45, 0.92);
}
[data-theme="dark"] #header.header-scrolled {
    background: rgba(15, 23, 42, 0.92);
}

