/* Socle Forge16 — style Graphite (sombre, bordures fines, orange réservé aux liens).
   Composants f-* utilisables par les modules : voir README.md « Composants d'interface ». */
:root {
  --fond: #0a0a0a; --noir: #000; --surface: #171717; --bord: #262626; --bord-fort: #464646;
  --texte: #fafafa; --texte-2: #a1a1a1; --texte-3: #737373; --pale: #e5e5e5; --lien: #ff8833;
  --ok: #3ecf8e; --attention: #f5b841; --erreur: #ff5f56; --info: #2e73fc;
  --rayon: 10px; --rayon-bouton: 8px; --espace: 16px;
  --police: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hauteur-barre: 64px;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte); font: 400 16px/1.5 var(--police);
  font-feature-settings: "clig" 0, "liga" 0; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
a { color: var(--lien); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--texte-3); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.01em; }
.f-titre { font-size: 28px; line-height: 1.15; letter-spacing: -.5px; }
.f-sous-titre { font-size: 20px; line-height: 1.4; }
.f-discret { color: var(--texte-2); }
.f-petit { font-size: 13px; color: var(--texte-2); }
[x-cloak] { display: none !important; }

/* --- Mise en page : barre latérale (bureau), onglets en bas (mobile) --- */
.f-app { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.f-lateral {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; border-right: 1px solid var(--bord);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 20px; background: var(--fond);
}
.f-marque { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 600; font-size: 15px; }
.f-marque small { display: block; font-weight: 400; color: var(--texte-3); font-size: 12px; }
.f-logo { width: 28px; height: 28px; border-radius: 7px; background: var(--texte); color: var(--fond);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.f-nav { display: flex; flex-direction: column; gap: 2px; }
.f-nav-titre { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--texte-3); padding: 8px 10px 4px; }
.f-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--rayon-bouton);
  color: var(--texte-2); font-size: 14px; font-weight: 500; }
.f-nav a:hover { background: var(--surface); color: var(--texte); text-decoration: none; }
.f-nav a[aria-current="page"] { background: var(--surface); color: var(--texte); box-shadow: inset 0 0 0 1px var(--bord); }
.f-nav svg, .f-onglets svg { width: 18px; height: 18px; flex: none; }
.f-lateral-pied { margin-top: auto; border-top: 1px solid var(--bord); padding: 12px 8px 0; font-size: 13px; }
.f-contenu { min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 48px; max-width: 1152px; width: 100%; }
.f-entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.f-barre-mobile, .f-onglets { display: none; }

@media (max-width: 860px) {
  .f-app { grid-template-columns: 1fr; }
  .f-lateral { display: none; }
  .f-barre-mobile {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(10,10,10,.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--bord);
  }
  .f-contenu { padding: 20px 16px calc(var(--hauteur-barre) + 32px + env(safe-area-inset-bottom)); }
  .f-titre { font-size: 24px; }
  .f-onglets {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset: auto 0 0 0; z-index: 30;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(10,10,10,.92);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--bord);
  }
  .f-onglets a, .f-onglets button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; border: 0;
    background: none; color: var(--texte-3); font-size: 11px; font-weight: 500; border-radius: var(--rayon-bouton);
    -webkit-user-select: none; user-select: none; min-height: 48px; justify-content: center;
  }
  .f-onglets a[aria-current="page"] { color: var(--texte); }
  .f-onglets a:active, .f-onglets button:active { background: var(--surface); transform: scale(.96); }
  .f-feuille { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; }
  .f-feuille > div {
    width: 100%; max-height: 80dvh; overflow-y: auto; background: var(--fond); border-top: 1px solid var(--bord);
    border-radius: 16px 16px 0 0; padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  }
  .f-feuille .f-poignee { width: 40px; height: 4px; border-radius: 4px; background: var(--bord-fort); margin: 0 auto 12px; }
}
@media (min-width: 861px) { .f-feuille { display: none !important; } }

/* --- Composants --- */
.f-pile { display: flex; flex-direction: column; gap: 16px; }
.f-rangee { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.f-grille { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.f-carte { background: var(--fond); border: 1px solid var(--bord); border-radius: var(--rayon); padding: var(--espace); min-width: 0; }
.f-carte > h2, .f-carte > header h2 { font-size: 15px; font-weight: 600; }
.f-carte > header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.f-carte-surface { background: var(--surface); }
.f-bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: var(--rayon-bouton); border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, transform .1s; white-space: nowrap;
}
.f-bouton:hover { background: var(--bord); text-decoration: none; }
.f-bouton:active { transform: scale(.98); }
.f-bouton-principal { background: var(--pale); color: #0a0a0a; border-color: var(--pale); }
.f-bouton-principal:hover { background: #fff; }
.f-bouton-danger { color: var(--erreur); }
.f-bouton-lien { background: none; border: 0; padding: 0; min-height: 0; color: var(--lien); }
.f-bouton[disabled], .htmx-request.f-bouton { opacity: .6; pointer-events: none; }
.f-champ { display: flex; flex-direction: column; gap: 6px; }
.f-champ label, .f-etiquette { font-size: 14px; font-weight: 500; }
.f-champ .f-aide { font-size: 13px; color: var(--texte-2); }
.f-champ .f-erreur { font-size: 13px; color: var(--erreur); }
.f-requis::after { content: " *"; color: var(--texte-3); }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font-size: 16px; background: var(--noir);
  border: 1px solid var(--bord); border-radius: var(--rayon); transition: border-color .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--bord-fort); }
.f-champ-invalide input, .f-champ-invalide select, .f-champ-invalide textarea { border-color: var(--erreur); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--pale); }
input[type=color] { width: 56px; height: 40px; border: 1px solid var(--bord); border-radius: var(--rayon-bouton); background: none; }
fieldset { border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; margin: 0; }
legend { padding: 0 6px; font-size: 14px; font-weight: 600; }
.f-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 20px; font-size: 12px;
  font-weight: 500; border: 1px solid var(--bord); color: var(--texte-2); white-space: nowrap; }
