/* ── FastFlowTrack — Mobile / Responsive ──────────────────────────────────── */

/* ── Tablet (≤900px) ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --header-h: 50px; }

  .hstats { display: none; }
  .header { padding: 0 10px; gap: 6px; }
  .logo-sub { display: none; }
  .logo-name { font-size: 15px; }
  .logo-mark { width: 28px; height: 28px; }
  .logo-mark svg { width: 15px; height: 15px; }
  .hdr-btns { gap: 4px; }
  .hdr-btns .btn { padding: 5px 8px; font-size: 12px; }

  /* Sidebar: hidden off-screen, slides in when .open */
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    width: 220px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }

  /* Hide sidebar space in the flex layout */
  .sidebar { flex-shrink: 0; width: 0; padding: 0; border: none; }
  .sidebar.open { width: 220px; padding: 10px 0; border-right: 1px solid var(--border); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(0,0,0,.55);
    z-index: 49;
  }
  .sidebar-backdrop.open { display: block; }

  /* Detail panel: full-screen fixed overlay */
  .dp {
    position: fixed !important;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    z-index: 40;
    overflow-y: auto;
  }

  .wo-grid { grid-template-columns: 1fr; gap: 8px; }
  .toolbar { gap: 6px; }
  .sw { max-width: 100%; flex: 1 1 140px; }
  .vtog .vbtn { padding: 5px 7px; font-size: 12px; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .odg { grid-template-columns: 1fr; }
  .ob-row { grid-template-columns: 20px 1fr 90px 85px 20px; }
}

/* ── Mobile (≤600px) ──────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --header-h: 48px; }

  .site-footer { display: none; }
  .header { padding: 0 8px; gap: 4px; }
  .menu-toggle { display: flex !important; }
  .hdr-btns { gap: 3px; }
  .hdr-btns .btn { padding: 5px 7px; font-size: 12px; }
  .hdr-btn-export,
  .hdr-btn-customers { display: none; }

  /* Push content above bottom nav */
  .main-inner { padding-bottom: 70px; }

  /* Detail panel above bottom nav */
  .dp { bottom: 58px !important; }

  .wo-card { padding: 10px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 12px 12px 0 0;
    max-height: 90vh;
    width: 100%;
    max-width: 100%;
  }

  .kanban { padding-bottom: 12px; }
  .kb-col { width: 195px; }

  .lr-cop { display: none; }
  .lr-right { flex-direction: column; gap: 3px; align-items: flex-end; }

  .dp-acts .btn { min-height: 40px; }
  .op-row-hdr { padding: 10px; min-height: 44px; }
  .or-name { font-size: 15px; }
  .ms-inp { width: 48px; padding: 6px; font-size: 15px; }
  .op-st-row { gap: 4px; flex-wrap: wrap; }
  .op-st-row .btn { min-height: 36px; flex: 1; justify-content: center; font-size: 12px; }

  .admin-two-col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Menu toggle (desktop: hidden) ───────────────────────────────────────── */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg3);
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle:active { background: var(--bg4); }

/* ── Bottom nav ───────────────────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  z-index: 45;
  padding: 5px 0 max(5px, env(safe-area-inset-bottom));
}
@media (max-width: 600px) {
  .bottom-nav { display: flex; }
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: .04em;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  justify-content: center;
}
.bn-item.active { color: var(--amber); }
.bn-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.bn-item.active svg { stroke: var(--amber); }

/* ── Touch improvements ───────────────────────────────────────────────────── */
@media (hover: none) {
  .nav-item { padding: 10px 14px; min-height: 44px; }
  .btn { min-height: 36px; }
  .btn.sm { min-height: 32px; }
  .btn.xs { min-height: 28px; }
  .wo-card { -webkit-tap-highlight-color: transparent; }
  .preset-btn { padding: 8px 12px; font-size: 14px; min-height: 40px; }
  .wo-card:hover { border-color: var(--border); }
  .nav-item:hover { background: transparent; color: var(--muted); }
  .nav-item.active:hover { background: var(--amber-bg); color: var(--amber-t); }
}

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
  .header, .sidebar, .toolbar, .bottom-nav,
  .menu-toggle, .sidebar-backdrop { display: none !important; }
  .app { height: auto; overflow: visible; }
  .body { overflow: visible; height: auto; }
  .main-wrap, .main { overflow: visible; }
  .dp { position: static !important; width: 100% !important; bottom: auto !important; }
}
