/*
  ai-prices — feuille de style unique, sans dependance externe.
  Direction : dossier editorial sobre (papier chaud, encre marine, chiffres
  en tabulaire) — un produit qui doit inspirer confiance a un investisseur,
  pas une demo technique. Polices systeme uniquement (aucune police
  telechargee) : serif d'affichage + sans-serif de texte + mono pour les
  chiffres alignes.
*/

:root {
  color-scheme: light;
  --page: #f7f4ec;
  --surface: #fffdf8;
  --surface-raised: #ffffff;
  --ink: #16181c;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --hairline: #e1ded2;
  --hairline-strong: #c9c5b6;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #e7eef8;
  --serie-us: #2a78d6;
  --serie-ue: #eb6834;
  --good: #0ca30c;
  --warn-bg: #fbf3df;
  --warn-border: #e0c67c;
  --warn-ink: #6b4e00;
  --shadow: 0 1px 2px rgba(22, 24, 28, 0.04), 0 8px 24px rgba(22, 24, 28, 0.06);

  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #17181a;
    --surface-raised: #1e1f21;
    --ink: #f5f4ef;
    --ink-secondary: #c3c2b7;
    --ink-muted: #8f8d84;
    --hairline: #2c2c2a;
    --hairline-strong: #3a3a37;
    --accent: #5b9be0;
    --accent-ink: #0d0d0d;
    --accent-soft: #1c2a3a;
    --serie-us: #3987e5;
    --serie-ue: #d95926;
    --good: #0ca30c;
    --warn-bg: #2a2410;
    --warn-border: #6b5a1c;
    --warn-ink: #e0c67c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #17181a;
  --surface-raised: #1e1f21;
  --ink: #f5f4ef;
  --ink-secondary: #c3c2b7;
  --ink-muted: #8f8d84;
  --hairline: #2c2c2a;
  --hairline-strong: #3a3a37;
  --accent: #5b9be0;
  --accent-ink: #0d0d0d;
  --accent-soft: #1c2a3a;
  --serie-us: #3987e5;
  --serie-ue: #d95926;
  --good: #0ca30c;
  --warn-bg: #2a2410;
  --warn-border: #6b5a1c;
  --warn-ink: #e0c67c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0 0 0.4em;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.4rem);
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.1rem;
}

.chiffres {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Structure ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--hairline);
}

.site-header__inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-header__brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
}

.site-header__mark {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--ink);
  color: var(--page);
  padding: 0.28em 0.5em;
  border-radius: 3px;
}

.site-header__wordmark {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

.site-nav {
  display: flex;
  gap: 1.4rem;
  font-size: 0.95rem;
}

.site-nav a {
  color: var(--ink-secondary);
  text-decoration: none;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  color: var(--ink);
}

.site-nav a.est-actif {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.page {
  max-width: 76rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-entete {
  margin-bottom: 1.75rem;
}

.page-entete p {
  color: var(--ink-secondary);
  max-width: 46rem;
}

.site-footer {
  border-top: 1px solid var(--hairline);
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--ink-muted);
}

/* ---------- Cartes & filtres ---------- */

.carte {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

.filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: end;
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}

.filtres__champ {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filtres__champ label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.filtres select,
.filtres button {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-raised);
  color: var(--ink);
}

.filtres button {
  background: var(--ink);
  color: var(--page);
  border-color: var(--ink);
  cursor: pointer;
}

.filtres__reinit {
  color: var(--ink-muted);
  font-size: 0.85rem;
  align-self: center;
  text-decoration: underline;
}

/* ---------- Tableaux ---------- */

.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 42rem;
  font-size: 0.92rem;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 0.9rem 1rem 0;
  color: var(--ink-secondary);
  font-size: 0.85rem;
}

thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--surface);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hairline-strong);
  white-space: nowrap;
}

th.triable {
  cursor: pointer;
  user-select: none;
}

th.triable:hover {
  color: var(--ink);
}

th.triable::after {
  content: "⇅";
  margin-left: 0.35em;
  opacity: 0.4;
  font-size: 0.85em;
}

th.triable.tri-asc::after {
  content: "↑";
  opacity: 1;
}

th.triable.tri-desc::after {
  content: "↓";
  opacity: 1;
}

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

td.num, th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.lien-source {
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---------- Badges de methode ---------- */

.methode {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.82rem;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.methode__trait {
  width: 1.4em;
  height: 0;
  border-top: 2px solid var(--ink-secondary);
}

.methode--reconstitue .methode__trait {
  border-top-style: dashed;
}

/* ---------- Graphiques ---------- */

.graphique {
  position: relative;
  height: 360px;
  margin-bottom: 0.5rem;
}

.graphique--haute {
  height: 480px;
}

.graphique-legende {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-size: 0.85rem;
  color: var(--ink-secondary);
  margin-bottom: 1rem;
}

.graphique-legende__item {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}

.graphique-legende__trait {
  width: 1.6em;
  height: 0;
  border-top: 2px solid var(--ink-secondary);
}

.graphique-legende__trait--pointille {
  border-top-style: dashed;
}

/* ---------- Statistiques (page souverainete) ---------- */

.stat-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
}

.stat-hero__valeur {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.4rem, 1.8rem + 2vw, 3.6rem);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.stat-hero__contexte {
  max-width: 34rem;
  color: var(--ink-secondary);
  font-size: 0.95rem;
}

.stat-hero__contexte strong {
  color: var(--ink);
}

.avertissement {
  display: flex;
  gap: 0.75rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-ink);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  font-size: 0.9rem;
  margin: 1rem 0 1.25rem;
}

