:root {
  --bg: #0c0c0c;
  --bg-2: #141012;
  --surface: #17140f;
  --surface-2: #1f1b14;
  --line: rgba(212, 175, 55, 0.18);
  --line-strong: rgba(212, 175, 55, 0.45);
  --gold: #d4af37;
  --gold-2: #dfb76c;
  --gold-3: #f3cf7a;
  --text: #f4ecd8;
  --muted: #a89f8a;
  --danger: #e5675b;
  --wa: #25d366;
  --st-recu: #e8c547;
  --st-atelier: #5aa9f0;
  --st-pret: #3ccf7a;
  --st-livre: #8f8a7c;
  --radius: 14px;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tabbar-h: 68px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; font-variant-numeric: lining-nums; }
body { min-height: 100dvh; }
/* Page fixe sur téléphone : ni glissement sur les côtés, ni rebond, ni zoom (double appui, pincement) */
html, body { overflow-x: clip; overscroll-behavior: none; touch-action: pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.modal-open { overflow: hidden; }
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
a { color: var(--gold-2); }

.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(180deg, #0c0c0c 70%, rgba(12, 12, 12, 0.92));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line-strong); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--serif); font-weight: 700; font-size: 22px; letter-spacing: 0.14em; line-height: 1;
  background: linear-gradient(180deg, var(--gold-3), var(--gold) 60%, #a8842a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { font-size: 9px; letter-spacing: 0.12em; color: var(--gold-2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 10px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.sync-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-pill.ok .dot { background: var(--st-pret); box-shadow: 0 0 8px var(--st-pret); }
.sync-pill.busy .dot { background: var(--gold); animation: pulse 1s infinite; }
.sync-pill.err .dot { background: var(--danger); }
.sync-pill.off .dot { background: var(--st-recu); }
@keyframes pulse { 50% { opacity: 0.3; } }

main { padding: 16px; }
.view { display: none; }
.view.active { display: block; animation: fade 0.18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.view-title { font-family: var(--serif); font-weight: 600; font-size: 26px; color: var(--gold-3); margin: 4px 0 16px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.backup-late { color: var(--danger); font-weight: 600; }
.version { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }

/* ---------- Cards & forms ---------- */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card-title { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--gold-2); margin: 0 0 12px; letter-spacing: 0.02em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.input {
  width: 100%; background: #0f0d0a; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font: inherit; font-size: 16px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15); }
.input.invalid { border-color: var(--danger); }
textarea.input { resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; min-height: 1em; }
.hint.err { color: var(--danger); }

.phone-row { display: flex; gap: 8px; }
.icon-btn {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface-2); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; fill: var(--gold-2); }
.icon-btn.wa svg { fill: var(--wa); }
.icon-btn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; user-select: none;
  transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-gold { background: linear-gradient(180deg, var(--gold-3), var(--gold) 55%, #b48f2c); color: #1a1408; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--gold-2); }
.btn-wa { background: var(--wa); color: #06260f; }
.btn-danger { background: transparent; border-color: rgba(229, 103, 91, 0.5); color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 15px 20px; font-size: 16px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; }

.reste-box {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 10px; background: rgba(212, 175, 55, 0.08); border: 1px dashed var(--line-strong);
}
.reste-box strong { font-family: var(--serif); font-size: 26px; color: var(--gold-3); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 4px; }
.switch { position: relative; width: 54px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #2b261d; border-radius: 30px; transition: 0.2s; cursor: pointer; border: 1px solid var(--line); }
.slider::before { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); transition: 0.2s; }
.switch input:checked + .slider { background: rgba(212, 175, 55, 0.3); border-color: var(--gold); }
.switch input:checked + .slider::before { transform: translateX(24px); background: var(--gold-3); }

/* Sélecteur de pièces : liste alphabétique compacte, défilante */
.pieces-list {
  max-height: 290px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 12px; background: #0f0d0a;
}
.pieces-list.invalid { border-color: var(--danger); }
.piece-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 0; border-bottom: 1px solid var(--line); }
.piece-item:last-child { border-bottom: none; }
.piece-item.on { background: rgba(212, 175, 55, 0.12); }
.piece-name {
  flex: 1; min-width: 0; text-align: left; background: none; border: none; color: var(--text);
  font: inherit; font-size: 15px; padding: 9px 12px; cursor: pointer;
}
.piece-item.on .piece-name { color: var(--gold-3); font-weight: 600; }
.qty-n { min-width: 24px; text-align: center; font-weight: 700; color: var(--gold-3); font-size: 16px; }
.qty-btn {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--gold-2); font-size: 20px; line-height: 1; cursor: pointer;
}
.pieces-summary { font-size: 14px; margin-bottom: 8px; color: var(--gold-3); }
.pieces-summary strong { color: var(--gold); }
.custom-piece { display: flex; gap: 8px; margin-top: 10px; }
.custom-piece .input { flex: 1; }

/* Dépôt : deux boutons, puis les vignettes */
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-buttons .btn { padding: 14px 8px; text-align: center; }
.extra-thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.extra-thumbs:not(:empty) { margin-top: 8px; }
.extra-thumb { position: relative; aspect-ratio: 1; }
.extra-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--gold); display: block; }
.extra-thumb button { position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: #0f0d0a; color: var(--danger); font-size: 16px; line-height: 1; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 10px 16px; font-size: 15px; cursor: pointer;
}
.chip.on { background: linear-gradient(180deg, var(--gold-3), var(--gold)); color: #1a1408; border-color: var(--gold); font-weight: 700; }

details.more > summary { cursor: pointer; color: var(--gold-2); font-size: 14px; list-style: none; }
details.more > summary::before { content: '▸ '; }
details.more[open] > summary { margin-bottom: 12px; }
details.more[open] > summary::before { content: '▾ '; }

.form-actions { display: flex; gap: 10px; position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
.form-actions .btn-lg { flex: 1; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); }

/* ---------- Stats & list ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 6px; text-align: center; cursor: pointer; transition: border-color 0.15s;
}
.stat strong { display: block; font-family: var(--serif); font-size: 26px; line-height: 1; }
.stat span { font-size: 11px; color: var(--muted); }
.stat.active { border-color: var(--gold); background: rgba(212, 175, 55, 0.14); box-shadow: inset 0 -3px 0 var(--gold); }
.stat.active span { color: var(--gold-3); font-weight: 600; }
/* Les onglets se lisent comme un parcours : magasin → atelier → réparé → livré */
.stat { position: relative; }
.stat:not(:last-child)::after { content: '›'; position: absolute; right: -8px; top: 50%; transform: translateY(-50%); z-index: 1; color: var(--gold); font-size: 15px; line-height: 1; }
/* Hauteur de deux lignes réservée : la liste ne saute pas d'un onglet à l'autre */
.stage-hint { margin: -2px 0 12px; font-size: 13px; line-height: 1.3; min-height: 2.6em; color: var(--muted); }
.courier-btn { margin: 0 0 12px; }
.stat[data-statut="recu"] strong { color: var(--st-recu); }
.stat[data-statut="atelier"] strong { color: var(--st-atelier); }
.stat[data-statut="pret"] strong { color: var(--st-pret); }
.stat[data-statut="livre"] strong { color: var(--st-livre); }

.search-row { margin-bottom: 12px; }
.filter-note { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--gold-2); margin-bottom: 10px; }
.filter-note button { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; }

.list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.item {
  display: flex; gap: 12px; padding: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.15s;
}
.item:hover { border-color: var(--line-strong); }
.item.st-recu { border-left: 4px solid var(--st-recu); }
.item.st-atelier { border-left: 4px solid var(--st-atelier); }
.item.st-pret { border-left: 4px solid var(--st-pret); }
.item.st-livre { border-left: 4px solid var(--st-livre); }
.thumb {
  width: 64px; height: 64px; border-radius: 10px; flex-shrink: 0; overflow: hidden;
  background: #0f0d0a; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--gold); font-family: var(--serif); font-size: 22px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-body { flex: 1; min-width: 0; }
/* Nom long : l'atelier passe à la ligne au lieu de le couper */
.item-top { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.item-name { max-width: 100%; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-atelier { flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--st-atelier); }
.item-ref { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.item-desc { font-size: 13px; color: var(--muted); margin: 3px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.item-reste { margin-left: auto; color: var(--gold-3); font-weight: 600; }
.item-person { font-size: 13px; font-weight: 600; color: var(--gold-3); margin-top: 2px; }
.chips.invalid { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 12px; }
.item-next { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.thumb-sachet { width: 48px; height: 48px; align-self: center; }
.unsynced { font-size: 11px; color: var(--st-recu); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid; }
.badge.recu { color: var(--st-recu); border-color: rgba(232, 197, 71, 0.4); background: rgba(232, 197, 71, 0.08); }
.badge.atelier { color: var(--st-atelier); border-color: rgba(90, 169, 240, 0.4); background: rgba(90, 169, 240, 0.08); }
.badge.pret { color: var(--st-pret); border-color: rgba(60, 207, 122, 0.4); background: rgba(60, 207, 122, 0.08); }
.badge.livre { color: var(--st-livre); border-color: rgba(143, 138, 124, 0.4); background: rgba(143, 138, 124, 0.08); }

.price-row { display: flex; gap: 8px; align-items: stretch; }
.price-row .input { flex: 1; min-width: 0; }
.price-entry { margin-top: 8px; }
.price-set { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.price-set > span { font-size: 13px; color: var(--muted); }
.price-set strong { font-family: var(--serif); font-size: 24px; line-height: 1; color: var(--gold-3); margin-right: auto; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty strong { display: block; font-family: var(--serif); font-size: 20px; color: var(--gold-2); margin-bottom: 6px; }

/* Ateliers */
.atelier { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.atelier.inactive { opacity: 0.5; }
.atelier-count {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(90, 169, 240, 0.1); border: 1px solid rgba(90, 169, 240, 0.35); color: var(--st-atelier); cursor: pointer;
}
.atelier-count strong { font-family: var(--serif); font-size: 22px; line-height: 1; }
.atelier-count small { font-size: 9px; white-space: nowrap; }
.atelier-body { flex: 1; min-width: 0; }
.atelier-name { font-weight: 600; font-size: 16px; }
.atelier-spec { font-size: 12px; color: var(--muted); }
.atelier-actions { display: flex; gap: 6px; }
.atelier-actions .icon-btn { width: 38px; height: 38px; }
.atelier-actions .icon-btn svg { width: 17px; height: 17px; }

.atelier-compte { margin-top: 6px; }
.mois-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mois-nav strong { font-family: var(--serif); font-size: 20px; color: var(--gold-2); text-transform: capitalize; }
.mois-nav .icon-btn { font-size: 22px; color: var(--gold-2); }
.mois-nav .icon-btn[disabled] { opacity: 0.3; }
.mois-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
/* Compte d'un atelier */
.compte-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.compte-row input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--gold); }
.compte-row.manque { opacity: 0.7; }
.compte-row.manque .compte-prix { color: var(--danger); font-size: 12px; }
.compte-nom { flex: 1; min-width: 0; font-size: 14px; }
.compte-nom small { display: block; color: var(--muted); font-size: 12px; }
.compte-prix { flex-shrink: 0; font-weight: 600; }
.compte-total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0; }
.compte-total strong { font-family: var(--serif); font-size: 26px; color: var(--gold-3); }
.compte-ecart { padding: 12px; border-radius: 10px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.compte-ecart.ok { color: var(--st-pret); background: rgba(60, 207, 122, 0.1); }
.compte-ecart.plus { color: #ff6b5c; background: rgba(229, 103, 91, 0.15); }
.compte-ecart.moins { color: var(--st-recu); background: rgba(232, 197, 71, 0.1); }
.compte-histo { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.compte-histo small { display: block; font-size: 12px; color: var(--muted); }
.ecart-plus { color: #ff6b5c; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(12, 12, 12, 0.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.tab { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: none; color: var(--muted); font-size: 11px; cursor: pointer; padding: 8px 0; }
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab.active { color: var(--gold-3); }
.tab-main svg { width: 30px; height: 30px; padding: 4px; border-radius: 50%; background: linear-gradient(180deg, var(--gold-3), var(--gold)); fill: #1a1408; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.7); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative; width: 100%; max-width: 720px; max-height: 92dvh; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg-2); border: 1px solid var(--line-strong); border-bottom: none;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up 0.2s ease-out;
}
@keyframes up { from { opacity: 0; } }
.sheet-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 22px; line-height: 1; cursor: pointer; color: var(--gold-2); }
.sheet h2 { font-family: var(--serif); font-size: 24px; color: var(--gold-3); margin: 0 40px 4px 0; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.detail-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.detail-photos a { position: relative; display: block; text-decoration: none; }
.detail-photos img { width: 100%; height: 220px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #0f0d0a; }
.detail-photos span { position: absolute; left: 8px; bottom: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); color: var(--gold-3); }
.detail-extras { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.detail-extras a { position: relative; display: block; text-decoration: none; }
.detail-extras img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.detail-extras span { position: absolute; left: 4px; right: 4px; bottom: 4px; font-size: 10px; padding: 1px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); color: var(--gold-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin-bottom: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.step { text-align: center; font-size: 11px; padding: 8px 2px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); cursor: pointer; }
.step.done { color: var(--text); }
.step.current { border-color: var(--gold); color: var(--gold-3); background: rgba(212, 175, 55, 0.1); font-weight: 600; }
.step .em { display: block; font-size: 16px; margin-bottom: 2px; }
.action-stack { display: flex; flex-direction: column; gap: 8px; }
.action-stack .btn { width: 100%; }
.action-stack .price-row .btn { width: auto; }
.contact-row { display: flex; gap: 8px; }
.contact-row .btn { flex: 1; }
.contact-row .input { flex: 3; }

/* ---------- Écran de verrouillage ---------- */
/* Ouverture de l'app : logo or, reflet lumineux, filet doré, puis le champ du code */
#lock {
  position: fixed; inset: 0; z-index: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 24px calc(env(safe-area-inset-bottom) + 16px);
  background: radial-gradient(circle at 50% 38%, #2a2110 0%, var(--bg) 58%);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
#lock.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.lk-logo { position: relative; width: min(64vw, 280px); aspect-ratio: 760 / 519; }
.lk-logo img { width: 100%; height: 100%; }
.lk-shine {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 246, 214, 0.95) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%; background-position: 130% 0;
  -webkit-mask: url(../assets/logo-receipt.png) center / contain no-repeat;
  mask: url(../assets/logo-receipt.png) center / contain no-repeat;
}
.lk-line { width: min(56vw, 240px); height: 1px; margin-top: 22px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.lk-sub { margin-top: 12px; font-size: 10px; font-weight: 500; letter-spacing: 0.45em; text-transform: uppercase; color: var(--gold-2); }
.lk-form { display: flex; flex-direction: column; align-items: center; width: min(72vw, 260px); margin-top: 44px; }
.lk-input {
  width: 100%; text-align: center; background: transparent; color: var(--gold-3);
  border: none; border-bottom: 1px solid var(--line-strong); border-radius: 0;
  padding: 10px 0; font: inherit; font-size: 22px; letter-spacing: 0.4em; outline: none;
  transition: border-color 0.2s;
}
.lk-input::placeholder { color: var(--muted); font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase; }
.lk-input:focus { border-bottom-color: var(--gold); }
.lk-btn {
  margin-top: 22px; padding: 11px 34px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--gold); background: transparent; color: var(--gold-3);
  font-size: 12px; font-weight: 600; letter-spacing: 0.3em; text-transform: uppercase;
}
.lk-show { margin-top: 16px; background: none; border: none; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; }
.lk-btn:active { background: rgba(212, 175, 55, 0.2); }
.lk-msg { min-height: 18px; margin-top: 12px; font-size: 13px; color: var(--danger); }
#lock.shake .lk-input { animation: shake 0.4s; border-bottom-color: var(--danger); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* L'effet est rejoué à chaque verrouillage (classe « play ») */
#lock.play .lk-logo { animation: lk-in 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
#lock.play .lk-shine { animation: lk-shine 1s ease-in-out 0.4s both; }
#lock.play .lk-line { animation: lk-line 0.6s ease-out 0.3s both; }
#lock.play .lk-sub { animation: lk-fade 0.4s ease 0.4s both; }
/* Le champ du code est utilisable presque tout de suite */
#lock.play .lk-form { animation: lk-rise 0.3s ease 0.15s both; }
@keyframes lk-in { from { opacity: 0; transform: scale(0.9); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes lk-shine { from { background-position: 130% 0; } to { background-position: -30% 0; } }
@keyframes lk-line { from { width: 0; } }
@keyframes lk-fade { from { opacity: 0; } }
@keyframes lk-rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  #lock.play .lk-logo, #lock.play .lk-line, #lock.play .lk-sub, #lock.play .lk-form { animation: lk-fade 0.3s both; }
  .lk-shine { display: none; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 80;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--gold); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px);
  transition: 0.2s; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--danger); }

/* ---------- Receipt ---------- */
.receipt-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.85); overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
.receipt-wrap { max-width: 400px; margin: 0 auto; }
.receipt {
  background: #fffdf7; color: #1b1712; border-radius: 6px; padding: 20px 18px;
  font-family: var(--sans); font-size: 13px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
/* En-tête du reçu : logo or sur papier blanc, sans aplat noir */
.receipt .r-logo { padding: 4px 0 0; }
.receipt .r-logo img { width: 62%; max-width: 210px; height: auto; aspect-ratio: 760 / 519; margin: 0 auto; }
.receipt .r-tagline {
  text-align: center; font-size: 10px; letter-spacing: 0.32em; text-transform: uppercase; color: #8a6a14;
  margin: 8px 0 12px; padding-bottom: 10px; border-bottom: 1px solid #c9ad5f;
}
.receipt .r-title { text-align: center; font-family: var(--serif); font-weight: 700; font-size: 20px; letter-spacing: 0.06em; margin: 4px 0 2px; }
.receipt .r-ref {
  text-align: center; font-weight: 800; font-size: 20px; letter-spacing: 0.1em; color: #1b1712;
  border: 1.5px solid #1b1712; border-radius: 4px; padding: 6px 8px 7px; margin: 6px auto 14px; width: fit-content;
}
.receipt .r-ref small { display: block; font-size: 9px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; color: #8a6a14; margin-bottom: 2px; }
/* Emplacement vide pour le cachet Ben Daoud */
.receipt .r-stamp {
  position: relative; height: 34mm; margin: 14px 0 8px;
  border: 1.5px dashed #8a6a14; border-radius: 6px;
}
.receipt .r-stamp-label { position: absolute; top: 6px; left: 10px; font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: #8a6a14; }
.receipt .r-stamp-name { position: absolute; bottom: 6px; right: 10px; font-size: 10px; font-weight: 700; letter-spacing: 0.2em; color: #c9ad5f; }
.receipt .r-sep { border: none; border-top: 1px dashed #b9a777; margin: 10px 0; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.receipt .r-row span:first-child { color: #6e6450; }
.receipt .r-row span:last-child { text-align: right; font-weight: 600; }
.receipt .r-photo { width: 100%; max-height: 180px; object-fit: contain; margin: 8px 0; border-radius: 4px; }
.receipt .r-foot { text-align: center; font-size: 11px; color: #6e6450; margin-top: 12px; line-height: 1.5; }
.receipt .r-warn { display: inline-block; margin-bottom: 6px; font-size: 12px; font-weight: 700; color: #1b1712; }
/* Bon du coursier : une partie par atelier */
.receipt .r-group { padding-top: 6px; }
.receipt .r-group + .r-group { border-top: 2px solid #1b1712; margin-top: 14px; padding-top: 14px; }
.receipt .r-count { text-align: center; font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: #8a6a14; margin-bottom: 8px; }
.receipt .r-item { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed #d8cba5; }
.receipt .r-item img { height: 48px; width: auto; max-width: none; border-radius: 4px; flex-shrink: 0; }
.receipt .r-item small { color: #6e6450; }
.receipt .r-noimg { width: 48px; height: 48px; border-radius: 4px; background: #f1ead8; flex-shrink: 0; }
.receipt .r-stamp-sm { height: 20mm; margin-top: 10px; }
.receipt-actions { display: flex; gap: 8px; margin: 14px 0 24px; flex-wrap: wrap; }
.receipt-actions .btn { flex: 1; }

@media print {
  @page { size: 80mm auto; margin: 4mm; }
  /* Seul le reçu est imprimé : le reste de l'app est retiré (pas de pages blanches) */
  body > *:not(#receiptBackdrop), .receipt-wrap > *:not(.receipt) { display: none !important; }
  html, body { background: #fff !important; height: auto !important; overflow: visible !important; }
  .receipt-backdrop { position: static; background: none; padding: 0; overflow: visible; }
  .receipt-wrap { max-width: none; }
  .receipt { width: 100%; box-shadow: none; border-radius: 0; padding: 0; }
  .receipt { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Une page par atelier sur le bon du coursier */
  .receipt .r-group + .r-group { break-before: page; border-top: none; }
  .receipt .r-item { break-inside: avoid; }
}

@media (max-width: 340px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat::after { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .brand-sub { font-size: 8px; }
}
