/* Espace admin South — feuille de calcul : bandeau nuit, papier crème, onglets de feuilles en bas. */
:root {
  --nuit: #0B1D2E; --nuit-2: #13293F; --nuit-3: #1E3A55; --creme: #FFF8E6;
  --papier: #FBFAF6; --papier-2: #F4F1E8; --blanc: #FFFFFF;
  --encre: #13202D; --encre-2: #4A5866; --encre-3: #8A96A1;
  --trait: #E6E1D3; --trait-fort: #CFC8B4;
  --soleil: #FFDC31; --soleil-pale: #FFF6CC; --soleil-fonce: #8A6A00;
  --mer: #0A74B8; --mer-pale: #E3F2FC;
  --vert: #1E7F47; --vert-pale: #E2F3E8;
  --rouge: #B8322A; --rouge-pale: #FBE7E4;
  --ambre: #A35F00; --ambre-pale: #FDF0D9;
  --smash: #D9261C;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --haut: 56px; --outils: 52px; --onglets: 44px;
  --rayon: 6px;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 13.5px; color: var(--encre); background: var(--papier); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--mer); outline-offset: 2px; }
svg.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Bandeau du haut ── */
.haut { position: fixed; inset: 0 0 auto 0; height: var(--haut); background: var(--nuit); color: var(--creme); display: flex; align-items: center; gap: 20px; padding: 0 16px; z-index: 30; }
.haut .marque { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex: none; }
.haut .marque img { height: 46px; display: block; margin: 0 -6px; }
.haut .marque span { font-family: var(--serif); font-size: 20px; letter-spacing: .01em; color: var(--creme); opacity: .9; padding-left: 10px; border-left: 1px solid var(--nuit-3); }
.indic { display: flex; align-items: stretch; gap: 0; margin-left: 8px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.indic::-webkit-scrollbar { display: none; }
.indic div { padding: 0 16px; border-left: 1px solid var(--nuit-3); white-space: nowrap; display: flex; flex-direction: column; justify-content: center; }
.indic div:first-child { border-left: 0; }
.indic small { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #8FA6BC; }
.indic b { font-family: var(--mono); font-weight: 500; font-size: 15px; color: var(--blanc); }
.indic b.soleil { color: var(--soleil); }
.indic b.alerte { color: #FF9B8F; }
.haut .droite { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: none; }
.synchro { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8FA6BC; background: none; border: 1px solid var(--nuit-3); border-radius: 999px; padding: 6px 12px; cursor: pointer; transition: border-color .2s, color .2s; }
.synchro:hover { border-color: var(--soleil); color: var(--creme); }
.synchro .point { width: 7px; height: 7px; border-radius: 50%; background: #3FCF7F; box-shadow: 0 0 0 3px rgba(63, 207, 127, .18); }
.synchro.en-cours svg { animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.moi { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--soleil); color: var(--nuit); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.moi button { background: none; border: 0; color: #8FA6BC; cursor: pointer; padding: 6px; border-radius: var(--rayon); display: flex; }
.moi button:hover { color: var(--creme); background: var(--nuit-2); }

/* ── Barre d'outils de la feuille ── */
.outils { position: fixed; top: var(--haut); left: 0; right: 0; height: var(--outils); background: var(--papier); border-bottom: 1px solid var(--trait-fort); display: flex; align-items: center; gap: 10px; padding: 0 16px; z-index: 20; }
.outils h1 { font-family: var(--serif); font-weight: 400; font-size: 26px; margin: 0 8px 0 0; letter-spacing: -.01em; white-space: nowrap; }
.outils .sep { width: 1px; height: 24px; background: var(--trait-fort); }
.outils .droite { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.recherche { display: flex; align-items: center; gap: 6px; background: var(--blanc); border: 1px solid var(--trait-fort); border-radius: var(--rayon); padding: 0 10px; height: 32px; color: var(--encre-3); }
.recherche input { border: 0; outline: 0; background: none; font: inherit; width: 180px; color: var(--encre); }
.segments { display: inline-flex; background: var(--papier-2); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 2px; }
.segments button { border: 0; background: none; padding: 5px 11px; border-radius: 4px; cursor: pointer; color: var(--encre-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.segments button[aria-pressed="true"] { background: var(--blanc); color: var(--encre); box-shadow: 0 1px 2px rgba(19, 32, 45, .12); }
.segments button em { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--encre-3); margin-left: 4px; }
.navmois { display: inline-flex; align-items: center; border: 1px solid var(--trait-fort); border-radius: var(--rayon); background: var(--blanc); height: 32px; }
.navmois button { border: 0; background: none; width: 30px; height: 100%; cursor: pointer; color: var(--encre-2); display: grid; place-items: center; }
.navmois button:hover { background: var(--papier-2); }
.navmois span { padding: 0 10px; font-weight: 600; min-width: 128px; text-align: center; text-transform: capitalize; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--rayon); border: 1px solid var(--nuit); background: var(--nuit); color: var(--creme); font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; transition: background .15s; }
.btn:hover { background: var(--nuit-3); }
.btn.clair { background: var(--blanc); color: var(--encre); border-color: var(--trait-fort); }
.btn.clair:hover { background: var(--papier-2); }
.btn.soleil { background: var(--soleil); border-color: #E8C41E; color: var(--nuit); }
.btn.soleil:hover { background: #FFE45C; }
.btn:disabled { opacity: .5; cursor: default; }
.case-libre { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--encre-2); cursor: pointer; white-space: nowrap; }

/* ── La feuille ── */
.feuille { position: fixed; top: calc(var(--haut) + var(--outils)); bottom: var(--onglets); left: 0; right: 0; overflow: auto; background: var(--blanc); }
table.grille { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 13px; }
.grille th, .grille td { border-right: 1px solid var(--trait); border-bottom: 1px solid var(--trait); padding: 0 10px; height: 34px; white-space: nowrap; text-align: left; }
.grille thead th { position: sticky; top: 0; z-index: 3; background: var(--papier-2); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--encre-2); height: 32px; border-bottom: 1px solid var(--trait-fort); }
.grille .col1 { position: sticky; left: 0; z-index: 2; background: inherit; min-width: 230px; max-width: 300px; border-right: 1px solid var(--trait-fort); }
.grille thead .col1 { z-index: 4; background: var(--papier-2); }
.grille tbody tr { background: var(--blanc); }
.grille .num { text-align: right; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grille .num.fort { font-weight: 600; }
.grille .vide { color: #C3BDAE; }
.grille tbody tr.lig:hover { background: #FFFCEF; }
.grille tbody tr.lig { cursor: pointer; }
.grille tr.groupe td { background: var(--papier); height: 30px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--encre-2); border-bottom-color: var(--trait-fort); }
.grille tr.groupe td em { font-style: normal; font-family: var(--mono); color: var(--encre-3); margin-left: 6px; letter-spacing: 0; }
.grille tfoot td { position: sticky; bottom: 0; z-index: 3; background: var(--papier-2); font-weight: 600; border-top: 1px solid var(--trait-fort); height: 36px; }
.grille tfoot .col1 { z-index: 4; background: var(--papier-2); }
.grille .courant { background: var(--soleil-pale); }
.grille thead th.courant { background: var(--soleil); color: var(--nuit); }
.grille tfoot td.courant { background: #FFEB8A; }
.grille tr.titre td { font-weight: 600; }
.grille tr.titre td.col1 { font-family: var(--serif); font-size: 17px; font-weight: 400; }
.grille tr.sous td { color: var(--encre-2); }
.grille tr.sous td.col1 { padding-left: 24px; font-size: 12.5px; }
.grille tr.ecart td { border-top: 1px solid var(--trait-fort); }
.nom { font-weight: 600; color: var(--encre); }
.sousnom { display: block; font-size: 11.5px; color: var(--encre-3); margin-top: -2px; font-weight: 400; }
.grille td .deux { display: flex; flex-direction: column; justify-content: center; line-height: 1.25; padding: 4px 0; }
.grille tr.haute td { height: 44px; }
.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 1px 5px; border-radius: 3px; margin-left: 6px; vertical-align: 1px; }
.tag.smash { background: var(--rouge-pale); color: var(--smash); }
.tag.corpolab { background: var(--mer-pale); color: var(--mer); }
.tag.test { background: var(--papier-2); color: var(--encre-3); }
.etat { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.etat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.etat.ok { color: var(--vert); } .etat.ko { color: var(--rouge); } .etat.attente { color: var(--ambre); } .etat.neutre { color: var(--encre-3); } .etat.bleu { color: var(--mer); }
.pos { color: var(--vert); } .neg { color: var(--rouge); }
.du { font-weight: 600; color: var(--rouge); }
td.chaud { background: color-mix(in srgb, var(--rouge-pale) calc(var(--h, 0) * 100%), transparent); }
.grille a { color: var(--mer); text-decoration: none; font-weight: 500; margin-right: 10px; display: inline-flex; align-items: center; gap: 3px; }
.grille a:hover { text-decoration: underline; }
.grille a svg.ic { width: 12px; height: 12px; }
.grille tr.annule td { color: #B4AC99; text-decoration: line-through; }
.lienbtn { background: none; border: 0; padding: 0; color: var(--mer); font-weight: 500; cursor: pointer; }
.lienbtn:hover { text-decoration: underline; }
.lienbtn.rouge { color: var(--rouge); }
.vidage { padding: 48px; text-align: center; color: var(--encre-3); }
.pied { padding: 14px 16px 24px; font-size: 12px; color: var(--encre-3); line-height: 1.6; max-width: 900px; background: var(--blanc); }
.pied b { color: var(--encre-2); font-weight: 600; }
.avert { display: inline-flex; align-items: center; gap: 6px; color: var(--ambre); font-weight: 500; }

/* ── Onglets de feuilles (en bas) ── */
.onglets { position: fixed; left: 0; right: 0; bottom: 0; height: var(--onglets); background: var(--papier-2); border-top: 1px solid var(--trait-fort); display: flex; align-items: flex-start; padding: 0 12px; gap: 2px; z-index: 30; overflow-x: auto; }
.onglets button { position: relative; height: 34px; margin-top: -1px; padding: 0 16px; border: 1px solid transparent; border-top: 0; border-radius: 0 0 var(--rayon) var(--rayon); background: none; cursor: pointer; color: var(--encre-2); font-weight: 500; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.onglets button:hover { color: var(--encre); background: rgba(255, 255, 255, .6); }
.onglets button[aria-selected="true"] { background: var(--blanc); color: var(--encre); font-weight: 600; border-color: var(--trait-fort); box-shadow: inset 0 3px 0 var(--soleil); }
.onglets button em { font-style: normal; font-family: var(--mono); font-size: 11px; background: var(--papier); border: 1px solid var(--trait); color: var(--encre-2); border-radius: 999px; padding: 0 6px; }
.onglets button em.rouge { background: var(--rouge-pale); border-color: #F2C8C2; color: var(--rouge); }
.onglets .note-droite { margin-left: auto; align-self: center; font-size: 11.5px; color: var(--encre-3); white-space: nowrap; padding-left: 16px; }

/* ── Panneau latéral (fiche, formulaires) ── */
dialog.panneau { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(460px, 100%); border: 0; padding: 0; background: var(--papier); box-shadow: -24px 0 48px rgba(11, 29, 46, .18); color: var(--encre); }
dialog.panneau[open] { animation: entre .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes entre { from { transform: translateX(32px); opacity: 0; } }
dialog.panneau::backdrop { background: rgba(11, 29, 46, .32); }
.panneau form { display: flex; flex-direction: column; height: 100%; }
.panneau .tete { padding: 18px 20px 14px; border-bottom: 1px solid var(--trait-fort); background: var(--blanc); display: flex; align-items: flex-start; gap: 12px; }
.panneau .tete h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 0; line-height: 1.1; }
.panneau .tete p { margin: 4px 0 0; color: var(--encre-3); font-size: 12.5px; }
.panneau .fermer { margin-left: auto; background: none; border: 0; cursor: pointer; padding: 6px; border-radius: var(--rayon); color: var(--encre-2); display: flex; }
.panneau .fermer:hover { background: var(--papier-2); }
.panneau .corps { padding: 6px 20px 20px; overflow-y: auto; flex: 1; }
.panneau .actions { padding: 12px 20px; border-top: 1px solid var(--trait-fort); background: var(--blanc); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.panneau .actions .erreur { margin: 0 auto 0 0; }
.resume { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--blanc); margin: 14px 0 4px; }
.resume div { padding: 10px 12px; border-left: 1px solid var(--trait); }
.resume div:first-child { border-left: 0; }
.resume small { display: block; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--encre-3); }
.resume b { font-family: var(--mono); font-weight: 500; font-size: 15px; }
fieldset { border: 0; padding: 0; margin: 18px 0 0; }
legend { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--encre-3); padding: 0; margin-bottom: 6px; }
.champs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.champs .large { grid-column: 1 / -1; }
label.champ { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: var(--encre-2); }
label.champ input, label.champ select { height: 36px; border: 1px solid var(--trait-fort); border-radius: var(--rayon); padding: 0 10px; font: inherit; font-size: 14px; color: var(--encre); background: var(--blanc); width: 100%; }
label.champ input:focus, label.champ select:focus { outline: none; border-color: var(--mer); box-shadow: 0 0 0 3px var(--mer-pale); }
label.champ .aide { font-weight: 400; color: var(--encre-3); font-size: 11.5px; }
.case { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--encre-2); margin-top: 12px; cursor: pointer; }
.erreur { color: var(--rouge); font-size: 12.5px; font-weight: 500; min-height: 1em; }
.liste-liens { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.liste-liens a { display: inline-flex; align-items: center; gap: 4px; color: var(--mer); font-weight: 500; text-decoration: none; font-size: 12.5px; background: var(--mer-pale); padding: 4px 9px; border-radius: 999px; }

/* ── Connexion ── */
.accueil { min-height: 100%; background: var(--nuit); display: grid; place-items: center; padding: 32px 16px; position: relative; overflow: hidden; }
.accueil .vagues { position: absolute; inset: auto 0 0 0; width: 100%; height: 46%; opacity: .5; pointer-events: none; }
.accueil .bloc { position: relative; width: min(400px, 100%); }
.accueil .bloc > img { height: 120px; display: block; margin: -20px auto 6px; }
.accueil .carte { background: var(--papier); border-radius: 10px; padding: 26px 26px 22px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35); }
.accueil h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0 0 4px; line-height: 1.1; }
.accueil .intro { color: var(--encre-2); font-size: 13px; margin: 0 0 16px; line-height: 1.5; }
.accueil label.champ { margin-top: 12px; }
.accueil .btn { width: 100%; justify-content: center; height: 40px; margin-top: 18px; font-size: 14px; }
.accueil .erreur { margin-top: 10px; }
.accueil .bas { text-align: center; color: #8FA6BC; font-size: 11.5px; margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.qr { display: flex; justify-content: center; padding: 12px; background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--rayon); margin: 6px 0 10px; }
.secret { font-family: var(--mono); font-size: 12.5px; background: var(--papier-2); padding: 8px; border-radius: var(--rayon); word-break: break-all; text-align: center; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--mono); background: var(--blanc); border: 1px dashed var(--trait-fort); padding: 12px; border-radius: var(--rayon); margin: 10px 0; text-align: center; }
.chargement { padding: 48px; color: var(--encre-3); display: flex; gap: 10px; align-items: center; justify-content: center; }
.chargement::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--trait-fort); border-top-color: var(--nuit); animation: tourne .8s linear infinite; }

/* ── Toast ── */
.toast { position: fixed; bottom: calc(var(--onglets) + 14px); left: 50%; transform: translateX(-50%); background: var(--nuit); color: var(--creme); padding: 10px 16px; border-radius: var(--rayon); font-size: 13px; z-index: 50; box-shadow: 0 10px 30px rgba(11, 29, 46, .3); display: flex; gap: 8px; align-items: center; }
.toast::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--soleil); }

/* ── Téléphone ── */
@media (max-width: 760px) {
  .haut { gap: 10px; padding: 0 12px; }
  .haut .marque span, .synchro span, .moi .avatar { display: none; }
  .indic div { padding: 0 10px; }
  .outils { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 8px; }
  .outils h1 { font-size: 22px; width: 100%; }
  .outils .droite { margin-left: 0; }
  .outils .sep { display: none; }
  .recherche input { width: 110px; }
  .champs { grid-template-columns: 1fr; }
  .grille .col1 { min-width: 160px; }
  .onglets .note-droite { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
