/* compeener.css — design system Compeener, « le relevé ».
   Le marché est lu comme une carte bathymétrique : des paliers de bleu (abysse, nuit, cobalt, lagon, ciel) pour
   la profondeur, et une seule contre-couleur, le laiton des instruments : ce qui mérite d'être regardé (une cible A,
   l'action principale d'une bande sombre) et les repères (thèse, critères, sélection). Une seule famille, Instrument Sans, dont l'axe de
   largeur fait la hiérarchie : étroite (75) pour les titres et les chiffres, normale pour le texte.
   Référence complète : le design system « Compeener » (artifact) et docs/design-system.md. */

@import url("polices.css");

/* ---------- jetons : palette de référence (fixe) ---------- */
:root {
  --abysse: #06162C; --nuit: #0B2A4A; --cobalt: #1D5BD8; --lagon: #5B9BEF; --ciel: #BFD8F5; --ecume: #E3EEFB;
  --laiton: #C99A3B; --laiton-profond: #B08327;

  /* ---------- jetons de rôle : clair ---------- */
  --fond: #F6F8FB; --surface: #FFFFFF; --creux: #EDF2F8;
  --encre: #14233A; --titre: #0B2A4A; --discret: #4A5B73; --trait: #D6DFEA; --trait-fort: #7F8FA6;
  --action: #1D5BD8; --action-survol: #164AB5; --action-encre: #FFFFFF; --action-doux: #E3EEFB;
  --repere: #C99A3B; --repere-encre: #7D5A12; --repere-doux: #F6ECD6; --repere-sur: #06162C;
  --ok: #1F7A55; --ok-doux: #E2F3EA; --attention: #995900; --attention-doux: #FBEFD9; --erreur: #B5332A; --erreur-doux: #FBE5E2;
  --focus: #1D5BD8;
  /* bande sombre : identique dans les deux thèmes (c'est la carte) */
  --bande: #06162C; --bande-encre: #EAF1FA; --bande-discret: #A9BCD6; --bande-trait: #1E3A5F; --bande-action: #8FBDF3;
  /* tiers de priorité : A laiton, B cobalt, C ardoise, X filiale exclue */
  --tA: #B08327; --tA-encre: #06162C; --tB: #1D5BD8; --tB-encre: #FFFFFF; --tC: #5A6A80; --tC-encre: #FFFFFF; --tX: #7A8AA1;

  /* ---------- typographie ---------- */
  --police: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --etroit: 75%; --dense: 87.5%;
  --t-micro: 0.75rem; --t-legende: 0.8125rem; --t-ui: 0.875rem; --t-texte: 1rem; --t-chapo: 1.1875rem;
  --t-titre-4: 1.25rem; --t-titre-3: 1.5625rem; --t-titre-2: 2rem; --t-titre-1: 2.75rem; --t-affiche: clamp(2.75rem, 1.6rem + 4.4vw, 4.75rem);

  /* ---------- espacement, rayons, ombres, mouvement ---------- */
  --e-1: 4px; --e-2: 8px; --e-3: 12px; --e-4: 16px; --e-5: 24px; --e-6: 32px; --e-7: 48px; --e-8: 64px; --e-9: 96px;
  --r-1: 3px; --r-2: 6px; --r-3: 10px; --r-plein: 999px;
  --ombre-1: 0 1px 2px rgb(6 22 44 / 0.08); --ombre-2: 0 12px 32px -16px rgb(6 22 44 / 0.45);
  --duree: 160ms; --courbe: cubic-bezier(.2, .7, .2, 1);
  --largeur: 1160px;
  color-scheme: light;
}

