/*
 * Pages servies par le serveur, hors de l'application React : connexion (/login), « Listes de référence » (/admin), autorisation
 * du connecteur Claude (/oauth/authorize, mcp_acces.py). Une seule feuille pour les trois, à la charte (DESIGN.md) : fond gris clair,
 * surfaces blanches à filet de 1 px, en-tête bleu nuit avec le logo en version négative, bouton principal orange à texte noir.
 * Mode clair seulement.
 *
 * Servie SANS connexion, comme la police et le logo (Handler.FICHIERS_PUBLICS dans serve_cockpit.py) : la page de connexion
 * s'affiche avant toute session.
 *
 * Police : Cabin (licence OFL, assets/cabin-OFL.txt), les mêmes fichiers woff2 latins que l'application (paquet @fontsource/cabin
 * 5.3.0), copiés ici sous des noms stables.
 */
@font-face { font-family: 'Cabin'; font-style: normal; font-weight: 400; font-display: swap; src: url('cabin-latin-400.woff2') format('woff2'); }
@font-face { font-family: 'Cabin'; font-style: normal; font-weight: 600; font-display: swap; src: url('cabin-latin-600.woff2') format('woff2'); }
@font-face { font-family: 'Cabin'; font-style: normal; font-weight: 700; font-display: swap; src: url('cabin-latin-700.woff2') format('woff2'); }

:root {
  --orange: #FF4B00;
  --nuit: #283376;
  --noir: #1D1D1B;
  --gris-texte: #575756;
  --fond: #EDEDED;
  --blanc: #FFFFFF;
  --danger: #B71C1C;
  --positif: #1B5E20;
  --filet: rgba(29, 29, 27, 0.14);
  --voile: rgba(40, 51, 118, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--fond); color: var(--noir);
  font-family: Cabin, Calibri, 'Trebuchet MS', sans-serif; font-size: 14px; line-height: 1.45;
}
a { color: var(--nuit); }
:focus-visible { outline: 2px solid var(--nuit); outline-offset: 2px; }

/* En-tête bleu nuit : logo complet sur ordinateur (52 px de haut, 10 px de marge dans l'en-tête de 72 px, comme l'application),
   icône seule sur téléphone. Le logo n'est jamais déformé ni recoloré : seule sa hauteur est posée. */
.entete {
  background: var(--nuit); color: var(--blanc); min-height: 72px; display: flex; align-items: center; gap: 16px;
  padding: 5px max(24px, env(safe-area-inset-right)) 5px max(24px, env(safe-area-inset-left));
}
.entete img { display: block; height: 52px; width: auto; flex-shrink: 0; }
.entete .nom { font-size: 16px; font-weight: 700; line-height: 1.3; }

/* Contenu de la page : 24 px de marge sur ordinateur, 16 px sur téléphone (zones sûres comprises). */
.page { max-width: 1200px; margin: 0 auto; padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left)); }
.page.etroite { max-width: 456px; padding-top: 48px; }

.carte { background: var(--blanc); border: 1px solid var(--filet); border-radius: 8px; padding: 16px; }
.page.etroite .carte { padding: 24px; }

h1 { font-size: 22px; font-weight: 700; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 16px; font-weight: 700; line-height: 1.3; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.sub { color: var(--gris-texte); font-size: 13px; line-height: 1.4; }
.err { color: var(--danger); font-size: 13px; margin: 0 0 12px; }

/* Champs : 44 px de haut au moins, rayon de 8 px, filet du gris texte, anneau de focus bleu nuit. */
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=hidden]), select {
  font: inherit; color: var(--noir); background: var(--blanc); min-height: 44px; padding: 0 12px;
  border: 1px solid var(--gris-texte); border-radius: 8px; max-width: 100%;
}
input[type=checkbox] { width: 20px; height: 20px; margin: 0 8px 0 0; vertical-align: middle; accent-color: var(--nuit); }

/* Boutons en pilule, 44 px de haut au moins. Par défaut : secondaire (contour bleu nuit). Principal : aplat orange, texte noir. */
button, .bouton {
  font: inherit; font-weight: 700; min-height: 44px; padding: 0 20px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; text-decoration: none;
  background: transparent; color: var(--nuit); border: 1px solid var(--nuit);
}
button:hover, .bouton:hover { background: var(--voile); }
button:disabled { opacity: 0.38; cursor: default; background: transparent; }
button.principal, .bouton.principal { background: var(--orange); color: var(--noir); border-color: var(--orange); }
button.principal:hover, .bouton.principal:hover { background: var(--orange); filter: brightness(0.94); }
button.danger { color: var(--danger); border-color: var(--danger); }
.pleine { width: 100%; }

