/* ══════════════════════════════════════════
   MOBILE — адаптация для экранов < 768px
══════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── TOPBAR ───────────────────────────── */
  .tb-brand { margin-right: 0; margin-left: 2%; margin-top: -22px; }
  .tb-name  { font-size: 10px; letter-spacing: 2px; }

  .tb-stat, .tb-sep { display: none; }

  .tb-right { gap: 4px; margin-right: 10px; margin-top: -24px; }

  .tb-user-name { display: none; }
  .tb-user-role { display: none; }
  .tb-user-ava  { width: 24px; height: 24px; font-size: 9px; }

  .tb-bell-btn, .tb-msg-btn { width: 28px; height: 28px; font-size: 14px; }

  /* ── BOTNAV ───────────────────────────── */
  .botnav-img-desktop { display: none; }
  .botnav-img-mobile  { display: block; }

  .botnav-row {
    /* bottom_phone.png: 683×110px — inner zone x=65px, button-top y≈14px */
    left: calc(65 / 683 * 100%);
    right: calc(65 / 683 * 100%);
    gap: 0;
    align-items: flex-start;
    padding-top: calc(14 / 683 * 100%);
  }
  .nav-btn       { flex: 1; justify-content: center; }
  .nav-btn img   { width: 100%; height: auto; max-height: clamp(28px, 8vw, 48px); object-fit: contain; mix-blend-mode: multiply; }
  .nav-spacer    { display: none; }
  .nav-voice     { flex: 1; padding: 0 4px; font-size: 9px; letter-spacing: 0.5px; margin-right: 0; }

  /* ── STATUS STRIP ─────────────────────── */
  .ss-item { display: none; }
  .ss-dot  { display: none; }

  /* ── МОЙ ОТРЯД — вкладки ─────────────── */
  .mt-page { overflow: hidden; }

  .mt-page-hdr {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 10px;
  }

  /* 7 вкладок — горизонтальный скролл */
  .mt-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 3px;
    padding-bottom: 2px;
    width: 100%;
    flex-wrap: nowrap;
  }
  .mt-tabs::-webkit-scrollbar { display: none; }

  .mt-tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 9px;
    min-height: 30px;
  }

  /* Тело — вся оставшаяся высота */
  .mt-body { overflow-y: auto; overflow-x: hidden; }

  /* Профиль отряда — стек вместо трёх колонок */
  .mt-profile {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .mt-avatar-col { flex-direction: row; gap: 12px; }
  .mt-avatar { width: 56px; height: 56px; }
  .mt-avatar-letter { font-size: 22px; }

  .mt-info-col { width: 100%; }
  .mt-callsign { font-size: 18px; }

  .mt-stats-col {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
  }
  .mt-stat-item { flex: 1; min-width: 80px; }

  /* Кнопки редактирования */
  .mt-btn-create, .mt-btn-find { width: 100%; }
  .mt-btn-edit { width: 100%; margin-top: 8px; }

  /* Состав — участники в одну колонку */
  .mt-members-grid { grid-template-columns: 1fr !important; padding: 10px; }

  /* Модалы отряда */
  .mt-modal {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 90vh !important;
    overflow-y: auto;
  }

  /* Чат команды */
  .mt-chat { padding: 0; }
  .mt-chat-msgs { padding: 10px; }
  .mt-chat-input-row { padding: 8px 10px; }

  /* ── ЗАКАЗЫ ───────────────────────────── */
  .ob-list.ob-list-narrow { display: none; }

  .ob-detail {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-left: none;
  }

  .ob-toolbar { flex-wrap: wrap; padding: 8px 10px; gap: 6px; }
  .ob-search-wrap { flex: 1 1 100%; }
  .ob-filters { flex: 1 1 100%; flex-wrap: wrap; }
  .ob-select { flex: 1; min-width: 0; font-size: 11px; }

  .ob-page-hdr { padding: 8px 10px; }
  .ob-stats-row { flex-wrap: wrap; gap: 4px; }
  .ob-stat-chip { min-width: 48px; padding: 3px 8px; }
  .ob-page-hdr-left { gap: 8px; }
  .ob-page-title { font-size: 11px; letter-spacing: 2px; }

  /* Вкладки в детали заказа */
  .od-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 2px;
  }
  .od-tabs::-webkit-scrollbar { display: none; }
  .od-tab { white-space: nowrap; flex-shrink: 0; padding: 5px 10px; font-size: 10px; }

  /* Файлы в заказе */
  .of-list { gap: 6px; }
  .of-item { padding: 7px 10px; gap: 8px; }
  .of-meta { display: none; }

  /* Документы */
  .od-docs-grid { grid-template-columns: 1fr !important; }

  /* ── KANBAN / WORKSPACE ───────────────── */
  .kb-page { flex-direction: column; }

  /* Сайдбар проектов — горизонтальная полоса сверху */
  .kb-sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    border-bottom: 1px solid var(--steel);
    padding: 8px;
    gap: 6px;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .kb-sidebar::-webkit-scrollbar { display: none; }

  .kb-sidebar-title { display: none; }

  .kb-project-item {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 12px;
    border-radius: 2px;
    min-width: 0;
  }

  .kb-new-project-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 12px;
    width: auto;
  }

  .kb-new-project-form { display: none; }

  /* Kanban-доска — горизонтальный скролл колонок */
  .kb-board {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding: 10px;
    gap: 10px;
    align-items: flex-start;
    scrollbar-width: thin;
    scrollbar-color: var(--steel) transparent;
  }

  .kb-col {
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    height: calc(100vh - 240px);
    overflow-y: auto;
  }

  /* Модалы задач — fullscreen */
  .kb-modal-overlay { align-items: flex-end; padding: 0; }
  .kb-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 92vh !important;
    border-radius: 12px 12px 0 0 !important;
    overflow-y: auto;
  }

  /* ── ОБЛАЧНЫЙ ДИСК ────────────────────── */
  .disk-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .disk-quota { max-width: 100%; }

  /* Навигационная панель */
  .disk-nav { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .disk-breadcrumb { flex: 1 1 100%; }
  .disk-nav-actions { width: 100%; justify-content: flex-end; }

  /* Таблица файлов — упрощаем колонки */
  .disk-table-header {
    grid-template-columns: 28px 1fr 70px 60px !important;
  }
  .disk-col-meta,
  .disk-col-date { display: none; }

  .disk-row {
    grid-template-columns: 28px 1fr 70px 60px !important;
  }
  .disk-row-meta,
  .disk-row-date { display: none; }

  .disk-row-name { font-size: 11px; }
  .disk-row-size { font-size: 9px; }

  /* Форма новой папки */
  .disk-new-folder { flex-wrap: wrap; gap: 6px; }
  .disk-folder-input { width: 100%; }

  /* ── УВЕДОМЛЕНИЯ ──────────────────────── */
  .notif-overlay { padding: 0; }
  .notif-popup {
    width: 100vw !important;
    max-height: 85vh !important;
    top: auto !important;
    right: 0 !important;
    left: 0 !important;
    bottom: 0;
    position: fixed !important;
    border-radius: 12px 12px 0 0;
  }

  /* ── МЕССЕНДЖЕР ───────────────────────── */
  .messenger-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* ── ПРОФИЛЬ ПОПАП ────────────────────── */
  .profile-popup {
    width: 100vw !important;
    max-width: 100vw !important;
    right: 0 !important;
    left: 0 !important;
  }

  /* ── КАТАЛОГ ──────────────────────────── */
  .cat-grid { grid-template-columns: 1fr; padding: 10px; }
  .cat-toolbar { flex-wrap: wrap; padding: 8px 10px; }
  .cat-search-wrap { flex: 1 1 100%; }

  .cat-modal-overlay .cat-modal-panel,
  .cat-modal-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  /* ── ОНБОРДИНГ ────────────────────────── */
  .ob-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    overflow-y: auto;
  }
  .ob-overlay { align-items: flex-end; }

  /* ── НАСТРОЙКИ ────────────────────────── */
  .settings-body { padding: 10px !important; }
  .settings-section { padding: 12px !important; }

  /* Форма настроек — лейблы сверху */
  .settings-row { flex-direction: column; gap: 4px; }
  .settings-label { width: 100% !important; }
  .settings-value { width: 100% !important; }

  /* ── ГОЛОСОВОЙ ЧАТ ────────────────────── */
  .voice-panel {
    width: 100vw !important;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
  }

  /* ── MAP TABS ─────────────────────────── */
  .map-tabs { left: 10px; right: 10px; transform: none; justify-content: center; }
  .map-tab  { font-size: 10px; letter-spacing: 1px; padding: 4px 10px; }

  /* ── LOGIN ────────────────────────────── */
  .lp-box {
    margin: 0;
    width: 100vw !important;
    max-width: 100vw !important;
    min-height: 100dvh;
    border-radius: 0;
  }
  .lp-tabs { gap: 4px; }
  .lp-tab  { font-size: 10px; padding: 5px 10px; }

  /* ── АДМИН ────────────────────────────── */
  .adm-grid { grid-template-columns: 1fr !important; }

  /* ── ПОПАПЫ / МОДАЛКИ (общее) ─────────── */
  .portal-root .popup-overlay > div,
  .portal-root [class*="-modal"],
  .portal-root [class*="-popup"] {
    width: 96vw !important;
    max-width: 96vw !important;
    max-height: 90vh !important;
    overflow-y: auto;
  }

  /* ── CRM СТРАНИЦА ─────────────────────── */
  .crm-kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .crm-table-wrap { overflow-x: auto; }

  /* ── АНАЛИТИКА ────────────────────────── */
  .analytics-grid { grid-template-columns: 1fr !important; }
}

/* ── Очень маленькие экраны (< 480px) ── */
@media (max-width: 480px) {
  .tb-clock { display: none; }
  .ob-stat-chip { display: none; }
  .ob-stats-row { display: none; }
  .nav-voice span { display: none; }

  /* Kanban — ещё уже */
  .kb-col { min-width: 240px; max-width: 240px; }

  /* Диск — кнопки */
  .disk-nav-btn { font-size: 9px; padding: 4px 8px; }

  /* MT-вкладки — совсем маленькие */
  .mt-tab { font-size: 8px; padding: 4px 7px; }

  /* CRM KPI */
  .crm-kpi-grid { grid-template-columns: 1fr !important; }
}