/* ---------- jetons de rôle : sombre ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #071427; --surface: #0C1D36; --creux: #091830;
    --encre: #E6EEF8; --titre: #F4F8FD; --discret: #9DB0C8; --trait: #1D3557; --trait-fort: #4A6C99;
    --action: #7BAEF4; --action-survol: #9CC3F7; --action-encre: #06162C; --action-doux: #12305A;
    --repere: #D4A94E; --repere-encre: #E3BE6B; --repere-doux: #2C2616; --repere-sur: #06162C; --tA: #D4A94E;
    --ok: #5CC596; --ok-doux: #123426; --attention: #E8A13A; --attention-doux: #33260F; --erreur: #F08A7D; --erreur-doux: #3A1C1A;
    --focus: #9CC3F7; --bande: #040F20; --bande-trait: #1A3354;
    --tB: #7BAEF4; --tB-encre: #06162C; --tC: #9DB0C8; --tC-encre: #06162C; --tX: #7D8FA9;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #071427; --surface: #0C1D36; --creux: #091830;
  --encre: #E6EEF8; --titre: #F4F8FD; --discret: #9DB0C8; --trait: #1D3557; --trait-fort: #4A6C99;
  --action: #7BAEF4; --action-survol: #9CC3F7; --action-encre: #06162C; --action-doux: #12305A;
  --repere: #D4A94E; --repere-encre: #E3BE6B; --repere-doux: #2C2616; --repere-sur: #06162C; --tA: #D4A94E;
  --ok: #5CC596; --ok-doux: #123426; --attention: #E8A13A; --attention-doux: #33260F; --erreur: #F08A7D; --erreur-doux: #3A1C1A;
  --focus: #9CC3F7; --bande: #040F20; --bande-trait: #1A3354;
  --tB: #7BAEF4; --tB-encre: #06162C; --tC: #9DB0C8; --tC-encre: #06162C; --tX: #7D8FA9;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--encre); font: 400 var(--t-texte)/1.62 var(--police);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { max-width: 100%; }
a { color: var(--action); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--action-survol); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }
p { margin: 0; }
h1, h2, h3, h4, .ds-affiche, .ds-titre-1, .ds-titre-2, .ds-titre-3, .ds-titre-4 {
  margin: 0; color: var(--titre); font-family: var(--police); font-stretch: var(--etroit); font-weight: 620;
  letter-spacing: -0.012em; text-wrap: balance; }
.ds-affiche { font-size: var(--t-affiche); line-height: 0.98; font-weight: 640; letter-spacing: -0.018em; }
.ds-titre-1, h1 { font-size: var(--t-titre-1); line-height: 1.04; }
.ds-titre-2, h2 { font-size: var(--t-titre-2); line-height: 1.1; }
.ds-titre-3, h3 { font-size: var(--t-titre-3); line-height: 1.16; }
.ds-titre-4, h4 { font-size: var(--t-titre-4); line-height: 1.25; font-weight: 600; }
.ds-chapo { font-size: var(--t-chapo); line-height: 1.55; color: var(--discret); max-width: 36em; }
.ds-aide { font-size: var(--t-legende); line-height: 1.5; color: var(--discret); }
.ds-sur-titre { font-size: var(--t-ui); font-weight: 600; color: var(--repere-encre); margin-bottom: var(--e-2); }
.ds-chiffre { font-variant-numeric: tabular-nums; font-stretch: var(--dense); }
.ds-mesure { max-width: 68ch; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- mise en page ---------- */
.ds-conteneur { width: 100%; max-width: calc(var(--largeur) + 2 * 24px); margin-inline: auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
@media (max-width: 480px) { .ds-conteneur { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); } }
.ds-section { padding-block: var(--e-9); }
@media (max-width: 760px) { .ds-section { padding-block: var(--e-8); } }
.ds-bande { background: var(--bande); color: var(--bande-encre); position: relative; isolation: isolate; }
.ds-bande h1, .ds-bande h2, .ds-bande h3, .ds-bande .ds-affiche, .ds-bande .ds-titre-2, .ds-bande .ds-titre-3 { color: var(--bande-encre); }
.ds-bande .ds-chapo, .ds-bande .ds-aide { color: var(--bande-discret); }
.ds-bande .ds-sur-titre { color: var(--laiton); }
.ds-bande a:not(.ds-btn) { color: var(--bande-action); }
.ds-bande :focus-visible { outline-color: var(--laiton); }
.ds-releve-fond { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.ds-releve-fond img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- barre du haut ---------- */
.ds-barre { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--fond);
  border-bottom: 1px solid var(--trait); }