.avertissement__icone {
  font-family: var(--font-display);
  font-weight: 700;
  flex: none;
}

.puce-zone {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.puce-zone::before {
  content: "";
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--puce, var(--ink-muted));
}

.puce-zone--us {
  --puce: var(--serie-us);
}

.puce-zone--ue {
  --puce: var(--serie-ue);
}

/* ---------- Formulaires (evolution) ---------- */

.selecteur-offres {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.4rem 1rem;
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.25rem 0.25rem 0.25rem 0;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0.75rem;
}

.selecteur-offres label {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.88rem;
  padding: 0.15rem 0;
}

.selecteur-offres input[disabled] + span {
  color: var(--ink-muted);
}

.note {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-top: 0.5rem;
}

/* ---------- Vide ---------- */

.etat-vide {
  color: var(--ink-muted);
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

@media (max-width: 600px) {
  .site-header__wordmark {
    display: none;
  }

  .stat-hero {
    flex-direction: column;
  }
}

/* ---------- Espace protege : connexion ---------- */

.connexion {
  display: flex;
  justify-content: center;
  padding-top: 3rem;
}

.connexion__carte {
  width: 100%;
  max-width: 24rem;
}

.connexion__intro {
  color: var(--ink-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.connexion__formulaire {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.connexion__formulaire label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.connexion__formulaire input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-raised);
  color: var(--ink);
}

.connexion__erreur {
  margin-top: 1rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
}

/* ---------- Boutons ---------- */

.bouton {
  font: inherit;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
}

.connexion__formulaire button,
.bouton--principal {
  background: var(--ink);
  color: var(--page);
  border-color: var(--ink);
  font-weight: 600;
}

.bouton--valider {
  border-color: var(--good);
  color: var(--good);
}

.bouton--rejeter {
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

/* ---------- Simulateur ---------- */

.scenario__description {
  color: var(--ink-secondary);
  max-width: 46rem;
}

.scenario__formulaire {
  margin: 1.25rem 0;
}

.scenario__grille {
  display: grid;
  grid-template-columns: minmax(14rem, 22rem) 1fr;
  gap: 1.5rem 2rem;
  margin-bottom: 1rem;
}

.scenario__parametres h3,
.scenario__postes h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.champ {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.champ label {
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.note-inline {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 400;
}

.champ input,
.champ select {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface-raised);
  color: var(--ink);
}

.scenario__poste-vide {
  font-size: 0.85rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin: 0;
}

.scenario__resultat {
  margin-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  padding-top: 1.5rem;
}

.stat-hero--compact .stat-hero__valeur {
  font-size: clamp(1.8rem, 1.5rem + 1vw, 2.4rem);
}

.reperes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.repere-puce {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
}

.avertissement--alerte {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-ink);
}

.avertissement--ok {
  background: color-mix(in srgb, var(--good) 12%, var(--surface));
  border-color: var(--good);
  color: var(--ink);
}

.chiffre-negatif {
  color: var(--warn-ink);
}

/* Marque un chiffre derive d'une conversion non sourcee (ex. credits par
   titre publie) : sert a la fois dans le libelle de quantite d'un poste,
   sa ligne dans le tableau de decomposition, et le total qui en depend.
   Infobulle native (attribut title) + note de bas de tableau, pas
   seulement l'une ou l'autre. */
.marque-non-source {
  cursor: help;
  color: var(--warn-ink);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dotted var(--warn-ink);
}

.economies {
  margin-top: 1.25rem;
}

.bascule {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
}

.bascule:first-of-type {
  margin-top: 0.5rem;
  padding-top: 0;
  border-top: none;
}

.bascule__seuil {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.bascule__classement {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.bascule__classement > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0.6rem;
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
}

.bascule__classement dt,
.bascule__classement dd {
  margin: 0;
  color: var(--ink-secondary);
}

.bascule__classement dd {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Administration ---------- */

.admin-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-entete h2 {
  margin: 0;
}

.admin-decision {
  display: flex;
  gap: 0.5rem;
  white-space: nowrap;
}

.admin-decision form {
  margin: 0;
}

.statut {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--hairline);
  color: var(--ink-secondary);
}

.statut--ok {
  background: color-mix(in srgb, var(--good) 18%, transparent);
  color: var(--good);
}

.statut--echec {
  background: var(--warn-bg);
  color: var(--warn-ink);
}

@media (max-width: 720px) {
  .scenario__grille {
    grid-template-columns: 1fr;
  }
}
