/* ============================================================
   Facturation — feuille de style de l'interface
   ============================================================ */
:root {
  --accent: #16a34a;
  --accent-dark: #15803d;
  --accent-soft: #dcfce7;
  --accent-text: #166534;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e7ee;
  --text: #1b2430;
  --muted: #6b7686;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --sidebar: #0f1b2d;
  --sidebar-text: #c7d2e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea { user-select: text; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 15px; margin: 0; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
kbd { background: #eef1f6; border: 1px solid #d4dae3; border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 11.5px; font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- Mise en page ---------- */
#app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(22,163,74,.35); }
.brand-logo svg { width: 22px; height: 22px; }
.brand-name { font-weight: 700; color: #fff; font-size: 15.5px; }
.brand-sub { font-size: 12px; color: #8a98ad; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  background: transparent; border: 0; color: var(--sidebar-text); cursor: pointer; text-align: left; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 20px; height: 20px; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.nav-primary { color: #fff; background: var(--accent); margin: 6px 0 10px; box-shadow: 0 6px 16px rgba(22,163,74,.3); }
.nav-item.nav-primary:hover { background: var(--accent-dark); }
.nav-item.nav-primary.active { background: var(--accent-dark); }
.sidebar-footer { margin-top: auto; padding: 8px; }
.seller-chip { background: rgba(255,255,255,.06); border-radius: 10px; padding: 10px 12px; }
.seller-chip-name { color: #fff; font-weight: 600; font-size: 13px; }
.seller-chip-sub { font-size: 11.5px; color: #8a98ad; margin-top: 2px; }
.version { font-size: 11px; color: #5f6d82; margin-top: 10px; text-align: center; }

.content { flex: 1; overflow-y: auto; padding: 28px 32px 40px; }
.screen { display: none; max-width: 1400px; margin: 0 auto; }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .muted { margin-top: 4px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  background: #eef1f6; color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,.25); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; border-color: #d4dae3; }
.btn-outline:hover { background: #f4f6f9; border-color: #b8c1ce; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1f6; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 11px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; vertical-align: middle; }
.icon-btn:hover { background: #eef1f6; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.accent:hover { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.grow { flex: 1; }
.field.field-btn { justify-content: flex-end; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d4dae3; border-radius: 8px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid #d4dae3; border-radius: 8px; background: #fff; cursor: pointer; }
.color-row { display: flex; align-items: center; gap: 12px; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d4dae3; cursor: pointer; }
.form-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: #eef1f6; color: var(--muted); }
.badge.ok { background: var(--accent-soft); color: var(--accent-text); }
.badge.new { background: #fef3c7; color: #92400e; }

/* ---------- Autocomplétion ---------- */
.ac-wrap { position: relative; }
.ac-list {
  position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(16,24,40,.14); max-height: 280px; overflow-y: auto; padding: 5px;
}
.ac-item { padding: 9px 11px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.ac-item:hover, .ac-item.active { background: var(--accent-soft); }
.ac-item .ac-main { font-weight: 600; }
.ac-item .ac-sub { color: var(--muted); font-size: 12px; }
.ac-item .ac-price { font-weight: 700; color: var(--accent-text); white-space: nowrap; }
.ac-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 10px 10px; border-bottom: 1px solid var(--border); font-weight: 700; }
.table td { padding: 11px 10px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { width: 150px; }
.table td.actions { white-space: nowrap; text-align: right; }
.table .strong { font-weight: 700; }
.table .inv-num { font-family: Consolas, "Cascadia Mono", monospace; font-weight: 700; color: var(--accent-text); background: var(--accent-soft); padding: 3px 8px; border-radius: 6px; font-size: 12.5px; }

/* Lignes de vente */
.lines-wrap { overflow: visible; }
.table.lines .ac-list { min-width: 380px; }
.table.lines th, .table.lines td { padding: 6px 5px; }
.table.lines td input { padding: 8px 9px; }
.table.lines td.num { font-weight: 600; }
.table.lines .col-n { width: 36px; color: var(--muted); }
.table.lines .col-qty { width: 100px; }
.table.lines .col-unit { width: 80px; }
.table.lines .col-price { width: 125px; }
.table.lines .col-tva { width: 80px; }
.table.lines .col-amt { width: 115px; }
.table.lines .col-del { width: 40px; }
.table.lines td.num { padding-right: 10px; white-space: nowrap; }
.table.lines tr.empty-line td { color: var(--muted); text-align: center; padding: 18px; }

/* ---------- Vente ---------- */
.sale-layout { display: grid; grid-template-columns: 1fr 330px; gap: 18px; align-items: start; }
.sale-side { position: sticky; top: 0; }
.totals-card { background: linear-gradient(180deg, #fff, #f8fafc); }
.tot-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.tot-row b { font-variant-numeric: tabular-nums; }
.tot-timbre { gap: 8px; }
.tot-timbre .check { font-weight: 500; }
.timbre-rate { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; margin-left: auto; }
.timbre-rate input { width: 64px; padding: 4px 6px; text-align: right; }
.tot-net { border-bottom: 0; padding-top: 14px; font-size: 16px; }
.tot-net b { font-size: 22px; color: var(--accent-text); }
.words { margin-top: 10px; padding: 10px 12px; background: var(--accent-soft); color: var(--accent-text); border-radius: 8px; font-size: 12.5px; font-style: italic; line-height: 1.4; }

/* ---------- Tableau de bord ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: relative; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; background: #eef1f6; color: var(--muted); display: grid; place-items: center; margin-bottom: 12px; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.stat-accent { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border-color: transparent; color: #fff; }
.stat-accent .stat-icon { background: rgba(255,255,255,.18); color: #fff; }
.stat-accent .stat-label { color: rgba(255,255,255,.85); }
.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.chart { height: 180px; }
.chart svg { width: 100%; height: 100%; stroke: none; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar.today { opacity: 1; }
.chart .bar-bg { fill: #eef1f6; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart text.val { fill: var(--text); font-weight: 700; font-size: 10.5px; }
.mini-stats { display: flex; gap: 12px; margin-top: 12px; }
.mini-stats > div { flex: 1; background: #f8fafc; border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); line-height: 1.5; }
.empty svg { width: 42px; height: 42px; opacity: .4; margin-bottom: 10px; }

/* ---------- Toolbar / recherche ---------- */
.toolbar { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 240px; max-width: 460px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; }
.search input { padding-left: 36px; }

/* ---------- Réglages ---------- */
.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }

/* ---------- Modales ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,27,45,.45); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: calc(100vw - 40px); box-shadow: 0 24px 60px rgba(0,0,0,.25); animation: pop .18s ease; display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.modal-wide { width: 680px; }
.modal-sm { width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 12px; gap: 12px; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 6px 22px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 14px 14px; }
.modal-preview { width: calc(100vw - 60px); height: calc(100vh - 40px); }
.preview-body { flex: 1; background: #d9dee6; padding: 16px; overflow: hidden; border-radius: 0 0 14px 14px; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 6px; box-shadow: 0 8px 30px rgba(0,0,0,.15); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1b2430; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; align-items: center; gap: 10px; animation: pop .2s ease; font-weight: 500; max-width: 420px; }
.toast.ok { background: var(--accent-dark); }
.toast.err { background: var(--danger); }
.toast svg { width: 18px; height: 18px; }

/* ---------- Écran de connexion / activation ---------- */
#gate { position: fixed; inset: 0; z-index: 500; background: linear-gradient(160deg, #0f1b2d, #13283f); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
#gate[hidden] { display: none; }
.gate-card { width: 420px; max-width: calc(100vw - 40px); background: #fff; border-radius: 18px; padding: 34px 32px; box-shadow: 0 30px 70px rgba(0,0,0,.4); text-align: center; animation: pop .25s ease; }
.gate-logo { width: 58px; height: 58px; border-radius: 15px; background: var(--accent); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; box-shadow: 0 10px 24px rgba(22,163,74,.4); }
.gate-logo svg { width: 30px; height: 30px; }
.gate-title { font-size: 20px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 20px; }
.gate-view { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate-msg { font-size: 16px; font-weight: 700; }
.gate-sub { font-size: 13px; color: var(--muted); line-height: 1.5; max-width: 320px; }
.gate-field { width: 100%; text-align: left; }
.gate-field input { text-align: center; font-size: 15px; letter-spacing: 1px; font-family: Consolas, monospace; }
.gate-field label { text-align: left; }
.gate-adv { width: 100%; text-align: left; margin-top: -2px; }
.gate-adv summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.gate-adv .gate-field input { text-align: left; letter-spacing: 0; font-family: var(--font); font-size: 13px; }
.gate-btn { width: 100%; justify-content: center; margin-top: 4px; }
.gate-error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 9px 12px; font-size: 13px; width: 100%; }
.gate-icon-err { width: 52px; height: 52px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; }
.gate-icon-err svg { width: 28px; height: 28px; }
.gate-foot { color: #6b7d96; font-size: 12px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(22,163,74,.18); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Indicateur de connexion (barre latérale) ---------- */
.conn-chip { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 10px; padding: 8px 10px; border-radius: 9px; border: 0; background: rgba(255,255,255,.06); color: var(--sidebar-text); cursor: pointer; font-weight: 600; font-size: 12.5px; transition: background .15s; }
.conn-chip:hover { background: rgba(255,255,255,.12); }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; flex-shrink: 0; }
.conn-dot.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.25); }
.conn-dot.offline { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.2); }
.conn-dot.error { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.conn-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-sync { width: 15px; height: 15px; opacity: .6; }
.conn-chip.syncing .conn-sync { animation: spin 1s linear infinite; opacity: 1; }

/* Bandeau de reconnexion pendant l'utilisation */
.reconnect-banner { position: fixed; top: 0; left: 240px; right: 0; z-index: 90; background: #d97706; color: #fff; text-align: center; padding: 7px 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; }
.reconnect-banner .spinner { width: 15px; height: 15px; border-width: 2px; border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.reconnect-banner[hidden] { display: none; }

/* Réglages : synchro */
.sync-info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.sync-info > div { background: #f8fafc; border-radius: 9px; padding: 9px 12px; display: flex; flex-direction: column; gap: 2px; }
.sync-info .muted { font-size: 11.5px; }
.sync-info b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; font-family: Consolas, monospace; font-size: 12.5px; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b6c0ce; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .sale-layout { grid-template-columns: 1fr; }
  .sale-side { position: static; }
  .dash-grid, .settings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE — tiroir de navigation, mise en page tactile
   ============================================================ */
.mobile-topbar { display: none; }
.drawer-overlay { display: none; }

@media (max-width: 860px) {
  /* ---- Barre supérieure mobile ---- */
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 60;
    height: 58px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobile-burger, .mobile-new { width: 44px; height: 44px; border-radius: 12px; border: 0; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
  .mobile-burger { background: #eef1f6; color: var(--text); }
  .mobile-new { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,.3); }
  .mobile-burger svg, .mobile-new svg { width: 23px; height: 23px; }
  .mobile-title { flex: 1; font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
  .mobile-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

  /* ---- Tiroir ---- */
  #app { display: block; height: auto; min-height: 100vh; overflow: visible; }
  .content { padding: 14px 14px 32px; height: auto; overflow: visible; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 84vw; z-index: 80; overflow-y: auto;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 0 44px rgba(0,0,0,.45);
  }
  .sidebar.open { transform: none; }
  .drawer-overlay { display: block; position: fixed; inset: 0; background: rgba(15,27,45,.5); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .drawer-overlay.open { opacity: 1; pointer-events: auto; }
  .nav-item { padding: 14px 14px; font-size: 15px; }
  .nav-item.nav-primary { padding: 14px; }

  /* ---- En-têtes de page ---- */
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  h1 { font-size: 20px; }
  .head-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .head-actions .btn { width: 100%; justify-content: center; }
  .head-actions .btn-primary { grid-column: 1 / -1; }
  .btn-lg { width: 100%; justify-content: center; }

  /* ---- Formulaires plus gros (16px = pas de zoom automatique iOS) ---- */
  .card { padding: 16px; border-radius: 14px; margin-bottom: 14px; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: auto; }
  input[type=text], input[type=number], input[type=date], input[type=search], select, textarea { min-height: 48px; font-size: 16px; }
  .btn { padding: 12px 16px; }
  .btn-sm { padding: 10px 13px; font-size: 14px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search { max-width: none; min-width: 0; }
  .field.inline { flex-direction: column; align-items: stretch; }
  .form-row { gap: 10px; }

  /* ---- Tableau de bord ---- */
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 20px; }
  .stat-icon { width: 34px; height: 34px; margin-bottom: 8px; }

  /* ---- Vente ---- */
  .sale-side { position: static; }
  .tot-net { font-size: 17px; }
  .tot-net b { font-size: 26px; }
  .words { font-size: 13px; }

  /* ---- Lignes de produits en CARTES lisibles ---- */
  .table.lines thead { display: none; }
  .table.lines, .table.lines tbody { display: block; }
  .table.lines tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    border: 1px solid var(--border); border-radius: 12px; padding: 16px 12px 12px; margin-bottom: 14px; background: #fff; position: relative;
  }
  .table.lines td { display: block; padding: 0; border: 0; }
  .table.lines td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 5px; }
  .table.lines td input { width: 100%; padding: 11px 12px; }
  .table.lines .col-n { position: absolute; top: -11px; left: 14px; background: var(--accent); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; padding: 0; }
  .table.lines .col-n::before { content: none; }
  .table.lines .ld-des { grid-column: 1 / -1; }
  .table.lines .ld-amt { background: #f6f9fc; border-radius: 9px; padding: 9px 11px; text-align: right; font-weight: 700; }
  .table.lines .ld-amt[data-c="ttc"] { grid-column: 1 / -1; color: var(--accent-text); }
  .table.lines .ld-del { grid-column: 1 / -1; }
  .table.lines .ld-del::before { content: none; }
  .table.lines .ld-del .icon-btn { width: 100%; height: 46px; border: 1px solid var(--danger-soft); color: var(--danger); border-radius: 10px; background: var(--danger-soft); }
  .table.lines .ld-del .icon-btn::after { content: 'Supprimer cette ligne'; margin-left: 8px; font-weight: 600; font-size: 14px; }
  .table.lines .ac-list { min-width: 0; left: 0; right: 0; }

  /* ---- Modales plein écran ---- */
  .modal-backdrop { align-items: stretch; }
  .modal { width: 100%; max-width: none; height: 100%; max-height: 100%; border-radius: 0; }
  .modal-wide, .modal-sm { width: 100%; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { flex-direction: column-reverse; padding: 12px 16px; }
  .modal-foot .btn { width: 100%; justify-content: center; }
  .modal-head { flex-wrap: wrap; gap: 8px; }
  .modal-preview { width: 100vw; height: 100vh; }
  .modal-preview .head-actions { width: auto; display: flex; grid-template-columns: none; }
  .modal-preview .head-actions .btn { width: auto; }
  .preview-body { padding: 6px; }

  /* ---- Tables (historique, produits, clients) : défilement horizontal fluide ---- */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .card > .table-wrap > table:not(.lines) { min-width: 620px; }
  .table .col-actions, .table td.actions { white-space: nowrap; }

  /* ---- Divers ---- */
  .settings-grid { grid-template-columns: 1fr; }
  .color-row { flex-wrap: wrap; }
  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
