/* ==========================================================================
   FSF InfraTech — design system
   Charte : verts doux, cartes très arrondies, boutons segmentés, chiffres forts.
   Mouvement : court, ease-out, uniquement transform / opacity / couleurs.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  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-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  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;
}

:root {
  /* Surfaces */
  --bg: #F3F5F1;
  --surface: #FFFFFF;
  --surface-2: #F6F7F3;
  --panel: #EDF4EE;
  --panel-head: #EEF3EC;
  --line: #E1E6DF;
  --line-strong: #C9D2CA;

  /* Texte */
  --ink: #1D3A2F;
  --text: #33423B;
  --muted: #6A746E;
  --faint: #8A948E;

  /* Marque */
  --brand: #3A7459;
  --brand-600: #33684F;
  --brand-700: #2B5943;
  --brand-ink: #2A5B45;
  --focus: rgb(58 116 89 / .22);

  /* Statuts métier (CDCF) : pastille = couleur vive, texte = version foncée lisible */
  --ok: #10B981;   --ok-ink: #0B6E4B;  --ok-bg: #E3F4EB;
  --warn: #F59E0B; --warn-ink: #8F5400; --warn-bg: #FCF0DA;
  --ko: #EF4444;   --ko-ink: #AE2222;  --ko-bg: #FCE7E6;
  --none: #9AA39D; --none-ink: #5E6862; --none-bg: #EEF0EC;

  /* Formes */
  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-pill: 999px;

  --shadow-card: 0 1px 2px rgb(29 58 47 / .04), 0 24px 48px -28px rgb(29 58 47 / .18);
  --shadow-btn: 0 1px 2px rgb(29 58 47 / .14), 0 10px 22px -10px rgb(29 58 47 / .45);
  --shadow-pop: 0 12px 32px -8px rgb(29 58 47 / .22);

  /* Mouvement */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 650; }
h2 { font-size: 22px; font-weight: 650; }
h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0 0 .75em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.eyebrow {
  display: block;
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 10px;
}
[hidden] { display: none !important; }
.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; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- Mise en page ---------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-weight: 750; font-size: 14px; letter-spacing: -.02em;
  position: relative; overflow: hidden;
}
.brand-mark::after { /* fil tricolore discret */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, #00853F 0 33.3%, #FDEF42 33.3% 66.6%, #E31B23 66.6%);
}
.brand-name { font-weight: 700; letter-spacing: -.01em; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: var(--r-md);
  color: var(--text); font-weight: 550;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav a:hover { text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .nav a:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); } }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(29 58 47 / .06); }
.nav a[aria-current="page"] svg { color: var(--brand); }
.nav svg { width: 20px; height: 20px; color: var(--faint); flex: none; }
.nav .soon { margin-left: auto; font-size: 11px; font-weight: 650; color: var(--faint); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 1px 8px; }
.nav a.disabled { pointer-events: none; opacity: .65; }