/* Connexion et autorisation du connecteur : une carte au centre, champs et boutons sur toute la largeur. */
.formulaire input:not([type=hidden]) { width: 100%; margin-bottom: 16px; }
.formulaire button { width: 100%; }
.formulaire button + button, .formulaire + .bouton { margin-top: 12px; }
.carte ul { padding-left: 20px; margin: 8px 0 16px; }

/* « Listes de référence » (/admin). Les identifiants et classes lus par le JavaScript de la page ne changent pas. */
a.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }
a.back:hover { text-decoration: underline; }
#root { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; margin-top: 16px; }
#root section { background: var(--blanc); border: 1px solid var(--filet); border-radius: 8px; padding: 16px; min-width: 0; }
#root section h2, .tiergroup h2 {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gris-texte); line-height: 1.5;
}
.row { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.row .val { flex: 1; padding: 4px 8px; border-radius: 8px; min-width: 0; word-break: break-word; }
.row .val:focus { outline: 2px solid var(--nuit); outline-offset: 0; background: var(--voile); }
.row button { min-width: 44px; padding: 0 12px; font-weight: 400; }
/* Lot 28 (V21) : poignée à gauche, menu « Plus d'actions » à droite, deux boutons-icônes discrets (sans contour) de 44 px. */
.row .poignee, .row .plus { min-width: 44px; width: 44px; padding: 0; border: none; color: var(--gris-texte); flex-shrink: 0; }
.row .poignee { cursor: grab; }
.row .poignee:active { cursor: grabbing; }
.row .poignee svg, .row .plus svg { width: 20px; height: 20px; fill: currentColor; }
.row .poignee:hover, .row .plus:hover, .row .plus[aria-expanded=true] { color: var(--nuit); background: var(--voile); }
.row.pris { opacity: 0.5; }
.row.cible { box-shadow: inset 0 2px 0 var(--nuit); }
.menu-ligne {
  position: absolute; z-index: 10; min-width: 200px; padding: 4px 0; background: var(--blanc);
  border: 1px solid var(--filet); border-radius: 8px; box-shadow: 0 4px 16px rgba(29, 29, 27, 0.12);
}
.menu-ligne button {
  display: flex; width: 100%; justify-content: flex-start; border: none; border-radius: 0; padding: 0 16px;
  font-weight: 400; color: var(--noir);
}
.menu-ligne button.danger { color: var(--danger); }
.menu-ligne button:focus-visible { outline-offset: -2px; }
.row input[type=color] { width: 44px; height: 44px; padding: 0; border: none; background: none; flex-shrink: 0; }
.add { margin-top: 8px; border-top: 1px solid var(--filet); padding-top: 8px; }
.add input { flex: 1; min-width: 0; }
.add button { background: var(--orange); color: var(--noir); border-color: var(--orange); }
.add button:hover { background: var(--orange); filter: brightness(0.94); }
.tiersec { margin-top: 32px; }
.tiersec > h1 { font-size: 16px; line-height: 1.3; margin-bottom: 4px; }
.tiergroup { background: var(--blanc); border: 1px solid var(--filet); border-radius: 8px; padding: 16px; margin-bottom: 12px; min-width: 0; }
.tierrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--filet); }
.tierrow:first-of-type { border-top: none; }
.tierrow .niv { flex: 1 1 200px; min-width: 0; word-break: break-word; }
.tierrow .cnt { color: var(--gris-texte); font-size: 13px; }
.tierrow .def { color: var(--gris-texte); font-size: 12px; font-style: italic; }
#compform input:not([type=checkbox]), #compform select { width: 100%; }
#compform label { font-weight: 400; }
#compform label input[type=checkbox] { margin-top: 0; }
#cf-save { background: var(--orange); color: var(--noir); border-color: var(--orange); }
#cf-save:hover { background: var(--orange); filter: brightness(0.94); }
/* Tableaux des conflits et des connexions : écrits par le JavaScript, ils défilent dans leur propre conteneur sur téléphone. */
#conflictroot, #loginroot {
  overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--blanc); border: 1px solid var(--filet); border-radius: 8px; padding: 8px;
}
#conflictroot table { min-width: 640px; }
#loginroot table { min-width: 300px; }
#conflictroot th, #conflictroot td, #loginroot th, #loginroot td { padding: 8px; vertical-align: top; }
#conflictroot th, #loginroot th { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gris-texte); }
#conflictroot > p, #loginroot > p { margin: 8px; }

/* Téléphone : un seul seuil, moins de 900 px, comme l'application. */
@media (max-width: 899.98px) {
  .entete { min-height: 56px; padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); gap: 12px; }
  .entete img { height: 32px; }
  .page { padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
  .page.etroite { padding-top: 24px; }
  .page.etroite .carte { padding: 16px; }
}
