/* Toltiko — DA « Ticket & comptoir » (.claude/DA-TENDANCES.md § 3).
   Une seule couleur pleine à l'écran : Encaisser. Le reste : fond, carte blanche, encre. */
:root {
  --fond: #F5F4EF; --carte: #FFFFFF; --fond-2: #ECEAE2; --trait: #D6D2C6;
  --encre: #1D1B16; --encre-2: #4A463C;
  --action: #0F5C4C; --action-presse: #0B4A3D; --sur-action: #FFFFFF;
  --focus: #B87F0D;
  --paye-fg: #14532D; --paye-bg: #DCF0E2;
  --erreur: #A8321E; --erreur-bg: #FBE9E5;
  --horsligne-fg: #6B4400; --horsligne-bg: #FCEFD2;
  --r: 12px; --r-s: 8px;
  font-family: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* alias gardés pour les écrans qui les citent */
  --ink: var(--encre); --muted: var(--encre-2); --line: var(--trait); --bg: var(--fond); --card: var(--carte);
  --brand: var(--action); --brand-2: var(--action); --ok: var(--paye-fg); --bad: var(--erreur); --warn: var(--horsligne-fg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fond); color: var(--encre); -webkit-tap-highlight-color: transparent; }
body { display: flex; flex-direction: column; overscroll-behavior: none; font-size: 16px; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; user-select: none; }
input, select { font: inherit; font-size: 16px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num, .pp, .lt, .big, #total, .due, .changebox strong { font-variant-numeric: tabular-nums; }
h1 { font-size: 24px; margin: 0 0 14px; } h2 { font-size: 20px; margin: 0 0 12px; } h3 { font-size: 16px; margin: 16px 0 6px; }

/* en-tête : clair, l'encre porte la marque, la couleur reste au bouton Encaisser */
#top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--carte); border-bottom: 1px solid var(--trait); }
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 160px; }
.brand strong { font-size: 20px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand strong::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--action); }
.brand span { font-size: 13px; color: var(--encre-2); }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { background: transparent; border: 0; padding: 12px 16px; border-radius: var(--r-s); white-space: nowrap; color: var(--encre-2); font-weight: 600; }
.tab:active { background: var(--fond-2); }
.tab.on { background: var(--fond-2); color: var(--encre); box-shadow: inset 0 -3px 0 var(--encre); }
.right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.lang { display: flex; border: 1px solid var(--trait); border-radius: var(--r-s); overflow: hidden; }
.lang button { background: transparent; border: 0; padding: 9px 12px; color: var(--encre-2); font-weight: 600; }
.lang button.on { background: var(--encre); color: var(--carte); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--fond-2); color: var(--encre); white-space: nowrap; }
.pill.ok { background: var(--paye-bg); color: var(--paye-fg); } .pill.off { background: var(--horsligne-bg); color: var(--horsligne-fg); }

main { flex: 1; min-height: 0; overflow: auto; }
.sale { display: grid; grid-template-columns: minmax(0, 64fr) minmax(340px, 36fr); height: 100%; }
.catalog { display: flex; flex-direction: column; padding: 14px; gap: 12px; min-height: 0; }
.scan { width: 100%; padding: 14px 16px; border: 2px solid var(--trait); border-radius: var(--r); background: var(--carte); color: var(--encre); font-size: 18px; }
.scan::placeholder { color: var(--encre-2); }
.scan:focus { outline: none; border-color: var(--encre); }
/* gros catalogues (19 catégories chez Cig2Vap) : quatre rangées au plus, le reste défile, les tuiles gardent la place */
.cats { display: flex; gap: 6px; flex-wrap: wrap; flex: none; max-height: 196px; overflow-y: auto; }
.cat { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--trait); border-radius: 999px; background: var(--carte); font-weight: 700; font-size: 15px; }
.cat[style]::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.cat:active { background: var(--fond-2); }
.cat.on { background: var(--encre); border-color: var(--encre); color: var(--carte); }
.cat.on::before { box-shadow: 0 0 0 2px var(--carte); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; overflow: auto; align-content: start; padding-bottom: 14px; }
.prod { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px 12px 14px; text-align: left;
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); transition: transform 80ms ease-out; }
.prod::before { content: ""; position: absolute; inset: -1px -1px auto; height: 7px; border-radius: var(--r) var(--r) 0 0; background: var(--c, var(--trait)); }
.prod:active { transform: scale(.97); background: var(--fond-2); }
.pn { font-weight: 600; font-size: 17px; line-height: 1.2; flex: 1 0 auto; hyphens: auto; overflow-wrap: anywhere; }
.pp { font-size: 18px; font-weight: 700; }
.ps { font-size: 14px; color: var(--encre-2); }
.prod.low .ps { color: var(--erreur); font-weight: 700; }

