/* Base commune Blabla : tokens + composants. Voir DESIGN.md. Thème clair uniquement. */
:root {
  /* Palette « lime électrique sur papier crème » (DESIGN.md). Un seul chromatique : le lime. */
  --bg: #ffffff;          /* toile */
  --bg-alt: #f5f5eb;      /* papier crème */
  --fill: #ebebdf;        /* fond neutre des contrôles */
  --hairline: #d2d2c8;    /* cendre : bordures */
  --hairline-soft: #e4e4da;
  --text: #14140f;        /* encre */
  --text-2: #30302a;      /* charbon */
  --muted: #6e6e64;       /* graphite */
  --stone: #919183;
  --accent: #beff50;      /* lime : unique couleur d'action (fond) */
  --accent-hover: #b0f53a;
  --accent-ink: #14140f;  /* texte posé sur le lime, et « accent » en texte */
  --accent-soft: #f5f5eb;
  --accent-ring: rgba(20, 20, 15, .16);
  --link: #14140f;
  --island: #30302a;      /* îlot sombre, rare */
  --ok: #3d5a00;      --ok-soft: #e6ffbd;
  --warn: #7a4b00;    --warn-soft: #fbefd4;
  --danger: #b3261e;  --danger-soft: #fbe9e7;

  --font: "Inter", "OTSono", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 96px;
  --w-page: 1200px; --w-app: 1080px; --w-form: 680px; --w-auth: 400px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 28px; --r-pill: 9999px;
  --shadow-1: none;  /* pas d'ombres : contraste tonal uniquement */
  --shadow-2: none;
  --ease: cubic-bezier(.25, .1, .25, 1);
  --radius: var(--r-sm); /* compatibilité */
  color-scheme: light;
}

@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: url("/public/fonts/inter-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 500; font-display: swap;
  src: url("/public/fonts/inter-latin-ext-var.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ─── Socle ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: "ss01", "cv11"; overflow-x: hidden; }
body.alt { background: var(--bg-alt); }
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
/* Liens « blocs » (lignes, cartes, marques, pastilles) : pas de soulignement, le bloc est l'affordance. */
.brand, .list-row, .quick-row, .rule-link, .back-link, .pill, .kpi-alert, .ct-link, .int-card, .auth-brand, .pub-brand, .skip,
.brand:hover, .list-row:hover, .quick-row:hover, .rule-link:hover, .pill:hover, .kpi-alert:hover, .ct-link:hover, .int-card:hover, .auth-brand:hover, .pub-brand:hover { text-decoration: none; }
:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--accent-ring); border-radius: var(--r-sm); }
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3, h4 { margin: 0 0 .4em; color: var(--text); font-weight: 500; }
h1 { font-size: clamp(1.75rem, 3.2vw, 2.5rem); line-height: 1.08; letter-spacing: -.03em; }
h2 { font-size: 1.5rem; line-height: 1.17; letter-spacing: -.02em; }
h3 { font-size: 1.125rem; line-height: 1.3; letter-spacing: -.01em; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
.display { font-size: clamp(2.75rem, 7.5vw, 5.625rem); line-height: .92; font-weight: 500; letter-spacing: -.03em; }
.lead { font-size: 1.25rem; line-height: 1.45; color: var(--muted); }
.eyebrow { display: inline-block; font-size: .75rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--text); margin-bottom: var(--s3); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.caption { font-size: .75rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
code, kbd { font-family: var(--mono); font-size: .85em; background: var(--fill); border-radius: 6px; padding: 1px 6px; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--s5) 0; }

main { max-width: var(--w-app); margin: 0 auto; padding: var(--s6) var(--s4) var(--s8); }
main.narrow { max-width: var(--w-form); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ─── Barre de l'application ────────────────────────────── */
.appbar { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline); }
.appbar-in { max-width: var(--w-app); margin: 0 auto; padding: 0 var(--s4); height: 56px; display: flex; align-items: center; gap: var(--s4); }
.appbar .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 1.125rem; letter-spacing: -.03em; color: var(--text); text-decoration: none; flex: none; }
.appbar .brand svg { width: 26px; height: 26px; }
.appnav { display: flex; gap: 2px; flex: 1; justify-content: center; min-width: 0; }
.appnav a { padding: 6px 14px; border-radius: var(--r-pill); color: var(--text-2); font-size: .875rem; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background .2s var(--ease), color .2s var(--ease); }
.appnav a:hover { background: var(--bg-alt); color: var(--text); }
.appnav a[aria-current="page"] { background: var(--text); color: var(--bg-alt); }
.appbar form { margin: 0; flex: none; }
.appbar .logout { font-size: .875rem; color: var(--muted); }
.appbar-link { flex: none; font-size: .875rem; font-weight: 500; color: var(--text); }
.console-tag { margin-left: 4px; padding: 2px 8px; border-radius: var(--r-pill); background: var(--text); color: var(--bg-alt); font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; }
/* Bandeaux globaux : maintenance, mode « Voir comme ce client », annonce. */
.site-banner { display: flex; align-items: center; justify-content: center; gap: var(--s3); flex-wrap: wrap; padding: 10px var(--s4); font-size: .875rem; text-align: center; }
.site-banner form { margin: 0; }
.site-banner.warn { background: var(--warn-soft); color: var(--text); }
.site-banner.info { background: var(--bg-alt); color: var(--text); border-bottom: 1px solid var(--hairline); }
.site-banner.imp { background: var(--island); color: var(--bg-alt); }
@media (max-width: 760px) {
  .appbar-in { height: auto; flex-wrap: wrap; padding-top: 10px; gap: 8px; }
  .appbar .brand { flex: 1; }
  .appnav { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px; margin: 0 calc(-1 * var(--s4)); padding-left: var(--s4); padding-right: var(--s4); }
  .appnav::-webkit-scrollbar { display: none; }
}

