/* ─── Design system app.sharingworker.com — fidèle aux maquettes docs/suivi_bracelet ─── */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/fonts/BricolageGrotesque-Variable.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/IBMPlexMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/IBMPlexMono-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/IBMPlexMono-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/Inter-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #0B0B0C;
  --panel: #17171A;
  --panel-2: #141414;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);
  --red: #E2001A;
  --green: #4FD17B;
  --orange: #FF7A00;
  --text: #fff;
  --dim: rgba(255, 255, 255, 0.6);
  --faint: rgba(255, 255, 255, 0.42);
  --title: 'Bricolage Grotesque', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --body: 'Inter', system-ui, sans-serif;
  --red-shadow: 0 16px 40px rgba(226, 0, 26, 0.38);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--body); font-size: 16px; line-height: 1.45;
  overscroll-behavior-y: none;
}

#app {
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 18px calc(24px + env(safe-area-inset-bottom));
}
.screen { display: flex; flex-direction: column; flex: 1; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

h1, h2, h3 { font-family: var(--title); letter-spacing: -0.02em; margin: 0; }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 4px 16px; }
.topbar .back {
  all: unset; cursor: pointer; font-size: 26px; color: var(--dim);
  padding: 4px 10px 6px 2px; margin-left: -2px;
}
.topbar-title { font-family: var(--title); font-weight: 600; font-size: 19px; line-height: 1.1; }
.topbar-sub { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 4px; letter-spacing: .04em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.iconbtn {
  all: unset; cursor: pointer; width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid rgba(255,255,255,.14); display: flex; align-items: center;
  justify-content: center; color: rgba(255,255,255,.7); flex-shrink: 0;
}
.applogo { width: 30px; height: 30px; object-fit: contain; }

/* ── Labels mono ── */
.mono-label {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: rgba(255,255,255,.45);
}
.section-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.section-head .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.section-head span { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; }

/* ── Cartes ── */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 18px 20px; }
.card-lg { border-radius: 24px; padding: 22px; }
.card + .card { margin-top: 12px; }

/* ── Boutons ── */
button { font: inherit; }
.btn {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  border-radius: 20px; text-align: center;
  font-family: var(--title); font-weight: 600; font-size: 21px; color: #fff;
  min-height: 64px; padding: 10px 20px;
  transition: transform .06s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--red); box-shadow: var(--red-shadow); }
.btn-secondary { background: var(--panel); border: 1.5px solid var(--border-strong); }
.btn-ghost { border: 1.5px solid var(--border-strong); font-family: var(--body); font-weight: 500; font-size: 17px; color: rgba(255,255,255,.75); }
.btn-action {
  min-height: 92px; border-radius: 22px; justify-content: flex-start; padding: 0 24px; gap: 18px;
}
.btn-action .btn-title { font-size: 23px; line-height: 1; display: block; text-align: left; }
.btn-action .btn-sub {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em; display: block;
  margin-top: 5px; color: rgba(255,255,255,.8); text-align: left; text-transform: uppercase;
}
.btn-secondary .btn-sub { color: rgba(255,255,255,.55); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn-small {
  all: unset; box-sizing: border-box; cursor: pointer; flex: 1; min-height: 44px;
  border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--body); font-weight: 500; font-size: 14px; color: #fff;
  border: 1px solid var(--border-strong); padding: 4px 10px;
}
.btn-small.danger { border-color: rgba(226,0,26,.5); color: var(--red); }
.btn-small.selected { background: rgba(79,209,123,.12); border-color: rgba(79,209,123,.5); }
.btn-small.selected.danger { background: rgba(226,0,26,.12); border-color: rgba(226,0,26,.6); }

/* ── Formulaires ── */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 7px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; height: 54px; border-radius: 12px; background: var(--bg);
  border: 1px solid rgba(255,255,255,.12); color: #fff; padding: 0 14px;
  font-family: var(--body); font-size: 16px; outline: none;
}
input:focus, select:focus { border-color: rgba(226,0,26,.55); box-shadow: 0 0 0 3px rgba(226,0,26,.12); }
input::placeholder { color: rgba(255,255,255,.4); }
.form-error { color: var(--red); font-size: 14px; margin: 10px 0 0; min-height: 20px; }