.ds-barre .ds-conteneur { display: flex; align-items: center; gap: var(--e-5); min-height: 64px; flex-wrap: wrap; padding-block: var(--e-2); }
.ds-barre--simple { position: static; border-bottom: 0; background: transparent; }
.ds-barre--simple { padding: var(--e-5) max(24px, env(safe-area-inset-right, 0px)) 0 max(24px, env(safe-area-inset-left, 0px)); }
.ds-marque { display: inline-flex; align-items: center; }
.ds-marque img { height: 34px; width: auto; display: block; }
.ds-logo-sombre { display: none !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ds-logo-clair { display: none !important; }
  :root:not([data-theme="light"]) .ds-logo-sombre { display: block !important; } }
:root[data-theme="dark"] .ds-logo-clair { display: none !important; }
:root[data-theme="dark"] .ds-logo-sombre { display: block !important; }
.ds-nav { display: flex; align-items: center; gap: var(--e-5); margin-left: auto; flex-wrap: wrap; }
.ds-nav a:not(.ds-btn) { color: var(--encre); text-decoration: none; font-weight: 550; font-size: var(--t-ui); }
.ds-nav a:not(.ds-btn):hover { color: var(--action); }
.ds-nav .ds-actions { gap: var(--e-2); }

/* ---------- boutons ---------- */
.ds-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2); min-height: 42px;
  padding: 0 var(--e-5); border-radius: var(--r-2); border: 1.5px solid transparent; font: 600 var(--t-ui)/1 var(--police);
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background var(--duree) var(--courbe),
  border-color var(--duree) var(--courbe), color var(--duree) var(--courbe); }
.ds-btn--plein { background: var(--action); color: var(--action-encre); }
.ds-btn--plein:hover { background: var(--action-survol); color: var(--action-encre); }
.ds-btn--contour { border-color: var(--trait-fort); color: var(--titre); background: var(--surface); }
.ds-btn--contour:hover { border-color: var(--action); color: var(--action); }
.ds-btn--discret { color: var(--action); background: transparent; padding-inline: var(--e-3); }
.ds-btn--discret:hover { background: var(--action-doux); }
.ds-btn--danger { color: var(--erreur); border-color: currentColor; background: transparent; }
.ds-btn--danger:hover { background: var(--erreur-doux); color: var(--erreur); }
/* le laiton : l'action principale d'une bande sombre, une seule par page */
.ds-btn--laiton { background: var(--laiton); color: var(--abysse); }
.ds-btn--laiton:hover { background: #D8AE57; color: var(--abysse); }
.ds-bande .ds-btn--contour { background: transparent; color: var(--bande-encre); border-color: #3F5F88; }
.ds-bande .ds-btn--contour:hover { border-color: var(--bande-encre); color: var(--bande-encre); }
.ds-btn--grand { min-height: 50px; padding: 0 var(--e-6); font-size: var(--t-texte); }
.ds-btn--petit { min-height: 32px; padding: 0 var(--e-3); font-size: var(--t-legende); }
.ds-btn[disabled], .ds-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.ds-actions { display: flex; flex-wrap: wrap; gap: var(--e-3); align-items: center; }

/* ---------- affichage clair / sombre (assets/mode.js) ---------- */
.ds-mode { display: inline-flex; border: 1px solid var(--trait-fort); border-radius: var(--r-2); overflow: hidden; }
.ds-mode button { appearance: none; background: transparent; border: 0; cursor: pointer; min-height: 32px; padding: 0 var(--e-3);
  font: 600 var(--t-legende)/1 var(--police); color: var(--discret); }
.ds-mode button + button { border-left: 1px solid var(--trait-fort); }
.ds-mode button[aria-pressed="true"] { background: var(--action-doux); color: var(--titre); }
.ds-mode button:focus-visible { outline-offset: -2px; }

/* ---------- cartes ---------- */
.ds-carte { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--r-3); padding: var(--e-6);
  display: flex; flex-direction: column; gap: var(--e-4); min-width: 0; }
.ds-carte--centre { max-width: 560px; margin: var(--e-8) auto; box-shadow: var(--ombre-1); }
.ds-carte--erreur { border-top: 3px solid var(--erreur); }
.ds-carte p { color: var(--encre); }

/* ---------- formulaires ---------- */
.ds-form { display: grid; gap: var(--e-5); }
.ds-form--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-form--2 .ds-champ--large { grid-column: 1 / -1; }
@media (max-width: 560px) { .ds-form--2 { grid-template-columns: minmax(0, 1fr); } }
.ds-champ { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ds-champ > label, .ds-label { font-size: var(--t-ui); font-weight: 600; color: var(--titre); }
.ds-champ .ds-facultatif { font-weight: 400; color: var(--discret); }
.ds-input, .ds-champ input:not([type="checkbox"]):not([type="radio"]), .ds-champ textarea, .ds-champ select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-2); border: 1px solid var(--trait-fort);
  background: var(--surface); color: var(--encre); font: 400 var(--t-texte)/1.4 var(--police); }
