/* ============================================================
   style.css — Kutimo Hub v2.0
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:      #0f0f0f;
    --bg2:     #1a1a1a;
    --bg3:     #242424;
    --border:  #2e2e2e;
    --text:    #e8e8e8;
    --text2:   #9a9a9a;
    --accent:  #3B8BD4;
    --blue:    #3B8BD4;
    --orange:  #E8593C;
    --green:   #2ecc71;
    --red:     #e74c3c;
    --radius:  10px;
    --sidebar: 220px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* ── Layout app ───────────────────────────────────────────── */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    overflow-y: auto;
}

#sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 12px;
    border-bottom: 1px solid var(--border);
}

#logo {
    font-size: 17px;
    font-weight: 600;
    color: var(--accent);
}

/* ── Badge WS ─────────────────────────────────────────────── */
#ws-indicator {
    font-size: 9px;
    transition: color .3s;
    cursor: default;
}
#ws-indicator.ws-on  { color: var(--green); }
#ws-indicator.ws-off { color: var(--red); animation: wsBlink 1.2s infinite; }
@keyframes wsBlink { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ── Horloge & batterie ───────────────────────────────────── */
#time-display {
    font-size: 28px;
    font-weight: 300;
    text-align: center;
    padding: 12px 0 4px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

#bat-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 12px;
}
#bat-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
}
.bat-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width .5s;
}
.bat-fill.bat-low { background: var(--red); }
#bat-pct { font-size: 12px; color: var(--text2); min-width: 34px; text-align: right; }

/* ── Navigation ───────────────────────────────────────────── */
#nav-list {
    list-style: none;
    margin-top: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    color: var(--text2);
    font-size: 14px;
    transition: background .15s, color .15s;
    border-radius: 0;
    position: relative;
}
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--text); }
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px 0;
    font-size: 11px;
    color: var(--text2);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ── Contenu principal ────────────────────────────────────── */
#content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.page { display: none; }
.page.active { display: block; }

h1 {
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text);
}
h2 {
    font-size: 17px;
    font-weight: 500;
    margin-bottom: 12px;
}
h3 { font-size: 14px; font-weight: 500; margin: 12px 0 8px; }

/* ── Boutons ──────────────────────────────────────────────── */
button {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
button:hover  { background: var(--border); border-color: var(--text2); }
button:active { background: var(--bg2); }

/* ── Inputs ───────────────────────────────────────────────── */
input[type="text"],
input[type="number"],
input[type="password"],
textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    width: 100%;
    margin-bottom: 8px;
    outline: none;
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* Select iOS style natif amélioré */
select {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 36px 10px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    width: 100%;
    margin-bottom: 8px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239a9a9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
select:focus { border-color: var(--accent); }

/* Range sliders iOS style avec progression colorée */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    border: none;
    padding: 0;
    cursor: pointer;
    outline: none;
    background: linear-gradient(to right, var(--accent) 0%, var(--accent) 50%, var(--border) 50%, var(--border) 100%);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
    cursor: pointer;
    margin-top: -9px;
}
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
}
input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--border);
}
input[type="range"]::-moz-range-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--accent);
}


/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}
.tabs button {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--text2);
    padding: 8px 16px;
    font-size: 14px;
    margin-bottom: -1px;
}
.tabs button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Dashboard ────────────────────────────────────────────── */
.dash-section-title {
    font-size: 11px; font-weight: 600; color: var(--text2);
    letter-spacing: .08em; margin: 16px 0 10px;
}
.dash-topbar {
    display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.dash-kpi {
    flex: 1; min-width: 80px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px;
    display: flex; flex-direction: column; gap: 3px;
}
#dash-kpi-print { border-color: var(--accent); }
.dash-kpi-val {
    font-size: 20px; font-weight: 300; color: var(--text);
    font-variant-numeric: tabular-nums; line-height: 1;
}
.dash-kpi-sep { font-size: 13px; color: var(--border); margin: 0 3px; }
.dash-kpi-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }

/* Cards impressions actives */
#dash-active-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 12px; }
.dash-active-card {
    background: var(--bg2); border: 1px solid var(--accent);
    border-radius: var(--radius); padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
}
.dac-header { display: flex; align-items: center; gap: 8px; }
.dac-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-print  { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: dotPulse 1.5s infinite; }
.dot-pause  { background: var(--blue); }
.dot-online { background: var(--green); }
.dot-offline{ background: var(--border); }
@keyframes dotPulse { 0%,100%{opacity:1} 50%{opacity:.3} }
.dac-name { flex: 1; font-weight: 500; font-size: 14px; }
.dac-badge { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; background: rgba(59,139,212,.15); color: var(--accent); }
.dac-temps { display: flex; background: var(--bg3); border-radius: 8px; overflow: hidden; }
.dac-temp { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px; gap: 1px; }
.dac-sep { width: 1px; background: var(--border); margin: 6px 0; flex-shrink: 0; }
.dac-temp-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.dac-temp-val { font-size: 22px; font-weight: 300; line-height: 1; }
.dac-hotend { color: var(--accent); }
.dac-bed    { color: var(--blue); }
.dac-temp-target { font-size: 11px; color: var(--text2); }
.dac-prog-wrap { display: flex; flex-direction: column; gap: 5px; }
.dac-prog-bg { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.dac-prog-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s; min-width: 2px; }
.dac-prog-info { display: flex; justify-content: space-between; }
.dac-file { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.dac-pct  { font-size: 12px; font-weight: 500; color: var(--accent); }
.dac-btn-detail { font-size: 12px; padding: 5px 12px; background: transparent; border: 1px solid var(--border); color: var(--text2); align-self: flex-end; }
.dac-btn-detail:hover { color: var(--text); border-color: var(--text2); }
.dac-elapsed { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* Mini cards toutes imprimantes */
.dash-mini-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dash-mini-card {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; padding: 6px 14px; font-size: 13px;
}
.dmc-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dmc-name { font-weight: 500; }
.dmc-state{ color: var(--text2); font-size: 11px; }

/* Modules relais dashboard */
.dash-modules-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dash-relay-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; background: var(--bg2); border: 1px solid var(--border);
    border-radius: 20px; font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s;
}
.dash-relay-btn.relay-active { border-color: var(--green); background: rgba(46,204,113,.08); }
.relay-dot   { width: 8px; height: 8px; border-radius: 50%; transition: background .2s; }
.relay-name  { color: var(--text); }
.relay-state { font-size: 11px; color: var(--text2); margin-left: 2px; }

/* ── Dashboard config settings ─────────────────────────────── */
.dash-cfg-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.dash-cfg-label { font-size: 14px; color: var(--text); }

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-card-val { font-size: 26px; font-weight: 300; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-card-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }

/* ── Historique ────────────────────────────────────────────── */
.history-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; margin-bottom: 6px; }
.hr-file    { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hr-printer { color: var(--text2); white-space: nowrap; }
.hr-date    { color: var(--text2); font-size: 12px; white-space: nowrap; }
.hr-badge   { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.hr-ok      { background: rgba(46,204,113,.15); color: #2ecc71; }
.hr-fail    { background: rgba(231,76,60,.15); color: #e74c3c; }

/* ── Dashboard cards imprimantes ──────────────────────────── */
#dash-printers-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.dash-printer-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color .2s;
}
.dash-printer-card:has(.dot-printing) { border-color: var(--accent); }
.dash-printer-card:has(.dot-online)   { border-color: var(--border); }
.dash-printer-card:has(.dot-offline)  { opacity: .6; }

/* Header carte */
.dpc-header {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dpc-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background .3s;
}
.dpc-dot.dot-printing { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: dotPulse 1.5s infinite; }
.dpc-dot.dot-online   { background: var(--green); }
.dpc-dot.dot-offline  { background: var(--border); }
@keyframes dotPulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.dpc-name {
    flex: 1;
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dpc-state-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-printing { background: rgba(59,139,212,.18); color: var(--accent); }
.badge-idle     { background: rgba(46,204,113,.12); color: var(--green); }
.badge-offline  { background: var(--bg3); color: var(--text2); }

/* Températures */
.dpc-temps {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg3);
    border-radius: 8px;
    overflow: hidden;
}
.dpc-temp-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 10px;
    gap: 1px;
}
.dpc-temp-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
    flex-shrink: 0;
}
.dpc-temp-label {
    font-size: 10px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.dpc-temp-val {
    font-size: 20px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transition: color .3s;
}
.dpc-temp-target {
    font-size: 11px;
    color: var(--text2);
}

/* Progression */
.dpc-progress-wrap { display: flex; flex-direction: column; gap: 5px; }
.dpc-progress-bar-bg {
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
}
.dpc-progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .6s ease;
    min-width: 2px;
}
.dpc-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dpc-filename {
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.dpc-pct {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.dpc-elapsed {
    font-size: 11px;
    color: var(--text2);
}

/* Actions */
.dpc-actions { display: flex; justify-content: flex-end; }
.dpc-btn-detail {
    font-size: 12px;
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text2);
}
.dpc-btn-detail:hover { color: var(--text); border-color: var(--text2); }

/* ── Dashboard modules relais ─────────────────────────────── */
.dash-modules-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.dash-relay-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dash-relay-btn.relay-active {
    border-color: var(--green);
    background: rgba(46,204,113,.08);
}
.relay-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    transition: background .2s;
}
.relay-name { color: var(--text); }
.relay-state { font-size: 11px; color: var(--text2); margin-left: 2px; }

/* ── Liste imprimantes ────────────────────────────────────── */
.printer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.conn-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.conn-dot.connected { background: var(--green); }
.conn-dot.offline   { background: var(--red);   }
.printer-row-name   { flex: 1; font-weight: 500; }
.printer-status-label { font-size: 12px; color: var(--text2); }

/* ── Détail imprimante ────────────────────────────────────── */
.temps-row { display: flex; gap: 24px; margin-bottom: 16px; }
.prog-row  { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#detail-prog-bar-wrap { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
#detail-prog-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s; }
.ctrl-row  { display: flex; gap: 8px; margin-bottom: 16px; }
.speed-row, .fan-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 14px; }
#detail-gcode-wrap { display: flex; gap: 8px; margin-bottom: 16px; }
#detail-gcode-input { flex: 1; margin-bottom: 0; }
#detail-filename { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

/* ── Fichiers SD ──────────────────────────────────────────── */
.file-btn {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 4px;
    font-size: 13px;
}

/* ── Modules ──────────────────────────────────────────────── */
.module-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
}
.module-row span:first-child { flex: 1; }
.relay-btn { font-size: 13px; padding: 6px 14px; }
.relay-btn.relay-on { background: var(--green); border-color: var(--green); color: #000; }

/* ── Automatisations ──────────────────────────────────────── */
.auto-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
}
.auto-row span { flex: 1; font-size: 13px; }

