/* Justificatifs — direction visuelle : le ticket de caisse.
   Papier thermique, encre monospace, filets pointillés, bord déchiré.
   Tout est pensé pour une main, en extérieur, en pleine lumière. */

:root {
  --encre:        #17181C;
  --encre-pale:   #6B6C70;
  --papier:       #F6F5F1;
  --papier-haut:  #FFFFFF;
  --filet:        #CFCDC4;
  --danger:       #B42318;
  --ok:           #0F766E;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --r: 4px;
  --pad: 20px;
  --safe-bas: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--encre);
  color: var(--encre);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  display: flex; flex-direction: column;
}

#app { display: flex; flex-direction: column; min-height: 100dvh; background: var(--papier); }
#app[hidden] { display: none; }

main {
  flex: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: var(--pad) var(--pad) 96px;
}

.ecran { display: none; }
.ecran.actif { display: block; animation: apparait .18s ease-out; }
@keyframes apparait { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------- Typographie */

.eyebrow {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--encre-pale);
  margin: 0 0 10px;
}

h1 { font-size: 30px; line-height: 1.1; margin: 0 0 6px; letter-spacing: -.02em; }
.sous-titre { margin: 0 0 24px; color: var(--encre-pale); font-size: 15px; }

.chemin {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  color: var(--encre-pale); word-break: break-all; margin: 0;
}

.resume { font-size: 13px; color: var(--encre-pale); text-align: center; margin: 16px 0 0; }
.erreur { color: var(--danger); font-size: 14px; margin: 12px 0 0; }
.avertissement { color: #92400E; font-size: 13px; margin: 12px 0 0; }

/* ------------------------------------------------------------ Le ticket */
/* Signature de l'interface : le bord inférieur déchiré du papier thermique. */

.ticket {
  background: var(--papier-haut);
  padding: 28px var(--pad) 34px;
  position: relative;
  border-radius: var(--r) var(--r) 0 0;
}
.ticket::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -10px; height: 10px;
  background:
    linear-gradient(-45deg, transparent 50%, var(--papier-haut) 50%) 0 0 / 12px 10px repeat-x,
    linear-gradient( 45deg, transparent 50%, var(--papier-haut) 50%) 0 0 / 12px 10px repeat-x;
}

.ticket--login {
  width: 100%; max-width: 420px; margin: auto;
}
#ecran-login {
  min-height: 100dvh; display: none; padding: 24px;
  align-items: center; justify-content: center;
}
#ecran-login.actif { display: flex; }

.ticket--imprime { text-align: center; margin-bottom: 34px; }
.conf-marchand { font-size: 22px; font-weight: 600; margin: 0 0 10px; }

/* ------------------------------------------------------------- Contrôles */

.champ { margin-bottom: 18px; }
.champ label {
  display: block; margin-bottom: 6px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--encre-pale);
}
.champ input {
  width: 100%; padding: 14px 12px;
  font-family: var(--sans); font-size: 17px; color: var(--encre);
  background: var(--papier-haut);
  border: 1px solid var(--filet); border-radius: var(--r);
  appearance: none;
}
.champ input:focus-visible { outline: 2px solid var(--encre); outline-offset: 1px; }
.champ--court input { max-width: 220px; }
.champ--recherche input { font-size: 18px; }

.repli { margin-bottom: 20px; }
.repli summary {
  font-size: 14px; color: var(--encre-pale); cursor: pointer;
  padding: 6px 0; list-style: none;
}
.repli summary::-webkit-details-marker { display: none; }
.repli summary::before { content: "+ "; font-family: var(--mono); }

.bouton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 20px;
  font-family: var(--sans); font-size: 16px; font-weight: 600;
  border-radius: var(--r); border: 1px solid var(--encre);
  cursor: pointer; text-decoration: none;
}
.bouton--plein { background: var(--encre); color: var(--papier); width: 100%; }
.bouton--fantome { background: transparent; color: var(--encre); }
.bouton--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.bouton:disabled { opacity: .45; cursor: default; }
.bouton:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }

.actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 8px; }

.lien-discret {
  background: none; border: 0; color: var(--encre-pale);
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em;
  text-transform: uppercase; cursor: pointer; padding: 8px;
}

/* ------------------------------------------------------------ Déclencheur */

.capture-zone { padding-top: 24px; }

