:root {
  /* Identité visuelle : #cbdad7 · #708683 · #f0f1f2 (+ nuances plus foncées pour le texte lisible) */
  --bg: #F0F1F2; --card: #fff; --ink: #26332F; --muted: #566865; --line: #CBDAD7;
  --brand: #708683; --accent: #4F6562; --accent-ink: #fff; --danger: #8A2D2D;
  --vallet-bg: #CBDAD7; --vallet-ink: #2F403D;
  --montaigu-bg: #5B7370; --montaigu-ink: #fff;
  --new-bg: #E4ECE9; --new-ink: #3E524F;
  --cancel-bg: #F9E3E1; --cancel-ink: #8A2D2D;
  --photo-bg: #E4ECE9; --photo-ink: #3E524F;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171E1D; --card: #212B29; --ink: #E6EEEC; --muted: #A9BAB6; --line: #364543;
    --brand: #708683; --accent: #9DB7B2; --accent-ink: #14201E; --danger: #F2A5A0;
    --vallet-bg: #3A4B48; --vallet-ink: #DCE8E5;
    --montaigu-bg: #708683; --montaigu-ink: #0F1715;
    --new-bg: #2C3B38; --new-ink: #CBDAD7;
    --cancel-bg: #4B2422; --cancel-ink: #F6C6C2;
    --photo-bg: #2C3B38; --photo-ink: #CBDAD7;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
#app, .view { height: 100%; }
.ico { display: inline-flex; vertical-align: middle; flex: none; }

/* Écran : zone qui défile + barre d'actions + onglets */
.screen { display: flex; flex-direction: column; height: 100%; max-width: 640px; margin: 0 auto; }
.scroll > * { flex-shrink: 0; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; padding-top: max(16px, env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 16px; align-content: flex-start; }
.footer { display: flex; gap: 12px; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
.footer > * { flex: 1; }
.footer .stack-s { width: 100%; }
.tabbar { display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; min-height: 56px; color: var(--muted); font-size: 13px; }
.tab.active { color: var(--accent); font-weight: 700; }

/* Typo */
.h1 { font-size: 24px; line-height: 1.2; margin: 0; }
.h2 { font-size: 20px; margin: 0; }
.h3 { font-size: 17px; margin: 0; }
.section-title, .eyebrow, .label { font-size: 12px; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0; }
.eyebrow { text-transform: capitalize; letter-spacing: 0; font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong, strong { font-weight: 700; }
.center { text-align: center; }
.pad { padding: 16px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.name { font-weight: 700; overflow-wrap: anywhere; }
.struck { text-decoration: line-through; color: var(--muted); }
.error { color: var(--danger); margin: 0; font-weight: 600; }
.ok { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.warn { color: var(--danger); }
.value { font-weight: 600; }

/* Mise en page */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.stack-xs { display: flex; flex-direction: column; gap: 4px; }
.row, .inline, .row-between, .name-line { display: flex; align-items: center; gap: 10px; }
.row-between { justify-content: space-between; }
.inline, .name-line { flex-wrap: wrap; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; gap: 8px; } .chips.wrap { flex-wrap: wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cartes et listes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card.row { padding: 14px 16px; }
.card.is-cancelled { opacity: .7; }
.card-keep { border-color: var(--accent); border-width: 2px; }
.list { overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.info { padding: 4px 16px; }
.info > * { padding: 12px 0; }
.info > * + * { border-top: 1px solid var(--line); }
.info-row { display: flex; align-items: center; gap: 12px; min-height: 44px; overflow-wrap: anywhere; }
.note-row { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; }
.time { font-weight: 700; min-width: 56px; } .time small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--vallet-bg); color: var(--vallet-ink);
  display: grid; place-items: center; font-weight: 700; flex: none; }
.dot-flag { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--accent);
  color: var(--accent-ink); font-size: 13px; font-weight: 700; display: grid; place-items: center; }

/* Pastilles */
.chip, .pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px;
  font-size: 13px; font-weight: 700; background: var(--line); color: var(--ink); white-space: nowrap; }
.chip-vallet { background: var(--vallet-bg); color: var(--vallet-ink); }
.chip-montaigu { background: var(--montaigu-bg); color: var(--montaigu-ink); }
.chip-new { background: var(--new-bg); color: var(--new-ink); }
.chip-cancel { background: var(--cancel-bg); color: var(--cancel-ink); }
.chip-src, .chip-topic { background: var(--photo-bg); color: var(--photo-ink); padding: 2px 10px; }
.chip-src-manuel { background: var(--line); color: var(--muted); }
.chip-rec { background: var(--cancel-bg); color: var(--cancel-ink); }
.pill { background: var(--photo-bg); color: var(--photo-ink); }
.chip-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px;
  padding: 8px 14px; min-height: 40px; font: inherit; font-size: 14px; font-weight: 600; }
.chip-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Bannières */
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); }
.banner-teal { background: var(--vallet-bg); color: var(--vallet-ink); }
.banner-amber { background: var(--new-bg); color: var(--new-ink); }
.banner-red { background: var(--cancel-bg); color: var(--cancel-ink); }

/* Formulaires et boutons */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .fieldset legend { font-weight: 600; font-size: 14px; }
.input { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: 48px; }
.input:focus { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.area { min-height: 88px; resize: vertical; }
.searchbox { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 0 14px; color: var(--muted); }
.searchbox .input { border: 0; padding-left: 0; outline: 0; }
.fieldset { border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; margin: 0; }
.radio { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.radio input { width: 22px; height: 22px; accent-color: var(--accent); }
.todo { display: flex; gap: 8px; align-items: flex-start; } .todo .ico { margin-top: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: 14px; border: 1.5px solid transparent; font: inherit; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: .5; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; font: inherit; font-weight: 700; color: var(--accent); min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--accent); }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-weight: 600; color: var(--accent); align-self: flex-start; }
.login { margin: auto; width: 100%; max-width: 380px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action { display: flex; flex-direction: column; gap: 8px; padding: 16px; color: var(--accent); }
.action strong { color: var(--ink); }

/* Photos */
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-tile { position: relative; display: block; border-radius: 12px; overflow: hidden; background: var(--line); }
.photo-tile img, .preview { width: 100%; display: block; border-radius: 12px; }
.photo-label { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.65); color: #fff;
  font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 140px;
  border: 2px dashed var(--accent); border-radius: var(--radius); color: var(--accent); font-weight: 700; cursor: pointer; background: var(--card); }

/* Vocal */
.voice-center { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 0; }
.rec-btn { width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; }
.rec-stop { background: #C0392B; color: #fff; }
.square { width: 28px; height: 28px; background: #fff; border-radius: 6px; display: block; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #C0392B; animation: pulse 1s infinite; }
.big-time { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wave { display: flex; align-items: center; gap: 3px; height: 40px; }
.wave span { width: 4px; height: 100%; background: var(--accent); border-radius: 2px; animation: wave 1s ease-in-out infinite; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes wave { 0%, 100% { transform: scaleY(.2); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .wave span, .spinner, .rec-dot { animation: none; } }

/* Message flottant */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 420px;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; text-align: center; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
.toast.show { opacity: 1; } .toast.error { background: #8A2D2D; color: #fff; }

/* Tableau « Tests énergétiques » */
.tests { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.tgroup { display: grid; grid-template-columns: 64px 1fr; border-top: 1px solid var(--line); }
.tgroup:first-child { border-top: 0; }
.tname { background: var(--vallet-bg); color: var(--vallet-ink); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; padding: 8px 4px; }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; }
.tcell { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-left: 1px solid var(--line); border-top: 1px solid var(--line); min-width: 0; }
.tgrid .tcell:nth-child(-n+2) { border-top: 0; }
.tgrid .tcell:nth-child(odd) { border-left: 0; }
.tgrid .tcell:nth-child(2n) { border-left: 1px solid var(--line); }
.tpoint { font-size: 12px; font-weight: 700; color: var(--muted); }
.tval { font-weight: 600; overflow-wrap: anywhere; min-height: 24px; }
.tinput { min-height: 40px; padding: 6px 10px; border-radius: 8px; }

/* Vignettes de l'écran Clients */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px; }
.tile-num { font-size: 40px; line-height: 1.1; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.tile-label { font-weight: 700; }
.tile-link { color: var(--muted); font-size: 13px; margin-top: 6px; display: inline-flex; align-items: center; gap: 2px; }
.tile-alert { border-color: var(--accent); border-width: 2px; }
[hidden] { display: none !important; }

/* Écran Aujourd'hui : compteur et liste compacte */
.daycount { display: flex; align-items: baseline; gap: 12px; padding: 16px; }
.daycount-num { font-size: 44px; line-height: 1; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.daycount-label { font-weight: 700; font-size: 17px; }
.list-row .time { min-width: 52px; }
.list-row.is-cancelled { opacity: .7; }

/* À venir : blocs par jour + rappel SMS */
.day-head { border-bottom: 1px solid var(--line); }
.row-link { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.row-link .name { overflow: hidden; text-overflow: ellipsis; }
.row-link .time { min-width: 52px; }
.pill-sms { background: var(--accent); color: #fff; text-decoration: none; flex-shrink: 0; width: 40px; height: 40px; padding: 0; justify-content: center; }

.icon-btn.spin svg { animation: spin 1s linear infinite; }

/* À venir : seul le jour est en gras */
.row-light .name, .row-light .time { font-weight: 400; }

/* Livre de recettes : choix en gros boutons */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { min-height: 48px; padding: 0 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-size: 16px; cursor: pointer; }
.opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.opt-pill { min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 15px; }
.opt-pill[aria-pressed="true"] { background: var(--line); border-color: var(--accent); color: var(--ink); }
.opt-dashed { border-style: dashed; border-color: var(--brand); color: var(--accent); }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; flex: none; }
.seg .opt { border: 0; border-radius: 0; min-width: 72px; }
.row-between.gap { gap: 12px; }
.card-form { border: 2px solid var(--brand); }
.hint { background: var(--bg); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.h-sub { font-weight: 700; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.kpi-num { font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1.05; }
.kpi-label { font-size: 14px; color: var(--muted); margin-top: 6px; }
.bar { height: 10px; border-radius: 5px; background: var(--bg); }
.bar > span { display: block; height: 10px; border-radius: 5px; background: var(--accent); }
.stack-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--bg); }
.lines-row { display: flex; justify-content: space-between; gap: 12px; }
.chart svg { width: 100%; height: auto; }
.date-col { width: 46px; font-size: 14px; color: var(--muted); line-height: 1.25; flex: none; }
.row-unpaid { background: var(--cancel-bg); }
.sub-unpaid { color: var(--danger); font-weight: 600; }
.select { appearance: auto; }
.charge-row { display: grid; grid-template-columns: 1fr 96px 44px; gap: 8px; align-items: center; }

/* Import de l'historique et comparaison de périodes */
.chip-todo { background: transparent; border: 1.5px dashed var(--brand); color: var(--accent); }
.map-row { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-size: 14px; }
.period-row { display: flex; gap: 8px; align-items: stretch; }
.period-btn { flex: 1; min-width: 0; min-height: 64px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 0 14px; font: inherit; cursor: pointer; text-align: left; }
.period-btn.on { background: var(--line); border-color: var(--accent); }
.period-name { font-size: 17px; font-weight: 700; }
.delta { display: inline-block; border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 700; background: var(--bg); color: var(--ink); }
.delta-up { background: var(--new-bg); color: var(--accent); }
.delta-down { background: var(--cancel-bg); color: var(--cancel-ink); }
.pts { font-size: 14px; font-weight: 700; color: var(--muted); }
.pts.delta-up { background: none; color: var(--accent); } .pts.delta-down { background: none; color: var(--danger); }
.cmp-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px 12px; border-top: 1px solid var(--line); }
.cmp-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cmp-line .bar { flex: 1; }
.cmp-line b, .cmp-line > span:last-child { width: 44px; text-align: right; }
.cmp-tag { width: 64px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-b > span { background: var(--line); border: 1.5px solid var(--brand); box-sizing: border-box; }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; box-sizing: border-box; }
.sw-a { background: var(--accent); } .sw-b { background: var(--line); border: 1.5px solid var(--brand); }
.sheet-overlay { position: fixed; inset: 0; background: rgba(20, 30, 28, .5); display: flex; align-items: flex-end; z-index: 50; }
.sheet { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; }
a.opt { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