.cart { display: flex; flex-direction: column; background: var(--carte); border-left: 1px solid var(--trait); min-height: 0; }
.lines { flex: 1; overflow: auto; padding: 6px 10px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left; padding: 12px 8px; background: transparent; border: 0; border-bottom: 1px dashed var(--trait); border-radius: 0; }
.line:active { background: var(--fond-2); }
.ln { font-weight: 600; font-size: 17px; } .lq { grid-column: 1; font-size: 14px; color: var(--encre-2); } .lq em { color: var(--paye-fg); font-style: normal; font-weight: 700; }
.lt { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 700; font-size: 18px; } .line.neg .lt, .line.neg .ln { color: var(--erreur); }
.empty { color: var(--encre-2); padding: 32px 12px; text-align: center; font-size: 17px; }
.sum { padding: 12px 16px; border-top: 1px solid var(--trait); }
.row { display: flex; gap: 8px; align-items: center; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; margin-top: 16px; } .row.wrap { flex-wrap: wrap; margin-top: 16px; }
.sum .row { justify-content: space-between; padding: 3px 0; font-size: 16px; }
.sum .big { font-size: 22px; font-weight: 700; align-items: baseline; } .sum .big #total { font-size: 40px; letter-spacing: -.02em; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; border-top: 1px solid var(--trait); }
.actions .btn { min-height: 56px; }
.actions .pay { grid-column: 1 / -1; font-size: 22px; font-weight: 700; min-height: 76px; }

.btn { border: 1px solid var(--trait); background: var(--carte); padding: 11px 16px; border-radius: var(--r-s); font-weight: 600; min-height: 44px; }
.btn:active { background: var(--fond-2); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--sur-action); }
.btn.primary:active { background: var(--action-presse); }
.btn.primary:disabled { background: var(--fond-2); border-color: var(--trait); color: var(--encre-2); cursor: default; }
.btn.ghost { background: transparent; }
.btn.warn { background: var(--horsligne-bg); border-color: var(--horsligne-fg); color: var(--horsligne-fg); }
.btn.small { padding: 7px 12px; font-size: 14px; min-height: 40px; } .btn.big { padding: 18px; font-size: 19px; min-height: 64px; }
.btn:disabled { opacity: .5; cursor: default; }

#modal { position: fixed; inset: 0; background: rgba(29, 27, 22, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
#modal[hidden] { display: none; }
.sheet { background: var(--carte); border-radius: 16px; padding: 22px; width: min(460px, 100%); max-height: 92vh; overflow: auto; }
.sheet.wide { width: min(720px, 100%); }
.form label, .payment label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 14px; color: var(--encre-2); font-weight: 600; }
.form input, .form select, .payment input { padding: 12px 14px; border: 1px solid var(--trait); border-radius: var(--r-s); color: var(--encre); background: var(--carte); font-size: 18px; }
.err { color: var(--erreur); font-weight: 600; }
.payment .due { display: flex; justify-content: space-between; align-items: baseline; font-size: 24px; padding: 6px 0; } .payment .due strong { font-size: 32px; }
.payment .due.small { font-size: 15px; color: var(--encre-2); }
.methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; } .notes { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.notes .btn { min-height: 52px; min-width: 76px; font-size: 17px; }
.plist { list-style: none; padding: 0; margin: 0 0 8px; } .plist li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--trait); }
.changebox { background: var(--paye-bg); color: var(--paye-fg); padding: 14px; border-radius: var(--r); font-size: 20px; text-align: center; margin-bottom: 14px; font-weight: 600; }
.changebox strong { font-size: 40px; display: block; }