/* ── Scheduler ────────────────────────────────────────────── */
.sched-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
}
.sched-row span:first-child { flex: 1; font-size: 13px; }
#sched-form {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
#sched-form input, #sched-form select { margin-bottom: 10px; }
#sched-hour, #sched-minute { width: auto; width: 70px; display: inline-block; margin-right: 8px; }

/* ── iOS Toggles ──────────────────────────────────────────── */
.ios-toggle {
    display: inline-block;
    width: 44px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background .2s;
    vertical-align: middle;
    flex-shrink: 0;
}
.ios-toggle::after {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    background: var(--text);
    border-radius: 50%;
    top: 3px; left: 3px;
    transition: transform .2s, background .2s;
}
.ios-toggle.toggle-on { background: var(--accent); }
.ios-toggle.toggle-on::after { transform: translateX(18px); }

/* ── Stat row ─────────────────────────────────────────────── */
.stat-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: var(--text2);
    margin-top: 12px;
}

/* ── History / logs ───────────────────────────────────────── */
.history-row {
    padding: 8px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 4px;
}
#logs-content, #stats-content {
    font-family: monospace;
    font-size: 12px;
    color: var(--text2);
    white-space: pre-wrap;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    max-height: 50vh;
    overflow-y: auto;
}

/* ── Modale confirm ───────────────────────────────────────── */
#modalOverlay {
    background: rgba(0,0,0,.6);
}
#modalBox {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 320px;
    width: 90%;
}
#modalMsg { margin-bottom: 16px; font-size: 15px; }
#modalBox div { display: flex; gap: 10px; justify-content: flex-end; }
#modalOk { background: var(--accent); border-color: var(--accent); color: #fff; }
#modalOk:hover { background: #c9482b; }