.sidebar-foot { margin-top: auto; padding: 14px 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.sidebar-foot .who { font-weight: 650; color: var(--ink); line-height: 1.3; }
.sidebar-foot .role { font-size: 13px; color: var(--muted); }
.sidebar-foot .row { flex-wrap: nowrap; }

.main { min-width: 0; padding: 20px 32px 48px; }
.topbar { display: flex; align-items: center; gap: 16px; min-height: 56px; margin-bottom: 20px; }
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.topbar .search .input { padding-left: 42px; height: 46px; background: var(--surface); }
.topbar .spacer { flex: 1; }
.btn.menu-btn { display: none; }
.scrim { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 60ch; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-aside { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Cartes ------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 28px 32px; }
.card-pad-sm { padding: 20px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 28px 0; }
.card-head + .card-body { padding-top: 16px; }
.card-body { padding: 24px 28px 28px; }
.card-flat { box-shadow: none; border-radius: var(--r-lg); }
.panel { background: var(--panel); border: 1px solid #DDE8DE; border-radius: var(--r-lg); padding: 24px 28px; }

/* Grand chiffre (esprit « 259 € ») */
.figure { font-size: clamp(44px, 5vw, 60px); font-weight: 750; letter-spacing: -0.045em; line-height: 1; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.figure-sub { margin-top: 10px; color: var(--muted); }

/* KPI */
.kpi { padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; min-height: 148px; }
.kpi-label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 40px; font-weight: 750; letter-spacing: -.04em; line-height: 1.05; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 18px; font-weight: 650; letter-spacing: -.01em; color: var(--muted); margin-left: 2px; }
.kpi-foot { margin-top: auto; font-size: 13px; color: var(--muted); }
.kpi--accent { background: var(--panel); border-color: #DDE8DE; }

/* ---------- Tableaux (esprit grille tarifaire) -------------------------- */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table thead th {
  background: var(--panel-head);
  text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--brand-700);
  padding: 20px 20px;
}
.table thead th:first-child { padding-left: 28px; }
.table td { padding: 18px 20px; border-top: 1px solid var(--line); vertical-align: middle; }
.table td:first-child { padding-left: 28px; }
.table td:last-child, .table th:last-child { padding-right: 28px; }
.table .t-main { color: var(--ink); font-weight: 650; }
.table .t-main a { color: inherit; }
.table .t-sub { display: block; font-size: 13px; color: var(--muted); font-weight: 450; }
.table .t-num { color: var(--brand-ink); font-weight: 600; font-size: 16px; }
.table .t-right { text-align: right; }
.table tbody tr { transition: background-color 120ms ease; }
@media (hover: hover) and (pointer: fine) { .table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); } }
.table-empty { padding: 48px 28px; text-align: center; color: var(--muted); }

/* Barre de filtres */
.filters { display: grid; grid-template-columns: minmax(200px, 1.4fr) repeat(4, minmax(140px, 1fr)); gap: 12px; }

/* ---------- Boutons ----------------------------------------------------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: var(--r-md); border: 1px solid transparent;
  font: inherit; font-weight: 650; font-size: 15.5px; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-btn); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--brand-600); }
  .btn-primary:hover .arrow { transform: translateX(2px); }
  .btn-secondary:hover { border-color: var(--line-strong); background: var(--surface-2); }
  .btn-ghost:hover { background: color-mix(in srgb, var(--surface) 80%, transparent); }
  .btn-danger:hover { background: #fbdcdb; }
}
.btn .arrow { transition: transform 160ms var(--ease-out); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--brand-700); }
.btn-danger { background: var(--ko-bg); color: var(--ko-ink); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }
.btn[disabled] { opacity: .45; pointer-events: none; box-shadow: none; }

/* ---------- Formulaires ------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-weight: 600; color: var(--ink); font-size: 15px; }
.label .opt { font-weight: 450; color: var(--faint); font-size: 13px; margin-left: 4px; }
.input, .select, .textarea {
  width: 100%; min-height: 52px; padding: 12px 16px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.select {
  -webkit-appearance: none; appearance: none; padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231D3A2F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 20px;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.hint { font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.error { font-size: 13.5px; color: var(--ko-ink); font-weight: 550; }
.is-invalid { border-color: var(--ko) !important; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 550; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.fieldset { border: 0; padding: 0; margin: 0; }
.form-section { padding-top: 8px; }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 28px; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; }

/* Contrôle segmenté (esprit T1…T5) — basé sur des radios, accessible au clavier */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: grid; place-items: center; text-align: center;
  min-height: 56px; padding: 6px 10px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2);
  font-weight: 650; color: var(--ink); cursor: pointer; line-height: 1.25;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.segmented label:active { transform: scale(0.97); }
.segmented input:checked + label { background: var(--brand); border-color: var(--brand); color: #fff; }
.segmented input:focus-visible + label { box-shadow: 0 0 0 4px var(--focus); }
@media (hover: hover) and (pointer: fine) { .segmented input:not(:checked) + label:hover { border-color: var(--brand); } }

/* Onglets = même langage que le contrôle segmenté, en liens */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; color: var(--ink);
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.tabs a:hover { text-decoration: none; }
.tabs a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs .count { font-size: 12.5px; font-weight: 700; background: rgb(0 0 0 / .06); border-radius: var(--r-pill); padding: 0 8px; }
.tabs a[aria-current="page"] .count { background: rgb(255 255 255 / .22); }

/* Puces (esprit « Options ») */
.chips { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chips-label { font-weight: 650; color: var(--ink); margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 14.5px; color: var(--ink);
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.chip:hover { text-decoration: none; }
.chip[aria-pressed="true"], .chip.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .chip:not(.is-active):hover { border-color: var(--line-strong); } }

/* ---------- Statuts ----------------------------------------------------- */
.status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 10px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 650; white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--ok   { color: var(--ok-ink);   background: var(--ok-bg); }
.status--ok::before   { background: var(--ok); }
.status--warn { color: var(--warn-ink); background: var(--warn-bg); }
.status--warn::before { background: var(--warn); }
.status--ko   { color: var(--ko-ink);   background: var(--ko-bg); }
.status--ko::before   { background: var(--ko); }
.status--none { color: var(--none-ink); background: var(--none-bg); }
.status--none::before { background: var(--none); }
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* ---------- Listes ------------------------------------------------------ */
.bullets { margin: 0; padding-left: 20px; color: var(--muted); }
.bullets li { margin-bottom: 6px; }
.bullets li::marker { color: var(--ink); }
.dl { display: grid; grid-template-columns: minmax(140px, 200px) minmax(0, 1fr); gap: 0; margin: 0; }
.dl dt, .dl dd { padding: 14px 0; border-top: 1px solid var(--line); margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; font-weight: 550; }
.dl dd { color: var(--ink); font-weight: 550; }
.dl > :nth-child(1), .dl > :nth-child(2) { border-top: 0; }
.contact-line { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--brand-ink); }
.contact-line svg { width: 20px; height: 20px; flex: none; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; padding-top: 0; }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 7px; }
.feed .what { color: var(--ink); font-weight: 550; line-height: 1.4; }
.feed .when { font-size: 13px; color: var(--muted); }

.bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; transform-origin: left; }

/* ---------- Carte ------------------------------------------------------- */
.map { height: 460px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); background: var(--panel); isolation: isolate; }
.map--tall { height: calc(100vh - 220px); min-height: 480px; }
.map--sm { height: 260px; }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .25); }
.pin--ok { background: var(--ok); } .pin--warn { background: var(--warn); } .pin--ko { background: var(--ko); } .pin--none { background: var(--none); }
.leaflet-popup-content-wrapper { border-radius: 16px; box-shadow: var(--shadow-pop); font-family: var(--font); }
.leaflet-popup-content { margin: 14px 18px; font-size: 14px; line-height: 1.45; }
.leaflet-popup-content b { color: var(--ink); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Messages ---------------------------------------------------- */
.toast-zone { position: fixed; right: 24px; top: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 12px; max-width: 420px;
  padding: 14px 18px; border-radius: var(--r-md); background: #1D3A2F; color: #fff; font-weight: 550; border: 1px solid rgb(255 255 255 / .08);
  box-shadow: var(--shadow-pop);
  opacity: 1; transform: translateY(0);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(-8px); } }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); transition-duration: 150ms; }
.toast--error { background: var(--ko-ink); }
.alert { padding: 14px 18px; border-radius: var(--r-md); background: var(--ko-bg); color: var(--ko-ink); font-weight: 550; }
.alert--info { background: var(--panel); color: var(--brand-700); }

.empty { text-align: center; padding: 56px 24px; }
.empty h3 { margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 20px; }

