/* ============================================================
   Waale Caisse — styles (mobile d'abord, iPhone 13 : 390 × 844)
   Thème clair très contrasté : lisible en plein soleil au marché
   ============================================================ */
:root {
  --bg: #f4efe6;
  --card: #fffdf9;
  --ink: #1d1a16;
  --ink2: #6b6358;
  --line: #e4dccf;
  --amber: #c8862a;
  --amber-d: #9e6519;
  --amber-l: #f6e7cf;
  --green: #2f7d4f;
  --red: #b3392f;
  --radius: 14px;
  --tabs-h: 58px;
  --paybar-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-padding-bottom: calc(var(--tabs-h) + var(--paybar-h) + env(safe-area-inset-bottom, 0px) + 12px); scroll-padding-top: 70px; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 16px; /* 16px : évite le zoom auto de Safari */
  -webkit-appearance: none; appearance: none;
}
select { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6358' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-l); }
textarea { resize: vertical; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.err { color: var(--red); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }

/* ---------- Boutons ---------- */
.btn { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:disabled { background: #b9b1a5; border-color: #b9b1a5; }
.btn.ghost { background: var(--amber-l); border-color: transparent; color: var(--amber-d); }
.btn.danger { color: var(--red); }
.btn.big { padding: 14px 18px; font-size: 17px; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.link { color: var(--amber-d); font-weight: 600; text-decoration: none; font-size: 14px; }

/* ---------- Marque ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 22px; letter-spacing: .5px; }
.brand small { color: var(--ink2); }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; background: var(--amber); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; font-family: Georgia, serif; }
.brand.small .brand-mark { width: 30px; height: 30px; font-size: 16px; border-radius: 8px; }
.brand.small { font-weight: 700; font-size: 17px; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 26px 22px;
  box-shadow: 0 10px 40px rgba(60, 40, 10, .1); }
.login-card h2 { margin: 22px 0 6px; }
.login-card label { display: block; margin-top: 14px; font-size: 14px; color: var(--ink2); font-weight: 600; }
.login-card input { margin-top: 5px; }
.login-card .btn { width: 100%; margin-top: 20px; }

/* ---------- Structure ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: calc(8px + var(--safe-t)) 16px 8px; background: rgba(244, 239, 230, .94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.day-total { border: 0; background: var(--ink); color: #fff; border-radius: 10px; padding: 5px 12px; text-align: right; line-height: 1.1; cursor: pointer; }
.day-total small { display: block; font-size: 11px; opacity: .7; }
.day-total b { font-size: 16px; }
.view { padding: 12px 16px 0; max-width: 760px; margin: 0 auto; }
.spacer { height: calc(var(--tabs-h) + var(--paybar-h) + var(--safe-b) + 20px); }
#v-ventes .spacer, #v-reglages .spacer { height: calc(var(--tabs-h) + var(--safe-b) + 20px); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.card-title .muted { font-weight: 500; font-size: 14px; }
.card-title { font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-title.pad { margin: 18px 2px 8px; }
.pad { padding-left: 2px; padding-right: 2px; }
.row2 { display: flex; gap: 10px; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
.field { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); }
.field input, .field select, .field textarea { margin-top: 4px; color: var(--ink); font-weight: 400; }
.empty { text-align: center; color: var(--ink2); padding: 14px; margin: 0; }
.empty.small { padding: 6px; font-size: 14px; }

/* ---------- En-tête de vente ---------- */
.sale-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sale-no { font-weight: 700; font-size: 18px; }
.sale-time { color: var(--ink2); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- Interrupteur commerçant ---------- */
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; padding-bottom: 6px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw { width: 48px; height: 29px; border-radius: 20px; background: #d8cfc1; position: relative; transition: .2s; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: .2s; }
.switch input:checked + .sw { background: var(--green); }
.switch input:checked + .sw::after { left: 22px; }
.sw-lbl { font-size: 14px; font-weight: 600; line-height: 1.1; }
.sw-lbl small { display: block; color: var(--ink2); font-weight: 400; }

/* ---------- Grille produits ---------- */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.pbtn { position: relative; border: 0; border-radius: 10px; min-height: 54px; padding: 6px 6px 5px;
  color: #fff; text-align: left; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); cursor: pointer; overflow: hidden; }
.pbtn:active { transform: scale(.95); filter: brightness(1.1); }
.pbtn .pn { font-weight: 700; font-size: 12.5px; line-height: 1.12; word-break: break-word; padding-right: 14px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }
.pbtn.light { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12), inset 0 0 0 1px rgba(0, 0, 0, .08); }
.pbtn.light .pn { text-shadow: none; }
.pbtn .pp i { font-style: normal; font-size: 10px; opacity: .8; }
.pbtn .pp { font-size: 11.5px; margin-top: 2px; opacity: .92; font-variant-numeric: tabular-nums; }
.pbtn .badge { position: absolute; top: -5px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px; padding: 0 5px;
  background: var(--ink); color: #fff; border: 2px solid var(--bg); font-weight: 800; font-size: 12px; display: grid; place-items: center; }
.pbtn { overflow: visible; }
.pbtn .nr { position: absolute; bottom: 6px; right: 7px; font-size: 10px; opacity: .8; }
.pbtn.pulse { animation: pulse .25s; }
@keyframes pulse { 50% { transform: scale(.93); } }

/* ---------- Panier ---------- */
.cart { list-style: none; margin: 0; padding: 0; }
.cart li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.cart li:first-child { border-top: 0; }
.cart .cn { flex: 1; min-width: 0; }
.cart .cn b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart .cn small { color: var(--ink2); }
.qty { display: flex; align-items: center; gap: 2px; }
.qty button { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-size: 20px;
  font-weight: 700; line-height: 1; cursor: pointer; }
.qty span { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart .ct { width: 74px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Segments / pastilles ---------- */
.seg { display: flex; background: #ece5d9; border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.card .seg { margin-bottom: 0; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.small button { padding: 7px 2px; font-size: 13px; }
.remise-input { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.remise-input input { font-size: 20px; font-weight: 700; text-align: right; }
.remise-input span { font-size: 20px; font-weight: 700; width: 24px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills button { flex: 1 1 calc(33% - 8px); border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  padding: 12px 6px; font-weight: 600; font-size: 14px; cursor: pointer; }
.pills button.on { border-color: var(--ink); background: var(--ink); color: #fff; }

/* ---------- Totaux ---------- */
.totals > div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals small { color: var(--ink2); }
.totals #row-rist b, .totals #row-remise b { color: var(--green); }
.totals .grand { border-top: 1.5px dashed var(--line); margin-top: 6px; padding-top: 10px; font-size: 19px; }

/* ---------- Barre de validation ---------- */
.paybar { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 30;
  height: var(--paybar-h); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(60, 40, 10, .08); }
.paybar small { display: block; color: var(--ink2); font-size: 12px; }
.paybar b { font-size: 24px; font-variant-numeric: tabular-nums; }
.paybar .btn { flex: 0 0 auto; }

/* ---------- Onglets ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; display: flex; background: var(--ink);
  padding-bottom: var(--safe-b); height: calc(var(--tabs-h) + var(--safe-b)); }
.tabs button { flex: 1; border: 0; background: transparent; color: #a79f93; font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.tabs button i { font-style: normal; font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: #fff; }
.tabs button.on i { filter: none; opacity: 1; }

/* ---------- Synthèse ventes ---------- */
.sum-main { display: grid; grid-template-columns: .7fr 1fr 1fr; gap: 8px; }
.sum-main > div { background: var(--bg); border-radius: 10px; padding: 8px; }
.sum-main small { display: block; color: var(--ink2); font-size: 12px; }
.sum-main b { font-size: 17px; font-variant-numeric: tabular-nums; }
.sum-main .hl { background: var(--ink); color: #fff; }
.sum-main .hl small { color: #cfc6b8; }
.sum-sub { font-size: 13px; color: var(--ink2); margin-top: 8px; }
details summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details summary::after { content: "▾"; color: var(--ink2); }
details[open] summary::after { content: "▴"; }
details summary::-webkit-details-marker { display: none; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl td { padding: 6px 0; border-top: 1px solid var(--line); }
.tbl td.r { text-align: right; white-space: nowrap; padding-left: 8px; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0 0 12px; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list:empty { display: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li.click { cursor: pointer; }
.list li.click:active { background: var(--amber-l); }
.list .li-main { flex: 1; min-width: 0; }
.list .li-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li-main small { color: var(--ink2); }
.list .li-right { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .li-right small { display: block; font-weight: 400; color: var(--ink2); }
.list li.off { opacity: .5; }
.list li.annul .li-right { text-decoration: line-through; color: var(--red); }
.dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.updown { display: flex; flex-direction: column; gap: 2px; }
.updown button { border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 30px; height: 22px; font-size: 11px; cursor: pointer; padding: 0; }
.chk { width: 26px; height: 26px; flex: none; accent-color: var(--green); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--amber-l); color: var(--amber-d); margin-left: 4px; vertical-align: middle; }
.tag.g { background: #dcefe2; color: var(--green); }
.tag.r { background: #f6dcd9; color: var(--red); }
.who { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }
.journal { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.journal li { padding: 6px 0; border-top: 1px solid var(--line); }
.journal small { color: var(--ink2); }

/* ---------- Feuille modale ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(29, 26, 22, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: var(--card);
  border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 12px; }
.sheet .field { margin-bottom: 12px; }
.sheet .chkline { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-weight: 600; }
.sheet .actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet .actions .btn { flex: 1; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.colors button { width: 36px; height: 36px; border-radius: 10px; border: 3px solid transparent; cursor: pointer; }
.colors button.on { border-color: var(--ink); }
.ok-big { text-align: center; padding: 6px 0 4px; }
.ok-big .check { width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; font-size: 34px;
  display: grid; place-items: center; margin: 0 auto 10px; }
.ok-big b { display: block; font-size: 32px; font-variant-numeric: tabular-nums; }
.detail-lines { list-style: none; padding: 0; margin: 10px 0; font-size: 15px; }
.detail-lines li { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  max-width: 90vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.toast.bad { background: var(--red); }

/* ---------- Écrans plus larges (iPad, ordinateur) ---------- */
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .pbtn { min-height: 72px; padding: 9px 8px 7px; }
  .pbtn .pn { font-size: 14px; }
  .paybar { padding: 0 max(16px, calc((100vw - 760px) / 2 + 16px)); }
}
@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 350px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
.click { cursor: pointer; }
input[type=checkbox].chk { -webkit-appearance: checkbox; appearance: auto; width: 26px; height: 26px; padding: 0; margin: 0; }

/* ---------- Hors ligne ---------- */
.net { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px; background: var(--amber-l); color: var(--amber-d); white-space: nowrap; }
.net.off { background: #3a342c; color: #fff; }
.net.bad { background: #f6dcd9; color: var(--red); }
.ok-big .check.off { background: var(--amber); }
.note { background: var(--amber-l); color: var(--amber-d); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0 0; }
.pending { border-color: var(--amber); background: #fffaf1; }
.list.flat { border: 0; border-radius: 0; background: transparent; margin-bottom: 10px; }
.list.flat li { padding-left: 0; padding-right: 0; }
.pending .btn { width: 100%; }
.pending .li-right .btn { width: auto; display: block; margin-top: 4px; }

.pick { width: 36px; height: 36px; border-radius: 10px; overflow: hidden; border: 2px dashed #b9b1a5; position: relative; cursor: pointer;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer; }
.preview { margin-top: 6px; width: 25%; min-width: 86px; }
.preview .pbtn { display: flex; cursor: default; }

/* ---------- Rapprochement ---------- */
.list .li-main small b.pt { display: inline; font-weight: 700; color: var(--ink); white-space: nowrap; }
.exports { display: flex; gap: 8px; margin: 0 0 10px; }
.exports .btn { flex: 1; text-align: center; text-decoration: none; color: var(--ink); }
#pay-time { font-variant-numeric: tabular-nums; }
.sheet .actions { flex-wrap: wrap; }