/* ─── Messages ──────────────────────────────────────────── */
.flash, .alert-warn, .alert-error, .alert-info { display: block; padding: 12px 16px; border-radius: var(--r-md); font-size: .9375rem; line-height: 1.45; }
.flash { max-width: var(--w-app); margin: var(--s4) auto 0; background: var(--ok-soft); color: var(--text); }
body > .flash { width: calc(100% - 2 * var(--s4)); }
.flash.error, .alert-error { background: var(--danger-soft); color: #7a1610; }
.alert-warn { background: var(--warn-soft); color: #5c3800; }
.alert-info { background: var(--bg-alt); color: var(--text); border: 1px solid var(--hairline); }

/* ─── Boutons ───────────────────────────────────────────── */
.btn, button.btn, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 9px 20px;
  border-radius: var(--r-xl); border: 0; background: var(--accent); color: var(--accent-ink); font: 500 .9375rem/1.2 var(--font);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .2s var(--ease), transform .1s var(--ease); }
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--hairline); }
.btn.secondary:hover { background: var(--bg-alt); }
.btn.ghost { background: transparent; color: var(--text); text-decoration: underline; text-underline-offset: 3px; padding-left: 10px; padding-right: 10px; }
.btn.ghost:hover { background: transparent; text-decoration-thickness: 2px; }
.btn.dark { background: var(--text); color: var(--bg-alt); }
.btn.dark:hover { background: var(--island); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: #f6d5d1; }
.btn.sm { min-height: 32px; padding: 6px 14px; font-size: .8125rem; }
.btn.lg { min-height: 48px; padding: 13px 28px; font-size: 1.0625rem; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
a.more::after { content: " ›"; }

/* ─── Champs ────────────────────────────────────────────── */
label { display: block; font-weight: 500; font-size: .9375rem; margin: var(--s4) 0 6px; }
.field { margin-bottom: var(--s4); }
.field > label { margin-top: 0; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .8125rem; margin-top: 6px; }
label .hint { display: inline; margin: 0 0 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], input[type=tel], textarea, select {
  width: 100%; min-height: 44px; padding: 11px 14px; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  font: 400 1rem/1.4 var(--font); background: var(--bg); color: var(--text); transition: border-color .2s var(--ease), box-shadow .2s var(--ease); -webkit-appearance: none; appearance: none; }
input::placeholder, textarea::placeholder { color: var(--stone); }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--text); box-shadow: 0 0 0 4px var(--accent-ring); }
textarea { min-height: 110px; resize: vertical; }
select { padding-right: 40px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%236e6e64' stroke-width='1.75' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center; }
input[type=checkbox], input[type=radio] { accent-color: var(--text); width: 18px; height: 18px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; margin: var(--s3) 0; cursor: pointer; }
.check input { margin-top: 2px; flex: none; }

/* Interrupteur iOS : <label class="switch"><input type="checkbox"><span class="track"></span> Libellé</label> */
.switch { display: inline-flex; align-items: center; gap: 12px; font-weight: 500; margin: var(--s3) 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 51px; height: 31px; border-radius: var(--r-pill); background: var(--fill); flex: none; transition: background .2s var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: inset 0 0 0 1px var(--hairline); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { background: var(--text); box-shadow: none; }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--accent-ring); }