/* ── Numéros bracelets ── */
.mono-num { font-family: var(--mono); font-weight: 600; font-size: 29px; letter-spacing: 1px; }
.mono-num.md { font-size: 26px; }

/* ── Barres de signal ── */
.sig { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.sig i { width: 4px; display: block; background: rgba(255,255,255,.18); }
.sig i:nth-child(1) { height: 6px; } .sig i:nth-child(2) { height: 10px; }
.sig i:nth-child(3) { height: 14px; } .sig i:nth-child(4) { height: 18px; }
.sig[data-level="1"] i:nth-child(-n+1), .sig[data-level="2"] i:nth-child(-n+2),
.sig[data-level="3"] i:nth-child(-n+3), .sig[data-level="4"] i:nth-child(-n+4) { background: var(--green); }

/* ── Tuiles récap (présents / manquants / inconnus) ── */
.kpis { display: flex; gap: 8px; }
.kpi { flex: 1; border-radius: 14px; padding: 10px 4px; text-align: center; border: 1px solid; }
.kpi b { font-family: var(--mono); font-weight: 600; font-size: 26px; display: block; }
.kpi span { font-size: 11px; color: var(--dim); }
.kpi.green { background: rgba(79,209,123,.1); border-color: rgba(79,209,123,.3); } .kpi.green b { color: var(--green); }
.kpi.red { background: rgba(226,0,26,.12); border-color: rgba(226,0,26,.4); } .kpi.red b { color: var(--red); }
.kpi.orange { background: rgba(255,122,0,.1); border-color: rgba(255,122,0,.35); } .kpi.orange b { color: var(--orange); }

/* ── Notes / info ── */
.note {
  display: flex; gap: 10px; font-size: 13px; color: rgba(255,255,255,.55);
  line-height: 1.5; text-align: left;
}
.note .i { color: var(--orange); flex-shrink: 0; }
.note.boxed { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }

/* ── États vides / plein écran ── */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 20px; padding: 24px 20px; }
.empty .ring {
  width: 100px; height: 100px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px dashed rgba(255,255,255,.16);
}
.empty .ring.orange { border: 1px solid rgba(255,122,0,.35); background: rgba(255,122,0,.1); }
.empty .ring.red { border: 1px solid rgba(226,0,26,.4); background: rgba(226,0,26,.1); }
.empty .ring.green { border: 1.5px solid rgba(79,209,123,.5); background: rgba(79,209,123,.12); }
.empty h2 { font-size: 24px; font-weight: 600; }
.empty p { font-size: 16px; color: var(--dim); margin: 8px 0 0; }

