/* =============================================================================
   Design system — un seul fichier, aucun build.
   Discipline : tout passe par les tokens ci-dessous. Aucune valeur de couleur,
   de taille ou d'espacement en dur dans les regles. Theme clair uniquement.
   ============================================================================= */
:root {
  /* --- Couleurs (echelle zinc + accents), contrastes verifies sur blanc ------
     foreground        #09090b  18.9:1   texte principal
     foreground-soft   #3f3f46  10.4:1   valeurs secondaires
     muted-foreground  #52525b   7.6:1   libelles, en-tetes de colonnes      */
  --background: #ffffff;
  --foreground: #09090b;
  --foreground-soft: #3f3f46;
  --muted-foreground: #52525b;
  --card: #ffffff;
  --surface: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --ring: #71717a;

  /* Statuts : texte fonce sur fond tres clair, ratio >= 4.5:1 */
  --ok-fg: #15803d;
  --ok-bg: #dcfce7;
  --ok-line: #16a34a;
  --ok-row: #f6fdf8;
  --ko-fg: #b91c1c;
  --ko-bg: #fee2e2;
  --ko-line: #dc2626;
  --ko-row: #fffafa;

  /* --- Typographie : echelle fermee, 5 pas, pas un de plus --------------- */
  --fs-xs: 0.6875rem;   /* 11px — en-tetes de colonnes, badges */
  --fs-sm: 0.8125rem;   /* 13px — texte secondaire */
  --fs-md: 0.875rem;    /* 14px — corps */
  --fs-lg: 1rem;        /* 16px — titres de carte */
  --fs-xl: 1.25rem;     /* 20px — titre de page */

  --lh-tight: 1.25;
  --lh-body: 1.4;
  --ls-tight: -0.02em;  /* titres */
  --ls-body: -0.006em;  /* corps : resserre la pile systeme */
  --ls-caps: 0.05em;    /* petites capitales */

  /* --- Espacement : multiples de 4, 6 pas ------------------------------- */
  --s1: 0.25rem;  /*  4px */
  --s2: 0.5rem;   /*  8px */
  --s3: 0.75rem;  /* 12px */
  --s4: 1rem;     /* 16px */
  --s5: 1.5rem;   /* 24px */
  --s6: 2rem;     /* 32px */

  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --control-h: 2.625rem;      /* 42px — cible tactile */
  --control-h-sm: 2.25rem;    /* 36px — desktop */
  --measure: 60rem;           /* largeur de lecture max */
  --shadow-pop: 0 0.5rem 1.5rem rgb(9 9 11 / 0.13), 0 0.125rem 0.375rem rgb(9 9 11 / 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
}

/* Chiffres alignes en colonne : dates, compteurs. */
.tnum, .item-meta, .badge { font-variant-numeric: tabular-nums; }

h1, h2, h3, p { margin: 0; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }

/* Mobile d'abord : une seule media query, en fin de fichier. */
.container { max-width: var(--measure); margin: 0 auto; padding: 0 var(--s3); }

/* --- Barre superieure ----------------------------------------------------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s4);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--s2);
  padding-block: var(--s3);
}
.brand {
  display: flex; align-items: baseline; gap: var(--s2);
  color: var(--foreground); text-decoration: none;
}
/* Contraste dans l'en-tete : nom de l'app en gras, site en secondaire. */
.brand-app {
  font-size: var(--fs-md); font-weight: 650;
  letter-spacing: var(--ls-tight); line-height: var(--lh-tight);
}
.brand-site {
  font-size: var(--fs-md); font-weight: 550;
  color: var(--foreground-soft);
  padding-left: var(--s2);
  border-left: 1px solid var(--border-strong);
}
/* --- Menu de compte (hamburger, mobile et desktop) ----------------------- */
.menu { position: relative; }
.menu-toggle {
  display: flex; align-items: center; justify-content: center;
  width: var(--control-h-sm); height: var(--control-h-sm);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--foreground);
  cursor: pointer;
}
.menu-toggle:hover, .menu[open] .menu-toggle { background: var(--surface); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 20;
  min-width: 13rem;
  padding: var(--s1);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.menu-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) var(--s3) var(--s3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s1);
}
.menu-item {
  display: flex; align-items: center;
  width: 100%; min-height: var(--control-h);
  padding: 0 var(--s3);
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--foreground);
  font: inherit; font-weight: 550; letter-spacing: inherit;
  text-align: left; text-decoration: none;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface); }
