/* =====================================================================
   TOUTENVÉLO LE HAVRE — APP LIVRAISON BIO
   styles.css — thème sombre, accent vert lime TEV (cohérent avec Hub,
   Tournée, Maintenance, Documents). Pensé téléphone d'abord.
   ===================================================================== */

:root {
  --fond:        #141509;
  --surface:     #262624;
  --surface-2:   #30302d;
  --ligne:       #3d3d38;
  --lime:        #a8c63c;
  --lime-sombre: #8aa62f;
  --texte:       #f2f1ec;
  --texte-doux:  #a3a29a;
  --vert:        #6fa84a;
  --orange:      #e0913a;
  --rouge:       #c05a5a;
  --ocean:       #3f9fbf;
  --rayon:       12px;
  --rayon-s:     8px;
  --ombre:       0 2px 12px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body { padding-bottom: 60px; }
a { color: var(--lime); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-variant-numeric: tabular-nums; }
.doux { color: var(--texte-doux); }
.petit { font-size: 13px; }
.gros { font-size: 18px; font-weight: 700; }
.droite { text-align: right; }
.cache { display: none !important; }

/* ---------------------------------------------------------------------
   BARRE DU HAUT
   --------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--fond);
  border-bottom: 1px solid var(--ligne);
}
.topbar .dedans {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
.topbar .titre { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; white-space: nowrap; }
.topbar .version { font-size: 11px; color: var(--texte-doux); font-weight: 400; margin-left: 6px; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
  color: var(--texte-doux); padding: 6px 10px; border-radius: var(--rayon-s);
  font-size: 14px; white-space: nowrap;
}
.topbar nav a.actif, .topbar nav a:hover { color: var(--texte); background: var(--surface); text-decoration: none; }

/* ---------------------------------------------------------------------
   PAGE
   --------------------------------------------------------------------- */
.page { max-width: 1080px; margin: 0 auto; padding: 14px 16px; }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--texte-doux); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
h2:first-child { margin-top: 6px; }

/* ---------------------------------------------------------------------
   BOUTONS
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); color: var(--texte);
  border: 1px solid var(--ligne); border-radius: var(--rayon-s);
  padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; line-height: 1.2;
}
.btn:hover { border-color: var(--texte-doux); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primaire { background: var(--lime); color: #141509; border-color: var(--lime); }
.btn.primaire:hover { background: var(--lime-sombre); }
.btn.danger { color: var(--rouge); }
.btn.petit { padding: 6px 10px; font-size: 13px; }
.btn.lien { background: none; border: none; color: var(--lime); padding: 4px 6px; }

/* ---------------------------------------------------------------------
   BANDEAU SYNCHRO / MESSAGES
   --------------------------------------------------------------------- */
.bandeau {
  background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon);
  padding: 12px 14px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.bandeau .texte { flex: 1; min-width: 200px; font-size: 14px; }
.bandeau.attention { border-color: var(--orange); }
.bandeau.erreur { border-color: var(--rouge); }
.bandeau details { width: 100%; font-size: 13px; color: var(--texte-doux); }
.bandeau details summary { cursor: pointer; color: var(--texte); }
.bandeau ul { margin: 6px 0 0; padding-left: 18px; }
.bandeau li { margin: 2px 0; }

/* ---------------------------------------------------------------------
   FILTRES
   --------------------------------------------------------------------- */
