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

body {
  font-family: 'Share Tech Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 20;
  gap: 4px;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-logo {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.6rem;
  color: var(--cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(0,229,255,.35);
  margin-bottom: 12px;
  writing-mode: horizontal-tb;
  text-decoration: none;
  transition: opacity .15s;
}
.sidebar-logo:hover { opacity: .7; }

.nav-item {
  width: 85%;
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: 10px;
  color: var(--dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: .3px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: color .15s, background .15s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-item .ico { font-size: 1.5rem; line-height: 1; }

.nav-item:hover  { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active {
  background: rgba(0,229,255,.1);
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  box-shadow: inset 0 0 8px rgba(0,229,255,.1);
}
.nav-item.active .ico { color: var(--cyan); }

/* ── Main content ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 14px;
  min-height: 100dvh;
  animation: fadeIn .18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* ── Topbar ── */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -14px -14px 14px -14px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0,229,255,.35);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logout-btn {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.88rem;
  letter-spacing: 1px;
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
}

.logout-btn:hover { background: rgba(255,61,107,.12); border-color: var(--red); color: var(--red); }

#clock      { font-size: 0.94rem; color: var(--dim); line-height: 1; }

/* ── Cards ── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 0.73rem;
  letter-spacing: 3px;
  color: var(--dim);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.98rem;
}
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--dim); }
.info-val  { color: var(--text); }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

/* ── Relay / Toggle ── */
.relay-big {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.relay-big.on { border-color: rgba(0,255,136,.4); background: rgba(0,255,136,.04); }

.rb-name  { font-size: 1.13rem; }
.rb-state { font-family: 'Orbitron', sans-serif; font-size: 0.88rem; margin-top: 5px; color: var(--dim); }
.relay-big.on .rb-state { color: var(--green); }

.tog {
  width: 54px; height: 30px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  transition: background .2s, border-color .2s;
  pointer-events: none;
  flex-shrink: 0;
}
.tog::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--dim);
  top: 3px; left: 4px;
  transition: left .2s, background .2s, box-shadow .2s;
}
.relay-big.on .tog { background: rgba(0,255,136,.15); border-color: var(--green); }
.relay-big.on .tog::after { left: 27px; background: var(--green); box-shadow: 0 0 8px rgba(0,255,136,.6); }

.relay-row { display: flex; gap: 8px; }
.relay-chip {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.relay-chip .rc-label { font-size: 0.73rem; color: var(--dim); letter-spacing: 1px; }
.relay-chip .rc-val   { font-family: 'Orbitron', sans-serif; font-size: 1.06rem; margin-top: 4px; color: var(--dim); }
.relay-chip.on { border-color: rgba(0,255,136,.4); background: rgba(0,255,136,.05); }
.relay-chip.on .rc-val { color: var(--green); text-shadow: 0 0 6px rgba(0,255,136,.4); }

/* ── Buttons ── */
.seg { display: flex; gap: 8px; margin: 8px 0; }
.seg-btn {
  flex: 1;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all .15s;
}
.seg-btn.active { background: rgba(0,229,255,.12); border-color: var(--cyan); color: var(--cyan); }

.act-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.9rem;
  letter-spacing: 1px;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .15s;
}
.act-btn:active { opacity: .7; }
.act-btn.g { background: rgba(0,255,136,.15);  color: var(--green);  border: 1px solid rgba(0,255,136,.3); }
.act-btn.o { background: rgba(255,149,0,.15);  color: var(--orange); border: 1px solid rgba(255,149,0,.3); }
.act-btn.r { background: rgba(255,61,107,.15); color: var(--red);    border: 1px solid rgba(255,61,107,.3); }

.inp-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.inp-row label { font-size: 0.85rem; color: var(--dim); min-width: 90px; }
.inp-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.94rem;
  padding: 5px 8px;
  border-radius: 6px;
  width: 130px;
}
.inp-row input:focus { outline: none; border-color: var(--cyan); }

/* ── Gauges / Arcs SVG ── */
.kpi-arc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 4px;
  text-align: center;
}
.arc-label { font-size: 0.73rem; letter-spacing: 2px; color: var(--dim); margin-top: 2px; }
.arc-val   { font-family: 'Orbitron', sans-serif; font-size: 1.4rem; fill: var(--cyan); text-anchor: middle; dominant-baseline: central; }
.arc-unit  { font-size: 0.85rem; fill: var(--dim); }

.acs { fill: none; stroke: #000; stroke-width: 16; stroke-linecap: round; stroke-dasharray: 314.2 62.8; }
.act { fill: none; stroke: #1a2035; stroke-width: 10; stroke-linecap: round; stroke-dasharray: 314.2 62.8; }
.acf { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.acf.cyan   { stroke: var(--cyan); }
.acf.green  { stroke: var(--green); }
.acf.heat   { stroke: var(--green); }
.acf.ram    { stroke: var(--cyan); }
.acf.orange { stroke: var(--orange); }

.gauge { margin: 6px 0 2px; }
.gauge-track  { height: 10px; background: #0d1628; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.gauge-fill   { height: 100%; border-radius: 5px; background: linear-gradient(to right, var(--cyan), var(--green)); transition: width .6s ease; }
.gauge-fill.heat { background: linear-gradient(to right, var(--green), var(--orange)); }
.gauge-fill.ram  { background: linear-gradient(to right, var(--cyan), var(--orange)); }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge.ok  { background: rgba(0,255,136,.15); color: var(--green); border: 1px solid rgba(0,255,136,.25); }
.badge.off { background: rgba(255,61,107,.12); color: var(--red);  border: 1px solid rgba(255,61,107,.25); }
.badge.cyan-ok { background: rgba(0,229,255,.15); color: var(--cyan); border: 1px solid rgba(0,229,255,.25); }

/* ── RSSI ── */
.rssi-bar  { display: inline-block; width: 56px; height: 6px; background: var(--border); border-radius: 3px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.rssi-fill { height: 100%; border-radius: 3px; background: var(--green); transition: width .5s; }

/* ── LED slider ── */
.led-slider { width: 100%; accent-color: var(--cyan); margin: 10px 0; cursor: pointer; }

/* ── Misc ── */
.pc-stat     { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.pc-stat-key { font-size: 0.81rem; color: var(--dim); }
.pc-stat-val { font-size: 0.94rem; font-family: 'Orbitron', sans-serif; transition: color .4s; }
.pc-footer   { text-align: center; font-size: 0.69rem; color: var(--dim); padding: 4px 0 8px; }

#msg { text-align: center; font-size: 0.81rem; color: var(--dim); padding: 6px 0; min-height: 22px; }

/* ════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════ */

/* ── Tablette (< 900px) — sidebar icônes seulement ───── */
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }

  .nav-item {
    width: 52px;
    font-size: 0;
  }
  .nav-item .ico { font-size: 1.5rem; }
  .sidebar-logo { display: none; }
}

/* ── Mobile (< 600px) — navbar en bas ────────────────── */
@media (max-width: 600px) {
  :root { --sidebar-w: 0px; }

  body { flex-direction: column; padding-bottom: 70px; }

  .sidebar {
    width: 100%;
    height: 64px;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-logo { display: none; }

  .nav-item {
    width: 52px;
    min-width: 52px;
    height: 52px;
    flex-shrink: 0;
  }
  .nav-item .ico { font-size: 1.3rem; }

  .main {
    margin-left: 0;
    padding: 10px;
  }

  .topbar {
    margin: -10px -10px 10px -10px;
  }

  .grid2 {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  /* Arcs SVG plus petits sur mobile */
  .kpi-arc svg {
    width: 120px;
    height: 120px;
  }

  /* Cards plus compactes */
  .card { padding: 10px; }

  /* Inputs pleine largeur */
  .inp-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .inp-row input { width: 100%; }

  /* Segments */
  .seg-btn { font-size: 0.75rem; padding: 6px 4px; }

  /* AC icon row */
  .ac-icon-btn { font-size: 1.4rem; }
}
