/* HOMSLO CONTROL — mobile d'abord, thème sombre.
   Aucun style en ligne : la protection du navigateur (CSP) les interdit. */
:root {
  --bg: #0a0f1c;
  --bg2: #0f1b33;
  --card: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eaf0fb;
  --muted: #94a3bd;
  --accent: #5eead4;
  --accent2: #22c55e;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 18px;
  --tab-h: 68px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(94, 234, 212, 0.14), transparent 60%),
    radial-gradient(700px 420px at -10% 10%, rgba(34, 197, 94, 0.1), transparent 55%),
    var(--bg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
h1 { font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; display: block; }
.noscript { padding: 24px; }

/* Écrans plein cadre (connexion, code) */
.screen {
  max-width: 440px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: rise 0.4s ease both;
}
.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 6vh; }
.brand-logo { border-radius: 20px; box-shadow: 0 10px 40px rgba(94, 234, 212, 0.18); }
.foot { text-align: center; font-size: 0.9rem; }

/* Cartes et formulaires */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.85rem; color: var(--muted); }
input, select {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit; /* 16 px : évite le zoom automatique sur iPhone */
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .tab:focus-visible, .link:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input.code { text-align: center; font-size: 1.9rem; letter-spacing: 0.35em; padding-left: 0.35em; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  color: #04130f;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { filter: grayscale(0.6) brightness(0.8); cursor: progress; }
.btn.ghost { color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.btn.danger { color: #fff; background: rgba(248, 113, 113, 0.16); border: 1px solid rgba(248, 113, 113, 0.5); }
.link { align-self: center; min-height: 44px; padding: 0 12px; color: var(--muted); background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Messages */
.error { color: var(--danger); font-size: 0.95rem; }
.error[hidden] { display: none; }
.notice { padding: 12px 14px; border-radius: 14px; background: rgba(94, 234, 212, 0.1); border: 1px solid rgba(94, 234, 212, 0.3); }
.warn { color: var(--warn); font-size: 0.92rem; }

/* Double authentification */
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.secret { padding: 14px; text-align: center; border-radius: 14px; border: 1px dashed var(--line); background: rgba(0, 0, 0, 0.25); overflow-wrap: anywhere; }
.secret code { font: 600 1.15rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.06em; }
.qr summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.qr img { display: block; margin: 8px auto 0; background: #fff; padding: 10px; border-radius: 12px; }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 2px 0; }

/* Application connectée */
.shell { min-height: 100vh; min-height: 100dvh; }
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise 0.4s ease both;
}
.top { display: flex; align-items: center; gap: 12px; }
.top > div { flex: 1; min-width: 0; }
.top-logo { border-radius: 12px; }
.pill { padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--line); }
.pill.ok { color: var(--accent); border-color: rgba(94, 234, 212, 0.4); background: rgba(94, 234, 212, 0.08); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); }
.kpi-label { font-size: 0.8rem; color: var(--muted); }
.kpi-value { font-size: 1.9rem; font-weight: 700; color: var(--muted); }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--accent2); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18); }
.devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.device { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.device > div { min-width: 0; display: flex; flex-direction: column; }
.device strong { overflow-wrap: anywhere; font-weight: 600; }

/* Barre de navigation basse (pouce) */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10, 15, 28, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  max-width: 220px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.tab.on { color: var(--accent); background: rgba(94, 234, 212, 0.08); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) {
  .page { padding-top: 40px; }
}

/* Entreprises clientes */
.kpi-value.real { color: var(--accent); }
.co-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.co-card {
  width: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text);
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
}
.co-card:active { transform: scale(0.99); }
.co-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.co-main { min-width: 0; display: flex; flex-direction: column; }
.co-main strong { overflow-wrap: anywhere; font-weight: 600; }
.link.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; padding-left: 0; text-decoration: none; }

.banner { padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.banner.ok { background: linear-gradient(135deg, rgba(34, 197, 94, 0.16), rgba(94, 234, 212, 0.06)); border-color: rgba(94, 234, 212, 0.4); }
.banner.warn { background: linear-gradient(135deg, rgba(251, 191, 36, 0.16), rgba(248, 113, 113, 0.06)); border-color: rgba(251, 191, 36, 0.45); }
.banner-state { align-self: flex-start; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.banner.ok .banner-state { color: var(--accent); }
.banner.warn .banner-state { color: var(--warn); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 0 0 16px 0; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.tl-item > div { display: flex; flex-direction: column; min-width: 0; }
.tl-dot { width: 12px; height: 12px; margin-top: 5px; border-radius: 50%; background: var(--muted); flex: none; }
.tl-dot.ok { background: var(--accent2); }
.tl-dot.warn { background: var(--warn); }

/* Offres et abonnements */
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
select option { color: #0a0f1c; }
.sub-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sub-item, .plan-item { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.plan-item { background: var(--card); border-radius: var(--radius); }
.sub-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sub-title { font-size: 1rem; margin-top: 4px; }
.btn-row { display: flex; flex-direction: column; gap: 8px; }
.small-btn { min-height: 44px; }
.tl-dot.neutral { background: var(--muted); }

.struck { text-decoration: line-through; opacity: 0.7; }

.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; word-break: break-all; user-select: all; padding: 12px; border-radius: 12px; border: 1px dashed var(--line); background: rgba(255, 255, 255, 0.04); margin: 0; }
.small-secret { font-size: 0.78rem; }
.warn-text { color: #fbbf24; margin: 0; }
.reveal { border-color: rgba(251, 191, 36, 0.5); }
.top .small-btn { width: auto; padding-left: 14px; padding-right: 14px; }

/* Tableau de bord */
.month-row { display: flex; flex-direction: column; gap: 6px; padding-bottom: 6px; }
.month-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.month-paid { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.bar-svg { width: 100%; height: 10px; display: block; }
.bar-bg { fill: rgba(255, 255, 255, 0.08); }
.bar-fg { fill: var(--accent); }
.dash-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.prod-row { display: flex; flex-direction: column; gap: 6px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-bar { fill: rgba(94, 234, 212, 0.4); }
.chart-bar.now { fill: var(--accent); }
.chart-val { fill: var(--text); font-size: 10.5px; text-anchor: middle; font-variant-numeric: tabular-nums; }
.chart-label { fill: var(--muted); font-size: 10.5px; text-anchor: middle; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted); font: inherit; font-size: 0.9rem; cursor: pointer; }
.chip.on { color: var(--text); border-color: var(--accent); background: rgba(94, 234, 212, 0.12); }

/* HUB */
.pill.neutral { color: var(--muted); }
.sub-item .btn { width: 100%; }
.muted.small { display: block; }