.filtres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.chip {
  background: var(--surface); border: 1px solid var(--ligne); color: var(--texte-doux);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.chip.actif { background: var(--lime); color: #141509; border-color: var(--lime); font-weight: 600; }
.recherche { position: relative; flex: 1; min-width: 180px; }
.recherche input {
  width: 100%; background: var(--surface); border: 1px solid var(--ligne); color: var(--texte);
  border-radius: 999px; padding: 8px 14px 8px 34px; font-size: 14px; font-family: inherit;
}
.recherche .loupe { position: absolute; left: 12px; top: 7px; color: var(--texte-doux); }

/* ---------------------------------------------------------------------
   LISTE DES ARRIVAGES
   --------------------------------------------------------------------- */
.jour { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 10px; }
.jour .date { font-weight: 700; font-size: 15px; text-transform: capitalize; }
.jour .nb { color: var(--texte-doux); font-size: 13px; }
.jour.aujourdhui .date { color: var(--lime); }

.carte {
  background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon);
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
}
.carte:hover { border-color: var(--texte-doux); }
.carte.previsionnel { border-style: dashed; }
.carte.disparu { opacity: .6; }
.carte .ligne1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.carte .produit { font-weight: 700; font-size: 16px; }
.carte .quantite { color: var(--texte); font-size: 14px; }
.carte .ligne2 { color: var(--texte-doux); font-size: 13px; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.carte .statut { grid-column: 2; grid-row: 1; align-self: start; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 6px; text-transform: uppercase;
  background: var(--surface-2); color: var(--texte-doux);
}
.badge.ecole { background: #1f3a46; color: #8fd0ea; }
.badge.clsh { background: #3d2f45; color: #d3a8ee; }
.badge.recu { background: #2b4020; color: #b5e08a; }
.badge.prepare { background: #2b4020; color: #b5e08a; }
.badge.livre { background: #24402b; color: #9be0a8; }
.badge.annule { background: #402424; color: #e09a9a; }
.badge.annonce { background: var(--surface-2); color: var(--texte-doux); }
.badge.alerte { background: #4a3316; color: #f0b86a; }
.badge.lot { background: #33321f; color: #d9d27a; }

.vide { text-align: center; color: var(--texte-doux); padding: 40px 10px; }
.squelette { height: 64px; background: var(--surface); border-radius: var(--rayon); margin-bottom: 8px; opacity: .6; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------------------------------------------------------------------
   MODALE
   --------------------------------------------------------------------- */
.voile {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.voile.ouvert { display: flex; }
.modale {
  background: var(--fond); border: 1px solid var(--ligne); border-radius: var(--rayon) var(--rayon) 0 0;
  width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; padding: 16px;
  box-shadow: var(--ombre);
}
@media (min-width: 700px) {
  .voile { align-items: center; }
  .modale { border-radius: var(--rayon); }
}
.modale .entete { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.modale .entete h3 { margin: 0; font-size: 18px; flex: 1; }
.modale .fermer { background: none; border: none; color: var(--texte-doux); font-size: 22px; cursor: pointer; padding: 0 6px; }

.fiche { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 14px; }
.fiche .champ { background: var(--surface); border-radius: var(--rayon-s); padding: 8px 10px; }
.fiche .champ .etiquette { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-doux); }
.fiche .champ .valeur { font-size: 15px; }
.fiche .champ.large { grid-column: 1 / -1; }
.fiche .champ.verrou .etiquette::after { content: ' 🔒'; }

/* ---------------------------------------------------------------------
   TABLEAUX
   --------------------------------------------------------------------- */
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; }
.tableau th, .tableau td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
.tableau th { color: var(--texte-doux); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tableau td.num, .tableau th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tableau tr.sous-total td { background: var(--surface); font-weight: 700; }
.tableau tr.total td { font-weight: 700; border-top: 2px solid var(--ligne); }
.tableau tr.attention td { color: var(--orange); }
.defilable { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------------------------------------------------------------
   FORMULAIRES
   --------------------------------------------------------------------- */
.formulaire { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.formulaire label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .04em; }
.formulaire label.large { grid-column: 1 / -1; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--ligne); color: var(--texte);
  border-radius: var(--rayon-s); padding: 9px 10px; font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lime); }
textarea { min-height: 70px; resize: vertical; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.tableau input, .tableau select { padding: 5px 7px; font-size: 14px; }
.tableau input.court { width: 80px; }

/* ---------------------------------------------------------------------
   ONGLETS (référentiel)
   --------------------------------------------------------------------- */
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--ligne); margin-bottom: 14px; overflow-x: auto; }
.onglets button {
  background: none; border: none; color: var(--texte-doux); padding: 10px 14px; cursor: pointer;
  font-size: 14px; font-family: inherit; border-bottom: 2px solid transparent; white-space: nowrap;
}
.onglets button.actif { color: var(--texte); border-bottom-color: var(--lime); font-weight: 600; }

/* ---------------------------------------------------------------------
   TOAST
   --------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--texte); border: 1px solid var(--ligne);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 60; max-width: 90vw; text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--vert); }
.toast.erreur { border-color: var(--rouge); }

@media (max-width: 600px) {
  .fiche, .formulaire { grid-template-columns: 1fr; }
  .carte { grid-template-columns: 1fr; }
  .carte .statut { grid-column: 1; grid-row: auto; }
}
