/* EcoBox Innov NI — fond blanc, typographie système Apple (SF Pro), Inter en repli ; couleurs de la charte graphique EcoBox Innov */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --card: #f4f4f4; /* teinte claire du Gris Clair #E6E6E6 */
  --ink: #1d1d1f;
  --muted: #5f6368; /* Gris Structure */
  --line: #e6e6e6; /* Gris Clair */
  --accent: #2f7d32; /* Vert Écosystème */
  --accent-ink: #ffffff;
  --ok: #2f7d32;
  --warn: #c93400;
  --danger: #d70015;
  --off: #8e8e93;
  --cold: #1e4f91; /* Bleu Technologique : données, courbe et jauge */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Helvetica Neue", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; }
h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 2px; }
.title { font-size: 2.125rem; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; padding: 4px 4px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 4px; font-size: .9rem; }
.foot { margin-top: 4px; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 680px; margin: 0 auto; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 8px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1rem; letter-spacing: -0.02em; }
.brand img { width: auto; }
main { flex: 1; overflow-y: auto; padding: 0 16px 24px; }
.tab { display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--card); border-radius: 22px; padding: 20px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 500; padding: 5px 11px; border-radius: 99px; background: var(--card); color: var(--muted); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.pill.on i { background: var(--accent); }
.pill.warn i { background: #ff9f0a; }

nav {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  background: none; border: 0; color: var(--off); font: inherit; font-size: .68rem; font-weight: 500;
  padding: 8px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
nav button svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
nav button.on { color: var(--accent); }

/* Jauge */
.temp-card { padding-bottom: 16px; }
.gauge { position: relative; width: min(64vw, 250px); margin: 4px auto 0; aspect-ratio: 1; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 11; }
.gauge .track { stroke: var(--line); }
.gauge .arc { stroke: var(--off); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .6s, stroke .3s; }
.gauge.ok .arc { stroke: var(--cold); }
.gauge.warn .arc { stroke: #ff9f0a; }
.gauge.danger .arc { stroke: #ff3b30; }
.gauge-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.temp-value { font-size: 3.75rem; font-weight: 600; line-height: 1; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.temp-unit { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.temp-card p { margin-top: 8px; }

.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.status-line { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; margin: 0 0 16px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #c7c7cc; margin-top: 6px; flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 5px rgba(47, 125, 50, .18); }

/* Boutons */
.btn {
  width: 100%; padding: 14px 18px; border-radius: 14px; border: 0;
  background: var(--line); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(.985); opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 17px; font-size: 1.05rem; }
.btn.big.turn-on { background: var(--accent); color: #fff; }
.btn.big.turn-off { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.banner { border-radius: 18px; padding: 14px 18px; background: #fff1f0; color: #a4000f; font-weight: 500; }
.banner.warning { background: #fff6e5; color: #8a4b00; }
.banner strong { display: block; font-weight: 600; }
.banner strong + strong { margin-top: 4px; }

/* Consigne */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 12px; }
.stepper button {
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: #fff; color: var(--accent);
  font: inherit; font-size: 2rem; font-weight: 400; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px rgba(0, 0, 0, .04);
}
.stepper button:active { background: var(--line); }
.sp-val { text-align: center; font-variant-numeric: tabular-nums; }
.sp-val span { font-size: 3rem; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.sp-val small { font-size: 1.1rem; color: var(--muted); margin-left: 3px; }
.sp-val.dirty span { color: var(--accent); }
.presets { display: flex; gap: 8px; margin-bottom: 14px; }
.presets button {
  flex: 1; padding: 8px 4px; border-radius: 12px; border: 0; background: #fff; color: var(--ink);
  font: inherit; font-size: .8rem; font-weight: 500; cursor: pointer; line-height: 1.25;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}
.presets button b { display: block; font-size: .95rem; }
.presets button.on { box-shadow: 0 0 0 2px var(--accent); }

/* Formulaires */
label { display: block; font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .1);
  background: #fff; color: var(--ink); font: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
form .btn { margin-top: 18px; }

/* Login */
#login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px; padding: 24px; }
.login-card { width: min(100%, 380px); text-align: center; padding: 8px 0; }
.login-card .logo { display: block; width: min(72vw, 230px); height: auto; margin: 0 auto 10px; }
.tagline { color: var(--muted); font-size: 1rem; line-height: 1.35; }
.tagline strong { color: var(--accent); font-weight: 600; }
.login-card label { text-align: left; margin-top: 26px; }
.login-card input { background: var(--card); border-color: transparent; }

/* Contrôle segmenté */
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--line); border-radius: 10px; }
.segmented button { flex: 1; padding: 7px 0; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; }
.segmented button.on { background: #fff; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }

/* Graphique */
.chart-wrap { position: relative; }
#chart { width: 100%; height: 250px; display: block; touch-action: pan-y; }
.chart-tip { position: absolute; top: 0; pointer-events: none; background: var(--ink); color: #fff; font-size: .8rem; padding: 4px 9px; border-radius: 8px; white-space: nowrap; transform: translateX(-50%); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-top: 10px; }
.sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.sw.temp { background: var(--cold); }
.sw.thr { background: #ff3b30; }
.sw.off { background: var(--off); opacity: .4; height: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { text-align: center; padding: 16px 8px; }
.stat span { display: block; font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .78rem; }

/* Carte */
.map { height: 340px; border-radius: 22px; overflow: hidden; background: var(--card); display: grid; place-items: center; color: var(--muted); }
.date-card { display: flex; align-items: center; gap: 14px; padding: 12px 20px; }
.date-card label { margin: 0; white-space: nowrap; }

/* Journal */
.events { list-style: none; margin: 10px 0 0; padding: 0; }
.events li { padding: 11px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 8px 1fr; gap: 12px; font-size: .95rem; }
.events li:first-child { border-top: 0; }
.events .lv { width: 8px; border-radius: 4px; background: var(--off); }
.events .lv.danger { background: #ff3b30; }
.events .lv.warning { background: #ff9f0a; }
.events .lv.info { background: var(--cold); }
.events time { display: block; color: var(--muted); font-size: .8rem; }
#settings-msg.ok { color: var(--ok); }
#settings-msg.err { color: var(--danger); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Partenaire (fin de page) */
.partner { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 28px 0 8px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.partner img { width: 96px; height: auto; }
#login .partner { border-top: 0; margin: 0; padding: 0; }

/* Entrées / sorties */
.io-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.io-row:first-of-type { border-top: 0; }
.io-pills { display: flex; gap: 6px; }
.io-pills span { min-width: 46px; text-align: center; padding: 5px 0; border-radius: 10px; background: #fff; color: var(--muted); font-size: .8rem; font-weight: 600; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.io-pills span.on { background: var(--accent); color: #fff; box-shadow: none; }