.menu-toggle:focus-visible, .menu-item:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}

/* --- Titres de page ------------------------------------------------------- */
.page-head { margin-bottom: var(--s4); }
.page-title {
  font-size: var(--fs-xl); font-weight: 650;
  letter-spacing: var(--ls-tight); line-height: var(--lh-tight);
  margin-bottom: var(--s1);
}
.page-actions { margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s1); }

.muted { color: var(--muted-foreground); }
.small { font-size: var(--fs-sm); }
.strong { font-weight: 550; }
.center { text-align: center; }
.pad { padding: var(--s4); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }

/* --- Carte --------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-body, .card-header { padding: var(--s4); }
.card-header { padding-bottom: 0; }
.card-title {
  font-size: var(--fs-lg); font-weight: 650;
  letter-spacing: var(--ls-tight); line-height: var(--lh-tight);
  margin-bottom: var(--s1);
}
.card-desc { color: var(--muted-foreground); font-size: var(--fs-sm); }

.auth-wrap { max-width: 23rem; margin: var(--s5) auto; }

/* --- Formulaires --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s1); }
.label { font-size: var(--fs-sm); font-weight: 550; color: var(--foreground); }
.input {
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--s3);
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit; letter-spacing: inherit;
}
.input::placeholder { color: var(--muted-foreground); }
.input:focus-visible, .btn:focus-visible, summary:focus-visible,
.choice:focus-within, .check-inline:focus-within {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* --- Boutons : pleine largeur sur mobile --------------------------------- */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--s4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 550; letter-spacing: inherit;
  text-decoration: none;
  color: var(--foreground);
  background: transparent;
  cursor: pointer;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-outline { background: var(--card); border-color: var(--border-strong); }
.btn-ghost {
  width: auto; min-height: var(--control-h-sm);
  padding: 0 var(--s2);
  font-size: var(--fs-sm); color: var(--muted-foreground);
}
.btn-block { width: 100%; }

.form-footer {
  display: flex; flex-direction: column; gap: var(--s2);
  margin-top: var(--s4);
}

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center;
  padding: var(--s1) var(--s2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 650;
  letter-spacing: var(--ls-caps); text-transform: uppercase;
  color: var(--foreground-soft);
  background: var(--surface);
  white-space: nowrap;
}
.badge-success { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.badge-destructive { color: var(--ko-fg); background: var(--ko-bg); border-color: var(--ko-line); }

/* --- Alertes ------------------------------------------------------------- */
.alert {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  margin-bottom: var(--s4);
  font-size: var(--fs-sm);
}
.alert ul { margin: var(--s1) 0 0; padding-left: var(--s4); }
.alert-error { color: var(--ko-fg); background: var(--ko-bg); border-color: var(--ko-line); }
.alert-success { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }

/* --- Item : LE composant de liste, reutilise partout ---------------------
   Mobile  : nom + statut sur une ligne, metadonnees dessous.
   Desktop : trois colonnes alignees. Aucun tableau, donc rien qui deborde.  */
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s1) var(--s3);
  align-items: center;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.item:last-child { border-bottom: 0; }
.item-name {
  font-size: var(--fs-md); font-weight: 550;
  letter-spacing: var(--ls-tight);
  color: var(--foreground);
}
.item-meta {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 0 var(--s4);
  font-size: var(--fs-sm);
  color: var(--foreground-soft);
}
.meta-label { color: var(--muted-foreground); }

