/* ===== FoodCopilot — feuille de style (mobile d'abord) ===== */
:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --text: #1c1917;
  --muted: #57534e;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fff7ed;
  --ink: #1c1917;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --neg: #b91c1c;
  --neg-bg: #fef2f2;
  --neg-border: #fecaca;
  --pos: #a16207;
  --pos-bg: #fefce8;
  --pos-border: #fde68a;
  --in: #0f766e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 1px 3px rgb(0 0 0 / 0.04);
  --tap: 52px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
body.has-sticky { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.15rem; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.block { display: block; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9em; word-break: break-all; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading { text-align: center; color: var(--muted); padding: 48px 0; }

/* ----- En-tête et navigation ----- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.app-header-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand img { border-radius: 8px; }
.user-chip { font-size: 0.85rem; color: #d6d3d1; text-align: right; }
.user-chip strong { color: #fff; font-weight: 600; }
.app-nav {
  max-width: 1100px; margin: 0 auto; padding: 4px 8px 8px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.app-nav::-webkit-scrollbar { display: none; }
.nav-link {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px;
  padding: 0 14px; border-radius: 10px; color: #e7e5e4; text-decoration: none;
  font-weight: 600; font-size: 0.95rem; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav-link:hover { background: rgb(255 255 255 / 0.08); color: #fff; }
.nav-link.active { background: #fff; color: var(--ink); }
.nav-logout { margin-left: auto; color: #fca5a5; }

.view { max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; outline: none; }
.stack > * + * { margin-top: 16px; }
.page-title { font-size: 1.5rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { font-size: 1.1rem; margin: 28px 0 12px; }

/* ----- Cartes ----- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.editor > .card + .card, .editor > * + * { margin-top: 14px; }
.error-card { text-align: center; max-width: 520px; margin: 40px auto; }
.error-card p { margin: 12px 0 20px; }
.empty { text-align: center; color: var(--muted); }

/* ----- Boutons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; font: inherit; font-weight: 650; font-size: 1rem;
  text-decoration: none; cursor: pointer; user-select: none; touch-action: manipulation;
  transition: background-color .12s, border-color .12s, transform .05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: #a8a29e; }
.btn-danger { background: var(--neg); color: #fff; }
.btn-ghost-danger { background: transparent; color: var(--neg); border-color: var(--neg-border); }
.btn-ghost-danger:hover { background: var(--neg-bg); }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; min-height: 36px; text-decoration: underline; }
.btn-chip { min-height: 38px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); border-color: var(--border-strong); font-size: 0.9rem; }
.btn-lg { min-height: var(--tap); font-size: 1.05rem; padding: 0 22px; }
.btn-xl { min-height: 62px; font-size: 1.15rem; padding: 0 24px; }
.btn-block { width: 100%; }
.btn-validate { background: var(--ok); color: #fff; letter-spacing: .02em; }
.btn-validate:hover:not(:disabled) { background: #166534; }
.btn-hero {
  display: flex; width: 100%; min-height: 120px; font-size: 1.35rem; border-radius: 18px;
  margin-top: 18px; gap: 14px; box-shadow: 0 6px 18px rgb(194 65 12 / .28);
}
.btn-hero-plus {
  display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: rgb(255 255 255 / .2); font-size: 2rem; line-height: 1;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2);
  font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted);
}
.icon { width: 22px; height: 22px; flex: none; }

/* ----- Champs ----- */
.field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-weight: 650; margin-bottom: 6px; }
.field-hint { display: block; color: var(--muted); font-size: 0.88rem; margin: -2px 0 8px; }
.field-error, .form-error { color: var(--neg); font-weight: 600; font-size: 0.92rem; margin: 6px 0 0; }
.form-error { background: var(--neg-bg); border: 1px solid var(--neg-border); padding: 10px 12px; border-radius: var(--radius-sm); margin: 0 0 14px; }
.req { color: var(--neg); font-weight: 600; font-size: 0.85rem; }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); padding: 10px 12px; min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(194 65 12 / .18); }
input.invalid { border-color: var(--neg); background: var(--neg-bg); }
textarea { resize: vertical; min-height: 84px; }
.input-lg { min-height: var(--tap); font-size: 1.08rem; }
legend { padding: 0; }

.money-input { position: relative; }
.money-input input {
  min-height: 62px; font-size: 1.6rem; font-weight: 700; text-align: right;
  padding-right: 48px; font-variant-numeric: tabular-nums;
}
.money-suffix { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 1.35rem; font-weight: 700; color: var(--muted); pointer-events: none; }

