:root {
  --bg: #0d0f12;
  --card: #16191e;
  --card2: #1e222a;
  --line: #2a2f38;
  --text: #f3f5f8;
  --muted: #8d96a5;
  --accent: #d4ff3a;
  --accent-ink: #11140a;
  --accent-soft: rgba(212, 255, 58, 0.12);
  --gold: #ffc94d;
  --danger: #ff6464;
  --radius: 16px;
  --tab-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- démarrage */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- structure */
.screen { padding: calc(var(--safe-t) + 12px) 16px calc(var(--tab-h) + var(--safe-b) + 96px); max-width: 640px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 6px; }
.topbar h1 { font-size: 30px; line-height: 1.1; margin: 0; font-weight: 800; letter-spacing: -0.02em; flex: 1; }
.topbar .sub { color: var(--muted); font-size: 14px; }
.back { width: 40px; height: 40px; border-radius: 12px; background: var(--card); display: grid; place-items: center; flex: none; }
.back svg { width: 20px; height: 20px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin: 26px 4px 10px; }

/* ---------- barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: rgba(13, 15, 18, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs-in { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }

.fab {
  position: fixed; z-index: 21; right: max(16px, calc(50vw - 304px)); bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  height: 56px; padding: 0 22px 0 18px; border-radius: 28px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px;
  box-shadow: 0 10px 30px rgba(212, 255, 58, 0.25), 0 2px 8px rgba(0, 0, 0, 0.5);
}
.fab svg { width: 22px; height: 22px; }
.fab:active { transform: scale(.96); }

/* ---------- cartes & listes */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); min-height: 64px; }
.row:last-child { border-bottom: 0; }
button.row:active { background: var(--card2); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val { text-align: right; flex: none; }
.row .val b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.row .val .tag { display: block; font-size: 11px; color: var(--muted); font-weight: 700; margin-top: 1px; }
.row .val.none { color: var(--muted); font-size: 14px; }
.chev { color: var(--line); width: 16px; height: 16px; flex: none; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat.hl b { color: var(--accent); }

/* ---------- recherche & filtres */
.search { position: relative; margin-top: 14px; }
.search input { width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 14px 0 42px; font-size: 16px; outline: none; }
.search input:focus { border-color: var(--accent); }
.search svg { position: absolute; left: 14px; top: 13px; width: 20px; height: 20px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 2px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; border: 1px solid var(--line); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.sm { height: 30px; font-size: 13px; padding: 0 12px; }

/* ---------- vide */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 8px; }
.empty b { color: var(--text); display: block; font-size: 18px; margin-bottom: 6px; }

/* ---------- détail mouvement */
.hero { background: linear-gradient(160deg, #1d2410 0%, var(--card) 55%); border: 1px solid rgba(212, 255, 58, 0.18); border-radius: 22px; padding: 20px; margin-top: 10px; }
.hero .lbl { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hero .pr { font-size: 52px; font-weight: 850; letter-spacing: -0.03em; line-height: 1.05; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.hero .pr small { font-size: 22px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.hero .when { color: var(--muted); font-size: 14px; }
.hero .desc { color: var(--muted); font-size: 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.hero .none { font-size: 18px; color: var(--muted); margin: 10px 0; }
.btn { height: 50px; border-radius: 14px; padding: 0 18px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--card2); color: var(--text); }
.btn.danger { background: rgba(255, 100, 100, 0.12); color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }
.hero .btn { margin-top: 16px; }

.rm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.rm { background: var(--card); border-radius: 14px; padding: 10px 12px; text-align: left; border: 1px solid transparent; }
.rm.on { border-color: var(--accent); }
.rm span { color: var(--muted); font-size: 12px; font-weight: 700; }
.rm b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }

.chart { background: var(--card); border-radius: var(--radius); padding: 14px 10px 8px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .ax { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); }
.chart .pt { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart .pt.pr { fill: var(--accent); }
.chart .note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 4px; }

.pct { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; }
.pct div { background: var(--card); padding: 10px 6px; text-align: center; }
.pct span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.pct b { font-variant-numeric: tabular-nums; font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 4px 0; }

.badge { display: inline-block; font-size: 10px; font-weight: 850; letter-spacing: .06em; padding: 2px 6px; border-radius: 6px; vertical-align: 2px; margin-left: 6px; }
.badge.pr { background: var(--accent); color: var(--accent-ink); }
.badge.rx { background: rgba(255, 201, 77, 0.16); color: var(--gold); }
.badge.me { background: var(--card2); color: var(--muted); }
.del { width: 36px; height: 36px; border-radius: 10px; color: var(--muted); display: grid; place-items: center; flex: none; }
.del svg { width: 18px; height: 18px; }
.del:active { background: rgba(255, 100, 100, 0.12); color: var(--danger); }

.rank { width: 30px; height: 30px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.rank.r1 { background: var(--gold); color: #1a1405; }
.rank.r2 { background: #c9d1dc; color: #15181c; }
.rank.r3 { background: #d38b55; color: #1a0f06; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; font-weight: 800; flex: none; color: var(--accent); }
.row.mine .title { color: var(--accent); }

/* ---------- formulaires */
.field { margin-bottom: 14px; }
.field label, .lab { display: block; font-size: 13px; color: var(--muted); font-weight: 650; margin: 0 2px 6px; }
.input { width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2); padding: 0 14px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { height: 80px; padding: 12px 14px; resize: none; }
.big-in { display: flex; gap: 10px; }
.big-in .unit-wrap { flex: 1; position: relative; }
.big-in input { width: 100%; height: 76px; border-radius: 18px; border: 1px solid var(--line); background: var(--card2); font-size: 38px; font-weight: 800; padding: 0 64px 0 18px; outline: none; font-variant-numeric: tabular-nums; }
.big-in input:focus { border-color: var(--accent); }
.big-in .u { position: absolute; right: 16px; top: 0; height: 76px; display: flex; align-items: center; color: var(--muted); font-weight: 700; font-size: 18px; pointer-events: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--card); border-radius: var(--radius); width: 100%; text-align: left; }
.switch .k { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch .k::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on .k { background: var(--accent); }
.switch.on .k::after { transform: translateX(20px); background: var(--accent-ink); }
.switch .t { font-weight: 650; }
.switch .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 2px 10px; }
.ok-msg { color: var(--accent); font-size: 14px; margin: 4px 2px 10px; }
.seg { display: flex; background: var(--card2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; height: 38px; border-radius: 9px; font-weight: 650; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ---------- connexion */
.auth { min-height: 100vh; padding: calc(var(--safe-t) + 40px) 22px 40px; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; }
.logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin-bottom: 18px; }
.auth h1 { font-size: 34px; margin: 0 0 4px; font-weight: 850; letter-spacing: -0.02em; }
.auth p.lead { color: var(--muted); margin: 0 0 26px; }
.auth .seg { margin-bottom: 22px; }

/* ---------- feuille (bottom sheet) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; margin: 0 auto; max-width: 640px;
  background: var(--card); border-radius: 22px 22px 0 0; max-height: calc(100vh - var(--safe-t) - 24px);
  display: flex; flex-direction: column; animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-h { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.sheet-h h3 { margin: 0; font-size: 19px; flex: 1; font-weight: 800; }
.sheet-h .x { width: 34px; height: 34px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; }
.sheet-h .x svg { width: 16px; height: 16px; }
.sheet-b { padding: 6px 16px calc(var(--safe-b) + 18px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet .list { background: var(--card2); }
.sheet .row { border-color: #2f3540; }
.sheet .input, .sheet .big-in input { background: var(--bg); }
.sheet .chip { background: var(--card2); }
.sheet .chip.on { background: var(--accent); }
.sheet .switch { background: var(--card2); }
.current { background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 650; margin-bottom: 14px; }
.grp { font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin: 16px 4px 8px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- toast & célébration */
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%); z-index: 60; background: var(--card2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 14px; font-weight: 650; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: drop .25s; max-width: calc(100vw - 32px); }
.toast.err { color: var(--danger); }
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.party { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0, 0, 0, 0.78); animation: fade .2s; overflow: hidden; }
.party-in { text-align: center; padding: 30px; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.party .emo { font-size: 72px; }
.party .t { color: var(--accent); font-weight: 900; font-size: 15px; letter-spacing: .2em; margin-top: 8px; }
.party .v { font-size: 56px; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin: 6px 0; }
.party .m { font-size: 18px; font-weight: 700; }
.party .d { display: inline-block; margin-top: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 850; padding: 6px 14px; border-radius: 20px; }
.party .tap { color: var(--muted); font-size: 13px; margin-top: 26px; }
.confetti { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.footer-note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 30px; }
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: .06em; color: var(--accent); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1; height: 44px; font-size: 14px; }
.small-btn { height: 34px; padding: 0 12px; border-radius: 10px; background: var(--card2); font-size: 13px; font-weight: 650; flex: none; }
.small-btn.red { color: var(--danger); }
.offline { background: rgba(255, 100, 100, 0.12); color: var(--danger); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-top: 10px; }

@media (min-width: 700px) {
  .sheet { bottom: 50%; transform: translateY(50%); border-radius: 22px; animation: fade .2s; }
}
.spacer-s { height: 12px; }
.btn svg { width: 20px; height: 20px; flex: none; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat span { white-space: nowrap; }
.sheet.tall { height: calc(100vh - var(--safe-t) - 24px); }
a.btn { text-decoration: none; }
.err:empty, .ok-msg:empty { min-height: 0; margin: 0 0 12px; }
