/* ============================================================
   MENZIL LOGISTICS — v4 FINAL
   - Гамбургер кликабельный
   - Скрыть Войти/Регистрация после входа
   - Меньше шрифты в синих карточках
   ============================================================ */

@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    background: #0a0f1c !important;
    color: #f1f5f9 !important;
  }

  body {
    margin: 0 !important;
    padding: 0 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
  }

  .container, .main-container, main {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* ============================================
     1. ГАМБУРГЕР - КЛИКАБЕЛЬНЫЙ (z-index ВЫСОКИЙ!)
     ============================================ */
  .hamburger-btn,
  .menu-btn,
  [class*="hamburger"],
  button[onclick*="toggleMenu"],
  button[onclick*="toggleSidebar"] {
    position: fixed !important;
    top: 8px !important;
    left: 8px !important;
    z-index: 99999 !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 18px !important;
    border-radius: 10px !important;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ============================================
     2. ШАПКА - сдвинута вправо чтобы не мешать гамбургеру
     ============================================ */
  header, .header, body > .navbar, body > .top-bar {
    padding: 4px 10px 4px 58px !important;
    min-height: 50px !important;
    position: relative !important;
  }

  /* Логотип уменьшаем */
  header img[src*="logo"],
  header img[src*="menzil"],
  header img[alt*="MENZIL"],
  .logo img {
    max-width: 28px !important;
    max-height: 28px !important;
    width: 28px !important;
    height: 28px !important;
  }

  header [class*="brand"],
  header [class*="logo-text"],
  header h1 {
    font-size: 10px !important;
    line-height: 1.1 !important;
    letter-spacing: 0.5px !important;
    margin: 0 !important;
    font-weight: 700 !important;
  }

  header [class*="tagline"],
  header [class*="subtitle"] {
    font-size: 6px !important;
    line-height: 1 !important;
    letter-spacing: 1px !important;
    opacity: 0.55 !important;
  }

  /* ============================================
     3. КНОПКИ ВОЙТИ / РЕГИСТРАЦИЯ
     Видны ТОЛЬКО на гостевой главной (#page-home)
     ============================================ */
  /* По умолчанию скрываем */
  .btn-ghost,
  .auth-buttons,
  [class*="auth-btn"],
  header .login-btn,
  header .register-btn,
  header button[onclick*="showPage('login')"],
  header button[onclick*="showPage('register')"] {
    display: none !important;
  }

  /* Показываем только когда активна гостевая главная */
  body:has(#page-home.active) .btn-ghost,
  body:has(#page-home[style*="display: block"]) .btn-ghost,
  body:has(#page-home:not([style*="display: none"])) .btn-ghost,
  body:has(#page-home.active) header button[onclick*="login"],
  body:has(#page-home.active) header button[onclick*="register"] {
    display: inline-flex !important;
  }

  /* Также скрываем когда активна страница склада/админа/клиента */
  body:has(#page-warehouse.active) .btn-ghost,
  body:has(#page-admin.active) .btn-ghost,
  body:has(#page-client.active) .btn-ghost,
  body:has(#page-warehouse:not([style*="display: none"])) header [class*="login"],
  body:has(#page-warehouse:not([style*="display: none"])) header [class*="register"] {
    display: none !important;
  }

  /* ============================================
     4. БОКОВОЕ МЕНЮ
     ============================================ */
  .sidebar {
    z-index: 99998 !important;
  }

  .sidebar .sidebar-link {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 11px 14px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  .sidebar .sidebar-icon,
  .sidebar-link > span:first-child {
    font-size: 16px !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    width: 22px !important;
    text-align: center !important;
  }

  /* Скрываем повторные иконки */
  .sidebar-link [data-hidden-duplicate="true"],
  .sidebar-link span[data-emoji-added="true"]:not(:first-child),
  .sidebar-link > *:nth-child(n+3):not(:last-child) {
    display: none !important;
  }

  .sidebar .logo,
  .sidebar > div:first-child {
    padding: 14px !important;
    font-size: 13px !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1) !important;
  }

  .sidebar .lang-btn,
  .sidebar [class*="lang"] button {
    padding: 6px 10px !important;
    font-size: 11px !important;
    height: 32px !important;
    border-radius: 8px !important;
  }

  /* ============================================
     5. ВКЛАДКИ СКЛАДА
     ============================================ */
  [id^="wh-tab-"] {
    padding: 0 !important;
    background: transparent !important;
  }

  /* Заголовки H1 */
  [id^="wh-tab-"] h1,
  [id^="wh-tab-"] .dashboard-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    margin: 10px 12px 3px !important;
    padding: 0 !important;
    color: #f1f5f9 !important;
  }

  [id^="wh-tab-"] h1 + p,
  [id^="wh-tab-"] .dashboard-subtitle {
    font-size: 11px !important;
    color: #94a3b8 !important;
    margin: 0 12px 10px !important;
    line-height: 1.3 !important;
  }

  /* ============================================
     6. ТЁМНЫЕ ИНФО-КАРТОЧКИ
     ============================================ */
  [id^="wh-tab-"] [class*="info-card"]:not([class*="blue"]) {
    padding: 11px !important;
    margin: 7px 12px !important;
    border-radius: 12px !important;
    background: #1a2440 !important;
    border: 1px solid rgba(148, 163, 184, 0.08) !important;
  }

  [id^="wh-tab-"] [class*="info-card"]:not([class*="blue"]) h2,
  [id^="wh-tab-"] [class*="info-card"]:not([class*="blue"]) h3 {
    font-size: 13px !important;
    margin: 0 0 3px !important;
    line-height: 1.25 !important;
  }

  [id^="wh-tab-"] [class*="info-card"]:not([class*="blue"]) p {
    font-size: 10px !important;
    line-height: 1.35 !important;
    margin: 0 0 6px !important;
    color: #94a3b8 !important;
  }

  /* "Приём в Пекине" / Туркменистане - кнопка */
  [id^="wh-tab-"] button[onclick*="setLocation"] {
    padding: 9px 12px !important;
    font-size: 12px !important;
    height: 38px !important;
    border-radius: 10px !important;
    margin: 7px 12px !important;
    background: rgba(26, 36, 64, 0.7) !important;
    border: 1px solid rgba(148, 163, 184, 0.15) !important;
    color: #f1f5f9 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
  }

  /* ============================================
     7. СИНИЕ КАРТОЧКИ — УМЕНЬШИТЬ ВСЕ ТЕКСТЫ
     ============================================ */
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#2563eb"],
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#1e40af"],
  [id^="wh-tab-"] [style*="linear-gradient"][style*="3b82f6"],
  [id^="wh-tab-"] [style*="background"][style*="#2563eb"],
  [id^="wh-tab-"] [style*="background"][style*="#3b82f6"],
  [id^="wh-tab-"] .blue-card {
    padding: 12px 11px !important;
    border-radius: 14px !important;
    margin: 8px 12px !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22) !important;
  }

  /* ВАЖНО: Заголовок в синей карточке - МНОГО МЕНЬШЕ */
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#2563eb"] h2,
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#2563eb"] h3,
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#1e40af"] h2,
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#1e40af"] h3,
  [id^="wh-tab-"] [style*="linear-gradient"][style*="3b82f6"] h3,
  [id^="wh-tab-"] [style*="background"][style*="#2563eb"] h3,
  [id^="wh-tab-"] [style*="background"][style*="#3b82f6"] h3 {
    font-size: 14px !important;
    line-height: 1.2 !important;
    font-weight: 700 !important;
    margin: 0 0 4px !important;
    color: #fff !important;
  }

  /* Описание в синей карточке */
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#2563eb"] p,
  [id^="wh-tab-"] [style*="linear-gradient"][style*="#1e40af"] p,
  [id^="wh-tab-"] [style*="linear-gradient"][style*="3b82f6"] p,
  [id^="wh-tab-"] [style*="background"][style*="#2563eb"] p {
    font-size: 10px !important;
    line-height: 1.35 !important;
    margin: 0 0 8px !important;
    color: rgba(255,255,255,0.82) !important;
  }

  /* ============================================
     8. ФЛЕКС-РЯД с полем + кнопкой + камерой
     ============================================ */
  [id^="wh-tab-"] [style*="display"][style*="flex"][style*="gap"] {
    display: flex !important;
    align-items: stretch !important;
    gap: 6px !important;
  }

  /* СКРЫТЬ ПУСТЫЕ КНОПКИ */
  [id^="wh-tab-"] button:empty:not([type="submit"]),
  [id^="wh-tab-"] [role="button"]:empty,
  [id^="wh-tab-"] [style*="display"][style*="flex"] > button:empty,
  [id^="wh-tab-"] [style*="display"][style*="flex"] > div:empty,
  [id^="wh-tab-"] [style*="display"][style*="flex"] > [style*="background"][style*="rgba(255"]:empty {
    display: none !important;
    width: 0 !important;
  }

  /* ============================================
     9. КНОПКА КАМЕРЫ - меньше
     ============================================ */
  button[onclick*="openCameraScanner"],
  button[onclick*="openCamera"],
  button[onclick*="scanBarcode"],
  button[onclick*="cameraScan"] {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    flex: 0 0 42px !important;
    padding: 0 !important;
    font-size: 18px !important;
    border-radius: 10px !important;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ============================================
     10. КНОПКИ ДЕЙСТВИЙ - компактные
     ============================================ */
  button[onclick*="markPackageArrived"],
  button[onclick*="markArrived"],
  button[onclick*="addPackageToShipment"],
  button[onclick*="addToShipment"],
  button[onclick*="searchPackage"],
  button[onclick*="searchByBarcode"],
  button[onclick*="findPackage"] {
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
    background: rgba(0,0,0,0.55) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    flex: 1 1 auto !important;
  }

  /* ============================================
     11. ПОЛЯ ВВОДА
     ============================================ */
  [id^="wh-tab-"] input[type="text"],
  [id^="wh-tab-"] input[type="number"],
  [id^="wh-tab-"] input[type="tel"],
  [id^="wh-tab-"] input[type="email"],
  [id^="wh-tab-"] select,
  [id^="wh-tab-"] .form-input {
    height: 42px !important;
    padding: 9px 12px !important;
    font-size: 13px !important;
    border-radius: 10px !important;
    background: rgba(0,0,0,0.45) !important;
    border: 1.5px solid rgba(148, 163, 184, 0.18) !important;
    color: #f1f5f9 !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  /* Поля штрих-кода */
  #wh-external-tracking,
  #wh-external-tracking-card,
  #wh-shipment-scan-input,
  #wh-barcode-search,
  #wh-arrival-input,
  input.scanner-input,
  input[placeholder*="штрих"],
  input[placeholder*="ML-2026"],
  input[placeholder*="Штрих"] {
    color: #00ff88 !important;
    font-family: 'Courier New', monospace !important;
    font-weight: 700 !important;
    letter-spacing: 1px !important;
    font-size: 12px !important;
  }

  /* ============================================
     12. КАРТОЧКИ СКЛАДОВ - одна строка
     ============================================ */
  #wh-tab-inventory > div:has(> button),
  #wh-tab-inventory [class*="warehouse-tabs"],
  [id^="wh-tab-"] [style*="grid-template-columns: 1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin: 8px 12px !important;
    padding: 0 !important;
  }

  #wh-tab-inventory > div > button,
  #wh-tab-inventory [class*="warehouse-tab"],
  button[onclick*="setWarehouseFilter"],
  button[onclick*="filterByWarehouse"] {
    padding: 10px 6px !important;
    background: #1a2440 !important;
    border-radius: 12px !important;
    border: 1.5px solid rgba(148, 163, 184, 0.1) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #f1f5f9 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    cursor: pointer !important;
    min-height: 46px !important;
    max-height: 52px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
  }

  #wh-tab-inventory button.active {
    background: linear-gradient(135deg, #1e40af, #1e3a8a) !important;
    border-color: #3b82f6 !important;
    color: #fff !important;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35) !important;
  }

  /* ============================================
     13. КОД КЛИЕНТА секция
     ============================================ */
  [id^="wh-tab-"] [class*="client-section"],
  [id^="wh-tab-"] > div:has(input[id*="client"]) {
    padding: 11px !important;
    margin: 7px 12px !important;
    border-radius: 12px !important;
  }

  /* Заголовок "👤 Код клиента" */
  [id^="wh-tab-"] [class*="client-section"] h3,
  [id^="wh-tab-"] [class*="client-title"] {
    font-size: 13px !important;
    margin: 0 0 3px !important;
  }

  /* Подсказка "(необязательно...)" */
  [id^="wh-tab-"] [class*="client-section"] p,
  [id^="wh-tab-"] [class*="client-hint"],
  [id^="wh-tab-"] label small {
    font-size: 10px !important;
    line-height: 1.3 !important;
    color: #94a3b8 !important;
    margin: 0 0 6px !important;
  }

  /* ============================================
     14. ФОТО ТОВАРА
     ============================================ */
  [id^="wh-tab-"] [style*="border"][style*="dashed"],
  [id^="wh-tab-"] [class*="photo-upload"] {
    padding: 9px 11px !important;
    min-height: 56px !important;
    max-height: 66px !important;
    border-radius: 12px !important;
    border: 2px dashed rgba(148, 163, 184, 0.22) !important;
    background: rgba(255,255,255,0.02) !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    cursor: pointer !important;
    margin-bottom: 5px !important;
  }

  [id^="wh-tab-"] [style*="border"][style*="dashed"] img,
  [id^="wh-tab-"] [style*="border"][style*="dashed"] [style*="font-size: 40"],
  [id^="wh-tab-"] [style*="border"][style*="dashed"] [style*="font-size:40"],
  [id^="wh-tab-"] [style*="border"][style*="dashed"] [style*="font-size: 48"],
  [id^="wh-tab-"] [style*="border"][style*="dashed"] [style*="font-size:48"] {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    font-size: 20px !important;
    margin: 0 !important;
    flex: 0 0 24px !important;
  }

  [id^="wh-tab-"] [style*="border"][style*="dashed"] span,
  [id^="wh-tab-"] [style*="border"][style*="dashed"] > div:not(:has(img)),
  [id^="wh-tab-"] [style*="border"][style*="dashed"] p {
    font-size: 10px !important;
    color: #94a3b8 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    text-align: left !important;
    font-weight: 500 !important;
  }

  /* ============================================
     15. РАЗМЕРЫ
     ============================================ */
  [id^="wh-tab-"] [style*="grid-template-columns: 1fr 1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 5px !important;
    margin-bottom: 7px !important;
  }

  [id^="wh-tab-"] input[id*="length"],
  [id^="wh-tab-"] input[id*="width"],
  [id^="wh-tab-"] input[id*="height"] {
    text-align: center !important;
    padding: 7px 4px !important;
    font-size: 12px !important;
    height: 38px !important;
  }

  /* ============================================
     16. РЕЗУЛЬТАТ + ГЛАВНАЯ КНОПКА
     ============================================ */
  [id^="wh-tab-"] [id*="total-amount"],
  [id^="wh-tab-"] [class*="amount-display"] {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05)) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    border-radius: 12px !important;
    padding: 11px !important;
    margin: 9px 12px !important;
    text-align: center !important;
  }

  [id^="wh-tab-"] button[type="submit"] {
    width: calc(100% - 24px) !important;
    padding: 12px 16px !important;
    margin: 10px 12px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    height: 46px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35) !important;
    letter-spacing: 0.4px !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
  }

  /* ============================================
     17. ПОЛЕ КОЛИЧЕСТВО
     ============================================ */
  .cargo-pieces-field {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.05)) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    border-radius: 12px !important;
    padding: 9px !important;
    margin: 9px 0 !important;
  }

  .cargo-pieces-field input {
    font-size: 16px !important;
    font-weight: 800 !important;
    text-align: center !important;
    color: #60a5fa !important;
    height: 42px !important;
  }

  /* ============================================
     18. БЕЙДЖИ СТАТУСОВ
     ============================================ */
  [class*="status"][class*="badge"],
  [style*="background"][style*="amber"],
  [style*="background"][style*="warning"] {
    display: inline-block !important;
    padding: 4px 8px !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  /* ============================================
     19. АНИМАЦИИ
     ============================================ */
  @keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  [id^="wh-tab-"] .card,
  [id^="wh-tab-"] [class*="package-card"] {
    animation: fadeInUp 0.25s ease !important;
  }

  .barcode-filled {
    background: rgba(0, 255, 136, 0.15) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3) !important;
  }
}

/* Маленькие экраны */
@media (max-width: 380px) {
  [id^="wh-tab-"] h1 { font-size: 17px !important; }
  button[onclick*="openCameraScanner"] {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    flex: 0 0 38px !important;
  }
  
  #wh-tab-inventory > div > button {
    font-size: 10px !important;
    padding: 8px 4px !important;
  }
}