.ds-champ textarea { min-height: 104px; resize: vertical; }
.ds-input:focus, .ds-champ input:focus, .ds-champ textarea:focus, .ds-champ select:focus {
  outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-doux); }
.ds-champ input[aria-invalid="true"] { border-color: var(--erreur); }
.ds-case { display: flex; gap: var(--e-3); align-items: flex-start; font-size: var(--t-ui); line-height: 1.5; color: var(--encre); }
.ds-case input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--action); flex: none; }
.ds-piege { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- alertes ---------- */
.ds-alerte { border-radius: var(--r-2); padding: var(--e-3) var(--e-4); font-size: var(--t-ui); line-height: 1.5;
  background: var(--action-doux); color: var(--encre); border: 1px solid transparent; }
.ds-alerte--ok { background: var(--ok-doux); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.ds-alerte--attention { background: var(--attention-doux); border-color: color-mix(in srgb, var(--attention) 35%, transparent); }
.ds-alerte--erreur { background: var(--erreur-doux); border-color: color-mix(in srgb, var(--erreur) 35%, transparent); }

/* ---------- pastilles (tiers, statuts) ---------- */
.ds-pastille { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 24px; height: 22px;
  padding: 0 8px; border-radius: var(--r-1); font: 700 var(--t-micro)/1 var(--police); letter-spacing: .02em;
  background: var(--creux); color: var(--discret); white-space: nowrap; }
.ds-pastille--A { background: var(--tA); color: var(--tA-encre); }
.ds-pastille--B { background: var(--tB); color: var(--tB-encre); }
.ds-pastille--C { background: var(--tC); color: var(--tC-encre); }
.ds-pastille--X { background: transparent; color: var(--tX); box-shadow: inset 0 0 0 1.5px var(--tX); text-decoration: line-through; }
.ds-pastille--attente { background: var(--attention-doux); color: var(--attention); }
.ds-pastille--ok { background: var(--ok-doux); color: var(--ok); }
.ds-pastille--refus { background: var(--erreur-doux); color: var(--erreur); }
.ds-pastille--repere { background: var(--repere-doux); color: var(--repere-encre); }
.ds-point { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- tableaux ---------- */
.ds-defile { overflow-x: auto; min-width: 0; }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--t-ui); font-variant-numeric: tabular-nums; }
.ds-table th { text-align: left; font-weight: 600; font-size: var(--t-legende); color: var(--discret); padding: 8px 12px;
  border-bottom: 1px solid var(--trait-fort); white-space: nowrap; }
.ds-table td { padding: 10px 12px; border-bottom: 1px solid var(--trait); vertical-align: top; }
.ds-table .ds-n { text-align: right; font-stretch: var(--dense); white-space: nowrap; }
.ds-table tr:hover td { background: var(--creux); }

/* ---------- divers ---------- */
.ds-liste-def { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--e-5); margin: 0; font-size: var(--t-ui); }
.ds-liste-def dt { color: var(--discret); }
.ds-liste-def dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.ds-citation { margin: 0; padding: var(--e-3) var(--e-4); background: var(--creux); border-radius: var(--r-2); font-style: italic; color: var(--encre); }
.ds-code { font: 600 var(--t-texte)/1.4 var(--police); font-stretch: var(--dense); letter-spacing: .06em; font-variant-numeric: tabular-nums;
  background: var(--repere-doux); color: var(--repere-encre); padding: 6px 10px; border-radius: var(--r-1); user-select: all; overflow-wrap: anywhere; }
