
* { box-sizing: border-box; }
body {
    font-family: Arial, sans-serif;
    background: linear-gradient(#000033,#77b5fe,#000033);
    background-attachment: fixed;
    color: #ffffff;
    margin: 0;
    padding: 10px 5px;
    text-align: center;
    width: 100%;
    max-width: 100%;
}
.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: rgba(18,18,30,0.95);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #333;
}
h1 { color: #77b5fe; text-align: center; margin: 8px 0 2px; font-size: 1.5em; }
h2 { color: #77b5fe; text-align: center; margin: 10px 0 8px; font-size: 1.2em; border-bottom: 1px solid #333; padding-bottom: 6px; }
.version { text-align: center; font-size: 0.82em; color: #888; margin-top: 0; margin-bottom: 10px; }
.version span { font-weight: bold; color: #77b5fe; }
/* Pastille de liaison : verte tant que /json repond, rouge des qu'il ne repond plus */
.link-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #666; margin-right: 4px; vertical-align: middle; }
.link-dot.ok { background: #4caf50; box-shadow: 0 0 5px rgba(76,175,80,0.8); }
.link-dot.ko { background: #e53935; box-shadow: 0 0 5px rgba(229,57,53,0.8); }
/* Deux onglets : la barre occupe toute la largeur de la page */
.onglets { width: 100%; max-width: 100%; margin: 6px auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.Bonglet { border: none; background-color: rgba(255,255,255,0.08); border-radius: 6px; padding: 8px 6px; min-width: 0; min-height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #ccc; text-decoration: none; text-align: center; font-size: 0.95em; font-weight: 500; line-height: 1.1; transition: background 0.2s, color 0.2s; }
.Bonglet:hover { background-color: rgba(255,255,255,0.15); color: #fff; }
.Bonglet.active { background-color: #007bff; color: #fff; font-weight: bold; }
.Bonglet.active:hover { background-color: #0069d9; }
#pied { display: flex; justify-content: space-between; font-size: 11px; margin-top: 12px; padding-top: 8px; border-top: 1px solid #333; color: #666; }
.section { display: none; padding: 10px 0; margin-top: 0; background-color: transparent; width: 100%; }
.section.active { display: block; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
p { margin: 4px 0; }
span { font-weight: bold; color: #77b5fe; }
a:link { color: #aaf; text-decoration: none; }
a:visited { color: #ccf; text-decoration: none; }
form { margin-top: 10px; padding: 8px 5px; border: none; border-radius: 0; background-color: transparent; width: 100%; }
form label { display: block; margin-bottom: 3px; font-weight: bold; }
form input[type='text'], form input[type='password'], form input[type='number'], form input[type='file'] {
    width: 100%; padding: 6px; margin-bottom: 6px; border: 1px solid #888; border-radius: 3px; box-sizing: border-box; background: #222; color: #fff;
}
button {
    background-color: #333; color: white; border: 1px solid #555; border-radius: 4px; padding: 5px 10px; cursor: pointer; margin: 3px;
    width: auto; display: inline-block; font-size: 0.85em;
}
button:hover { background-color: #444; }
.info-text { background-color: rgba(62,194,247,0.3); border-left: 3px solid #77b5fe; padding: 6px; margin: 5px 0; font-size: 0.85em; color: #fff; }

/* ===== Cartes de statut ===== */
.status-box { padding: 12px 14px; border-radius: 8px; border: 1px solid; color: #ffffff; box-sizing: border-box; text-align: left; }
.status-box h3 { margin-top: 0; margin-bottom: 8px; font-size: 0.95em; color: #ffffff; font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 5px; }
.status-box p { margin: 4px 0; font-size: 0.9em; color: #ddd; }
.status-box span { color: #77b5fe; font-weight: bold; }
/* Strictement les 4 teintes des cartes du compteur d'eau (jaune, cyan, bleu, violet) */
.status-box-solaire { background-color: rgba(80, 60, 30, 0.85); border-color: rgba(255, 206, 86, 0.5); }
.status-box-batterie { background-color: rgba(30, 60, 60, 0.85); border-color: rgba(75, 192, 192, 0.5); }
.status-box-reseau { background-color: rgba(30, 50, 80, 0.85); border-color: rgba(54, 162, 235, 0.5); }
.status-box-energie { background-color: rgba(50, 30, 80, 0.85); border-color: rgba(153, 102, 255, 0.5); }
.status-box-pilotage { background-color: rgba(30, 60, 60, 0.85); border-color: rgba(75, 192, 192, 0.5); }
.status-box-systeme { background-color: rgba(50, 30, 80, 0.85); border-color: rgba(153, 102, 255, 0.5); }
.status-box-large { grid-column: 1 / -1; }
/* Sens de l'energie : vert = produit/fourni, orange = preleve au reseau, bleu = stocke */
.v-prod { color: #7dffb3 !important; }
.v-conso { color: #ffb74d !important; }
.v-charge { color: #64b5f6 !important; }
.v-off { color: #999 !important; }
/* Jauge de charge batterie */
.soc-bar { height: 14px; background: #1a1a28; border: 1px solid #444; border-radius: 4px; overflow: hidden; margin: 6px 0 8px; }
.soc-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2a8f5a, #4caf50); transition: width 0.4s, background 0.4s; }
.soc-fill.low { background: linear-gradient(90deg, #b71c1c, #e53935); }
.soc-fill.mid { background: linear-gradient(90deg, #ef6c00, #ffa726); }
/* Badge d'etat de marche de l'onduleur */
.runstate { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.82em; font-weight: bold; background: rgba(255,255,255,0.12); color: #ddd; }
.runstate.ok { background: rgba(76,175,80,0.25); color: #7dffb3; }
.runstate.warn { background: rgba(255,167,38,0.25); color: #ffb74d; }
.runstate.err { background: rgba(229,57,53,0.3); color: #ff8a80; }

/* ===== Carte Pilotage ===== */
.ctrl-modes { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 10px; }
.btn-mode { flex: 1 1 auto; min-width: 88px; padding: 6px 8px; font-size: 0.8em; background: rgba(255,255,255,0.08); color: #ccc; border: 1px solid #555; border-radius: 6px; cursor: pointer; margin: 0; transition: background 0.2s, color 0.2s, border-color 0.2s; }
.btn-mode:hover { background: rgba(255,255,255,0.18); color: #fff; }
.btn-mode.active { background: #1a6fd4; color: #fff; font-weight: bold; border-color: rgba(140,200,255,0.6); }
.ctrl-row { display: flex; align-items: center; gap: 5px; margin: 5px 0; flex-wrap: wrap; }
.ctrl-row label { flex: 0 0 auto; margin: 0; font-size: 0.82em; font-weight: bold; white-space: nowrap; }
.ctrl-row input[type='number'] { flex: 0 0 90px; min-width: 70px; padding: 4px 6px; margin: 0; border: 1px solid #666; border-radius: 4px; background: #1a1a2e; color: #fff; font-size: 0.82em; }
.ctrl-row button { flex: 0 0 auto; padding: 4px 10px; font-size: 0.78em; margin: 0; background-color: #28a745; color: #fff; border: 1px solid #218838; }
.ctrl-row button:hover { background-color: #218838; }
.ctrl-note { font-size: 0.76em; color: #999; margin-top: 6px; }

/* ===== Page Parametres : groupes repliables ===== */
#settings-section { padding: 5px 3px; margin-top: 8px; width: 100%; }
#settings-section h2 { margin: 0 0 8px 0; font-size: 1.1em; text-align: center; }
.settings-group { margin: 8px 0; border: 1px solid #444; border-radius: 8px; background: rgba(25,25,45,0.7); overflow: hidden; text-align: left; }
.settings-group summary { padding: 10px 12px; cursor: pointer; font-weight: bold; font-size: 0.95em; background: rgba(40,40,70,0.8); color: #77b5fe; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; border-bottom: 1px solid transparent; }
.settings-group[open] summary { border-bottom: 1px solid #555; }
.settings-group summary::-webkit-details-marker { display: none; }
.settings-group summary::after { content: '\25B6'; font-size: 0.65em; margin-left: auto; transition: transform 0.2s; }
.settings-group[open] summary::after { transform: rotate(90deg); }
.settings-group summary:hover { background: rgba(50,50,90,0.9); }
.settings-group.danger { border-color: rgba(198,40,40,0.6); }
.settings-group.danger summary { background: rgba(80,20,20,0.7); color: #ff8a80; }
.settings-group.danger summary:hover { background: rgba(100,25,25,0.8); }
.group-content { padding: 8px 10px; }
.group-content form { margin: 0; padding: 0; }
.group-content h4 { margin: 12px 0 4px 0; font-size: 0.85em; color: #aaa; border-bottom: 1px solid #444; padding-bottom: 3px; }
.group-content h4:first-child { margin-top: 2px; }
.settings-group .info-text { padding: 5px 8px; margin: 4px 0; font-size: 0.82em; }
.form-row { display: flex; align-items: center; gap: 5px; margin: 4px 0; flex-wrap: wrap; }
.form-row label { flex: 0 0 auto; margin: 0; font-size: 0.82em; font-weight: bold; white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.form-row input[type='text'], .form-row input[type='password'] { flex: 0 0 160px; min-width: 100px; max-width: 200px; padding: 4px 6px; border: 1px solid #666; border-radius: 4px; background: #1a1a2e; color: #fff; font-size: 0.82em; box-sizing: border-box; margin: 0; appearance: auto; }
.form-row input[type='number'] { flex: 0 0 80px; min-width: 60px; max-width: 100px; padding: 4px 6px; border: 1px solid #666; border-radius: 4px; background: #1a1a2e; color: #fff; font-size: 0.82em; box-sizing: border-box; margin: 0; appearance: auto; }
.form-row select { flex: 0 0 130px; min-width: 90px; max-width: 160px; padding: 4px 6px; border: 1px solid #666; border-radius: 4px; background: #1a1a2e; color: #fff; font-size: 0.82em; box-sizing: border-box; margin: 0; appearance: auto; }
.form-row input[type='file'] { flex: 0 0 auto; min-width: 0; max-width: 220px; padding: 4px 6px; font-size: 0.8em; color: #ccc; margin: 0; }
.form-row input:focus, .form-row select:focus { border-color: #77b5fe; outline: none; }
.form-row input[type='checkbox'] { accent-color: #28a745; width: 16px; height: 16px; cursor: pointer; flex: 0 0 auto; }
.form-row button { flex: 0 0 auto; padding: 4px 10px; font-size: 0.78em; margin: 0; background-color: #28a745; color: white; border: 1px solid #218838; border-radius: 4px; cursor: pointer; white-space: nowrap; min-width: 0; }
.form-row button:hover { background-color: #218838; }
.form-row .btn-neutre { background-color: #37474f; border-color: #546e7a; }
.form-row .btn-neutre:hover { background-color: #455a64; }
.form-action { margin: 6px 0 2px; display: flex; flex-wrap: wrap; gap: 6px; }
.form-action button { padding: 5px 12px; font-size: 0.8em; background-color: #28a745; color: white; border: 1px solid #218838; border-radius: 4px; cursor: pointer; width: auto; display: inline-block; }
.form-action button:hover { background-color: #218838; }
.form-action .btn-danger { background: #c62828; border-color: #e53935; }
.form-action .btn-danger:hover { background: #b71c1c; }
.current-val { font-size: 0.76em; color: #888; margin: 0; padding: 0 2px; flex: 0 0 auto; white-space: nowrap; display: inline; }
.current-val span { color: #77b5fe; font-weight: bold; }
/* Boutons radio en ligne (mode donnees, sujets MQTT, ecran) */
.radio-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0; }
.radio-line > label:first-child { flex: 0 0 auto; font-size: 0.82em; font-weight: bold; margin: 0; }
.radio-opt { display: flex; align-items: center; gap: 4px; font-size: 0.82em; color: #ccc; cursor: pointer; font-weight: normal; margin: 0; }
.radio-opt input[type='radio'] { accent-color: #28a745; width: 15px; height: 15px; cursor: pointer; margin: 0; }

/* ===== OTA ===== */
.ota-panel { border: 1px solid #555; border-radius: 6px; padding: 8px 10px; margin: 8px 0; font-size: 0.85em; box-sizing: border-box; }
.ota-panel h4 { margin: 0 0 4px; font-size: 1em; color: #77b5fe; }
.ota-ver { margin: 0 0 8px; color: #aaa; }
.ota-ver strong { color: #7dffb3; }
.ota-upload-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0; padding: 0; }
.ota-upload-form input[type="file"] { max-width: 100%; color: #ccc; font-size: 0.9em; width: auto; margin: 0; }
.btn-ota-update { padding: 5px 12px; font-size: 0.85em; background: #28a745; color: #fff; border: 1px solid #218838; border-radius: 4px; cursor: pointer; }
.btn-ota-update:hover { background: #218838; }
.btn-ota-update:disabled { opacity: 0.5; cursor: not-allowed; }
.ota-progress-wrap { max-width: 400px; margin: 6px 0; }
.ota-progress-label { font-size: 0.82em; color: #77b5fe; margin-bottom: 2px; text-align: center; }
.ota-progress-track { height: 14px; background: #1a1a28; border-radius: 3px; overflow: hidden; border: 1px solid #444; }
.ota-progress-bar { height: 100%; width: 0%; background: #2a8f5a; transition: width 0.1s; }
.ota-status { text-align: center; font-weight: bold; min-height: 1.1em; margin: 4px 0; font-size: 0.85em; color: #9cf; }

/* ===== Tablette et mobile ===== */
@media (max-width: 768px) {
    body { padding: 5px 3px; }
    .container { padding: 8px 6px; border: none; border-radius: 0; }
    h1 { font-size: 1.3em; margin: 3px 0; }
    h2 { font-size: 1.1em; margin: 4px 0; }
    .onglets { max-width: 100%; gap: 4px; }
    .Bonglet { padding: 6px 4px; min-height: 32px; font-size: 0.85em; }
    .status-grid { grid-template-columns: 1fr; gap: 6px; }
    .status-box { padding: 8px 10px; }
    .status-box h3 { font-size: 0.9em; }
    .status-box p { font-size: 0.85em; margin: 2px 0; }
    form { padding: 5px 3px; }
    button { padding: 5px 8px; font-size: 0.85em; }
    .settings-group { margin: 5px 0; -webkit-tap-highlight-color: transparent; }
    .settings-group summary { -webkit-touch-callout: none; }
    .btn-mode { min-width: 78px; font-size: 0.76em; }
}
@media (max-width: 480px) {
    body { padding: 3px 2px; }
    .container { padding: 4px 3px; }
    h1 { font-size: 1.1em; }
    h2 { font-size: 1em; }
    .Bonglet { padding: 5px 3px; min-height: 30px; font-size: 0.8em; }
    .form-row { flex-wrap: wrap; }
    .form-row label { flex: 0 0 100%; }
    .form-row input[type='text'], .form-row input[type='password'] { flex: 1 1 110px; min-width: 80px; max-width: 100%; }
    .form-row select { flex: 1 1 110px; min-width: 80px; max-width: 100%; }
    .current-val { margin-left: 0; }
    .ctrl-modes { gap: 4px; }
    .btn-mode { flex: 1 1 44%; min-width: 0; font-size: 0.74em; }
}