.grid-2 { display: grid; gap: 0 16px; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Choix tactiles (restaurant, service, type) */
.choice-group { border: 1px solid var(--border); }
.choice-group legend { font-weight: 700; font-size: 1.1rem; float: left; width: 100%; margin-bottom: 12px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; clear: both; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 68px; padding: 8px; border-radius: 12px;
  border: 2px solid var(--border-strong); background: var(--surface);
  font-weight: 700; font-size: 1.12rem; transition: all .12s;
}
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-hover); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input:focus-visible + span { outline: 3px solid rgb(194 65 12 / .35); outline-offset: 2px; }
.choice-in input:checked + span { border-color: var(--in); background: #f0fdfa; color: var(--in); box-shadow: inset 0 0 0 1px var(--in); }
.choice-out input:checked + span { border-color: var(--neg); background: var(--neg-bg); color: var(--neg); box-shadow: inset 0 0 0 1px var(--neg); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span {
  display: inline-flex; align-items: center; min-height: 46px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--border-strong); background: var(--surface); font-weight: 600;
}
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid rgb(194 65 12 / .35); outline-offset: 2px; }

/* ----- Alertes ----- */
.alert { border-radius: var(--radius); padding: 14px 16px; border: 1px solid; }
.alert p { margin: 6px 0 12px; }
.alert ul { margin: 8px 0 14px; padding-left: 20px; }
.alert-error { background: var(--neg-bg); border-color: var(--neg-border); color: #7f1d1d; }
.notice { background: var(--accent-soft); border: 1px solid #fed7aa; border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 16px; }
.notice-lock { background: var(--ok-bg); border-color: var(--ok-border); color: #14532d; font-weight: 600; }

/* ----- Connexion ----- */
.auth-wrap { min-height: 80vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 22px; }
.auth-card h1 { font-size: 1.6rem; margin-top: 10px; }
.auth-card > p { margin: 4px 0 22px; }
.auth-logo { display: block; border-radius: 14px; }

/* ----- Paires clé / valeur ----- */
.kv { display: grid; gap: 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kv dd { margin: 2px 0 0; font-weight: 650; font-size: 1.05rem; }
@media (min-width: 640px) {
  .kv-3 { grid-template-columns: 2fr 1fr 1.4fr; }
  .kv-4 { grid-template-columns: repeat(4, 1fr); }
}
.kv-3 #clock { font-variant-numeric: tabular-nums; font-size: 1.3rem; }
.kv-meta dd { font-weight: 500; font-size: 0.95rem; }

.amounts { margin: 0; }
.amounts > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.amounts > div:last-child { border-bottom: 0; }
.amounts dt { color: var(--muted); }
.amounts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.amt-in { color: var(--in); }
.amt-out { color: var(--neg); }

/* ----- Saisie de clôture ----- */
.editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.editor-title { font-size: 1.3rem; }
.editor-head p { margin: 4px 0 0; }
.save-status { font-size: 0.85rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.save-saved { color: var(--ok); background: var(--ok-bg); }
.save-pending, .save-saving { color: var(--muted); background: var(--surface-2); }
.save-error { color: var(--neg); background: var(--neg-bg); white-space: normal; }
.step {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 0.95rem; flex: none;
}
.totals-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 1.05rem; }
.totals-row strong { font-variant-numeric: tabular-nums; }

/* Mouvements */
.mv-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.mv-item {
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.mv-item .btn-ghost-danger { grid-column: 1 / -1; min-height: 42px; }
@media (min-width: 640px) {
  .mv-item { grid-template-columns: 72px 1fr auto; align-items: center; }
  .mv-item .btn-ghost-danger { grid-column: auto; }
}
.mv-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; flex-wrap: wrap; }
.mv-amount { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.mv-in .mv-amount { color: var(--in); }
.mv-out .mv-amount { color: var(--neg); }
.thumb { display: block; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-strong); background: #fff; }
@media (min-width: 640px) { .thumb { width: 72px; height: 72px; } }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.badge-in { background: #ccfbf1; color: #115e59; }
.badge-out { background: #fee2e2; color: #991b1b; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-off { background: #e7e5e4; color: #44403c; }
.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.85rem; }

/* Comptage */
.count-head, .count-row { display: grid; grid-template-columns: 76px minmax(150px, 1fr) minmax(96px, auto); gap: 10px; align-items: center; }
.count-head { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 0 4px 6px; }
.count-head span:nth-child(3) { text-align: right; }
.count-group { font-size: 0.95rem; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.count-row { padding: 6px 4px; border-bottom: 1px solid var(--border); border-radius: 8px; }
.count-row.has-qty { background: var(--accent-soft); }
.denom { font-weight: 800; font-size: 1.12rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.denom-billet::before { content: ""; display: inline-block; width: 6px; height: 16px; border-radius: 2px; background: var(--in); margin-right: 8px; vertical-align: -2px; opacity: .55; }
.denom-piece::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--pos); margin-right: 6px; vertical-align: -1px; opacity: .55; }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: 6px; max-width: 240px; }
.step-btn {
  height: 52px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: var(--surface);
  font-size: 1.6rem; font-weight: 700; color: var(--text); cursor: pointer; touch-action: manipulation; padding: 0;
}
.step-btn:active { background: var(--border); }
.qty { min-height: 52px; text-align: center; font-size: 1.35rem; font-weight: 800; padding: 6px 4px; font-variant-numeric: tabular-nums; }
.subtotal { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.count-total {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--ink); color: #fff;
}
.count-total span { font-weight: 700; letter-spacing: .03em; font-size: 0.95rem; }
.count-total strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .card { padding: 14px; }
  .count-head, .count-row { grid-template-columns: 60px minmax(0, 1fr) 80px; gap: 6px; }
  .denom { font-size: 1.02rem; }
  .denom-billet::before, .denom-piece::before { display: none; }
  .stepper { grid-template-columns: 44px minmax(40px, 1fr) 44px; gap: 4px; }
  .step-btn, .qty { height: 50px; min-height: 50px; }
  .subtotal { font-size: 0.92rem; }
}
@media (max-width: 330px) {
  .count-head, .count-row { grid-template-columns: 56px 1fr; }
  .count-head span:nth-child(3) { display: none; }
  .subtotal { grid-column: 2; font-size: 0.9rem; color: var(--muted); }
}

/* Résultat */
.result-grid { display: grid; gap: 10px; }
@media (min-width: 640px) { .result-grid { grid-template-columns: 1fr 1fr 1.2fr; } }
.result-cell { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.result-label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.result-value { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-note { font-weight: 650; }
.result-variance.var-zero { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.result-variance.var-neg { background: var(--neg-bg); border-color: var(--neg-border); color: var(--neg); }
.result-variance.var-pos { background: var(--pos-bg); border-color: var(--pos-border); color: var(--pos); }
.result-variance .result-label { color: inherit; }
.formula { margin: 12px 0 14px; }
.explanation { margin-top: 14px; padding: 14px; border-radius: 12px; border: 1px dashed var(--border-strong); }
.explanation p { margin: 6px 0 0; white-space: pre-wrap; }

/* Barre de totaux toujours visible */
.sticky-totals {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  background: var(--ink); color: #fff;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgb(0 0 0 / .18);
}
.sticky-totals > div { display: flex; flex-direction: column; align-items: center; padding: 2px 4px; border-radius: 10px; }
.sticky-totals span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: #d6d3d1; font-weight: 700; }
.sticky-totals strong { font-size: 1.12rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sticky-totals .var-zero strong { color: #86efac; }
.sticky-totals .var-neg { background: rgb(239 68 68 / .22); }
.sticky-totals .var-neg strong { color: #fca5a5; }
.sticky-totals .var-pos { background: rgb(234 179 8 / .2); }
.sticky-totals .var-pos strong { color: #fde68a; }
@media (min-width: 700px) { .sticky-totals strong { font-size: 1.35rem; } }

/* Validation */
.validate-box { background: var(--surface); border: 2px solid var(--ok); border-radius: var(--radius); padding: 18px; }
.validate-box p { margin: 0 0 14px; font-weight: 600; }

/* ----- Boîtes de dialogue ----- */
.dialog {
  border: 0; padding: 0; border-radius: 18px; width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
.dialog::backdrop { background: rgb(28 25 23 / .55); }
.dialog-small { width: min(460px, calc(100vw - 24px)); }
.dialog-body { padding: 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.dialog-head h2 { margin: 0; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; position: sticky; bottom: -18px; background: var(--surface); padding: 12px 0 18px; margin-bottom: -18px; }
.confirm-message { font-size: 1.08rem; font-weight: 600; margin: 8px 0 0; }
@media (max-width: 560px) {
  .dialog:not(.dialog-small) { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .dialog-actions { grid-template-columns: 1fr; }
  .dialog-actions .btn-primary { order: -1; }
}
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .photo-actions { grid-template-columns: 1fr; } }
.photo-actions .btn { position: relative; }
.photo-preview { margin-top: 12px; padding: 12px; border: 2px solid var(--ok-border); background: var(--ok-bg); border-radius: 12px; }
.photo-preview img { display: block; max-height: 55vh; margin: 0 auto 10px; border-radius: 8px; background: #fff; }
.photo-preview p { margin: 0 0 4px; }

/* CA réel perçu (CA espèces − sorties) */
.real-revenue {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 14px 16px; border-radius: 12px;
  background: #eff6ff; border: 2px solid #93c5fd; color: #1e3a8a;
}
.real-revenue-label { display: block; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 0.95rem; }
.real-revenue-formula { display: block; font-size: 0.85rem; color: #1e40af; }
.real-revenue-value { font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.choices-3 { grid-template-columns: repeat(3, 1fr); }
.choices-3 .choice span { font-size: 1.02rem; line-height: 1.2; }

/* Clôtures annulées : consultables mais grisées */
.badge-cancelled { background: #e7e5e4; color: #57534e; text-decoration: line-through; }
.notice-cancelled { background: #f5f5f4; border-color: #a8a29e; color: #44403c; }
.notice-cancelled .block { margin-top: 4px; }
.is-cancelled .summary-body { filter: grayscale(1); opacity: .6; }
.row-cancelled td { color: #a8a29e; background: #fafaf9; }
.history-table .row-cancelled .var-pill, .history-table .row-cancelled strong { color: #a8a29e; background: none; }
.row-cancelled td[data-label="Date"] a { text-decoration: line-through; }
@media (max-width: 960px) { .history-table tr.row-cancelled { background: #fafaf9; opacity: .75; } }

/* CA total, clôture antidatée */
.sales-total {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 4px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
}
.sales-total span { font-weight: 800; letter-spacing: .03em; font-size: 0.95rem; }
.sales-total small { display: block; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.sales-total strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.amounts .amounts-total { border-top: 2px solid var(--border-strong); }
.amounts .amounts-total dt { color: var(--text); font-weight: 700; }
.backdated-flag {
  margin: 10px 0 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; font-weight: 600; font-size: 0.92rem;
}
.badge-tiny { font-size: 0.68rem; padding: 1px 6px; margin-left: 6px; }
.admin-options h2 { font-size: 1.05rem; }
.btn-chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ----- Encaissements ----- */
:root {
  --pay-cash: #2a78d6;
  --pay-card: #eb6834;
  --pay-voucher: #1baf7a;
  --pay-online: #eda100;
  --chart-grid: #e7e5e4;
  --chart-surface: #ffffff;
}
.pay-cash { fill: var(--pay-cash); stroke: var(--pay-cash); background: var(--pay-cash); }
.pay-card { fill: var(--pay-card); stroke: var(--pay-card); background: var(--pay-card); }
.pay-voucher { fill: var(--pay-voucher); stroke: var(--pay-voucher); background: var(--pay-voucher); }
.pay-online { fill: var(--pay-online); stroke: var(--pay-online); background: var(--pay-online); }
.chart .pay-cash, .chart .pay-card, .chart .pay-voucher, .chart .pay-online { stroke: none; }
.donut .donut-arc { fill: none; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; vertical-align: -1px; margin-right: 6px; }

.stats-filters { display: grid; gap: 4px 16px; }
@media (min-width: 760px) { .stats-filters { grid-template-columns: minmax(220px, 1fr) 2fr; align-items: end; } .stats-filters .stats-dates { grid-column: 1 / -1; grid-template-columns: 1fr 1fr auto; align-items: end; } }
.stats-filters .presets { margin-bottom: 0; }
.stats-dates { gap: 0 10px; grid-template-columns: 1fr 1fr; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-hero { grid-column: 1 / -1; background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--muted); display: flex; align-items: center; }
.kpi-hero .kpi-label, .kpi-hero .kpi-sub { color: #d6d3d1; }
.kpi-value { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.kpi-hero .kpi-value { font-size: 2.2rem; }
.kpi-sub { font-size: 0.85rem; color: var(--muted); }

.charts-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .charts-grid { grid-template-columns: minmax(300px, 1fr) 2fr; } }
.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px; }
.donut-label { fill: var(--muted); font-size: 13px; font-weight: 600; }
.donut-value { fill: var(--text); font-size: 20px; font-weight: 800; }
.donut-empty { stroke: var(--chart-grid); }
.legend { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; }
.legend-values { flex-direction: column; gap: 10px; font-size: 0.95rem; color: var(--text); min-width: 220px; }
.legend-values li { display: grid; grid-template-columns: 18px 1fr auto 64px; align-items: center; gap: 6px; }
.legend-values .muted { text-align: right; font-size: 0.85rem; }
.legend-values strong { font-variant-numeric: tabular-nums; }

.chart-card { position: relative; min-width: 0; }
.chart-box { width: 100%; min-height: 260px; }
.chart { display: block; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { stroke: #a8a29e; stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit.active { fill: rgb(28 25 23 / .05); }
.chart-tip {
  position: absolute; top: 0; left: 0; z-index: 5; min-width: 200px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .15); padding: 10px 12px; display: grid; gap: 4px; font-size: 0.88rem;
}
.tip-row { display: flex; align-items: center; gap: 4px; }
.tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.tip-total { border-top: 1px solid var(--border); padding-top: 4px; font-weight: 700; }

.hbar + .hbar { margin-top: 14px; }
.hbar-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.hbar-head span { font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-track { display: flex; gap: 2px; height: 22px; }
.hbar-seg { display: block; height: 100%; min-width: 2px; }
.hbar-seg:last-child { border-radius: 0 4px 4px 0; }
.table-plain { box-shadow: none; border: 0; }
.stats details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
@media (max-width: 760px) {
  .table-plain table { font-size: 0.85rem; }
  .table-plain th, .table-plain td { padding: 8px 6px; }
}

/* ----- Historique ----- */
.filters summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; gap: 8px; list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
.filters summary::before { content: "▸"; transition: transform .15s; }
.filters[open] summary::before { transform: rotate(90deg); }
.filters-grid { display: grid; gap: 0 14px; margin-top: 14px; }
@media (min-width: 640px) { .filters-grid { grid-template-columns: repeat(3, 1fr); } }
.filters-grid .field { margin-bottom: 12px; }
.presets, .filters-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface-2); font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-table tbody tr { cursor: pointer; }
.history-table tbody tr:hover, .history-table tbody tr:focus { background: var(--accent-soft); outline: none; }
.history-table a { color: inherit; font-weight: 700; text-decoration: none; }
.var-pill { display: inline-block; padding: 2px 8px; border-radius: 8px; font-weight: 700; }
.var-pill.var-zero { color: var(--ok); background: var(--ok-bg); }
.var-pill.var-neg { color: var(--neg); background: var(--neg-bg); }
.var-pill.var-pos { color: var(--pos); background: var(--pos-bg); }
.row-inactive td { color: var(--muted); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Tableaux en cartes sur mobile et tablette en portrait */
@media (max-width: 960px) {
  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .history-table thead, .users-table thead, .cards-mobile thead { display: none; }
  .history-table tr, .users-table tr, .cards-mobile tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  }
  .history-table td, .users-table td, .cards-mobile td { border: 0; padding: 2px 0; text-align: left; }
  .history-table td::before, .users-table td[data-label]::before, .cards-mobile td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.72rem; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted); font-weight: 700;
  }
  .row-actions { grid-column: 1 / -1; justify-content: stretch; margin-top: 6px; }
  .row-actions .btn { flex: 1; }
}

.count-detail td, .count-detail th { padding: 8px 10px; }
.count-detail td:not(:first-child), .count-detail th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.count-detail tfoot th { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--text); background: var(--surface-2); }

.events { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }

/* ----- Accueil ----- */
.home { max-width: 640px; margin: 0 auto; }
.home .page-title { margin-top: 8px; }
.list-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.list-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: inherit; text-decoration: none; box-shadow: var(--shadow);
}

/* ----- Notifications ----- */
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); display: grid; gap: 8px; width: min(480px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgb(0 0 0 / .25); transition: opacity .3s, transform .3s; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--neg); }
.toast-warn { background: var(--pos); }
.toast-out { opacity: 0; transform: translateY(-8px); }

@media (min-width: 900px) {
  .view { padding: 24px 24px 48px; }
  .card { padding: 22px; }
}

.table-plain { overflow-x: auto; }
.stats-submit { grid-column: 1 / -1; margin-bottom: 16px; }
@media (min-width: 760px) { .stats-submit { grid-column: auto; } }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Export comptable */
.export-box h2 { margin-bottom: 4px; }
.export-box p { margin: 0 0 12px; }
.export-actions { display: grid; gap: 10px; }
@media (min-width: 760px) { .export-actions { grid-template-columns: repeat(3, 1fr); } }
.export-btn { flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; gap: 2px; padding: 12px 14px; min-height: 64px; }
.export-btn .small { font-weight: 500; line-height: 1.3; }

/* Administration : onglets, restaurants attribués */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.tab { min-height: 44px; padding: 0 16px; border: 0; background: none; font: inherit; font-weight: 650; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.check-list { display: grid; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.check-item input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
.check-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check-item small { display: block; color: var(--muted); }
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-static { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.82rem; white-space: nowrap; }
.resto-address { color: var(--muted); font-size: 0.9rem; }

.dl-link { display: inline-block; margin-top: 4px; font-weight: 600; }
@media (min-width: 760px) { .export-actions { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .export-actions { grid-template-columns: repeat(4, 1fr); } }

/* Historique : lecture d'un coup d'œil, sans retour à la ligne */
@media (min-width: 961px) {
  .closures-table td { white-space: nowrap; }
  .history-table td[data-label="CA total"] strong { font-size: 1.02rem; }
}

/* Administration : 5 onglets défilants sur mobile, réglages, droits sensibles */
.tabs-scroll { overflow-x: auto; scrollbar-width: none; }
.tabs-scroll::-webkit-scrollbar { display: none; }
.tabs-scroll .tab { flex: 0 0 auto; }
.chip-on { background: var(--accent-soft); border-color: #fed7aa; color: var(--accent-hover); font-weight: 600; }
.check-sensitive { border-style: dashed; }
.form-section { font-size: 1rem; margin: 6px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
legend.field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; flex-wrap: wrap; }
legend.field-label .btn-link { font-weight: 600; font-size: 0.9rem; min-height: 0; }

/* ----- Dépenses ----- */
.exp-filters-more { grid-column: 1 / -1; display: grid; gap: 0 14px; }
@media (min-width: 760px) { .exp-filters-more { grid-template-columns: repeat(3, 1fr); } }
.expenses-table tbody tr { cursor: pointer; }
.row-dup td { background: var(--neg-bg); }
.row-dup-certain td:first-child { box-shadow: inset 4px 0 0 var(--neg); }
.row-dup-possible td:first-child { box-shadow: inset 4px 0 0 #f87171; }
@media (max-width: 960px) { .history-table tr.row-dup { background: var(--neg-bg); border-color: var(--neg-border); } }
.badge-dup { background: var(--neg); color: #fff; margin-left: 6px; }
.dup-alert .btn-link { margin-left: 6px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.vat-block { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: var(--surface-2); }
.vat-block .field { margin-bottom: 10px; }
.vat-preview { margin: 0 0 4px; }
.vat-line { display: grid; grid-template-columns: 110px 1fr 1fr 40px; gap: 6px; margin-bottom: 6px; align-items: center; }
.vat-line select, .vat-line input { min-height: 46px; }
.vat-line .icon-btn { width: 40px; height: 40px; }
@media (max-width: 420px) { .vat-line { grid-template-columns: 1fr 1fr; } .vat-line .icon-btn { justify-self: end; } }
.vat-check { margin: 4px 0 6px; font-weight: 600; }
.vat-check.ok { color: var(--ok); }
.vat-check.ko { color: var(--neg); }
.mv-cat { margin-left: 6px; }

/* ----- Analyse, rapports, charges fixes, paie ----- */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notice-pending { background: #fff7ed; border-color: #fdba74; }
.kpi-ratio .kpi-value { color: var(--accent-hover); }
.rentability h2 { margin-bottom: 10px; }
.rentability .kpis { margin-bottom: 8px; }
.ranking .hbar-track { height: 16px; }
.ranking .hbar-head span:first-child { font-weight: 600; }
.ranking .hbar + .hbar { margin-top: 10px; }
.filters-inline { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .filters-inline { grid-template-columns: 2fr 1fr; } .filters-inline .field { margin-bottom: 0; } }
.grid-3 { display: grid; gap: 0 12px; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.money-sm input { min-height: 50px; font-size: 1.2rem; }
.pending-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pending-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 12px; border: 1px solid #fdba74; background: #fff7ed; }
.pending-item select { min-height: 44px; width: auto; }
.payroll-table td { vertical-align: middle; }
.payroll-table .money-input { max-width: 200px; }
.reports-table td.num { white-space: nowrap; }

/* ----- Synthèse : compte de résultat en tête ----- */
.pnl { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.pnl-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pnl-head > span:first-child { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; color: #d6d3d1; }
.pnl-basis { font-size: 0.8rem; color: #a8a29e; }
.pnl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 0; }
@media (min-width: 900px) { .pnl-grid { grid-template-columns: 1.3fr repeat(5, 1fr); } }
.pnl-cell { display: flex; flex-direction: column; gap: 2px; padding: 4px 14px; border-left: 1px solid rgb(255 255 255 / .18); min-width: 0; }
.pnl-cell:first-child, .pnl-grid > .pnl-cell:nth-child(2n + 1) { border-left: 0; }
@media (min-width: 900px) { .pnl-grid > .pnl-cell:nth-child(2n + 1) { border-left: 1px solid rgb(255 255 255 / .18); } .pnl-grid > .pnl-cell:first-child { border-left: 0; padding-left: 0; } }
.pnl-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em; color: #d6d3d1; font-weight: 700; }
.pnl-value { font-size: 1.35rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pnl-ca .pnl-value { font-size: 1.9rem; }
.pnl-sub { font-size: 0.85rem; color: #fdba74; font-weight: 600; }
.pnl-ca .pnl-sub { color: #a8a29e; }
.pnl-profit { background: rgb(34 197 94 / .16); border-radius: 10px; }
.pnl-profit .pnl-value, .pnl-profit .pnl-sub { color: #86efac; }
.pnl-loss { background: rgb(239 68 68 / .2); border-radius: 10px; }
.pnl-loss .pnl-value, .pnl-loss .pnl-sub { color: #fca5a5; }
.pnl-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 0.82rem; color: #a8a29e; }
.pnl-foot a { color: #fdba74; font-weight: 600; margin-left: auto; }

/* Calcul détaillé du théorique */
.formula { margin: 12px 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.formula-line { margin: 0; line-height: 1.9; font-variant-numeric: tabular-nums; }
.formula-line + .formula-line { margin-top: 6px; font-size: 0.92rem; }
.f-term { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; vertical-align: middle; padding: 2px 6px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; }
.f-term small { font-weight: 500; color: var(--muted); font-size: 0.72rem; }
.f-out { color: var(--neg); }
.f-total { font-size: 1.15rem; }

/* Synthèse : TVA collectée − déductible */
.vat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.vat-head h2 { margin: 0; }
.vat-grid { display: grid; gap: 10px; align-items: stretch; }
@media (min-width: 760px) { .vat-grid { grid-template-columns: 1fr auto 1fr auto 1.1fr; } }
.vat-cell { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.vat-op { display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: var(--muted); }
@media (max-width: 759px) { .vat-op { display: none; } }
.vat-due { background: var(--accent-soft); border-color: #fed7aa; }
.vat-due .kpi-value { color: var(--accent-hover); }
.vat-credit { background: var(--ok-bg); border-color: var(--ok-border); }
.vat-credit .kpi-value { color: var(--ok); }
.vat-card p { margin: 12px 0 0; }

/* Tableau des dépenses : le fournisseur et la catégorie passent à la ligne, les montants restent entiers */
.expenses-table td { vertical-align: middle; }
.expenses-table td[data-label="Fournisseur"], .expenses-table td[data-label="Catégorie"] { min-width: 120px; }
@media (min-width: 961px) and (max-width: 1100px) {
  .expenses-table th, .expenses-table td { padding: 10px 8px; }
}

/* Petits tableaux (Synthèse, tableaux simples) : plus compacts sur tablette pour éviter le défilement */
@media (max-width: 960px) {
  .table-plain table { font-size: 0.88rem; }
  .table-plain th, .table-plain td { padding: 8px 6px; }
}
/* Les tableaux d'administration et de charges passent aussi en cartes (sélecteur users-table) */
/* Téléphone : onglets d'administration sur plusieurs lignes (tous visibles), montants des cartes à gauche */
@media (max-width: 960px) {
  .tabs-scroll { flex-wrap: wrap; overflow: visible; border-bottom: 0; gap: 6px; }
  .tabs-scroll .tab { border: 1.5px solid var(--border-strong); border-radius: 999px; min-height: 40px; padding: 0 14px; }
  .tabs-scroll .tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
  .cards-mobile td.num, .history-table td.num, .users-table td.num { text-align: left; }
  .payroll-table .money-input { max-width: none; }
}

/* Paie : fiche d'avances d'un salarié */
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-hover); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }
.add-adv { margin-top: 6px; min-height: 34px; font-size: 0.82rem; }
.adv-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.adv-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.adv-item .badge { margin-left: 6px; }
.adv-item .btn-ghost-danger { min-height: 38px; }
.adv-total { margin: 4px 0 12px; }

/* Lecture automatique des factures */
.ocr-zone { background: var(--accent-soft); border: 1px dashed #fdba74; border-radius: var(--radius-sm); padding: 12px; }
.ocr-status { margin: 8px 0 0; font-weight: 600; }
.ocr-status.ok { color: #15803d; }
.ocr-status.warn { color: #b45309; }
.ocr-status.ko { color: #b91c1c; }
.ocr-filled { background: #fef9c3 !important; }

/* Documents en plusieurs pages (factures, ticket Z) */
.pg-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.pg-item { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px; position: relative; }
.pg-item img { width: 84px; height: 110px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.pg-item .icon-btn { position: absolute; top: -8px; right: -8px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; width: 28px; height: 28px; }
.pg-pdf { display: inline-flex; align-items: center; justify-content: center; width: 84px; height: 110px; font-size: 2.2rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); text-decoration: none; }
.z-current { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.z-current .thumb img { width: 84px; height: 110px; object-fit: cover; }
.z-hint { margin: 6px 0 0; color: #b45309; }
.z-hint .btn-link { padding: 0 4px; min-height: 0; }
.z-compare tr.z-diff td { color: #b91c1c; font-weight: 600; }
.ok-text { color: var(--ok); font-weight: 600; }
.z-current .thumb { width: 84px; height: 110px; }

/* Accueil : gros boutons empilés, pensés pour le pouce */
.hero-actions { display: grid; gap: 14px; margin-top: 18px; }
.hero-actions .btn-hero { margin-top: 0; }
@media (min-width: 761px) { .hero-actions { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
.btn-hero-alt { background: #1c1917; color: #fff; border-color: #1c1917; box-shadow: 0 6px 18px rgb(28 25 23 / .25); }
.btn-hero-alt:hover { background: #292524; }
.btn-hero-check { background: var(--ok-bg); color: var(--ok); border: 2px solid var(--ok-border); box-shadow: none; }
.btn-hero-check .btn-hero-plus { background: var(--ok); color: #fff; font-size: 1.3rem; }

/* Formulaire en pleine page (téléphone) : bouton d'envoi toujours à portée de pouce */
.page-form .card h2 { margin-bottom: 12px; }
.page-submit { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 5; }
.done-screen { text-align: center; padding-top: 24px; }
.done-check { width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; font-size: 2.6rem; color: #fff; background: var(--ok); }
.done-screen .hero-actions { text-align: left; }

/* Enveloppe à remettre (récapitulatif, fin de clôture) */
.envelope-box { display: grid; gap: 4px; padding: 16px; border-radius: var(--radius); background: #1c1917; color: #fafaf9; text-align: left; }
.envelope-label { font-weight: 700; letter-spacing: .02em; }
.envelope-amount { font-size: 2.2rem; line-height: 1.1; }
.envelope-box .small { color: #d6d3d1; }
.envelope-list { margin: 4px 0 0; padding-left: 18px; }

/* Saisi / ticket Z côte à côte */
.compare-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.compare-table th, .compare-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; white-space: normal; }
.compare-table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.compare-table .compare-total td { font-weight: 700; }
.compare-table .z-same { color: var(--ok); }
.compare-table .z-diff { color: #b91c1c; font-weight: 700; }
.z-hint.z-ok { color: var(--ok); }

/* Contrôle de l'enveloppe */
.badge-check-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-border); }
.badge-check-issue { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-check-todo { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.quick-check .btn-chip.active { background: #1c1917; color: #fff; border-color: #1c1917; }
.check-card { border: 2px solid #1c1917; }
.check-result { padding: 12px 14px; border-radius: var(--radius-sm); margin: 0 0 14px; }
.check-ok { background: var(--ok-bg); border: 1px solid var(--ok-border); color: #14532d; }
.check-issue { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.check-table td { vertical-align: middle; }
.money-input-sm input { min-height: 44px; font-size: 1rem; width: 120px; text-align: right; padding-right: 30px; }
.check-box { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
.check-box input { width: 22px; height: 22px; }
.check-actions { display: grid; gap: 10px; margin-top: 12px; }
.money-input-sm .money-suffix { font-size: 1rem; right: 10px; }
.hero-actions .btn-hero { justify-content: flex-start; padding: 0 22px; text-align: left; }
.done-screen .page-title { text-align: center; justify-content: center; }
/* Contrôle sur téléphone : une carte par poste au lieu d'un tableau à 4 colonnes */
@media (max-width: 640px) {
  .check-table thead { display: none; }
  .check-table, .check-table tbody { display: block; }
  .check-table tr { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .check-table td { border: 0; padding: 0; text-align: left !important; white-space: normal; }
  .check-table td:first-child { grid-column: 1 / -1; font-weight: 600; margin-bottom: 4px; }
  .check-table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
  .check-table td[hidden] { display: none; }
  .money-input-sm input { width: 110px; }
}

/* Plateformes de livraison : hors CA total, montants bruts */
.platforms { margin-top: 18px; padding-top: 6px; border-top: 1px dashed var(--border-strong); }
.platforms-box { display: grid; gap: 6px; margin: 14px 0; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.platforms-title { font-weight: 700; }
.platforms-title small { font-weight: 500; color: var(--muted); }
.platform-row { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.compare-table .compare-platform td { color: var(--muted); background: var(--surface-2); }

/* Cases à cocher (fiche restaurant) */
.channels-field { border: 0; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; flex: none; }
.platforms-card .kpis-inline { margin: 10px 0; }

/* Dépôt rapide de factures */
.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice-btn { background: var(--surface); border: 2px solid var(--border-strong); color: var(--text); }
.choice-btn.is-active { background: #1c1917; border-color: #1c1917; color: #fff; }
.deposit-resto { margin: 0; font-size: 1.15rem; }
.deposit-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.deposit-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.deposit-thumbs { display: flex; gap: 4px; flex: none; }
.deposit-thumbs img { width: 46px; height: 60px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.pg-pdf-sm { width: 46px; height: 60px; font-size: 1.5rem; }
.deposit-info { display: grid; gap: 2px; flex: 1; min-width: 0; }
.deposit-more { padding: 0; min-height: 32px; justify-content: flex-start; }
.center { text-align: center; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plain-list li { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 6px; }

/* Factures déposées à vérifier */
.inbox-card { border: 2px solid #fde68a; }
.inbox-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.inbox-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.inbox-item { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.inbox-doc { flex: none; }
.inbox-doc img { width: 56px; height: 74px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.inbox-body { display: grid; gap: 3px; flex: 1; min-width: 0; }
.inbox-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inbox-amount { margin-left: auto; font-variant-numeric: tabular-nums; }
.inbox-reason { color: #b45309; }
.inbox-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.inbox-reasons { margin: 6px 0 0; padding-left: 18px; color: #b45309; }
.btn-hero-inbox { background: #fffbeb; color: #92400e; border: 2px solid #fde68a; box-shadow: none; }
.btn-hero-inbox .btn-hero-plus { background: #b45309; color: #fff; font-size: 1.3rem; }
.btn-hero-inbox small { font-size: .85rem; font-weight: 500; }
