/*
 * Système de design commun — site, tableau de bord, scanner, pages client, admin.
 * Charte tonhabitué v1 : Crème 60 % · Encre 30 % · Corail 10 %. Le Corail reste rare, comme l'accent.
 * Motif de marque : l'accent du « é » devient le tampon (barre Corail inclinée ; à venir = contour).
 * Le Corail #FF6B4A ne sert jamais pour du texte sur Crème : utiliser --brand (Corail texte #C8432A).
 */
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque-ext.woff2") format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Familjen Grotesk"; src: url("/fonts/familjen-grotesk.woff2") format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Familjen Grotesk"; src: url("/fonts/familjen-grotesk-ext.woff2") format("woff2"); font-weight: 200 800; font-display: swap; unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  /* Marque — Encre, Crème, Corail */
  --coral: #FF6B4A;          /* « ton », accent, tampons, boutons (fond seulement) */
  --coral-strong: #F2512E;
  --on-coral: #141414;       /* Encre sur Corail : 6,5 : 1 */
  --brand: #C8432A;          /* Corail texte : liens, focus, petit texte sur Crème (4,6 : 1) */
  --brand-strong: #A6351F;
  --brand-soft: #FFE6DE;
  --accent: #FF6B4A;         /* tampons, récompenses */
  --accent-soft: #FFE6DE;
  --accent-ink: #9A2F17;
  /* Neutres chauds */
  --ink: #141414;            /* Encre */
  --ink-2: #3A3631;
  --muted: #6B655C;          /* Gris */
  --line: #ECE6DC;           /* Sable */
  --line-strong: #D8CFC1;
  --paper: #FAF7F2;          /* Crème */
  --surface: #FFFDFA;
  --surface-2: #F3EDE4;
  /* Sémantique */
  --ok: #18794E;   --ok-soft: #E1F3EA;
  --warn: #A15C07; --warn-soft: #FDF0DA;
  --bad: #B42318;  --bad-soft: #FDE8E6;
  --info: #2557A7; --info-soft: #E5EDFA;
  /* Typo */
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Familjen Grotesk", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --t-xs: .75rem; --t-sm: .875rem; --t-md: 1rem; --t-lg: 1.125rem; --t-xl: 1.375rem; --t-2xl: 1.75rem; --t-3xl: 2.25rem; --t-4xl: clamp(2.4rem, 5vw, 3.5rem);
  /* Espace, rayons, ombres */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(20, 20, 20, .06), 0 1px 1px rgba(20, 20, 20, .04);
  --shadow-2: 0 8px 24px rgba(20, 20, 20, .10);
  --focus: 0 0 0 3px rgba(200, 67, 42, .35);
  /* Tampon = accent du « é » du logo : parallélogramme incliné d'environ 30° */
  --stamp-skew: -30deg;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: var(--t-md); line-height: 1.55; -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; display: block; }
a { color: var(--brand); text-underline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: var(--t-3xl); font-weight: 800; }
h2 { font-size: var(--t-2xl); font-weight: 750; }
h3 { font-size: var(--t-xl); font-weight: 700; }
h4 { font-size: var(--t-lg); font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--brand-soft); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.xs { font-size: var(--t-xs); }
.eyebrow { font-size: var(--t-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Mise en page */
.container { width: 100%; max-width: 1160px; margin: 0 auto; padding-inline: var(--s-4); }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.grid > *, .row > *, .stack > * { min-width: 0; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 10px 18px; border-radius: var(--r-md); border: 1px solid transparent; font: 700 var(--t-md)/1.2 var(--f-body); cursor: pointer; text-decoration: none; background: var(--coral); color: var(--on-coral); transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--coral-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-accent { background: var(--ink); color: var(--paper); }
.btn-accent:hover { background: #2B2926; }
.btn-danger { background: var(--surface); color: var(--bad); border-color: #F1B8B2; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: var(--t-lg); }
.btn-block { width: 100%; }

/* Formulaires */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: var(--t-sm); color: var(--ink-2); }
.help { font-size: var(--t-xs); color: var(--muted); }
.error-text { font-size: var(--t-sm); color: var(--bad); }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: var(--t-md)/1.4 var(--f-body); }
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--brand); flex: none; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; inset: 0; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: var(--r-pill); transition: .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: var(--shadow-1); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); }
.card-tight { padding: var(--s-4); }
.card-header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.callout { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); font-size: var(--t-sm); }
.callout-info { background: var(--info-soft); border-color: #C7D7F2; }
.callout-warn { background: var(--warn-soft); border-color: #F2D8A8; }
.callout-ok { background: var(--ok-soft); border-color: #B8E0CB; }
.callout-bad { background: var(--bad-soft); border-color: #F1B8B2; }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--s-4) 0; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }

/* Statistiques */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: var(--t-sm); color: var(--muted); }
.stat-value { font-family: var(--f-display); font-size: var(--t-2xl); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-delta { font-size: var(--t-xs); font-weight: 600; }
.up { color: var(--ok); } .down { color: var(--bad); }

/* Tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-weight: 600; color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FBF8F3; }
.table .num { text-align: right; }

/* Onglets */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: 600 var(--t-sm) var(--f-body); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }

/* Tampons (motif de marque) */
.stamps { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 10px; }
/* Une visite = un accent plein (Corail par défaut, ou la couleur du commerce) ; à venir = même forme en contour. */
.stamps { justify-items: center; }
.stamp { width: 62%; aspect-ratio: 1; border-radius: 2px; border: 2px solid currentColor; opacity: .45; transform: skewX(var(--stamp-skew)); }
.stamp.is-filled { opacity: 1; background: var(--accent); border-color: var(--accent); }
.stamp-seal { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--brand); color: var(--brand); font: 800 1.1rem var(--f-display); }

/* Logo en ligne (docs/brand/logo-inline.svg.txt) : « ton » et l'accent en Corail, « habitu » prend la couleur du texte. */
.logo-svg { display: block; height: 1.6em; width: auto; overflow: visible; }
.logo-ton, .logo-acc { fill: var(--coral); }
.logo-hab { fill: currentColor; }

/* Toast et modale */
.toast-zone { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: var(--t-sm); }
.toast-ok { background: var(--ok); } .toast-bad { background: var(--bad); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 20, 20, .45); display: grid; place-items: center; padding: var(--s-4); z-index: 900; }
.modal { background: var(--surface); border-radius: var(--r-lg); padding: var(--s-5); width: min(100%, 520px); max-height: 90vh; overflow: auto; box-shadow: var(--shadow-2); }

/* États vides et chargement */
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: var(--s-3); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), #FBF8F3, var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-sm); min-height: 1em; }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
