:root{
  --bg:#f2f3f7;
  --card:#ffffff;
  --muted:#6b7280;
  --text:#111827;
  --line:#e5e7eb;

  --primary:#d32f2f;
  --danger:#dc2626;
  --ok:#16a34a;

  --z0:#9ca3af;
  --z1:#2563eb;
  --z2:#16a34a;
  --z3:#f59e0b;
  --z4:#f97316;
  --z5:#dc2626;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:var(--bg);
  color:var(--text);
  overflow-y:auto;
}

/* Appbar */
.appbar{
  position:sticky; top:0; z-index:50;
  height:56px;
  background:var(--primary);
  color:#fff;
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 10px;
}
.appTitle{
  font-weight:1000;
  letter-spacing:.02em;
  font-size:18px;
  flex:1;
}
.appbarRight{display:flex; align-items:center; gap:10px}
.iconBtn{
  border:none;
  background:transparent;
  color:#fff;
  font-size:24px;
  width:44px;
  height:44px;
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}
.iconBtn:active{transform:translateY(1px)}
.iconBtn:hover{background:rgba(255,255,255,.10)}

/* Pill */
.pill{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  background:rgba(255,255,255,.16);
  border:1px solid rgba(255,255,255,.22);
  display:inline-flex;
  align-items:center;
  gap:8px;
}
.pill .dot{width:8px;height:8px;border-radius:999px;background:#d1d5db}
.pill.live .dot{background:var(--ok)}

/* Main */
.main{
  padding:12px;
  min-height: calc(100vh - 56px);
}
.note{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
}

/* Grid */
.grid{
  display:grid;
  gap:12px;
  grid-template-columns:repeat(2, minmax(0,1fr));
}
@media (min-width: 900px){ .grid{grid-template-columns:repeat(3, minmax(0,1fr))} }
@media (min-width: 1200px){ .grid{grid-template-columns:repeat(4, minmax(0,1fr))} }

/* Card */
.card{
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:0 6px 14px rgba(0,0,0,.08);
  overflow:hidden;
  cursor:pointer;
  min-height:170px;
  display:flex;
  flex-direction:column;
}

/* ✅ Bandeau dégradé demandé (bleu→vert→jaune→orange→rouge) */
.cardHead{
  height:8px;
  background: linear-gradient(90deg,
    var(--z1) 0%,
    var(--z2) 25%,
    var(--z3) 50%,
    var(--z4) 75%,
    var(--z5) 100%
  );
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.cardBody{
  padding:12px;
  flex:1;
  display:flex;
  flex-direction:column;
}

.cardTopRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.powerBtn{
  width:44px;height:44px;
  border-radius:999px;
  border:2px solid rgba(0,0,0,.05);
  background:rgba(255,255,255,.65);
  font-size:20px;
  display:flex;align-items:center;justify-content:center;
}
.userBtn{
  width:44px;height:44px;
  border-radius:10px;
  border:2px solid rgba(0,0,0,.05);
  background:rgba(255,255,255,.65);
  font-size:20px;
  display:flex;align-items:center;justify-content:center;
}

.cardName{
  margin-top:4px;
  font-size:22px;
  font-weight:1000;
  text-align:center;
}
.cardSub{
  margin-top:6px;
  display:flex;
  justify-content:space-between;
  font-size:12px;
  color:rgba(0,0,0,.60);
}
.cardMainRow{
  margin-top:auto;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  padding-top:8px;
}
.hrBig{
  font-size:74px;
  font-weight:1000;
  line-height:1;
}
.pctBig{
  font-size:34px;
  font-weight:1000;
  line-height:1;
  text-align:right;
}
.heartMark{
  margin-top:6px;
  font-size:18px;
  text-align:right;
  opacity:.8;
}

/* Couleurs par %HRR (fond card) */
.card.z0{ background:#f3f4f6; }
.card.z1{ background:#eff6ff; }
.card.z2{ background:#ecfdf5; }
.card.z3{ background:#fffbeb; }
.card.z4{ background:#fff7ed; }
.card.z5{ background:#fef2f2; }

/* Drawer */
.backdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.35);
  z-index:90;
}
.drawer{
  position:fixed;
  top:0; left:0;
  width:min(320px, 86vw);
  height:100vh;
  background:#fff;
  z-index:100;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
}
.drawerHead{
  height:56px;
  background:var(--primary);
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 10px;
}
.drawerTitle{font-weight:1000}
.drawerNav{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.navItem{
  width:100%;
  text-align:left;
  border:1px solid var(--line);
  background:#fff;
  border-radius:12px;
  padding:12px 12px;
  font-weight:900;
  cursor:pointer;
}
.navItem.primary{background:#111827;color:#fff;border-color:transparent}
.navItem.danger{background:var(--danger);color:#fff;border-color:transparent}
.navItem.active{outline:3px solid rgba(63,81,181,.20)}
.navSep{height:1px;background:var(--line); margin:6px 0}
.drawerFoot{
  margin-top:auto;
  padding:12px;
  border-top:1px solid var(--line);
}
.hint{font-size:12px;color:var(--muted);line-height:1.35}
.hidden{display:none !important}

/* Buttons / modal */
.btn{
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
}
.btn.primary{background:#111827;color:#fff;border-color:transparent}
.btn.danger{background:var(--danger);color:#fff;border-color:transparent}
.btn:active{transform:translateY(1px)}

/* Modals scrollables (Samsung OK) */
.modal{
  position:fixed; inset:0;
  background:rgba(0,0,0,.42);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:110;
  overflow-y:auto;
}
.modalCard{
  width:min(820px,100%);
  max-height:95vh;
  overflow-y:auto;
  -webkit-overflow-scrolling: touch;
  background:#fff;
  border-radius:18px;
  box-shadow:0 30px 90px rgba(0,0,0,.25);
  border:1px solid rgba(0,0,0,.06);
}
.modalHead{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.modalTitle{font-weight:1000}
.modalBody{padding:14px}

.cols{display:grid;grid-template-columns:1fr;gap:14px}
@media(min-width:860px){ .cols{grid-template-columns:1fr 1fr;} }

.panel{
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px;
  background:#fff;
}
.panelTitle{font-weight:1000;margin-bottom:8px}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.row.spaceBetween{justify-content:space-between}
.field{display:flex;flex-direction:column;gap:6px;min-width:160px;flex:1}
label{font-size:12px;color:var(--muted);font-weight:800}
input{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  font-size:14px;
  outline:none;
}
input:focus{border-color:#c7cad3}
.list{display:flex;flex-direction:column;gap:10px}
.sep{height:1px;background:var(--line);margin:12px 0}
.muted12{font-size:12px;color:var(--muted);font-weight:800}
.fw800{font-weight:800}
.mt8{margin-top:8px}
.mt10{margin-top:10px}
.mt12{margin-top:12px}
.mb8{margin-bottom:8px}
.right{text-align:right}
.bigHr{font-size:34px;font-weight:1000}
.bigPct{font-size:28px;font-weight:1000}
.unit{font-size:12px;color:var(--muted);font-weight:800;margin-left:4px}

.badge{
  font-size:12px;border-radius:999px;border:1px solid var(--line);
  padding:6px 10px;color:var(--muted);background:#fff;
}
.badge.ok{color:#0f5132;border-color:#a7f3d0;background:#ecfdf5}
.badge.off{color:#7c2d12;border-color:#fecaca;background:#fff1f2}

.bar{margin-top:10px;height:8px;border-radius:999px;background:#eef0f6;overflow:hidden}
.barFill{height:100%;width:0%;background:#111827;border-radius:999px;transition:width .12s linear}

.deviceRow, .sessionItem{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px 12px;
  background:#fff;
}
.deviceMain{min-width:0}
.deviceName{font-weight:1000;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.deviceSub{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.deviceActions{display:flex;gap:8px;flex:none}
.mini{
  padding:8px 10px;border-radius:12px;border:1px solid var(--line);
  background:#fff;cursor:pointer;
}
.mini.primary{background:#111827;color:#fff;border-color:transparent}
.mini.danger{background:var(--danger);color:#fff;border-color:transparent}

.chart{
  width:100%;
  height:220px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
}

/* Paysage: compact */
@media (orientation: landscape){
  .main{padding:10px}
  .grid{gap:10px}
  .card{min-height:140px}
  .cardHead{height:6px}
  .hrBig{font-size:60px}
  .pctBig{font-size:28px}
  .note{display:none}
}