/* Pécule — mobile d'abord, PC ensuite. Couleurs en jetons, thème sombre sélectionné
   (pas inversé) ; couleurs de données issues de la palette validée. */

:root {
  color-scheme: light;
  --page: #eef0f3;
  --card: #ffffff;
  --card-2: #f6f7f9;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7d7c77;
  --line: #e3e5e8;
  --base: #c9ccd1;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e3eefc;
  --track: #cde2fb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --warn: #fab219;
  --serious: #ec835a;
  --crit: #d03b3b;
  --crit-text: #b42828;
  --warn-soft: #fff4dc;
  --crit-soft: #fde8e8;
  --good-soft: #e3f6e3;
  --bubble-me: #2a78d6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 0 rgba(16, 24, 40, .03);
  --ring: rgba(11, 11, 11, .10);
  --radius: 20px;
  --nav-h: 64px;
  /* Zones sûres (encoche, barre d'accueil de l'iPhone, bords arrondis en paysage) */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  /* Fond de la barre d'état de l'iPhone (appli ajoutée à l'écran d'accueil, texte blanc) */
  --status-bg: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --card: #1a1a19;
    --card-2: #222220;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #989791;
    --line: #2c2c2a;
    --base: #383835;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --accent-soft: #16273d;
    --track: #1c3555;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-text: #0ca30c;
    --crit-text: #f07a7a;
    --warn-soft: #33290f;
    --crit-soft: #3a1717;
    --good-soft: #12301a;
    --bubble-me: #2f6fc4;
    --shadow: none;
    --ring: rgba(255, 255, 255, .10);
    --status-bg: var(--page);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --card: #1a1a19;
  --card-2: #222220;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #989791;
  --line: #2c2c2a;
  --base: #383835;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --accent-soft: #16273d;
  --track: #1c3555;
  --series-1: #3987e5;
  --series-2: #d95926;
  --good-text: #0ca30c;
  --crit-text: #f07a7a;
  --warn-soft: #33290f;
  --crit-soft: #3a1717;
  --good-soft: #12301a;
  --bubble-me: #2f6fc4;
  --shadow: none;
  --ring: rgba(255, 255, 255, .10);
  --status-bg: var(--page);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
/* Barre d'état de l'iPhone en mode appli (« black-translucent » : texte blanc posé sur la page).
   Hauteur nulle partout ailleurs (navigateur, Android, PC). */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: var(--safe-t); background: var(--status-bg); pointer-events: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- Structure ------------------------------------------------------------- */

.app { min-height: 100%; }
.main { min-width: 0; }
.view {
  outline: none;
  padding: 4px calc(16px + var(--safe-r)) calc(var(--nav-h) + var(--safe-b) + 24px) calc(16px + var(--safe-l));
  max-width: 760px;
  margin: 0 auto;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-t) + 12px) calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(12px);
  max-width: 760px; margin: 0 auto;
}
.topbar h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { font-size: 13px; color: var(--ink-2); }
.topbar .grow { flex: 1; min-width: 0; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: var(--card); color: var(--ink);
  box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 22px; height: 22px; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.nav a {
  display: grid; place-items: center; align-content: center; gap: 2px;
  color: var(--ink-2); text-decoration: none; font-size: 11.5px; font-weight: 500;
  position: relative;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav a[aria-current="page"] .pill { background: var(--accent-soft); }
.nav .pill { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; }
.nav .dot {
  position: absolute; top: 8px; left: calc(50% + 10px);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--crit); border: 2px solid var(--card);
}
.nav .brand { display: none; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 232px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; bottom: auto;
    display: flex; flex-direction: column; gap: 4px;
    padding: calc(20px + var(--safe-t)) 12px 20px calc(12px + var(--safe-l));
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav a { display: flex; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 14px; font-size: 15px; }
  .nav .pill { width: auto; height: auto; background: none !important; }
  .nav a[aria-current="page"] { background: var(--accent-soft); }
  .nav .dot { top: 12px; left: 30px; }
  .nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; padding: 4px 12px 18px; }
  .nav .brand img { width: 32px; height: 32px; border-radius: 9px; }
  .view { padding-bottom: 40px; }
}