/* En-tete de liste : joue le role du <thead>. Contraste renforce. */
.list-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  padding-block: var(--s2);
  font-size: var(--fs-xs); font-weight: 650;
  letter-spacing: var(--ls-caps); text-transform: uppercase;
  color: var(--muted-foreground);
}
.list-head .item-meta { display: none; }   /* mobile : « Motif : … » est auto-libelle */

/* Statut : liseret plein a gauche + fond a peine teinte, pour que le texte
   reste a pleine lisibilite. */
.row-ok { border-left-color: var(--ok-line); background: var(--ok-row); }
.row-ko { border-left-color: var(--ko-line); background: var(--ko-row); }
.row-none { border-left-color: var(--border-strong); }

/* --- Controle quotidien -------------------------------------------------- */
.terminal-card { padding: var(--s3) var(--s4); }
.terminal-row { display: flex; flex-direction: column; gap: var(--s2); }
.choices { display: flex; gap: var(--s2); }
.choice {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--control-h);
  padding: 0 var(--s3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-md); font-weight: 550;
  cursor: pointer;
}
.choice input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: currentColor; }
.choice-ok:has(input:checked) { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.choice-ko:has(input:checked) { color: var(--ko-fg); background: var(--ko-bg); border-color: var(--ko-line); }
.reason-field {
  display: flex; flex-direction: column; gap: var(--s1);
  margin-top: var(--s3); padding-top: var(--s3);
  border-top: 1px dashed var(--border-strong);
}

/* --- Direction : lignes depliables (details/summary natif) --------------- */
.site-item { border-bottom: 1px solid var(--border); }
.site-item:last-child { border-bottom: 0; }
.site-item > summary { cursor: pointer; }
.site-item > summary:hover { background: var(--surface); }
.site-item > summary .item { border-bottom: 0; }
.site-item[open] > summary .item { border-bottom: 1px solid var(--border-strong); }
.site-item:not([open]) > summary .item-name::after { content: " \25B8"; color: var(--muted-foreground); }
.site-item[open] > summary .item-name::after { content: " \25BE"; color: var(--muted-foreground); }
.site-detail { background: var(--surface); padding-bottom: var(--s1); }
.site-detail .item { padding-left: var(--s5); background: var(--card); }

/* --- Formulaires en ligne (admin) --------------------------------------- */
.inline-form { display: flex; flex-direction: column; gap: var(--s2); }
.item .inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; }
.item .inline-form .input { width: auto; flex: 1 1 10rem; min-height: var(--control-h-sm); }
.check-inline { display: flex; align-items: center; gap: var(--s2); cursor: pointer; }
.check-inline input { width: 1.125rem; height: 1.125rem; margin: 0; }

/* =============================== Desktop ================================= */
@media (min-width: 44rem) {
  .container { padding: 0 var(--s4); }
  .topbar { margin-bottom: var(--s5); }
  .topbar-inner { padding-block: var(--s4); }

  .page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: var(--s4); margin-bottom: var(--s5);
  }
  .page-actions { margin-top: 0; align-items: flex-end; flex: 0 0 auto; }

  .card-body, .card-header { padding: var(--s5); }

  .btn { display: inline-flex; width: auto; min-height: var(--control-h-sm); }
  .btn-block { width: 100%; }
  .form-footer { flex-direction: row; align-items: center; gap: var(--s3); }

  .item { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.2fr); }
  .item-meta { grid-column: auto; justify-content: flex-end; }
  .meta-label { display: none; }             /* l'en-tete de colonne suffit */
  .list-head .item-meta { display: flex; }

  .terminal-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .choices { flex: 0 0 auto; }
  .choice { flex: 0 0 auto; min-width: 5.5rem; }
  .reason-field { max-width: 23rem; }

  .inline-form { flex-direction: row; align-items: center; }
  .inline-form .input { flex: 1 1 auto; }
}