/* ---------- Pagination -------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }
.pager a, .pager span.cur, .pager span.gap {
  min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600;
}
.pager a:hover { text-decoration: none; border-color: var(--line-strong); }
.pager span.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager span.gap { border: 0; background: none; }

/* ---------- Connexion --------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card .card-pad { padding: 40px 44px; }
.auth-title { font-size: 30px; margin-bottom: 8px; }

/* ---------- QR ---------------------------------------------------------- */
.qr-box { display: grid; place-items: center; padding: 20px; background: #fff; border-radius: var(--r-lg); border: 1px solid var(--line); }
.qr-box svg, .qr-box img { width: 220px; height: 220px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; background: var(--surface-2); border: 1px solid var(--line); padding: 2px 8px; border-radius: 8px; color: var(--ink); }

/* Plaque QR imprimable (A5) */
.plate { width: 148mm; min-height: 200mm; margin: 0 auto; padding: 14mm; background: #fff; border-radius: 8mm; border: 1px solid var(--line); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6mm; }
.plate .qr-box { border: 0; padding: 0; }
.plate .qr-box svg { width: 95mm; height: 95mm; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .plate { border: 0; }
}

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-aside { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 900;
    background: var(--bg); box-shadow: var(--shadow-pop);
    transform: translateX(-102%);
    transition: transform 240ms var(--ease-out);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .scrim { display: block; position: fixed; inset: 0; background: rgb(15 30 24 / .35); z-index: 800; opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 12px 16px 40px; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters > :first-child { grid-column: 1 / -1; }
  .form-grid .span-2 { grid-column: auto; }
  .card-pad { padding: 22px 20px; }
  .card-head { padding: 18px 20px 0; }
  .card-body { padding: 18px 20px 22px; }
  .table thead th:first-child, .table td:first-child { padding-left: 20px; }
  .table td:last-child, .table th:last-child { padding-right: 20px; }
  /* Tableaux empilés en cartes sur mobile */
  .table--stack thead { display: none; }
  .table--stack tr { display: block; padding: 14px 20px; border-top: 1px solid var(--line); }
  .table--stack td { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0 !important; border: 0; }
  .table--stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 550; }
  .table--stack td.t-first { display: block; }
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl dd { border-top: 0; padding-top: 0; }
  .toast-zone { left: 16px; right: 16px; top: 16px; }
  .topbar .search { display: none; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .segmented { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-property: opacity, background-color, color, border-color !important; }
  .btn:active, .segmented label:active { transform: none; }
}

/* ==========================================================================
   Lot 1.1 — thème sombre, préférences, connexion, personnalisation
   ========================================================================== */

/* ---- Thème sombre (neutres ; les teintes de marque viennent d'Apparence) -- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1613; --surface: #151E1A; --surface-2: #1B2621; --line: #25332C; --line-strong: #34463C;
  --ink: #E6EFE9; --text: #C8D4CD; --muted: #95A39B; --faint: #6F7D75;
  --ok-ink: #6EE7B7; --ok-bg: #0F2E22; --warn-ink: #FCD34D; --warn-bg: #33250A;
  --ko-ink: #FCA5A5; --ko-bg: #3A1515; --none-ink: #A9B4AE; --none-bg: #202A25;
  --shadow-card: 0 1px 2px rgb(0 0 0 / .3), 0 24px 48px -28px rgb(0 0 0 / .6);
  --shadow-btn: 0 1px 2px rgb(0 0 0 / .4), 0 10px 22px -10px rgb(0 0 0 / .7);
  --shadow-pop: 0 12px 32px -8px rgb(0 0 0 / .6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1613; --surface: #151E1A; --surface-2: #1B2621; --line: #25332C; --line-strong: #34463C;
    --ink: #E6EFE9; --text: #C8D4CD; --muted: #95A39B; --faint: #6F7D75;
    --ok-ink: #6EE7B7; --ok-bg: #0F2E22; --warn-ink: #FCD34D; --warn-bg: #33250A;
    --ko-ink: #FCA5A5; --ko-bg: #3A1515; --none-ink: #A9B4AE; --none-bg: #202A25;
    --shadow-card: 0 1px 2px rgb(0 0 0 / .3), 0 24px 48px -28px rgb(0 0 0 / .6);
    --shadow-btn: 0 1px 2px rgb(0 0 0 / .4), 0 10px 22px -10px rgb(0 0 0 / .7);
    --shadow-pop: 0 12px 32px -8px rgb(0 0 0 / .6);
  }
}
.panel { border-color: color-mix(in srgb, var(--brand) 14%, var(--line)); }
.kpi--accent { border-color: color-mix(in srgb, var(--brand) 14%, var(--line)); }
.select { background-color: var(--surface); }
:root[data-theme="dark"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E6EFE9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E6EFE9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); } }

/* ---- Préférences d'affichage ---------------------------------------------- */
html[data-text="grand"] { zoom: 1.12; }
html[data-motion="reduit"] *, html[data-motion="reduit"] *::before, html[data-motion="reduit"] *::after {
  transition-property: opacity, background-color, color, border-color !important;
}
html[data-motion="reduit"] .btn:active, html[data-motion="reduit"] .segmented label:active { transform: none; }

/* ---- Marque (logo personnalisé) ------------------------------------------- */
.brand-logo { width: 38px; height: 38px; border-radius: 12px; object-fit: contain; background: var(--surface); flex: none; }

/* ---- Avatars ---------------------------------------------------------------- */
.avatar {
  --s: 40px;
  width: var(--s); height: var(--s); flex: none;
  border-radius: 50%; object-fit: cover;
  display: inline-grid; place-items: center;
  background: var(--brand); color: #fff;
  font-weight: 700; font-size: calc(var(--s) * .38); letter-spacing: -.02em; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.who-row { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; }
.who-row:hover { text-decoration: none; }
.who-row > div { min-width: 0; }
.who-row .who, .who-row .role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Page de connexion scindée -------------------------------------------- */
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); background: var(--surface); }
.auth-split[data-position="gauche"] .auth-panel { order: 2; }
.auth-panel {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--login-panel, #274F3D); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  padding: 56px 48px; text-align: center;
}
.auth-panel-image { position: absolute; inset: 0; z-index: -2; background-size: cover; background-position: center; opacity: .22; filter: grayscale(.2); }
.auth-panel.motif::before, .auth-panel.motif::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; pointer-events: none;
  border: clamp(48px, 9vw, 140px) solid rgb(255 255 255 / .06);
}
.auth-panel.motif::before { width: 118vmin; height: 118vmin; left: -58vmin; top: -62vmin; }
.auth-panel.motif::after { width: 96vmin; height: 96vmin; right: -44vmin; bottom: -52vmin; }
.auth-logo { width: min(62%, 320px); aspect-ratio: 1; display: grid; place-items: center; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 18px 40px rgb(0 0 0 / .25)); }
.auth-logo-vide {
  width: 78%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid rgb(255 255 255 / .45); background: rgb(255 255 255 / .06);
  font-size: clamp(44px, 6vw, 76px); font-weight: 800; letter-spacing: -.03em;
}
.auth-panel h2 { color: #fff; font-size: clamp(22px, 2.3vw, 32px); font-weight: 700; max-width: 22ch; letter-spacing: -.02em; }
.auth-panel p { color: rgb(255 255 255 / .8); max-width: 44ch; margin: 0; }
.auth-flag { width: 120px; height: 5px; border-radius: 99px; background: linear-gradient(90deg, #00853F 0 33.3%, #FDEF42 33.3% 66.6%, #E31B23 66.6%); }
.auth-side { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-form { width: 100%; max-width: 420px; }
.auth-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 36px; text-align: center; }
.auth-head .brand-mark, .auth-head .brand-logo { width: 52px; height: 52px; border-radius: 16px; font-size: 17px; }
.auth-head .auth-app { font-weight: 700; color: var(--ink); line-height: 1.2; }
.auth-head .auth-app small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.auth-form h1 { text-align: center; font-size: 30px; margin-bottom: 8px; }
.auth-form .lead { text-align: center; color: var(--muted); margin-bottom: 28px; }
.auth-foot { margin-top: 40px; text-align: center; font-size: 13px; color: var(--faint); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-700); font-weight: 600; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.linkbtn[disabled] { color: var(--faint); cursor: default; text-decoration: none; }

/* Entrée discrète, une seule fois par page */
.auth-logo, .auth-form { opacity: 1; transform: none; transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out); }
@starting-style { .auth-logo { opacity: 0; transform: scale(.96); } .auth-form { opacity: 0; transform: translateY(8px); } }

/* Code à 6 chiffres */
.otp-input {
  text-align: center; font-size: 34px; font-weight: 700; letter-spacing: .42em; padding-left: .42em;
  font-variant-numeric: tabular-nums; min-height: 72px; caret-color: var(--brand);
}

@media (max-width: 900px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-split .auth-panel { order: 0 !important; padding: 32px 24px; gap: 14px; min-height: 0; }
  .auth-logo { width: 120px; }
  .auth-panel h2, .auth-panel p { display: none; }
  .auth-side { padding: 32px 16px 40px; justify-content: flex-start; }
  .auth-head { margin-bottom: 24px; }
  .auth-head .brand-mark, .auth-head .brand-logo, .auth-head .auth-app { display: none; }
}

/* ---- Paramètres : couleurs, images, aperçu ---------------------------------- */
.color-field { display: flex; align-items: center; gap: 12px; }
.color-field input[type="color"] { width: 56px; height: 52px; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; flex: none; }
.color-field .input { max-width: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--surface); cursor: pointer;
  box-shadow: 0 0 0 1px var(--line-strong); transition: transform 160ms var(--ease-out), box-shadow 150ms ease;
}
.swatch:active { transform: scale(.94); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.upload { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.upload .thumb {
  width: 76px; height: 76px; border-radius: 18px; object-fit: contain; flex: none;
  border: 1px solid var(--line); background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px;
}
.upload .thumb.round { border-radius: 50%; object-fit: cover; }
.upload input[type="file"] { max-width: 280px; font: inherit; font-size: 14px; color: var(--muted); }
.upload input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 8px 14px; margin-right: 10px; cursor: pointer;
}
.apercu-login { display: grid; grid-template-columns: 1fr 1fr; height: 220px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); }
.apercu-login[data-position="gauche"] .apercu-panneau { order: 2; }
.apercu-panneau { position: relative; overflow: hidden; display: grid; place-items: center; background: var(--login-panel, #274F3D); color: #fff; }
.apercu-panneau::before { content: ""; position: absolute; width: 280px; height: 280px; left: -140px; top: -150px; border-radius: 50%; border: 36px solid rgb(255 255 255 / .07); }
.apercu-panneau.sans-motif::before { display: none; }
.apercu-panneau img { width: 96px; height: 96px; object-fit: contain; position: relative; }
.apercu-panneau .vide { width: 88px; height: 88px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .45); display: grid; place-items: center; font-weight: 800; position: relative; }
.apercu-form { background: var(--surface); display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 0 24px; }
.apercu-form i { display: block; height: 12px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.apercu-form i.btn-fake { height: 18px; background: var(--brand); border: 0; margin-top: 4px; }
.device { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.device:first-child { border-top: 0; }
.device b { color: var(--ink); font-weight: 600; }