.ds-releve { display: flex; flex-direction: column; gap: 2px; }
.ds-releve b { font-stretch: var(--etroit); font-weight: 620; font-size: var(--t-titre-2); line-height: 1.05; color: var(--titre); font-variant-numeric: tabular-nums; }
.ds-releve span { font-size: var(--t-ui); color: var(--discret); }
.ds-bande .ds-releve b { color: var(--bande-encre); }
.ds-bande .ds-releve span { color: var(--bande-discret); }

/* ---------- pages simples (connexion, résultats de formulaires) ---------- */
.ds-page--simple { min-height: 100vh; background: var(--fond); }
.ds-centre { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.ds-carte--centre h1 { font-size: var(--t-titre-2); }

/* ---------- écran partagé (demande d'accès, connexion) : la carte à gauche, le formulaire à droite ---------- */
.ds-ecran { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.ds-ecran-carte { display: flex; flex-direction: column; justify-content: space-between; gap: var(--e-7);
  padding: var(--e-6) var(--e-7) var(--e-7); padding-left: max(var(--e-7), env(safe-area-inset-left, 0px)); }
.ds-ecran-carte .ds-marque img { height: 32px; }
.ds-ecran-carte .ds-titre-1 { max-width: 12em; }
.ds-ecran-carte .ds-chapo { margin-top: var(--e-4); }
.ds-ecran-form { display: flex; align-items: center; justify-content: center; padding: var(--e-8) var(--e-6);
  padding-right: max(var(--e-6), env(safe-area-inset-right, 0px)); }
.ds-ecran-form > div { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: var(--e-5); }
.ds-ecran-form .ds-titre-2 + p { color: var(--discret); }
@media (max-width: 860px) {
  .ds-ecran { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .ds-ecran-carte { padding: var(--e-5) max(16px, env(safe-area-inset-right, 0px)) var(--e-6) max(16px, env(safe-area-inset-left, 0px)); gap: var(--e-6); }
  .ds-ecran-form { padding: var(--e-6) max(16px, env(safe-area-inset-right, 0px)) var(--e-8) max(16px, env(safe-area-inset-left, 0px)); }
}
.ds-ecran-form > div > div:first-child { display: flex; flex-direction: column; gap: var(--e-2); }

/* ---------- onglets ---------- */
.ds-onglets { display: flex; gap: var(--e-1); border-bottom: 1px solid var(--trait); overflow-x: auto; }
.ds-onglets button { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: var(--e-3) var(--e-4); font: 600 var(--t-ui)/1 var(--police); color: var(--discret); cursor: pointer; white-space: nowrap;
  display: inline-flex; gap: var(--e-2); align-items: center; }
.ds-onglets button:hover { color: var(--titre); }
.ds-onglets button[aria-selected="true"] { color: var(--titre); border-bottom-color: var(--action); }
.ds-compte { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-plein); background: var(--repere); color: var(--repere-sur);
  font: 700 var(--t-micro)/20px var(--police); text-align: center; font-variant-numeric: tabular-nums; }
.ds-vide { padding: var(--e-7) var(--e-5); text-align: center; color: var(--discret); border: 1px dashed var(--trait-fort); border-radius: var(--r-3); }