.receipt, .report { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; width: 72mm; max-width: 100%; margin: 0 auto; color: #000; }
.receipt .c { text-align: center; margin: 4px 0; } .r2 { display: flex; justify-content: space-between; gap: 8px; } .r2.big { font-size: 16px; font-weight: 700; }
.receipt .sub, .sub { font-size: 12px; color: var(--encre-2); } .receipt hr, .report hr { border: 0; border-top: 1px dashed #000; }
table.vat { width: 100%; border-collapse: collapse; font-size: 12px; } table.vat th, table.vat td { text-align: right; padding: 1px 2px; } table.vat th:first-child, table.vat td:first-child { text-align: left; }

.page { padding: 20px 24px; max-width: 1100px; margin: 0 auto; } .page.narrow { max-width: 640px; }
.page .scan { margin-bottom: 12px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); overflow: hidden; }
.tbl th, .tbl td { padding: 12px; border-bottom: 1px solid var(--trait); text-align: left; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { font-size: 13px; color: var(--encre-2); background: var(--fond-2); font-weight: 700; } .tbl .num { text-align: right; white-space: nowrap; } .nowrap { white-space: nowrap; }
.tbl tr.low td { background: var(--erreur-bg); } .tbl tr.click { cursor: pointer; } .tbl tr.click:active td { background: var(--fond-2); }
.card { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.card > :first-child { margin-top: 0; }
.card p { line-height: 1.5; }
.report { width: auto; background: var(--carte); padding: 16px; border: 1px solid var(--trait); border-radius: var(--r); }
.more { color: var(--encre-2); font-size: 15px; margin: 4px 0; }

/* achats : marge, arrivage */
.margin { font-variant-numeric: tabular-nums; } .margin.neg { color: var(--erreur); border-color: var(--erreur); }
.page h2 { margin-top: 22px; }
.rhead { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.rhead label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--encre-2); }
.rhead select, .rhead input { padding: 12px 14px; border: 1px solid var(--trait); border-radius: var(--r-s); background: var(--carte); color: var(--encre); font-size: 17px; }
.cell { width: 6.5em; padding: 10px; border: 1px solid var(--trait); border-radius: var(--r-s); text-align: right; font-size: 17px; font-variant-numeric: tabular-nums; background: var(--carte); color: var(--encre); }
.cell.small { width: 4.5em; } .cell.bad { border-color: var(--erreur); background: var(--erreur-bg); }
.chk { width: 24px; height: 24px; accent-color: var(--action); }
.picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.rlines { margin-top: 4px; }
.rfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.rfoot .row.wrap { margin-top: 0; }
.rtotal { font-size: 18px; } .rtotal strong { font-size: 24px; font-variant-numeric: tabular-nums; margin-left: 8px; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 20; }
.toast { background: var(--encre); color: var(--carte); padding: 12px 18px; border-radius: var(--r); font-weight: 600; }
.toast.bad { background: var(--erreur); } .toast.good { background: var(--paye-fg); }

@media (hover: hover) and (pointer: fine) {
  .prod:hover, .cat:hover, .btn:hover, .tab:hover { border-color: var(--encre-2); }
  .btn.primary:hover { background: var(--action-presse); }
  .line:hover, .tbl tr.click:hover td { background: var(--fond); }
}
@media (prefers-reduced-motion: reduce) { .prod { transition: none; } .prod:active { transform: none; } }

@media (max-width: 820px) {
  .sale { grid-template-columns: minmax(0, 1fr); height: auto; } .catalog { min-width: 0; } .cart { border-left: 0; border-top: 1px solid var(--trait); }
  .brand { min-width: 0; } .brand span { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tab { padding: 12px 10px; }
  #top { flex-wrap: wrap; row-gap: 4px; padding: 8px 12px 0; }
  nav { order: 3; flex-basis: 100%; }
  .cats { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding-bottom: 2px; }
  .cat { flex: none; }
  /* le panier et Encaisser restent en bas d'écran, même sous 120 tuiles */
  .cart { position: sticky; bottom: 0; z-index: 2; max-height: 44vh; max-height: 44dvh; box-shadow: 0 -6px 16px rgba(29, 27, 22, .10); }
  .lines { min-height: 0; padding: 2px 10px; } .line { padding: 8px; } .empty { padding: 10px 12px; font-size: 15px; }
  .sum { padding: 8px 16px; } .sum .big #total { font-size: 32px; }
  .actions { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); } .actions { gap: 6px; } .actions .btn { min-height: 44px; padding: 6px 8px; } .actions .pay { min-height: 56px; font-size: 20px; }
  /* tableaux larges : ils défilent au lieu de couper les colonnes et les boutons */
  .tbl { display: block; overflow-x: auto; }
  .page { padding: 16px 12px; }
  .wrap-sm { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .rhead { grid-template-columns: minmax(0, 1fr); }
  .rfoot .row.wrap { width: 100%; } .rfoot .row.wrap .btn { flex: 1 1 auto; }
  /* une ligne d'arrivage = une carte : nom en haut, champs libellés dessous */
  .tbl.rlines { display: block; overflow: visible; border: 0; background: none; }
  .rlines tbody { display: block; }
  .rlines tr.rh { display: none; }
  .rlines tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; padding: 12px; margin-bottom: 10px; background: var(--carte); border: 1px solid var(--trait); border-radius: var(--r); }
  .rlines td { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 0; border: 0; text-align: left; }
  .rlines td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .rlines td[data-l]::before { content: attr(data-l); font-size: 13px; font-weight: 600; color: var(--encre-2); }
  .rlines .cell, .rlines .cell.small { width: 100%; }
  .rlines td.rdel { justify-content: flex-end; align-items: flex-end; }
}
@media (max-width: 420px) {
  nav { gap: 0; } .tab { flex: 1 1 auto; padding: 12px 6px; font-size: 14px; }
}

@media print {
  @page { size: 80mm auto; margin: 3mm; }
  body * { visibility: hidden !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area { position: absolute; left: 0; top: 0; width: 74mm; }
  #modal { position: static; background: none; padding: 0; } .sheet { box-shadow: none; padding: 0; }
  .report { border: 0; padding: 0; }
}