/* ── Scan ── */
.scan-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 34px; }
.scan-bg { background: radial-gradient(ellipse at 50% 38%, #2a0509 0%, var(--bg) 60%); margin: 0 -18px; padding: 0 18px; border-radius: 0; }
.scan-ring { position: relative; width: 240px; height: 240px; display: flex; align-items: center; justify-content: center; }
.scan-ring .r1, .scan-ring .r2, .scan-ring .r3 { position: absolute; border-radius: 50%; }
.scan-ring .r1 { inset: 0; border: 1px solid rgba(226,0,26,.18); }
.scan-ring .r2 { inset: 34px; border: 1px solid rgba(226,0,26,.28); }
.scan-ring .r3 { inset: 68px; border: 1.5px solid rgba(226,0,26,.45); }
.scan-ring .spinner {
  position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent;
  border-top-color: var(--red); border-right-color: var(--red); animation: spin 1.1s linear infinite;
}
.scan-count { font-family: var(--mono); font-weight: 600; font-size: 64px; line-height: 1; }
.scan-count small { font-size: 22px; color: rgba(255,255,255,.5); }
.scan-found { font-family: var(--mono); font-size: 14px; color: var(--red); letter-spacing: .06em; text-transform: uppercase; }
.scan-found.ok { color: var(--green); }

/* ── Lignes bracelet ── */
.brow { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.brow + .brow { margin-top: 10px; }
.brow .brow-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brow input { height: 50px; margin-top: 12px; }
.brow.alert { border-color: rgba(226,0,26,.3); }
.brow.warn { border-color: rgba(255,122,0,.28); }
.brow .who { font-size: 16px; color: rgba(255,255,255,.7); }
.brow .who.none { color: rgba(255,255,255,.4); }
.brow .meta { font-size: 13px; color: rgba(255,255,255,.5); }
.brow .actions { display: flex; gap: 8px; margin-top: 12px; }
.brow .rm { all: unset; cursor: pointer; color: rgba(255,255,255,.35); font-size: 20px; padding: 4px 8px; }
.add-row {
  width: 100%; min-height: 56px; border: 1.5px dashed rgba(255,255,255,.16); border-radius: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: rgba(255,255,255,.6); font-family: var(--body); font-weight: 500; font-size: 16px;
  background: none; cursor: pointer; margin-top: 10px;
}
.add-row b { font-size: 22px; color: var(--red); font-weight: 400; }

/* ── Liste chantiers / historiques ── */
.rowcard {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 16px 18px; cursor: pointer; color: #fff;
}
.rowcard + .rowcard { margin-top: 10px; }
.rowcard .grow { flex: 1; min-width: 0; }
.rowcard h3 { font-size: 18px; font-weight: 600; }
.rowcard .sub { font-size: 13px; color: var(--faint); margin-top: 3px; font-family: var(--mono); }
.rowcard .chev { color: rgba(255,255,255,.35); font-size: 20px; }
.chips { display: flex; gap: 14px; margin-top: 8px; font-family: var(--mono); font-size: 12px; flex-wrap: wrap; }
.chips .c { display: flex; align-items: center; gap: 7px; }
.chips .c i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Barre de progression parc ── */
.meter { height: 8px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; display: flex; }
.meter i { background: var(--green); display: block; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; padding: 3px 9px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  border: 1px solid var(--border-strong); color: var(--dim);
}
.badge.red { border-color: rgba(226,0,26,.5); color: var(--red); }
.badge.green { border-color: rgba(79,209,123,.4); color: var(--green); }
.badge.orange { border-color: rgba(255,122,0,.4); color: var(--orange); }

/* ── Tabs admin ── */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs button {
  all: unset; cursor: pointer; flex: 1; text-align: center; padding: 12px 6px;
  border-radius: 12px; border: 1px solid var(--border); font-family: var(--mono);
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim);
}
.tabs button.active { border-color: rgba(226,0,26,.55); color: #fff; background: rgba(226,0,26,.1); }

/* ── Curseur RSSI ── */
input[type=range] { width: 100%; accent-color: var(--red); height: 34px; }
.range-labels { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }

/* ── Toast ── */
#toasts { position: fixed; bottom: 24px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  background: var(--panel); border: 1px solid var(--border-strong); color: #fff;
  border-radius: 14px; padding: 13px 20px; font-size: 15px; max-width: 90vw;
  box-shadow: 0 12px 40px rgba(0,0,0,.6); animation: fadein .2s ease;
}
.toast.ok { border-color: rgba(79,209,123,.5); }
.toast.err { border-color: rgba(226,0,26,.6); }

/* ── Dialog / sheet ── */
dialog.sheet {
  border: 1px solid var(--border-strong); border-radius: 22px; background: var(--panel);
  color: #fff; padding: 24px; width: min(420px, calc(100vw - 36px)); font-family: var(--body);
}
dialog.sheet::backdrop { background: rgba(0,0,0,.65); }
dialog.sheet h3 { font-size: 20px; margin-bottom: 8px; }
dialog.sheet p { color: var(--dim); font-size: 15px; margin: 0 0 18px; }
dialog.sheet .row { display: flex; gap: 10px; margin-top: 8px; }

/* ── Divers ── */
.sticky-bottom {
  position: sticky; bottom: 0; padding: 14px 0 4px;
  background: linear-gradient(180deg, transparent, var(--bg) 40%);
}
.debug-chip {
  font-family: var(--mono); font-size: 10px; color: var(--orange);
  border: 1px dashed rgba(255,122,0,.5); padding: 2px 8px; border-radius: 7px;
}
.list-gap { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--faint); font-size: 14px; }
.spin-icon { animation: spin 1s linear infinite; display: inline-block; }
a { color: var(--orange); text-decoration: none; }
::-webkit-scrollbar { width: 0; height: 0; }