/* --- Cartes et blocs ------------------------------------------------------ */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
  outline: 1px solid var(--ring);
  outline-offset: -1px;
}
.card h2 { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .right { margin-left: auto; font-weight: 500; font-size: 13px; }
.card h2 svg { width: 18px; height: 18px; flex: none; }
svg.inline { width: 1em; height: 1em; vertical-align: -2px; }
.empty .avatar, .avatar { line-height: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 640px) { .grid-lg-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .grid-lg-2 > .card { margin: 0; } }

.hero { padding: 20px 18px 18px; }
.hero .label { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.hero .value { font-size: 52px; font-weight: 650; letter-spacing: -.02em; line-height: 1.05; margin: 6px 0 4px; }
.hero .value.neg { color: var(--crit-text); }
.hero .caption { font-size: 14px; color: var(--ink-2); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card-2); color: var(--ink);
}
.chip svg { width: 14px; height: 14px; }
.chip.ok { background: var(--good-soft); }
.chip.tight { background: var(--warn-soft); }
.chip.over { background: var(--crit-soft); }
.chip .st { width: 8px; height: 8px; border-radius: 50%; }
.chip.ok .st { background: var(--good); }
.chip.tight .st { background: var(--warn); }
.chip.over .st { background: var(--crit); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 8px -16px 0; padding: 0 16px 4px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.pick {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; white-space: nowrap; font-weight: 500;
}
.pick[aria-pressed="true"] { background: var(--ink); color: var(--page); border-color: var(--ink); }

/* Jauge : le remplissage porte l'état, la piste est un ton clair de la même rampe */
.meter { height: 10px; border-radius: 6px; background: var(--track); overflow: hidden; position: relative; }
.meter > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); max-width: 100%; }
.meter.tight { background: color-mix(in srgb, var(--warn) 28%, var(--card)); }
.meter.tight > i { background: var(--warn); }
.meter.over { background: color-mix(in srgb, var(--crit) 22%, var(--card)); }
.meter.over > i { background: var(--crit); }
.meter .tick { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .55; border-radius: 1px; }
.meter.thin { height: 6px; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 15px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.stat { background: var(--card-2); border-radius: 16px; padding: 12px; }
.stat .l { font-size: 13px; color: var(--ink-2); }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 2px; }
.stat .d { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.pos { color: var(--good-text); }
.neg { color: var(--crit-text); }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .ic {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--card-2); font-size: 20px;
}
.list .body { flex: 1; min-width: 0; }
.list .t { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .s { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.list .amt.in { color: var(--good-text); }
.list button.li-btn { all: unset; display: flex; align-items: center; gap: 12px; width: 100%; cursor: pointer; }
.list .meter { margin-top: 6px; }
.day-head { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 18px 4px 4px; }
.day-head::first-letter { text-transform: uppercase; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--card-2); color: var(--ink-2); margin-left: 6px; }

/* Alertes */
.alert { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.alert:first-child { border-top: 0; padding-top: 2px; }
.alert .lv { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; }
.alert .lv svg { width: 18px; height: 18px; }
.alert.warn .lv { background: var(--warn-soft); color: #9a6a00; }
.alert.alert .lv { background: var(--crit-soft); color: var(--crit-text); }
.alert.info .lv { background: var(--accent-soft); color: var(--accent); }
.alert.good .lv { background: var(--good-soft); color: var(--good-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .alert.warn .lv { color: var(--warn); } }
:root[data-theme="dark"] .alert.warn .lv { color: var(--warn); }
.alert .t { font-weight: 600; }
.alert .b { font-size: 14px; color: var(--ink-2); }
.alert .w { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Bulle de l'assistant sur l'accueil */
.speech { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 18px;
}
.speech .bubble { background: var(--card-2); border-radius: 4px 18px 18px 18px; padding: 12px 14px; font-size: 15px; flex: 1; }
.speech .actions { display: flex; gap: 8px; margin-top: 10px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 600; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
.btn.ghost { background: var(--card-2); color: var(--ink); }
.btn.danger { background: var(--crit-soft); color: var(--crit-text); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }

/* Formulaires */
.field { display: grid; gap: 6px; margin: 12px 0; }
.field > span { font-size: 14px; font-weight: 550; }
.field small { color: var(--ink-2); font-size: 12.5px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--card-2);
  border-radius: 12px; padding: 11px 12px; font-size: 16px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 8px 6px; font-size: 14px; font-weight: 550; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); outline: 1px solid var(--ring); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.switch:first-of-type { border-top: 0; }
.switch input { appearance: none; width: 48px; height: 28px; border-radius: 14px; background: var(--base); position: relative; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
code, .code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; background: var(--card-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
details > summary { cursor: pointer; font-weight: 550; padding: 6px 0; }

/* --- Graphiques ------------------------------------------------------------ */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--base); stroke-width: 1; }
.chart .ref { stroke: var(--ink-2); stroke-width: 1; }
.chart .ref-label { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.chart .s1 { stroke: var(--series-1); }
.chart .s2 { stroke: var(--series-2); }
.chart .area1 { fill: var(--series-1); opacity: .1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--card); stroke-width: 2; }
.chart .bar { fill: var(--series-1); }
.chart .bar.cur { fill: var(--series-1); opacity: .45; }
.chart .bar.on { fill: var(--series-1); opacity: 1; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.s1 { background: var(--series-1); }
.legend i.s2 { background: var(--series-2); }
.legend i.ref { background: var(--ink-2); height: 1px; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--page); border-radius: 10px; padding: 7px 10px;
  font-size: 12.5px; line-height: 1.35; white-space: nowrap; transform: translate(-50%, -100%);
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.tip b { font-weight: 650; }
.tip .k { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.table-view { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.table-view th, .table-view td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); }
.table-view td.n { text-align: right; font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.hbar:first-child { border-top: 0; }
.hbar .nm { font-size: 14.5px; font-weight: 550; display: flex; justify-content: space-between; gap: 8px; }
.hbar .tr { grid-column: 2 / 4; position: relative; height: 10px; }
.hbar .tr i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--series-1); }
.hbar .tr b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .6; }

/* --- Chat ---------------------------------------------------------------------- */

.chat { display: flex; flex-direction: column; min-height: calc(100dvh - 140px - var(--nav-h)); }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 8px 0 12px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 15.5px; word-wrap: break-word; }
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 8px; padding-left: 20px; }
.msg.me { align-self: flex-end; background: var(--bubble-me); color: #fff; border-radius: 18px 18px 4px 18px; }
.msg.bot { align-self: flex-start; background: var(--card); outline: 1px solid var(--ring); outline-offset: -1px; border-radius: 4px 18px 18px 18px; }
.msg.note { align-self: flex-start; background: var(--accent-soft); border-radius: 4px 18px 18px 18px; }
.msg .meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.msg .meta button { all: unset; cursor: pointer; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; }
.msg .meta button svg { width: 16px; height: 16px; }
.msg .tag { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.tool { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 4px 2px; }
.tool .spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.tool.done .spinner { animation: none; border-color: var(--good); }
.tool.fail .spinner { border-color: var(--crit); }
.tool.skip .spinner { border-color: var(--line); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 10;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 0 12px; background: linear-gradient(transparent, var(--page) 30%);
}
.composer textarea { flex: 1; resize: none; max-height: 140px; border-radius: 22px; padding: 11px 16px; border: 1px solid var(--line); background: var(--card); font-size: 16px; }
.composer .icon-btn { flex: none; }
.composer .send { background: var(--accent); color: var(--accent-ink); }
.composer .mic.on { background: var(--crit); color: #fff; }
@media (min-width: 900px) { .composer { bottom: 0; } .chat { min-height: calc(100dvh - 90px); } }
.suggest { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 6px; }
.suggest::-webkit-scrollbar { display: none; }
.empty { text-align: center; color: var(--ink-2); padding: 30px 10px; }
.empty .avatar { margin: 0 auto 12px; width: 56px; height: 56px; font-size: 26px; border-radius: 18px; }

/* --- Feuille du bas, toast, connexion ------------------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  width: 100%; max-width: 560px; max-height: 86vh; overflow: auto;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px calc(16px + var(--safe-r)) calc(20px + var(--safe-b)) calc(16px + var(--safe-l));
  animation: up .2s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--base); margin: 0 auto 12px; }
.sheet h3 { font-size: 18px; margin-bottom: 4px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.cat-grid button { display: flex; align-items: center; gap: 8px; text-align: left; border: 1px solid var(--line); background: var(--card-2); border-radius: 14px; padding: 10px; font-size: 14px; }
.cat-grid button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 14px; font-size: 14px;
  max-width: calc(100% - 32px); transition: all .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.banner { display: flex; gap: 10px; align-items: center; background: var(--warn-soft); border-radius: 14px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }
.banner svg { width: 18px; height: 18px; flex: none; }
.skeleton { height: 120px; border-radius: var(--radius); background: var(--card); margin: 12px 0; opacity: .6; }
.btn.lg { padding: 15px 18px; font-size: 17px; border-radius: 16px; }
.center { text-align: center; }

/* --- Connexion, premier compte, invitation ------------------------------------------ */

.auth {
  display: block; max-width: 440px; margin: 0 auto;
  padding: calc(var(--safe-t) + 6vh) calc(16px + var(--safe-r)) calc(32px + var(--safe-b)) calc(16px + var(--safe-l));
}
.auth-head { text-align: center; margin-bottom: 14px; }
.auth-head .logo { width: 64px; height: 64px; border-radius: 20px; }
.auth-head .name { font-weight: 700; font-size: 18px; color: var(--ink-2); margin-top: 4px; }
.auth h1 { font-size: 26px; text-align: center; margin-bottom: 10px; letter-spacing: -.01em; }
.auth .lead { font-size: 16.5px; color: var(--ink-2); text-align: center; margin: 0 0 6px; }
.auth .card { padding: 18px; }
.auth .card h2 { font-size: 18px; color: var(--ink); }
.auth .card p { margin: 0 0 12px; }
.auth > p.small { margin-top: 16px; }
.form-err { color: var(--crit-text); background: var(--crit-soft); border-radius: 12px; padding: 10px 12px; font-size: 14.5px; font-weight: 550; margin: 4px 0 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; margin: 4px 0 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }

/* --- Réglages : compte, famille, installation ------------------------------------------- */

.tag { flex: none; font-size: 12px; font-weight: 700; letter-spacing: .03em; padding: 3px 10px; border-radius: 999px; background: var(--card-2); color: var(--ink-2); }
.tag.ultra { background: linear-gradient(135deg, #f5b81c, #eb6834); color: #fff; }
.me-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.me-row .body, .member .body { flex: 1; min-width: 0; }
.me-row .t { font-weight: 650; font-size: 17px; }
.me-row .s { font-size: 13.5px; color: var(--ink-2); }
.avatar.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 15px; }
.sub-h { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 18px 0 4px; }
.invite-box { display: grid; gap: 10px; background: var(--accent-soft); border-radius: 14px; padding: 12px; margin-top: 10px; }
.invite-box .input { background: var(--card); font-size: 14px; }
.list.members > li { display: block; padding: 12px 0; }
.member .row { gap: 10px; }
.member .s { white-space: normal; }
.member.off .row .body, .member.off .spend { opacity: .55; }
.member .spend { margin: 10px 0 4px; }
.member .spend .meter { margin-top: 6px; }
.member .switch, .member .cap-row { padding: 8px 0; font-size: 15px; }
.member .switch:first-of-type { border-top: 1px solid var(--line); }
.cap-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }
.money { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; flex: none; }
.money .input { width: 84px; text-align: right; padding: 8px 10px; }
.field .lbl { font-size: 14px; font-weight: 550; }
.howto { margin-top: 12px; }
.howto + .howto { border-top: 1px solid var(--line); padding-top: 10px; }
.howto h3 { font-size: 15px; font-weight: 650; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