/* Contrôle segmenté : <div class="segmented"><label><input type="radio" name="m"><span>A</span></label>…</div> */
.segmented { display: inline-flex; background: var(--fill); border-radius: var(--r-pill); padding: 2px; gap: 2px; max-width: 100%; overflow-x: auto; }
.segmented label { margin: 0; font-weight: 500; font-size: .875rem; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; padding: 6px 16px; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap; color: var(--text-2); transition: background .2s var(--ease); }
.segmented input:checked + span { background: var(--text); color: var(--bg-alt); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-ring); }
/* Variante en liens (sans JavaScript) : <nav class="segmented"><a aria-current="true">A</a><a>B</a></nav> */
.segmented a { display: block; padding: 6px 16px; border-radius: var(--r-pill); white-space: nowrap; color: var(--text-2); font-weight: 500; font-size: .875rem; text-decoration: none; }
.segmented a[aria-current="true"] { background: var(--text); color: var(--bg-alt); }
.segmented a:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }

/* ─── Cartes, listes, grilles ───────────────────────────── */
.card { background: var(--bg); border: 1px solid var(--hairline-soft); border-radius: var(--r-xl); padding: var(--s6); }
body.alt .card { border-color: transparent; }
.card + .card { margin-top: var(--s4); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.flat { box-shadow: none; }
.card.raised { box-shadow: var(--shadow-1); }
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid > .card + .card { margin-top: 0; }

.list { background: var(--bg); border-radius: var(--r-xl); overflow: hidden; border: 1px solid var(--hairline-soft); }
body.alt .list { border-color: transparent; }
.list-row { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: 12px var(--s4); color: var(--text); text-decoration: none; position: relative; }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--s4); border-top: 1px solid var(--hairline-soft); }
a.list-row:hover { background: var(--bg-alt); text-decoration: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev::after { content: "›"; font-size: 1.4rem; line-height: 1; color: var(--stone); }
.list-head { margin: var(--s5) var(--s4) var(--s2); }

.empty { text-align: center; padding: var(--s7) var(--s5); }
.empty .icon { width: 56px; height: 56px; margin: 0 auto var(--s4); border-radius: var(--r-lg); display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.empty p { max-width: 460px; margin-left: auto; margin-right: auto; color: var(--muted); }

/* ─── Indicateurs ───────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 500; line-height: 1.4; background: var(--fill); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--bg-alt); color: var(--text); box-shadow: inset 0 0 0 1px var(--hairline); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.kpis { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--bg); border-radius: var(--r-xl); padding: var(--s5) var(--s5); border: 1px solid var(--hairline-soft); }
body.alt .kpi { border-color: transparent; }
.kpi-value { font-size: 2.25rem; font-weight: 500; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: .8125rem; margin-top: 2px; }
.stat .value { font-size: 2rem; font-weight: 500; letter-spacing: -.03em; }
.stat .label { color: var(--muted); font-size: .8125rem; }

/* ─── Tableaux ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { text-align: start; padding: 12px 12px; border-bottom: 1px solid var(--hairline-soft); vertical-align: top; }
th { font-size: .75rem; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-top: 8px; padding-bottom: 8px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg-alt); }

/* ─── Utilitaires de mise en page ───────────────────────── */
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.stack > * + * { margin-top: var(--s3); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--muted); }

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