:root {
  --bleu: #0b3d6b;
  --bleu-clair: #e8f0f7;
  --or: #c9a227;
  --vert: #0f7b4f;
  --rouge: #b42318;
  --orange: #b54708;
  --gris: #5b6470;
  --bord: #d7dde5;
  --fond: #f5f7fa;
  --blanc: #fff;
  --rayon: 10px;
  --ombre: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fond);
  color: #1a202c;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: .4rem 0; }
small, .petit { font-size: .82rem; color: var(--gris); }

.entete {
  background: var(--bleu);
  color: #fff;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  position: sticky;
  top: 0;
  z-index: 30;
}
.entete a { color: #fff; }
.marque { font-weight: 800; letter-spacing: .02em; font-size: 1.05rem; }
.marque span { color: var(--or); }
.entete .droite { margin-left: auto; display: flex; gap: .6rem; align-items: center; font-size: .85rem; }
.badge-offline { display: none; background: var(--orange); color: #fff; border-radius: 999px; padding: .15rem .5rem; font-size: .72rem; font-weight: 700; }
body.hors-ligne .badge-offline { display: inline-block; }

.nav-principal {
  display: flex;
  gap: .2rem;
  overflow-x: auto;
  background: #082e51;
  padding: 0 .5rem;
  scrollbar-width: none;
}
.nav-principal::-webkit-scrollbar { display: none; }
.nav-principal a {
  color: #cfe0f0;
  padding: .6rem .7rem;
  white-space: nowrap;
  font-size: .86rem;
  border-bottom: 3px solid transparent;
}
.nav-principal a.actif, .nav-principal a:hover { color: #fff; border-bottom-color: var(--or); text-decoration: none; }

.conteneur { max-width: 1180px; margin: 0 auto; padding: 1rem; }
.carte {
  background: var(--blanc);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1rem;
  margin-bottom: 1rem;
}
.carte h2 { margin-top: 0; }
.grille { display: grid; gap: 1rem; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grille-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { background: var(--blanc); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .85rem 1rem; }
.kpi .valeur { font-size: 1.35rem; font-weight: 800; color: var(--bleu); }
.kpi .libelle { font-size: .8rem; color: var(--gris); text-transform: uppercase; letter-spacing: .03em; }
.kpi.alerte .valeur { color: var(--rouge); }
.kpi.ok .valeur { color: var(--vert); }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .45rem .5rem; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; }
th { background: #f0f3f7; font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: #475467; }
tbody tr:hover { background: #fafcff; }
.tableau-defilant { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nombre, .montant { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

form label { display: block; font-weight: 600; font-size: .84rem; margin-bottom: .2rem; }
input, select, textarea {
  width: 100%;
  padding: .55rem .6rem;
  border: 1px solid #b9c2cd;
  border-radius: 8px;
  font: inherit;
  background: #fff;
  min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #7aa7d9; outline-offset: 1px; }
input[type="checkbox"] { width: auto; min-height: auto; }
.champ { margin-bottom: .7rem; }
.erreurs { color: var(--rouge); font-size: .82rem; margin: .15rem 0; }
.aide { font-size: .78rem; color: var(--gris); }

.bouton, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  background: var(--bleu);
  color: #fff;
  border: 1px solid var(--bleu);
  border-radius: 8px;
  padding: .55rem .9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 42px;
}
.bouton:hover, button:hover { filter: brightness(1.08); text-decoration: none; }
.bouton.secondaire { background: #fff; color: var(--bleu); }
.bouton.danger { background: var(--rouge); border-color: var(--rouge); }
.bouton.vert { background: var(--vert); border-color: var(--vert); }
.bouton.or { background: var(--or); border-color: var(--or); color: #1a202c; }
.bouton.petit { min-height: 34px; padding: .3rem .55rem; font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0; }
form.inline { display: inline; }

.messages { margin: 0 0 1rem; padding: 0; list-style: none; }
.messages li { padding: .6rem .8rem; border-radius: 8px; margin-bottom: .4rem; font-size: .9rem; }
.messages .success { background: #e7f6ec; color: #065f37; border: 1px solid #b7e4c7; }
.messages .error { background: #fdecea; color: #7a1c14; border: 1px solid #f5c2bd; }
.messages .warning { background: #fff4e5; color: #7a3d00; border: 1px solid #ffd8a8; }
.messages .info { background: var(--bleu-clair); color: #0b3d6b; border: 1px solid #bcd4e9; }

.etiquette { display: inline-block; padding: .12rem .45rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.etiquette.brouillon { background: #eef2f6; color: #475467; }
.etiquette.soumis { background: #e0f2fe; color: #075985; }
.etiquette.valide { background: #dcfce7; color: #166534; }
.etiquette.cloture { background: #ede9fe; color: #5b21b6; }
.etiquette.a-corriger { background: #fef3c7; color: #92400e; }
.etiquette.alerte { background: #fee4e2; color: #912018; }

.bloc-note { background: var(--bleu-clair); border-left: 4px solid var(--bleu); padding: .7rem .9rem; border-radius: 6px; font-size: .86rem; }
.bloc-alerte { background: #fff4e5; border-left: 4px solid var(--orange); padding: .7rem .9rem; border-radius: 6px; font-size: .86rem; }

.pied { text-align: center; font-size: .78rem; color: var(--gris); padding: 1.2rem; }
.entete-section { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.entete-section h1, .entete-section h2 { margin: 0; }

/* Grille de saisie du quart : cartes par pistolet sur mobile, tableau sur écran large */
.lignes-pompe { display: grid; gap: .7rem; }
@media (min-width: 900px) { .lignes-pompe { grid-template-columns: repeat(2, 1fr); } }
.pistolet-carte { border: 1px solid var(--bord); border-radius: 8px; padding: .6rem; background: #fbfdff; }
.pistolet-carte .titre { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.pistolet-carte .titre strong { font-size: .95rem; }
.grille-pistolet { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.grille-pistolet .pleine { grid-column: 1 / -1; }
@media (min-width: 620px) { .grille-pistolet { grid-template-columns: repeat(4, 1fr); } }
.grille-pistolet .champ { margin: 0; }
.grille-pistolet input, .grille-pistolet select { min-height: 38px; padding: .4rem .45rem; font-size: .86rem; }

.nav-bas { display: none; }
@media (max-width: 760px) {
  .entete { padding: .5rem .7rem; }
  .conteneur { padding: .7rem; }
  .carte { padding: .8rem; }
  .nav-bas {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--bord);
    z-index: 40;
    padding: .25rem 0 max(.25rem, env(safe-area-inset-bottom));
  }
  .nav-bas a { flex: 1; text-align: center; font-size: .68rem; color: var(--gris); padding: .3rem 0; }
  .nav-bas a.actif { color: var(--bleu); font-weight: 700; }
  .nav-bas a span { display: block; font-size: 1.15rem; line-height: 1.1; }
  body { padding-bottom: 60px; }
  h1 { font-size: 1.25rem; }
  .kpi .valeur { font-size: 1.15rem; }
  table { font-size: .8rem; }
  th, td { padding: .35rem .3rem; }
  .masquer-mobile { display: none; }
}
@media print {
  .entete, .nav-principal, .nav-bas, .actions, .bouton, button { display: none !important; }
  body { background: #fff; }
  .carte { box-shadow: none; border: 1px solid #999; }
}
