/* ═══════════════════════════════════════════════════════════════════════
   SMPro · Mobile-First Overlay
   Activé sur les écrans <=1024px (smartphone + tablette) via media query.
   Breakpoint aligné sur la bottom-nav v2 (#mob2-nav) pour cohérence.
   Non-invasif : ne touche pas au desktop.
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {

  /* ── Reset spacing + scroll-behavior ── */
  html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
  }
  body {
    font-size: 15px;
    line-height: 1.55;
    /* Évite le zoom auto iOS sur focus input */
    -webkit-text-size-adjust: 100%;
    /* Safe area iOS notch */
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
             env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  }

  :root {
    --mf-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mf-nav-h: 64px;
    --mf-touch: 44px;
    --mf-ink: #0B2140;
    --mf-blue: #1d70b7;
    --mf-green: #27ae60;
    --mf-red: #e74c3c;
    --mf-surface: rgba(255, 255, 255, 0.96);
    --mf-border: rgba(11, 33, 64, 0.10);
  }

  body.is-mobile,
  html.mf-mobile body {
    background: linear-gradient(180deg, #f7faff 0%, #eef5fb 100%) !important;
  }

  /* ── Inputs : 16px minimum pour bloquer le zoom auto iOS ── */
  input, textarea, select, button {
    font-size: 16px !important;
  }
  /* Tap target minimum 44x44 (Apple HIG) */
  button, a.btn, .tab, .icon-btn,
  input[type="button"], input[type="submit"],
  [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* ── Header / topbar : compact ── */
  .hdr, header.app-hdr {
    padding: 8px 12px !important;
    gap: 8px !important;
  }
  .hdr h1, .hdr .app-title {
    font-size: 16px !important;
  }
  .hdr .user-info, .hdr .clock-zone,
  .hdr .breadcrumb-zone, .hdr .header-search {
    display: none !important;
  }

  /* ── Sidebar / nav latérale : cachée par défaut, drawer ──
     2026-05-27 : #tabs-bar (sidebar V2) inclus pour ouvrir en drawer avec
     hamburger sur mobile — la user card en footer reste visible en bas. */
  .app-sidebar, .sidebar, nav.left-nav,
  body.topbar-v2-active.topbar-v2-sidebar #tabs-bar {
    position: fixed !important;
    top: 0 !important; left: 0 !important; bottom: 0 !important;
    width: 84vw !important; max-width: 320px !important;
    height: 100vh !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 1100 !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    display: flex !important;
  }
  body.mobile-drawer-open .app-sidebar,
  body.mobile-drawer-open .sidebar,
  body.mobile-drawer-open nav.left-nav,
  body.mobile-drawer-open.topbar-v2-active.topbar-v2-sidebar #tabs-bar {
    transform: translateX(0) !important;
  }
  /* En mobile drawer, le footer (position:fixed sur document.body) doit
     slider avec la sidebar. v404 : transform sync sur le footer comme sur
     le sidebar — caché par défaut, visible quand body.mobile-drawer-open. */
  body.topbar-v2-active.topbar-v2-sidebar .t2-footer {
    display: flex !important;
    width: 84vw !important;
    max-width: 320px !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    z-index: 1101 !important;
  }
  body.mobile-drawer-open.topbar-v2-active.topbar-v2-sidebar .t2-footer {
    transform: translateX(0) !important;
  }
  /* Quand le drawer est ouvert sur mobile, masquer la mob-bottom-nav qui
     surplombe la user card (z-index 888 vs 230) — l'utilisateur interagit
     avec le drawer, la bottom nav réapparaîtra à la fermeture. */
  body.mobile-drawer-open #mob-bottom-nav,
  body.mobile-drawer-open #mobile-bottom-nav,
  body.mobile-drawer-open .mf-bottom-nav {
    display: none !important;
  }
  /* Backdrop */
  body.mobile-drawer-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1099;
    animation: mfBackdropIn 0.28s ease;
  }
  @keyframes mfBackdropIn { from { opacity: 0 } to { opacity: 1 } }

  /* ── Main content : pleine largeur ── */
  .app-main, main, .content-area {
    margin-left: 0 !important;
    padding: 12px !important;
    padding-bottom: 88px !important;  /* place pour le bottom nav */
  }
  #main.main {
    top: calc(var(--hdr-h, 58px) + env(safe-area-inset-top, 0px)) !important;
    padding-inline: max(10px, env(safe-area-inset-left, 0px)) max(10px, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 18px) !important;
    scroll-padding-bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 24px);
  }
  .tabs, .tab-bar {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap !important;
  }
  .tabs::-webkit-scrollbar, .tab-bar::-webkit-scrollbar { display: none }
  .tab {
    flex-shrink: 0;
    padding: 10px 14px !important;
    font-size: 13px !important;
    white-space: nowrap;
  }

  /* ── Cards : pleine largeur, padding réduit ── */
  .card, .panel, .surface-card {
    margin: 0 0 12px !important;
    border-radius: 12px !important;
    padding: 14px !important;
  }
  .card, .panel, .kpi-card, .stat-card, .public-panel {
    content-visibility: auto;
    contain-intrinsic-size: 1px 220px;
  }
  .ch, .card-header, .panel-title {
    padding: 12px 14px !important;
    font-size: 14px !important;
  }
  .cb, .card-body {
    padding: 12px 14px !important;
  }

  /* ── Tables : transformation en cards stack ── */
  table.responsive-mobile,
  .data-table table,
  table.list-table,
  table.mf-card-table,
  .af-table,
  .dtlux {
    display: block !important;
    width: 100% !important;
  }
  table.responsive-mobile thead,
  .data-table table thead,
  table.list-table thead,
  table.mf-card-table thead,
  .af-table thead,
  .dtlux thead {
    display: none !important;
  }
  table.responsive-mobile tbody,
  .data-table table tbody,
  table.list-table tbody,
  table.mf-card-table tbody,
  .af-table tbody,
  .dtlux tbody {
    display: block !important;
  }
  table.responsive-mobile tr,
  .data-table table tbody tr,
  table.list-table tbody tr,
  table.mf-card-table tbody tr,
  .af-table tbody tr,
  .dtlux tbody tr {
    display: block !important;
    background: #fff !important;
    border: 1px solid #e6eaf2 !important;
    border-radius: 10px !important;
    padding: 12px !important;
    margin-bottom: 10px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  table.responsive-mobile td,
  .data-table table tbody td,
  table.list-table tbody td,
  table.mf-card-table tbody td,
  .af-table tbody td,
  .dtlux tbody td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start;
    gap: 14px;
    border: none !important;
    padding: 6px 0 !important;
    font-size: 13px !important;
    white-space: normal !important;
    word-break: break-word;
  }
  table.responsive-mobile td::before,
  .data-table table tbody td::before,
  table.mf-card-table tbody td::before,
  .af-table tbody td::before,
  .dtlux tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: #6b7280;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    margin-right: 12px;
    max-width: 42%;
  }
  table.mf-card-table td[data-label=""],
  table.mf-card-table td:not([data-label]) {
    display: block !important;
  }
  table.mf-card-table td[data-label=""]::before,
  table.mf-card-table td:not([data-label])::before {
    display: none !important;
  }

  /* ── Forms : labels au-dessus des champs, full-width ── */
  .form-row, .fr, .field-row {
    display: block !important;
  }
  .form-row > .fg, .fr > .fg, .field-row > .fg,
  .form-row > .field, .fr > .field {
    width: 100% !important;
    margin-bottom: 14px !important;
  }
  .fl, .field-label, label {
    font-size: 12px !important;
    margin-bottom: 6px !important;
  }
  .fi, .fta, .fs, .field-input {
    width: 100% !important;
    padding: 12px 14px !important;
    border-radius: 10px !important;
    font-size: 16px !important; /* anti-zoom iOS */
  }

  /* ── Modals : fullscreen sur mobile ── */
  .modal, dialog.modal {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    inset: 0 !important;
    margin: 0 !important;
  }
  .modal-content, dialog.modal > * {
    padding: 16px !important;
  }

  /* ── Boutons : full-width par défaut sur mobile ── */
  .btn {
    padding: 12px 16px !important;
    font-size: 14px !important;
  }
  .mfoot, .btn-row, .back-bar, .filter-bar, .signature-action-row {
    gap: 8px !important;
  }
  .mfoot .btn, .signature-action-row .btn {
    min-height: var(--mf-touch) !important;
  }
  .btn-block, .btn-full, .btn.full {
    width: 100% !important;
    justify-content: center !important;
  }

  /* ── Bottom navigation (fixed bottom bar) ── */
  .mf-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(60px + env(safe-area-inset-bottom, 0));
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    z-index: 1000;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
  }
  body:has(#mob-bottom-nav) .mf-bottom-nav,
  body:has(#mobile-bottom-nav) .mf-bottom-nav {
    display: none !important;
  }
  .mf-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: none;
    color: #6b7280;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 4px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mf-bottom-nav-item .mf-icon {
    width: 24px; height: 24px;
    display: grid; place-items: center;
    font-size: 20px;
  }
  .mf-bottom-nav-item.active {
    color: #0b2140;
  }
  .mf-bottom-nav-item.active .mf-icon::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: #f8fafc;
    margin-top: 2px;
  }
  .mf-bottom-nav-item:active {
    background: rgba(11, 33, 64, 0.05);
  }

  /* ── Floating Action Button (FAB) ── */
  .mf-fab {
    position: fixed;
    bottom: calc(76px + env(safe-area-inset-bottom, 0));
    right: 16px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #f8fafc;
    color: #c9a557;
    border: none;
    box-shadow: 0 8px 24px rgba(11, 33, 64, 0.35);
    display: grid; place-items: center;
    font-size: 28px;
    cursor: pointer;
    z-index: 999;
    transition: transform 0.15s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  .mf-fab:hover { box-shadow: 0 12px 32px rgba(11, 33, 64, 0.45) }
  .mf-fab:active { transform: scale(0.92) }

  /* ── Hamburger menu trigger ── */
  .mf-hamburger {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0));
    left: 12px;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    display: grid; place-items: center;
    cursor: pointer;
    z-index: 1050;
    color: #0b2140;
  }
  .mf-hamburger svg { width: 20px; height: 20px }

  /* Native-like command/search trigger */
  .mf-command-trigger {
    position: fixed;
    right: 14px;
    bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 14px);
    z-index: 980;
    min-width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 16px;
    background: linear-gradient(135deg, var(--mf-ink), var(--mf-blue));
    color: #fff;
    box-shadow: 0 12px 28px rgba(11, 33, 64, 0.28);
    display: grid;
    place-items: center;
    font-size: 20px;
  }
  .mf-command-trigger:active { transform: scale(0.94) }

  .mf-offline-pill {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 14px);
    z-index: 1250;
    border-radius: 14px;
    padding: 10px 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 10px 28px rgba(154, 52, 18, 0.14);
    display: none;
  }
  html.mf-offline .mf-offline-pill { display: block }

  /* ── Search bar mobile (full-width sticky top) ── */
  .mf-search {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    padding: 8px 12px;
    border-bottom: 1px solid #eef0f4;
  }
  .mf-search input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid #d4cfc2;
    font-size: 16px;
    background: #fbfaf6;
  }

  /* ── Notifications (toasts) ── */
  .toast, .notification-toast {
    position: fixed !important;
    bottom: calc(80px + env(safe-area-inset-bottom, 0)) !important;
    left: 12px !important; right: 12px !important;
    width: auto !important;
    max-width: none !important;
    z-index: 1200 !important;
  }

  /* ── Scroll plus fluide ── */
  .scrollable, .list, .scroll-area, [data-scroll] {
    -webkit-overflow-scrolling: touch;
  }

  /* ── KPIs/stat cards en grid 2col ── */
  .kpi-grid, .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .kpi, .stat-card {
    padding: 12px !important;
  }

  /* ── Login screen Marine Couture déjà responsive (≤900px) ── */
  /* On ne touche pas — déjà géré dans index.html */

  /* ── Admin.html : grids → 1 col ── */
  .grid, .charts-grid {
    grid-template-columns: 1fr !important;
  }

  .g2, .g3, .g4,
  .portal-form-grid-3,
  .public-grid,
  .usr-grid,
  .clients-grid {
    grid-template-columns: 1fr !important;
  }

  .cmdk-panel, .ai-chat, .notif-panel {
    max-width: 100vw !important;
  }

  .ai-fab {
    bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 72px) !important;
  }

  /* ── NDF : saisie vraiment mobile-first ── */
  body.mf-module-ndf .terrain-luxe-hero,
  body.mf-module-ndf .mod-hero {
    border-radius: 16px !important;
    padding: 18px 16px !important;
    margin-bottom: 12px !important;
  }
  body.mf-module-ndf .terrain-luxe-hero-inner {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  body.mf-module-ndf .terrain-luxe-title {
    font-size: 21px !important;
    line-height: 1.15 !important;
  }
  body.mf-module-ndf .terrain-luxe-sub {
    font-size: 12px !important;
    line-height: 1.45 !important;
  }
  body.mf-module-ndf .terrain-luxe-kpis {
    display: grid !important;
    grid-auto-flow: column;
    grid-auto-columns: minmax(136px, 42vw);
    grid-template-columns: none !important;
    gap: 8px !important;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  body.mf-module-ndf .terrain-luxe-kpi {
    min-height: 74px;
    scroll-snap-align: start;
  }
  body.mf-module-ndf #main > div[style*="display:flex"][style*="margin-bottom:14px"] {
    position: sticky;
    top: calc(var(--hdr-h, 58px) + env(safe-area-inset-top, 0px));
    z-index: 45;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
    margin: 0 -2px 12px !important;
    border: 1px solid var(--mf-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 26px rgba(11, 33, 64, 0.10);
  }
  body.mf-module-ndf #main > div[style*="display:flex"][style*="margin-bottom:14px"] .fi,
  body.mf-module-ndf #main > div[style*="display:flex"][style*="margin-bottom:14px"] .fs {
    width: 100% !important;
  }
  body.mf-module-ndf .mf-ndf-lines,
  body.mf-module-ndf #ndf-lignes {
    overflow: visible !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table {
    display: block !important;
    width: 100% !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table thead {
    display: none !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table tbody {
    display: grid !important;
    gap: 12px !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row {
    position: relative;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px !important;
    padding: 14px !important;
    border: 1px solid rgba(29, 112, 183, 0.14) !important;
    border-radius: 14px !important;
    background: #fff !important;
    box-shadow: 0 10px 24px rgba(11, 33, 64, 0.08);
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row::before {
    content: "Ticket";
    position: absolute;
    top: -9px;
    left: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e8f4fb;
    color: var(--mf-ink);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td {
    display: block !important;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td::before {
    content: attr(data-label);
    display: block !important;
    margin: 0 0 5px;
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(3),
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(4),
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(8),
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(10),
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(11) {
    grid-column: 1 / -1;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(5) .fi {
    border-color: rgba(39, 174, 96, 0.28) !important;
    background: #f6fff9 !important;
    font-weight: 900 !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(7) {
    align-self: end;
    padding: 12px 10px !important;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--mf-ink) !important;
    font-weight: 900;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(9) {
    display: flex !important;
    align-items: center;
    justify-content: space-between !important;
    min-height: 44px;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(10) {
    min-height: 48px;
    padding: 10px !important;
    border: 1px dashed rgba(29, 112, 183, 0.30) !important;
    border-radius: 12px;
    background: #f8fbff;
    text-align: center !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(10) span[onclick] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    background: #e8f4fb;
  }
  body.mf-module-ndf .mf-ndf-edit-table tr.ndf-ligne-row td:nth-child(11) > div {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
  }
  body.mf-module-ndf .mf-ndf-edit-table .fi,
  body.mf-module-ndf .mf-ndf-edit-table .fs {
    width: 100% !important;
    min-height: 46px !important;
    font-size: 16px !important;
    padding: 10px 12px !important;
  }
  body.mf-module-ndf .mf-ndf-totals {
    position: sticky !important;
    bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 8px);
    z-index: 55;
    width: 100% !important;
    min-width: 0 !important;
    border: 1px solid rgba(11, 33, 64, 0.10);
    box-shadow: 0 14px 32px rgba(11, 33, 64, 0.16);
  }
  body.mf-module-ndf .mf-ndf-actionbar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  body.mf-module-ndf .mf-ndf-actionbar .btn {
    width: 100% !important;
    justify-content: center !important;
  }
  body.mf-module-ndf table.mf-card-table td[data-label="Actions"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  body.mf-module-ndf table.mf-card-table td[data-label="Actions"] .btn {
    width: 100% !important;
  }

  /* ── Fiches terrain : portail, affaire et formulaire terrain tactiles ── */
  body.mf-module-fiches-terrain #main > div[style*="#0b1428"],
  body.mf-module-fiches-terrain .mod-hero {
    border-radius: 16px !important;
    padding: 20px 16px !important;
    margin-bottom: 12px !important;
  }
  body.mf-module-fiches-terrain #main > div[style*="#0b1428"] > div[style*="position:absolute"] {
    display: none !important;
  }
  body.mf-module-fiches-terrain #main > div[style*="#0b1428"] div[style*="font-size:26px"] {
    font-size: 22px !important;
    line-height: 1.16 !important;
  }
  body.mf-module-fiches-terrain #main > div[style*="display:flex"][style*="margin-bottom:16px"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    position: sticky;
    top: calc(var(--hdr-h, 58px) + env(safe-area-inset-top, 0px));
    z-index: 46;
    padding: 10px !important;
    margin: 0 -2px 12px !important;
    border: 1px solid var(--mf-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 26px rgba(11, 33, 64, 0.10);
  }
  body.mf-module-fiches-terrain #main > div[style*="display:flex"][style*="margin-bottom:16px"] .fi,
  body.mf-module-fiches-terrain #main > div[style*="display:flex"][style*="margin-bottom:16px"] .fs,
  body.mf-module-fiches-terrain #main > div[style*="display:flex"][style*="margin-bottom:16px"] .btn {
    width: 100% !important;
  }
  body.mf-module-fiches-terrain .ch-filter-bar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  body.mf-module-fiches-terrain .ch-fiche-row {
    padding: 14px !important;
    border-radius: 14px !important;
    border: 1px solid rgba(11, 33, 64, 0.10) !important;
    background: #fff !important;
    box-shadow: 0 8px 22px rgba(11, 33, 64, 0.07);
  }
  body.mf-module-fiches-terrain .ch-fiche-row + .ch-fiche-row {
    margin-top: 10px !important;
  }
  body.mf-module-fiches-terrain .ch-fiche-row > div:first-child,
  body.mf-module-fiches-terrain .terrain-modal-head {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  body.mf-module-fiches-terrain .ch-fiche-row .btn,
  body.mf-module-fiches-terrain .mf-ft-actionbar .btn {
    min-height: 44px !important;
    flex: 1 1 calc(50% - 6px);
  }
  body.mf-module-fiches-terrain .terrain-modal-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  body.mf-module-fiches-terrain #terrain-dynamic-sections .fg,
  body.mf-module-fiches-terrain [id^="ftf-"] {
    scroll-margin-top: calc(var(--hdr-h, 58px) + 16px);
  }
  body.mf-module-fiches-terrain textarea.fi,
  body.mf-module-fiches-terrain textarea.fta {
    min-height: 112px !important;
  }
  body.mf-module-fiches-terrain .terrain-chip,
  body.mf-module-fiches-terrain .bdg {
    white-space: normal !important;
    line-height: 1.25 !important;
  }
  body.mf-module-fiches-terrain #modal.open .mbox.wide,
  body.mf-module-fiches-terrain #modal.open .mbox {
    width: 100vw !important;
    max-width: 100vw !important;
    height: calc(var(--vh, 1vh) * 100) !important;
    max-height: calc(var(--vh, 1vh) * 100) !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    padding-bottom: calc(var(--mf-nav-h) + var(--mf-safe-bottom) + 16px) !important;
  }
  body.mf-module-fiches-terrain #modal.open .mfoot,
  body.mf-module-fiches-terrain .mf-ft-actionbar {
    position: sticky;
    bottom: 0;
    z-index: 60;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
    margin: 12px -4px -4px !important;
    border-top: 1px solid rgba(11, 33, 64, 0.10);
    border-radius: 14px 14px 0 0;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -12px 28px rgba(11, 33, 64, 0.12);
  }
  body.mf-module-fiches-terrain #ft-sig-canvas {
    width: 100% !important;
    height: 180px !important;
  }

  /* ── Print : déjà désactivé pour modal/btn ── */
}

@media (max-width: 1024px) and (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── États tablette : 600-900 ── */
@media (min-width: 600px) and (max-width: 1024px) {
  .mf-bottom-nav-item .mf-label {
    font-size: 11px;
  }
  .kpi-grid, .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ── Phase 0 — Mobile épuré : une seule nav (#mob2-nav) + FAB principal ──
   Masque les widgets flottants de bord sur TOUTES les vues mobiles
   (pas seulement le dashboard). Complète les règles de no-gold.css qui sont
   limitées à body.mf-dashboard-active. On conserve la bottom nav et le
   quick-add FAB (.qafab2-btn). */
@media (max-width: 1024px) {
  #epnl-wrap, .epnl-wrap,
  .mf-command-trigger,
  .mf-fab,
  .mf-hamburger,
  #pwa-install-fab,
  #mob2-pwa {
    display: none !important;
    pointer-events: none !important;
  }
}

/* ── Phase 1 — Boutons de capture terrain (GPS / dictée / appel) ── */
.mt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  margin: 4px 0 4px 6px;
  padding: 0 10px;
  border: 1px solid rgba(11, 33, 64, 0.14);
  border-radius: 10px;
  background: #f4f8fd;
  color: #0b2140;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.1s;
}
.mt-btn:active { transform: scale(0.94); }
.mt-btn:disabled { opacity: 0.5; cursor: progress; }
.mt-btn--gps { background: #eaf3fb; }
.mt-btn--voice { background: #f3eefc; }
.mt-btn--call { background: #eafaf0; }
.mt-btn.mt-busy { animation: mtPulse 1s ease infinite; }
.mt-btn.mt-rec {
  background: #fde8e8;
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.4);
  animation: mtPulse 1s ease infinite;
}
@keyframes mtPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.mt-tel-link {
  color: #1d70b7;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.mt-tel-link::before { content: "📞 "; font-weight: 400; }
.mt-tel-link:active { opacity: 0.6; }
/* ── Très petits écrans ── */
@media (max-width: 380px) {
  .mf-fab {
    width: 50px; height: 50px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0));
    font-size: 24px;
  }
  .hdr h1, .hdr .app-title {
    font-size: 14px !important;
  }
}

/* ── Dark mode mobile (auto si prefers-color-scheme + mobile) ── */
@media (max-width: 1024px) and (prefers-color-scheme: dark) {
  body.mobile-dark-supported {
    background: #0b1220;
    color: #e8eaff;
  }
  body.mobile-dark-supported .card,
  body.mobile-dark-supported .panel {
    background: #131a2b !important;
    border-color: #1f2940 !important;
  }
  body.mobile-dark-supported .mf-bottom-nav {
    background: rgba(11, 18, 32, 0.96);
    border-top-color: rgba(255, 255, 255, 0.08);
  }
  body.mobile-dark-supported .mf-bottom-nav-item { color: #8b9bb5 }
  body.mobile-dark-supported .mf-bottom-nav-item.active { color: #f4e8c8 }
  body.mobile-dark-supported .mf-hamburger {
    background: rgba(11, 18, 32, 0.95);
    color: #e8eaff;
    border-color: rgba(255, 255, 255, 0.08);
  }
}

/* ════════════════════════════════════════════════════════════════════════
   COMPACT PHONE — densité écran téléphone (≤430px, ex. Galaxy S26 ~412px)
   Réduit les tailles de texte, resserre les espacements, occupe toute la
   largeur. Les inputs restent à 16px (anti-zoom iOS).
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 430px) {
  body { font-size: 13.5px; line-height: 1.42; }

  /* Titres */
  h1 { font-size: 19px !important; line-height: 1.2 !important; }
  h2 { font-size: 16px !important; line-height: 1.25 !important; }
  h3 { font-size: 14px !important; }

  /* Réduit les grandes polices codées en inline (KPI, héros, valeurs) */
  [style*="font-size:30px"], [style*="font-size: 30px"] { font-size: 21px !important; }
  [style*="font-size:28px"], [style*="font-size: 28px"] { font-size: 20px !important; }
  [style*="font-size:26px"], [style*="font-size: 26px"] { font-size: 19px !important; }
  [style*="font-size:24px"], [style*="font-size: 24px"] { font-size: 18px !important; }
  [style*="font-size:22px"], [style*="font-size: 22px"] { font-size: 17px !important; }
  [style*="font-size:20px"], [style*="font-size: 20px"] { font-size: 16px !important; }
  [style*="font-size:18px"], [style*="font-size: 18px"] { font-size: 15px !important; }

  /* Densité : paddings/marges resserrés, pleine largeur */
  #main.main { padding-inline: 8px !important; }
  .card, .panel, .surface-card {
    padding: 11px !important;
    margin: 0 0 10px !important;
    border-radius: 12px !important;
  }
  .ch, .card-header, .panel-title { padding: 10px 11px !important; font-size: 13.5px !important; }
  .cb, .card-body { padding: 10px 11px !important; }

  /* Boutons / onglets plus compacts (cible tactile 44px conservée) */
  .btn { padding: 9px 12px !important; font-size: 12.5px !important; }
  .tab { padding: 8px 10px !important; font-size: 11.5px !important; }

  /* Grilles KPI / stats : 2 colonnes serrées qui remplissent la largeur */
  .kpi-grid, .stats-grid { gap: 6px !important; }
  .kpi, .stat-card, .kpi-card { padding: 10px !important; }

  /* Tables en cartes : texte plus dense */
  table.mf-card-table tbody td,
  .dtlux tbody td,
  .af-table tbody td { font-size: 12px !important; }
}