/* ── Caméra ───────────────────────────────────────────────── */
#cam-stream {
    width: 100%;
    max-width: 640px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
    margin-bottom: 12px;
    background: var(--bg3);
    min-height: 200px;
}


/* ── Upload gcode ─────────────────────────────────────────── */
#detail-upload-wrap { margin-top: 20px; }
#detail-upload-wrap h3 { margin-bottom: 10px; }

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    color: var(--text2);
    font-size: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: border-color .2s, background .2s;
    cursor: default;
}
.upload-dropzone.drag-over {
    border-color: var(--accent);
    background: rgba(59,139,212,.06);
}
.upload-file-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.upload-file-btn:hover { background: var(--border); }
.upload-fname {
    font-size: 12px;
    color: var(--accent);
    width: 100%;
    text-align: center;
}

.upload-bar-bg {
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
    margin: 10px 0 6px;
}
.upload-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .3s;
}
#upload-status {
    font-size: 12px;
    color: var(--text2);
}
#btn-upload-send {
    margin-top: 10px;
    width: 100%;
}
#btn-upload-send:disabled {
    opacity: .4;
    cursor: not-allowed;
}


/* ── Chart zoom slider ─────────────────────────────────────── */
.chart-controls { margin-bottom: 6px; }
.chart-zoom-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chart-zoom-label {
    font-size: 12px;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    min-width: 44px;
    text-align: right;
    font-weight: 500;
}
.chart-zoom-row input[type="range"] {
    flex: 1;
    height: 4px;
    margin: 0;
}
.chart-zoom-hint {
    font-size: 10px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ── Chart temp ───────────────────────────────────────────── */
#temp-chart {
    width: 100%;
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #111;
    display: block;
    max-width: 100%;
}

/* ── WiFi ─────────────────────────────────────────────────── */
#wifi-content p { margin-bottom: 8px; font-size: 14px; }
#wifi-scan-results { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }


/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-card-val {
    font-size: 28px;
    font-weight: 300;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat-card-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Historique rows ──────────────────────────────────────── */
.history-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 6px;
}
.hr-file    { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hr-printer { color: var(--text2); white-space: nowrap; }
.hr-date    { color: var(--text2); font-size: 12px; white-space: nowrap; }
.hr-badge   { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.hr-ok      { background: rgba(46,204,113,.15); color: #2ecc71; }
.hr-fail    { background: rgba(231,76,60,.15);  color: #e74c3c; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    :root { --sidebar: 56px; }
    .nav-item span:not(.nav-icon):not(.badge) { display: none; }
    .nav-item { justify-content: center; padding: 12px 0; }
    #logo, #bat-widget, #time-display { display: none; }
}

/* ── Night mode (classe sur body) ─────────────────────────── */
body.night-mode { filter: brightness(.6) sepia(.2); }
