/* Sensation « application iPhone » sur téléphone (≤ 600 px) : verre dépoli, ressorts, retour au toucher, feuilles qui glissent.
   Inspiré des principes Apple (HIG : Materials, Tab bars, Sheets, Motion ; Liquid Glass d'iOS 26, affiné en iOS 27) :
   barre flottante translucide qui se réduit au défilement, feuilles inset qui montent avec un ressort, animations courtes et interrompables.
   Chargé APRÈS responsive.css. N'agit que sous 600 px ; respecte « réduire les animations » et « réduire la transparence ». */
:root { --spring: cubic-bezier(.32, .72, 0, 1); --spring-soft: cubic-bezier(.2, .9, .25, 1.12); --glass-bg: color-mix(in srgb, var(--panel, #fff) 70%, transparent); --glass-line: color-mix(in srgb, var(--text, #000) 10%, transparent); }

@media (max-width: 600px) {
  :root { --bn-h: 62px; }

  /* ---- Barre pleine largeur en verre dépoli, collée au bas de l'écran ---- */
  body.has-bottom-nav { padding-bottom: calc(var(--bn-h) + env(safe-area-inset-bottom, 0px)); }
  #bottom-nav { left: 0; right: 0; bottom: 0; height: calc(var(--bn-h) + env(safe-area-inset-bottom, 0px)); padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); border: 0; border-top: 1px solid var(--glass-line); border-radius: 0; background: var(--glass-bg); -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%); box-shadow: 0 -4px 18px rgba(0, 0, 0, .08); transition: height .45s var(--spring), transform .45s var(--spring); }
  #bottom-nav .bn-item { border-top: 0; padding-left: 0; padding-right: 0; }
  #bottom-nav .bn-item .bn-lbl, #bottom-nav .bn-center .bn-lbl { font-size: 11px; letter-spacing: -.01em; }
  #bottom-nav .bn-pill { transition: background .3s var(--spring), transform .45s var(--spring-soft); }
  #bottom-nav .bn-item.on .bn-pill { transform: scale(1.04); background: var(--accent); color: var(--accent-fg, #fff); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent); }
  #bottom-nav .bn-item.on { color: var(--accent); }
  #bottom-nav .bn-lbl { transition: opacity .25s var(--spring), max-height .35s var(--spring); max-height: 16px; }
  #bottom-nav .bn-logo { transition: transform .45s var(--spring-soft), top .45s var(--spring); }
  /* réduite pendant le défilement vers le bas, réaffichée dès qu'on remonte (comme la barre d'onglets d'iOS) */
  body.bn-min #bottom-nav { height: calc(46px + env(safe-area-inset-bottom, 0px)); }
  body.bn-min #bottom-nav .bn-item .bn-lbl, body.bn-min #bottom-nav .bn-center .bn-lbl { opacity: 0; max-height: 0; }
  body.bn-min #bottom-nav .bn-pill { height: 28px; }
  body.bn-min #bottom-nav .bn-logo { top: -10px; transform: translateX(-50%) scale(.78); }

  /* une fenêtre ouverte passe devant : la barre s'efface vers le bas */
  body:has(.modal-overlay.show) #bottom-nav { transform: translateY(140%); pointer-events: none; }

  /* ---- Feuille inset en verre : monte avec un ressort, se referme en glissant ---- */
  #bottom-nav-sheet .bn-backdrop { background: rgba(10, 14, 22, .32); animation: bn-fade .28s ease both; }
  #bottom-nav-sheet .bn-sheet { left: 10px; right: 10px; bottom: calc(var(--bn-h) + 8px + env(safe-area-inset-bottom, 0px)); border-radius: 30px; border: 1px solid var(--glass-line); background: color-mix(in srgb, var(--panel, #fff) 84%, transparent); -webkit-backdrop-filter: blur(26px) saturate(180%); backdrop-filter: blur(26px) saturate(180%); animation: bn-up .5s var(--spring) both; touch-action: pan-y; }
  #bottom-nav-sheet.closing .bn-backdrop { animation: bn-fade-out .22s ease both; }
  #bottom-nav-sheet.closing .bn-sheet { animation: bn-down .26s cubic-bezier(.4, 0, 1, 1) both; }
  #bottom-nav-sheet .bn-sheet.dragging { animation: none; transition: none; }
  #bottom-nav-sheet .bn-tile { animation: bn-pop .45s var(--spring-soft) both; animation-delay: calc(var(--i, 0) * 18ms + 60ms); }

  /* ---- Retour au toucher : un léger enfoncement, rendu avec un ressort ---- */
  .bn-item, .bn-center, .bn-tile, .btn, .btn-sm, .btn-outline, .btn-primary, .chip, .tab-btn, main button:not(table button):not(.ag-ib):not(.sh-act):not(.qty-btn):not(.resize-handle) { transition: transform .38s var(--spring-soft), background-color .2s ease, opacity .2s ease; }
  .bn-item:active, .bn-center:active, .bn-tile:active, .btn:active, .btn-sm:active, .chip:active, main button:not(table button):active { transform: scale(.95); transition-duration: .08s; }
  .bn-center:active .bn-logo { transform: translateX(-50%) scale(.92); }
  .otbl tbody tr, .ag-t tbody tr, .sidebar-item, .cart-line, .vcl-item { transition: transform .38s var(--spring-soft), background-color .2s ease; }
  .otbl tbody tr:active, .ag-t tbody tr:active, .sidebar-item:active, .vcl-item:active { transform: scale(.985); transition-duration: .08s; }

  /* ---- Changement de page : fondu + glissement léger ---- */
  .page.active { animation: page-in .34s var(--spring) both; }
  body.ps-moving .page.active, body.ps-moving .ventes-col { animation: none !important; } /* pas d'animation d'entrée pendant un balayage */

  /* ---- Fenêtres : feuilles qui montent du bas, coins arrondis, poignée ---- */
  .modal-overlay { align-items: flex-end; padding: 0; transition: background .25s ease; }
  .modal-overlay.show { animation: bn-fade .25s ease both; }
  .modal-overlay .modal, .modal-overlay .modal.modal-wide { max-width: 100%; width: 100%; max-height: 90vh; border-radius: 28px 28px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); animation: bn-up-full .5s var(--spring) both; }
  .modal-overlay .modal-head { position: sticky; top: 0; z-index: 3; background: var(--panel); padding-top: 18px; border-radius: 28px 28px 0 0; }
  .modal-overlay .modal-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 5px; background: var(--border); }
  #modal-overlay:has(.modal.co-modal) { padding-bottom: 0 !important; } /* la barre du bas s'efface : plus de réserve sous la fenêtre */
  .modal.co-modal { max-height: 90vh !important; max-height: 90dvh !important; }
  .modal-overlay .modal-foot { position: sticky; bottom: 0; background: var(--panel); }

  /* ---- Listes : défilement élastique et ancrage doux ---- */
  .col-body, .otbl-wrap, .ag-wrap, .panel-row { overscroll-behavior-y: contain; scroll-behavior: smooth; }
}

@keyframes bn-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bn-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes bn-up { from { transform: translateY(40px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bn-down { from { transform: none; opacity: 1; } to { transform: translateY(60px) scale(.97); opacity: 0; } }
@keyframes bn-up-full { from { transform: translateY(100%); } to { transform: none; } }
@keyframes bn-pop { from { transform: translateY(12px) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Transparence réduite : le verre devient opaque (réglage d'accessibilité) */
@media (max-width: 600px) and (prefers-reduced-transparency: reduce) {
  #bottom-nav, #bottom-nav-sheet .bn-sheet { background: var(--panel, #fff); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Animations réduites : plus de ressort ni de glissement, seulement des changements instantanés */
@media (prefers-reduced-motion: reduce) {
  #bottom-nav, #bottom-nav *, #bottom-nav-sheet, #bottom-nav-sheet *, .page.active, .modal-overlay, .modal-overlay .modal, .bn-item, .bn-tile, .btn, .btn-sm, .chip { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}


/* ===== Lisibilité sur téléphone : le texte courant et les petites notes restent confortables ===== */
@media (max-width: 600px) {
  html body small, html body .small, html body .muted, html body .badge-muted, html body .ps-hint { font-size: max(12.5px, .82em); }
  html body [class*="vcl-"] small, html body .vcl-nm { font-size: max(12.5px, .85em) !important; }
  .otbl { font-size: 14.5px; }
  .otbl tbody td { line-height: 1.3; }
  .otbl tbody td:not(.otbl-first):not(.otbl-sel)::before { font-size: 12px; }
  .otbl tbody td.otbl-first { font-size: 16px; }
  main label, main .field { font-size: max(13.5px, .9em); }
  main input, main select, main textarea { font-size: 16px; } /* lisible, et iOS ne zoome pas à la saisie */
}

/* Impression : ni barre du bas ni feuille sur le papier, et plus de marge réservée */
/* ===== Barre du haut « application » (téléphone) ===== */
#hdr-title, #hdr-sync { display: none; }
@media (max-width: 600px) {
  #otchino-statusbar { display: none !important; } /* l'essentiel (connexion, synchro) passe dans la pastille du haut */
  body > header.header { height: calc(52px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 12px 0; gap: 10px; align-items: center; flex-wrap: nowrap; -webkit-backdrop-filter: blur(22px) saturate(180%); backdrop-filter: blur(22px) saturate(180%); } /* les couleurs de la barre restent celles du thème choisi (Paramètres › Apparence) */
  body > header.header #header-logo { order: 1; } body > header.header #hdr-title { order: 2; } body > header.header #hdr-sync { order: 3; } body > header.header #hdr-more { order: 4; } body > header.header #user-badge { order: 5; }
  #header-logo { flex: none; width: 34px; height: 34px; max-width: 76px; border-radius: 10px; }
  #header-logo:has(img) { width: auto; }
  #hdr-title { display: flex; flex-direction: column; justify-content: center; flex: 1 1 auto; min-width: 0; font-size: 1.18rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: inherit; }
  #hdr-title .ht-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #hdr-sync { display: inline-flex; flex: none; align-items: center; gap: 6px; min-width: 36px; height: 36px; padding: 0 11px; border: 0; border-radius: 999px; background: color-mix(in srgb, currentColor 14%, transparent); color: inherit; font: 700 12px/1 inherit; cursor: pointer; }
  #hdr-sync .hs-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px color-mix(in srgb, #22c55e 25%, transparent); }
  #hdr-sync[data-s="warn"] .hs-dot { background: #f59e0b; box-shadow: 0 0 0 3px color-mix(in srgb, #f59e0b 28%, transparent); animation: hs-pulse 1.2s ease-in-out infinite; }
  #hdr-sync[data-s="bad"] { background: color-mix(in srgb, #ef4444 30%, transparent); color: inherit; }
  #hdr-sync[data-s="bad"] .hs-dot { background: #ef4444; box-shadow: 0 0 0 3px color-mix(in srgb, #ef4444 25%, transparent); }
  #hdr-sync .hs-txt:empty { display: none; }
  #hdr-sync:not([data-s]) { display: none; }
  #hdr-more { flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: color-mix(in srgb, currentColor 14%, transparent); color: inherit; display: flex; align-items: center; justify-content: center; }
  #hdr-more:active, #hdr-sync:active { transform: scale(.92); }
  #user-badge { flex: none; width: 36px !important; height: 36px !important; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000)) !important; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
  /* bande des pages (sous-menu) : pastilles plus fines, discrètes, la page active pleine */
  html body #ot-submenu { background: transparent; border: 0; }
  html body #ot-submenu .ot-sm-row { padding: 8px 12px 6px; gap: 8px; }
  html body #ot-submenu .ot-sm-chip { min-height: 36px !important; padding: 0 15px; border: 1px solid var(--glass-line); border-radius: 999px; background: var(--glass-bg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); color: var(--text); font-size: 13.5px !important; font-weight: 600; }
  html body #ot-submenu .ot-sm-chip.active { background: var(--accent); border-color: transparent; color: var(--accent-fg, #fff); box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 35%, transparent); }
  html body #ot-submenu .ot-sm-btn { min-height: 36px !important; border-radius: 999px; padding: 0 14px; font-size: 13.5px !important; }
}
@keyframes hs-pulse { 50% { opacity: .35; } }

@media print {
  #bottom-nav, #bottom-nav-sheet { display: none !important; }
  body.has-bottom-nav { padding-bottom: 0 !important; }
}

/* ===== Plus de place pour le contenu (téléphone) : moins de marges, bandes plus basses, titres redondants masqués ===== */
@media (max-width: 600px) {
  :root { --bn-h: 58px; }
  html body main { padding: 0 !important; }
  html body main > .page { padding: 4px 6px 0 !important; }
  /* la barre du haut, la bande des pages et celle des colonnes : plus fines */
  body > header.header { height: calc(48px + env(safe-area-inset-top, 0px)); }
  html body #ot-submenu .ot-sm-row { padding: 5px 10px 3px; }
  html body #ot-submenu .ot-sm-chip, html body #ot-submenu .ot-sm-btn { min-height: 34px !important; }
  #vcol-tabs { padding: 2px 8px 4px; gap: 6px; }
  #vcol-tabs button { min-height: 34px; padding: 4px 14px; font-size: .82em; }
  /* les colonnes de l'écran Ventes : pas de cadre ni d'ombre lourde, bord à bord ; le titre est déjà dans la pastille du dessus */
  #ventes-panels { padding: 0 0 4px !important; }
  #ventes-panels.vtabs-on > .ventes-col { border-radius: 14px; box-shadow: 0 1px 6px rgba(40, 46, 60, .08); }
  #ventes-panels.vtabs-on > .ventes-col > .col-head .editable-title, #ventes-panels.vtabs-on > .ventes-col > .col-head .badge-muted:not(button) { display: none; }
  #ventes-panels.vtabs-on > .ventes-col > .col-head:not(:has(button, input, select)) { display: none; }
  #ventes-panels.vtabs-on > .ventes-col > .col-head:has(button) { justify-content: flex-end; padding: 6px 8px; }
  /* barre d'espace libre sous le contenu : seulement la hauteur du menu du bas */
  body.has-bottom-nav { padding-bottom: calc(var(--bn-h) + env(safe-area-inset-bottom, 0px)); }
}

/* ===== Écrans réorganisés pour le téléphone : liste d'articles de la prise de commande, suivi des commandes ===== */
@media (max-width: 600px) {
  /* Articles : recherche + catégories + « En stock » ; liste lisible (nom, stock total, prix) ; les stocks par magasin restent dans la fiche */
  #ventes-panels [data-vcol="articles"] > .col-head { display: none; }
  #mt-bar-v { display: none; }
  #vsc-chk { padding: 2px 10px 6px; gap: 10px; }
  #vsc-chk > .muted, #vsc-chk .vsc-sep, #vsc-chk label:has([data-sc]) { display: none; }
  #vsc-bar #vsc-head { display: none !important; }
  #grid-articles .sidebar-item { min-height: 52px; padding: 6px 12px !important; gap: 10px !important; }
  #grid-articles .sidebar-item .vsc-c { display: none; }
  #grid-articles .sidebar-item > span:nth-of-type(2) { font-size: 15px !important; line-height: 1.25; white-space: normal !important; }
  #grid-articles .sidebar-item .vsc-tot { font-size: 12.5px !important; }
  #grid-articles .sidebar-item .vsc-tot::before { content: 'Stock '; }
  #grid-articles .sidebar-item > span[style*="color:var(--accent)"] { font-size: 15px !important; min-width: 0 !important; }
  /* Suivi des commandes : les chiffres en bande qui défile, les colonnes vides réduites à leur titre */
  #suivi-root .sv-stats { display: flex !important; flex-wrap: nowrap !important; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
  #suivi-root .sv-stats::-webkit-scrollbar { display: none; }
  #suivi-root .sv-stat { flex: none; min-width: 128px; }
  #suivi-root .sv-grid { display: flex !important; flex-direction: column; align-items: stretch !important; gap: 8px; }
  #suivi-root .sv-col { width: 100%; box-sizing: border-box; }
  #suivi-root .sv-col h3 { display: flex; justify-content: space-between; align-items: center; }
  #suivi-root .sv-col:has(.sv-empty) { padding-bottom: 0; }
  #suivi-root .sv-col .sv-empty { display: none; }
  #suivi-root .sv-col:has(.sv-empty) h3 { margin: 0; padding: 10px 12px; opacity: .75; }
}

/* Caisse : une seule rangée « Afficher », le bouton Personnaliser (réglage rare) n'est affiché que sur tablette et ordinateur */
@media (max-width: 600px) {
  #caisse-toolbar { padding: 2px 8px 4px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #caisse-toolbar::-webkit-scrollbar { display: none; }
  #btn-ccustomize { display: none; }
}

/* Téléphone : la navigation entre pages se fait par balayage, glissé vers le haut sur le menu du bas ou appui sur le titre ;
   les pastilles de pages disparaissent de la bande (les boutons d'action restent), qui disparaît s'il n'y en a pas */
@media (max-width: 600px) {
  html body #ot-submenu [data-sm-id^="nav:"]:not([data-sm-id="nav:back"]), html body #ot-submenu .ot-sm-section, html body #ot-submenu .ot-sm-sep { display: none !important; }
  html body #ot-submenu.sm-nav-only { display: none !important; }
  #hdr-title { cursor: pointer; }
  #hdr-dots { display: flex; gap: 4px; margin-top: 3px; height: 6px; }
  #hdr-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .3; transition: opacity .3s, width .35s var(--spring); }
  #hdr-dots i.on { opacity: .95; width: 16px; border-radius: 4px; }
}

/* Téléphone : plus de bande de boutons sous l'en-tête. Ses actions sont dans la feuille du menu du bas (appui sur la rubrique, glissé vers le haut, appui sur le titre). */
@media (max-width: 600px) {
  html body #ot-submenu { display: none !important; }
  #bottom-nav-sheet .bn-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
  #bottom-nav-sheet .bn-act { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 16px; border: 1px solid var(--glass-line); border-radius: 16px; background: color-mix(in srgb, var(--text, #000) 5%, transparent); color: var(--text); font: 700 15px/1.1 inherit; text-decoration: none; }
  #bottom-nav-sheet .bn-act.primary { background: var(--accent); border-color: transparent; color: var(--accent-fg, #fff); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
  #bottom-nav-sheet .bn-act:active { transform: scale(.97); }
}

/* ===== Rangées de pastilles → petites icônes (public/mobile-iconbar.js) ===== */
@media (max-width: 600px) {
  [data-ibs] { display: flex; gap: 8px; padding: 2px 10px 4px; overflow-x: auto; scrollbar-width: none; align-items: center; }
  [data-ibs]::-webkit-scrollbar { display: none; }
  html body [data-ibs] > button[data-ib] { flex: 0 0 auto !important; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 40px; min-height: 40px; height: 40px; padding: 0 11px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; }
  [data-ibs] > button[data-ib] .ib-l, [data-ibs] > button[data-ib] .ib-c { display: none; }
  [data-ibs] > button[data-ib].on .ib-l, [data-ibs] > button[data-ib].active .ib-l, [data-ibs] > button[data-ib][aria-selected="true"] .ib-l { display: inline; }
  /* replié : seule la vue en cours reste, avec un petit chevron qui invite à déplier */
  [data-ibs="collapsed"] > button[data-ib]:not(.on):not(.active):not([aria-selected="true"]) { display: none; }
  [data-ibs="collapsed"] > button[data-ib] .ib-c { display: inline; opacity: .6; font-size: 12px; }
  [data-ibs="open"] > button[data-ib] { animation: ib-pop .4s var(--spring, cubic-bezier(.32, .72, 0, 1)) both; }
  [data-ibs="open"] > button[data-ib]:nth-child(2) { animation-delay: .03s; } [data-ibs="open"] > button[data-ib]:nth-child(3) { animation-delay: .06s; }
  [data-ibs="open"] > button[data-ib]:nth-child(4) { animation-delay: .09s; } [data-ibs="open"] > button[data-ib]:nth-child(n+5) { animation-delay: .12s; }
}
@keyframes ib-pop { from { opacity: 0; transform: translateY(-6px) scale(.8); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { [data-ibs] > button { animation: none !important; } }
/* pastille de nombre sur une rubrique du menu du bas (ex. ruptures) */
@media (max-width: 600px) {
  #bottom-nav .bn-pill { position: relative; }
  #bottom-nav .bn-badge { position: absolute; top: -4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font: 800 11px/18px inherit; text-align: center; box-shadow: 0 0 0 2px var(--panel, #fff); animation: bn-badge-in .5s var(--spring, cubic-bezier(.32, .72, 0, 1)) both; }
}
@keyframes bn-badge-in { from { transform: scale(0); } to { transform: scale(1); } }

/* Messages « rien à afficher » : lisibles, centrés, avec la marche à suivre (téléphone) */
@media (max-width: 600px) {
  .vj-empty, .vp-empty, .cmdp-empty, .co-empty, .otbl-empty, .vd-none, .ac-none, .rp-empty { padding: 26px 18px !important; text-align: center; font-size: 15px !important; line-height: 1.45; color: var(--muted); }
}