.f-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--texte-3); }
.f-badge-ok::before { background: var(--ok); }
.f-badge-attention::before { background: var(--attention); }
.f-badge-erreur::before { background: var(--erreur); }
.f-badge-info::before { background: var(--info); }
.f-alerte { border: 1px solid var(--bord); border-left: 3px solid var(--texte-3); border-radius: var(--rayon);
  padding: 12px 14px; font-size: 14px; background: var(--surface); }
.f-alerte-ok { border-left-color: var(--ok); }
.f-alerte-attention { border-left-color: var(--attention); }
.f-alerte-erreur { border-left-color: var(--erreur); }
.f-vide { text-align: center; padding: 40px 16px; color: var(--texte-2); border: 1px dashed var(--bord); border-radius: var(--rayon); }
.f-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.f-table th { text-align: left; font-weight: 500; color: var(--texte-3); font-size: 12px; text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 12px; border-bottom: 1px solid var(--bord); }
.f-table td { padding: 12px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.f-table tr:last-child td { border-bottom: 0; }
@media (max-width: 860px) {
  .f-table-cartes thead { display: none; }
  .f-table-cartes tr { display: block; border: 1px solid var(--bord); border-radius: var(--rayon); padding: 8px 12px; margin-bottom: 8px; }
  .f-table-cartes td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .f-table-cartes td::before { content: attr(data-libelle); color: var(--texte-3); font-size: 13px; text-align: left; }
}
.f-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: var(--texte-2);
  background: var(--surface); border: 1px solid var(--bord); border-radius: 6px; padding: 1px 6px; overflow-wrap: anywhere; }
.f-squelette { height: 80px; border-radius: var(--rayon); background: linear-gradient(90deg, var(--surface), var(--bord), var(--surface));
  background-size: 200% 100%; animation: f-lueur 1.4s ease-in-out infinite; }
@keyframes f-lueur { from { background-position: 100% 0 } to { background-position: -100% 0 } }
.f-apparition { animation: f-apparaitre .2s ease-out; }
@keyframes f-apparaitre { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* --- Page de connexion --- */
.f-connexion { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.f-connexion form { width: min(100%, 380px); }

/* --- Utilitaires (aucun style en ligne : CSP sans exception) --- */
.f-desc { margin: 4px 0 0; color: var(--texte-2); }
.f-m0 { margin: 0; } .f-mt8 { margin-top: 8px; } .f-mt12 { margin-top: 12px; }
.f-mb4 { margin-bottom: 4px; } .f-mb8 { margin-bottom: 8px; } .f-mb12 { margin-bottom: 12px; }
.f-p0 { padding: 0; } .f-carte-table { padding: 0 4px; } .f-carte-large { padding: 24px; }
.f-auto { width: auto; } .f-plein { width: 100%; }
.f-etroit { max-width: 560px; } .f-moyen { max-width: 720px; }
.f-nowrap { white-space: nowrap; } .f-centre { text-align: center; } .f-coupe { overflow-wrap: anywhere; }
.f-entre { justify-content: space-between; } .f-serre { gap: 8px; }
.f-tertiaire { color: var(--texte-3); } .f-sans-bord { border: 0; }
.f-liste-def { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; }
.f-liste-def dd { margin: 0; overflow-wrap: anywhere; }
.f-jauge { height: 6px; border-radius: 6px; background: var(--surface); border: 1px solid var(--bord); overflow: hidden; }
.f-jauge > span { display: block; height: 100%; background: var(--texte-2); }
.f-jauge-attention > span { background: var(--attention); } .f-jauge-erreur > span { background: var(--erreur); }
.f-logo-image { width: 28px; height: 28px; border-radius: 7px; object-fit: contain; }
progress.f-jauge { appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0; border-radius: 6px;
  background: var(--surface); overflow: hidden; }
progress.f-jauge::-webkit-progress-bar { background: var(--surface); border-radius: 6px; }
progress.f-jauge::-webkit-progress-value { background: var(--texte-2); border-radius: 6px; }
progress.f-jauge::-moz-progress-bar { background: var(--texte-2); border-radius: 6px; }
progress.f-jauge-attention::-webkit-progress-value { background: var(--attention); }
progress.f-jauge-attention::-moz-progress-bar { background: var(--attention); }
progress.f-jauge-erreur::-webkit-progress-value { background: var(--erreur); }
progress.f-jauge-erreur::-moz-progress-bar { background: var(--erreur); }
.f-compteur { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent, var(--lien));
  color: #0a0a0a; font-size: 12px; font-weight: 600; text-align: center; }
.f-donnee { white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: var(--texte-2); background: var(--noir); border: 1px solid var(--bord); border-radius: 8px;
  padding: 10px; max-height: 260px; overflow: auto; margin: 0; }
.f-etape { border-left: 2px solid var(--bord); padding: 2px 0 2px 14px; }
.f-etape-agent { border-left-color: var(--texte-2); }
.f-etape-outil { border-left-color: var(--accent, var(--lien)); }
details > summary { cursor: pointer; color: var(--texte-2); font-size: 13px; }

/* --- Mode simulation --- */
.f-bandeau-simulation { position: sticky; top: 0; z-index: 25; padding: 8px 16px; font-size: 13px; text-align: center;
  background: #2a1d0a; color: var(--attention); border-bottom: 1px solid #5a3d10; }
@media (max-width: 860px) { .f-bandeau-simulation { top: calc(52px + env(safe-area-inset-top)); } }
