/* Mon Budget — styles (mobile d'abord, thème clair/sombre automatique) */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --surface-3: #e6e8ee;
  --text: #0e1116;
  --text-2: #4b5160;
  --muted: #7a8090;
  --border: rgba(14, 17, 22, 0.08);
  --accent: #3461e8;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecff;
  --good: #0f8a3c;
  --good-soft: #e3f5ea;
  --warn: #b26a00;
  --warn-soft: #fff1d6;
  --bad: #c62f2f;
  --bad-soft: #fde6e6;
  --info-soft: #e8eefc;
  --pos: #0f7a36;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 18px;
  --radius-s: 12px;
  /* graphiques */
  --chart-surface: #fcfcfb;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --tick: #898781;
  --hero-good: linear-gradient(135deg, #1f9d55, #13804a);
  --hero-warn: linear-gradient(135deg, #e08a00, #c86f00);
  --hero-bad: linear-gradient(135deg, #e04646, #b82727);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #1f232b;
    --surface-3: #2a2f39;
    --text: #f1f2f5;
    --text-2: #c2c6d0;
    --muted: #8a90a0;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #6d8dff;
    --accent-ink: #0b1020;
    --accent-soft: #1e2847;
    --good: #3ccf73;
    --good-soft: #13301f;
    --warn: #f3b33d;
    --warn-soft: #3a2b0e;
    --bad: #ff6b6b;
    --bad-soft: #3d1717;
    --info-soft: #1b2338;
    --pos: #3ccf73;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --chart-surface: #1a1a19;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --grid: #2c2c2a;
    --axis: #383835;
    --tick: #898781;
    --hero-good: linear-gradient(135deg, #17713e, #0f5530);
    --hero-warn: linear-gradient(135deg, #9a5c00, #7a4700);
    --hero-bad: linear-gradient(135deg, #a32b2b, #7d1d1d);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #181b21;
  --surface-2: #1f232b;
  --surface-3: #2a2f39;
  --text: #f1f2f5;
  --text-2: #c2c6d0;
  --muted: #8a90a0;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #6d8dff;
  --accent-ink: #0b1020;
  --accent-soft: #1e2847;
  --good: #3ccf73;
  --good-soft: #13301f;
  --warn: #f3b33d;
  --warn-soft: #3a2b0e;
  --bad: #ff6b6b;
  --bad-soft: #3d1717;
  --info-soft: #1b2338;
  --pos: #3ccf73;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --chart-surface: #1a1a19;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --grid: #2c2c2a;
  --axis: #383835;
  --tick: #898781;
  --hero-good: linear-gradient(135deg, #17713e, #0f5530);
  --hero-warn: linear-gradient(135deg, #9a5c00, #7a4700);
  --hero-bad: linear-gradient(135deg, #a32b2b, #7d1d1d);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.noscroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.ic { flex: none; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; word-break: break-word; }
.mt { margin-top: 0.4rem; }
.pos { color: var(--pos); }
.neg { color: var(--bad); }
.row { display: flex; align-items: center; }
.gap { gap: 0.6rem; }
.gap-s { gap: 0.4rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack-s { display: flex; flex-direction: column; gap: 0.5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.grid-emoji { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.6rem; }

.splash { min-height: 100vh; display: grid; place-items: center; }
.splash img { border-radius: 16px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.94); opacity: 0.7; } }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 48px; padding: 0.7rem 1.1rem; border-radius: 14px; border: 1px solid transparent;
  font-weight: 600; background: var(--surface-2); color: var(--text); transition: transform 0.08s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface); border-color: var(--border); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger.ghost { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; color: var(--text-2);
}
.icon-btn:disabled { opacity: 0.3; }
.link { background: none; border: 0; color: var(--accent); padding: 0.4rem 0; font-weight: 500; }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.45rem 0.85rem; min-height: 36px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 0.9rem; font-weight: 500; white-space: nowrap;
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chips { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap; margin-left: 0.3rem;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.pill { padding: 0.15rem 0.6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.22); font-size: 0.8rem; font-weight: 600; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 0.8rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, .select-btn {
  width: 100%; min-height: 48px; padding: 0.65rem 0.85rem; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--surface-2); font-size: 16px; text-align: left;
  -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input:disabled { opacity: 0.6; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3rem; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; }
.pw-toggle.on { color: var(--accent); }
.otp { font-size: 1.5rem !important; letter-spacing: 0.4em; text-align: center !important; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; }
.check input { width: 20px; height: 20px; margin: 0.1rem 0 0; accent-color: var(--accent); flex: none; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 0.6rem 0.8rem; border-radius: var(--radius-s); font-size: 0.9rem; }
.meter-wrap { display: flex; flex-direction: column; gap: 0.3rem; }
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.meter span { height: 5px; border-radius: 3px; background: var(--surface-3); transition: background 0.2s; }
.meter[data-level="0"] span:nth-child(-n+1) { background: var(--bad); }
.meter[data-level="1"] span:nth-child(-n+1) { background: var(--bad); }
.meter[data-level="2"] span:nth-child(-n+2) { background: var(--warn); }
.meter[data-level="3"] span:nth-child(-n+3) { background: var(--good); }
.meter[data-level="4"] span { background: var(--good); }
.meter-label { font-size: 0.8rem; color: var(--muted); }
.search { background: var(--surface) !important; }
.emoji-input { text-align: center !important; font-size: 1.4rem !important; }
.inline-wrap { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); }
.inline-amount { width: 5.5rem !important; min-height: 40px !important; text-align: right !important; padding: 0.4rem 0.6rem !important; color: var(--text); }

/* ---------- Authentification ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 1.1rem; }
.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.brand-logo img { border-radius: 16px; box-shadow: var(--shadow); display: block; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.divider { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; padding: 0.8rem; background: var(--surface); border-radius: var(--radius-s); border: 1px dashed var(--muted); }
.codes code { font-family: ui-monospace, Menlo, monospace; font-size: 0.95rem; text-align: center; padding: 0.2rem; letter-spacing: 0.04em; }

/* ---------- Coquille ---------- */
.view { padding-bottom: calc(96px + var(--safe-b)); min-height: 100vh; }
.page { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem;
  padding: calc(18px + var(--safe-t)) 16px 14px; max-width: 640px; margin: 0 auto;
}
.page-head h1 { font-size: 1.5rem; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }
.page-sub::first-letter { text-transform: uppercase; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; display: grid; place-items: center;
}
.avatar.big { width: 52px; height: 52px; font-size: 1.3rem; flex: none; }
.sync-dot { display: inline-grid; place-items: center; width: 28px; height: 40px; color: var(--muted); }
.sync-dot[data-state="ok"] { color: var(--good); opacity: 0.7; }
.sync-dot[data-state="busy"] svg { animation: spin 1s linear infinite; color: var(--accent); }
.sync-dot[data-state="pending"] { color: var(--warn); }
.sync-dot[data-state="off"] { color: var(--bad); }
.offline-bar {
  position: sticky; top: 0; z-index: 30; padding: calc(6px + var(--safe-t)) 12px 6px; text-align: center;
  background: var(--warn-soft); color: var(--warn); font-size: 0.8rem; font-weight: 600; display: flex; gap: 0.3rem; justify-content: center; align-items: center;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--border);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 0.68rem; font-weight: 600; min-height: 50px; justify-content: center; }
.tab.on { color: var(--accent); }
.fab {
  justify-self: center; width: 58px; height: 58px; border-radius: 20px; border: 0; margin-top: -22px;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
}
.fab:active { transform: scale(0.95); }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.7rem; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.list-card { padding: 4px 0; gap: 0; }
.list-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 10px 16px 4px; }
.card > .list-label { padding-left: 16px; }
.line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.15rem 0; }
.line.total { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.3rem; }
.fold summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.fold summary::after { content: "▾"; color: var(--muted); }
.fold[open] summary::after { content: "▴"; }
.fold summary::-webkit-details-marker { display: none; }
.bullets { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.3rem; }
.steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; }

/* ---------- Accueil ---------- */
.hero {
  border: 0; text-align: left; width: 100%; color: #fff; border-radius: 24px; padding: 20px;
  display: flex; flex-direction: column; gap: 0.35rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  background: var(--hero-good);
}
.hero.warn { background: var(--hero-warn); }
.hero.bad { background: var(--hero-bad); }
.hero-top { display: flex; justify-content: space-between; align-items: center; font-weight: 600; opacity: 0.95; }
.hero-amount { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-day { font-size: 1.05rem; }
.muted-on { opacity: 0.8; }
.hero-bar { position: relative; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.22); margin-top: 0.6rem; overflow: hidden; }
.hero-bar-time { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, 0.28); }
.hero-bar-spent { position: absolute; inset: 0 auto 0 0; height: 4px; top: 2px; border-radius: 2px; background: #fff; }
.hero-legend { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.78rem; opacity: 0.85; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px; text-align: left; box-shadow: var(--shadow); min-width: 0;
}
.kpi-label { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-hint { font-size: 0.7rem; color: var(--accent); }
.kpis.three .kpi-hint { color: var(--muted); }
.quick .btn { min-height: 46px; }
.alert { display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.9rem; border-radius: var(--radius-s); background: var(--info-soft); font-size: 0.92rem; border: 0; text-align: left; width: 100%; }
.alert.warn { background: var(--warn-soft); }
.alert.bad { background: var(--bad-soft); }
.alert.good { background: var(--good-soft); }
.alert > span:nth-child(2) { flex: 1; }
.alert-ic { font-size: 1.15rem; flex: none; width: 1.6rem; text-align: center; }
.insight { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; }
.gauge, .goal { display: flex; flex-direction: column; gap: 0.3rem; color: inherit; padding: 0.2rem 0; }
.gauge-top { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.95rem; }
.gauge-num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge-num strong { color: var(--text); }
.gauge-foot { font-size: 0.78rem; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--good); transition: width 0.4s ease; }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--bad); }
.goal-bar > span { background: var(--accent); }
.goal-btn { border: 0; background: none; text-align: left; padding: 0.3rem 0; width: 100%; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.li, .tx {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 16px; width: 100%;
  border: 0; background: none; text-align: left; min-height: 56px;
}
.card .list .li { padding-left: 0; padding-right: 0; }
.tx + .tx, .li + .li { border-top: 1px solid var(--border); }
.tx:active { background: var(--surface-2); }
.tx.review { background: color-mix(in srgb, var(--warn-soft) 50%, transparent); }
.tx.faded { opacity: 0.5; }
.li.warn .tx-title { color: var(--bad); }
.tx-emoji { width: 38px; height: 38px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 1.15rem; flex: none; color: var(--text-2); }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.tx-badges .badge { margin: 0 0 0 0.2rem; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.pos { color: var(--pos); }
.ranked { counter-reset: r; }
.day { display: flex; flex-direction: column; gap: 6px; }
.day-head { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 0 4px; text-transform: capitalize; }
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-title { text-transform: capitalize; font-size: 1.15rem; }
.empty { text-align: center; padding: 2rem 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.empty-emoji { font-size: 2.6rem; }
.review-row { padding: 0.8rem 16px; display: flex; flex-direction: column; gap: 0.5rem; }
.review-row + .review-row { border-top: 1px solid var(--border); }
.review-top { display: flex; gap: 0.6rem; align-items: flex-start; }

/* ---------- Barres horizontales ---------- */
.hbar { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr auto; align-items: center; gap: 0.6rem; font-size: 0.88rem; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { position: relative; height: 10px; border-radius: 0 4px 4px 0; background: var(--surface-2); }
.hbar-track > span { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--s1); }
.hbar-track .avg { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--text); border-radius: 1px; box-shadow: 0 0 0 2px var(--surface); }
.hbar-val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hbar-val small { font-weight: 600; }

/* ---------- Graphiques ---------- */
.chart-wrap { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--tick); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .fill.s1 { fill: var(--s1); }
.chart .fill.s2 { fill: var(--s2); }
.chart .fill.s3 { fill: var(--s3); }
.chart .col { transition: opacity 0.15s; }
.chart .col.dim { opacity: 0.35; }
.chart .income-mark { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.chart .hit { fill: transparent; outline: none; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--s1); }
.chart .area.s1 { fill: var(--s1); opacity: 0.1; }
.chart .dot.s1 { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .pace { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 5; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.8rem; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw.s1 { background: var(--s1); }
.sw.s2 { background: var(--s2); }
.sw.s3 { background: var(--s3); }
.sw.inc { height: 2px; width: 12px; background: var(--text); border-radius: 1px; }
.sw.pace { height: 0; width: 14px; border-top: 2px dashed var(--muted); border-radius: 0; }
.sw.avgmark { width: 2px; height: 12px; background: var(--text); border-radius: 1px; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.5rem 0.65rem; font-size: 0.78rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); display: flex; flex-direction: column; gap: 0.15rem;
}
.tip strong { text-transform: capitalize; margin-bottom: 0.1rem; }
.tip-row { display: flex; align-items: center; gap: 0.4rem; color: var(--text-2); }
.tip-row b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; padding-left: 0.6rem; }
.table-view summary { font-size: 0.82rem; color: var(--accent); cursor: pointer; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 0.8rem; margin-top: 0.5rem; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 0.3rem 0.2rem; text-align: right; border-bottom: 1px solid var(--border); }
.table-view th:first-child, .table-view td:first-child { text-align: left; text-transform: capitalize; }

/* ---------- Segments ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-3); padding: 3px; border-radius: 12px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 0.5rem 0.4rem; border-radius: 9px; font-weight: 600; font-size: 0.88rem; color: var(--text-2); min-height: 38px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg.small button { padding: 0.25rem 0.6rem; min-height: 30px; font-size: 0.78rem; }

/* ---------- Réglages ---------- */
.profile { flex-direction: row; align-items: center; gap: 0.8rem; }
.profile > div:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.settings-group { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.settings-group > .seg { margin: 4px 12px 12px; }
.setting { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 16px; min-height: 54px; border: 0; background: none; text-align: left; width: 100%; color: var(--text); }
.setting + .setting { border-top: 1px solid var(--border); }
.setting:active { background: var(--surface-2); }
.setting-ic { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; font-size: 0.95rem; }
.setting-label { flex: 1; font-weight: 500; }
.setting-value { color: var(--muted); font-size: 0.88rem; text-align: right; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setting > .ic:last-child { color: var(--muted); }
.setting.danger { color: var(--bad); }
.setting.danger .setting-ic { background: var(--bad-soft); color: var(--bad); }
.shield-card { flex-direction: row; align-items: center; gap: 0.8rem; background: var(--warn-soft); border: 0; box-shadow: none; }
.shield-card.s2, .shield-card.s3 { background: var(--good-soft); }
.shield-card .shield-ic { color: var(--warn); }
.shield-card.s2 .shield-ic, .shield-card.s3 .shield-ic { color: var(--good); }
.qr { display: grid; place-items: center; }
.qr img { background: #fff; padding: 8px; border-radius: 12px; }
.secret { display: block; margin-top: 0.4rem; font-family: ui-monospace, Menlo, monospace; word-break: break-all; padding: 0.5rem; background: var(--surface-2); border-radius: 8px; }
.welcome { padding-top: calc(40px + var(--safe-t)); }
.choice { display: flex; gap: 0.9rem; align-items: center; padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); text-align: left; box-shadow: var(--shadow); }
.choice-ic { font-size: 1.8rem; }
.choice strong { display: block; }
.choice small { color: var(--muted); }

/* ---------- Feuilles modales ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background 0.2s;
}
.overlay.open { background: rgba(0, 0, 0, 0.42); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; background: var(--bg); border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); outline: none;
}
.overlay.open .sheet { transform: none; }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px 6px 18px; flex: none; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 0.9rem; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 22px; max-height: 86vh; }
}

/* ---------- Saisie rapide ---------- */
.np-display { text-align: center; font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding: 0.2rem 0; }
.np-display.pos { color: var(--pos); }
.np-sign { opacity: 0.6; margin-right: 0.1em; }
.np-cur { font-size: 1.6rem; opacity: 0.6; }
.np-opts { justify-content: center; }
.np-opts .np-date { width: auto; min-height: 36px; padding: 0.3rem 0.6rem; border-radius: 999px; font-size: 0.9rem; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.np-key { min-height: 54px; border-radius: 14px; border: 0; background: var(--surface); font-size: 1.5rem; font-weight: 600; box-shadow: var(--shadow); }
.np-key:active { background: var(--surface-3); }
.np-note { background: var(--surface) !important; }
.hint { text-align: center; color: var(--muted); font-size: 0.82rem; }
.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.cat-picker { display: flex; flex-direction: column; gap: 0.4rem; }
.cat-picker.disabled, .disabled .cat-picker { opacity: 0.45; }
.cat-group-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 0.3rem; }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; min-height: 76px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); font-size: 0.72rem; font-weight: 600; line-height: 1.15;
}
.cat-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.cat-btn:active { transform: scale(0.96); }
.cat-emoji { font-size: 1.5rem; }
.cat-name { text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.select-btn { display: flex; align-items: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 200;
  background: #1d2129; color: #fff; padding: 0.7rem 0.9rem 0.7rem 1rem; border-radius: 14px; display: flex; gap: 0.8rem; align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px); font-size: 0.92rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.bad { background: #b22a2a; }
.toast-btn { border: 0; background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 700; padding: 0.4rem 0.7rem; border-radius: 9px; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (forced-colors: active) {
  .bar > span, .hbar-track > span, .chart .fill { forced-color-adjust: none; }
}