.declencheur {
  width: 100%; aspect-ratio: 1 / 1; max-height: 46dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--papier-haut);
  border: 2px dashed var(--filet); border-radius: 8px;
  color: var(--encre); font-family: var(--sans); font-size: 18px; font-weight: 600;
  cursor: pointer;
}
.declencheur:active { background: #EFEEE8; }
.declencheur-icone {
  width: 66px; height: 52px; border: 2.5px solid var(--encre); border-radius: 6px;
  position: relative;
}
.declencheur-icone::before {
  content: ""; position: absolute; inset: 11px; border: 2.5px solid var(--encre); border-radius: 50%;
}
.declencheur-icone::after {
  content: ""; position: absolute; top: -9px; left: 16px; width: 22px; height: 8px;
  border: 2.5px solid var(--encre); border-bottom: 0; border-radius: 4px 4px 0 0;
  background: var(--papier-haut);
}
#btn-galerie { width: 100%; margin-top: 14px; }

.apercu {
  height: 190px; margin-bottom: 24px;
  background: var(--papier-haut); border: 1px solid var(--filet); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.apercu img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ------------------------------------------------------- Grille entreprises */

.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }

.tuile {
  min-height: 62px; padding: 12px 14px 12px 16px;
  display: flex; align-items: center; text-align: left;
  background: var(--papier-haut);
  border: 1px solid var(--filet); border-left: 5px solid var(--couleur, var(--filet));
  border-radius: var(--r);
  font-family: var(--sans); font-size: 15px; font-weight: 600; line-height: 1.25;
  color: var(--encre); cursor: pointer;
}
.tuile[aria-pressed="true"] {
  background: var(--encre); color: var(--papier); border-color: var(--encre);
  border-left-color: var(--couleur, var(--papier));
}
.tuile:focus-visible { outline: 2px solid var(--encre); outline-offset: 2px; }

/* -------------------------------------------------------------- Résultats */

.filtres { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.puce {
  flex: 0 0 auto; padding: 7px 13px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  background: transparent; color: var(--encre-pale);
  border: 1px solid var(--filet); border-radius: 100px; cursor: pointer;
}
.puce[aria-pressed="true"] { background: var(--encre); color: var(--papier); border-color: var(--encre); }
.puce--corbeille { margin-left: auto; border-style: dashed; }

.mois-titre {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--encre-pale); margin: 22px 0 8px; padding-bottom: 6px;
  border-bottom: 1px dashed var(--filet);
}

.ligne {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 13px 12px; margin-bottom: 6px; text-align: left;
  background: var(--papier-haut);
  border: 1px solid transparent; border-left: 4px solid var(--couleur, var(--filet));
  border-radius: var(--r); cursor: pointer;
}
.ligne:active { background: #EFEEE8; }
.ligne-date { font-family: var(--mono); font-size: 12.5px; color: var(--encre-pale); flex: 0 0 auto; }
.ligne-corps { flex: 1; min-width: 0; }
.ligne-marchand {
  font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ligne-meta {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--encre-pale);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ligne-alerte { color: var(--danger); }

/* ----------------------------------------------------------------- Cadres */

.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--pad); padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--encre); color: var(--papier);
}
.barre-titre {
  flex: 1; font-family: var(--mono); font-size: 12px;
  letter-spacing: .2em; text-transform: uppercase;
}
.barre .lien-discret { color: var(--papier); opacity: .65; }
.badge {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  background: var(--papier); color: var(--encre);
  padding: 4px 9px; border-radius: 100px;
}

.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--papier-haut); border-top: 1px solid var(--filet);
  padding-bottom: var(--safe-bas);
}
.onglet {
  padding: 16px 0; background: none; border: 0; cursor: pointer;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--encre-pale); border-top: 2px solid transparent; margin-top: -1px;
}
.onglet.actif { color: var(--encre); border-top-color: var(--encre); }

/* ------------------------------------------------------------ Visionneuse */

.visionneuse {
  position: fixed; inset: 0; z-index: 40;
  background: var(--encre);
  display: flex; flex-direction: column;
}
.visionneuse[hidden] { display: none; }
.visionneuse img { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #0B0C0E; }
.visionneuse-pied {
  padding: 16px var(--pad) calc(16px + var(--safe-bas));
  background: var(--papier); border-top: 1px solid var(--filet);
}
.visionneuse-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.fermer {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 2;
  width: 44px; height: 44px; font-size: 28px; line-height: 1;
  background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 50%; cursor: pointer;
}

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bas)); transform: translateX(-50%);
  z-index: 50; max-width: 90vw;
  padding: 12px 18px; border-radius: var(--r);
  background: var(--encre); color: var(--papier); font-size: 14.5px; text-align: center;
}
.toast[hidden] { display: none; }
.toast--erreur { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
