/* Spaif Dex — мобильный вид кабинета, срез 1 (пакет dex-mobilnaya, 30.09.2026).
   Работает ТОЛЬКО когда на <html> стоит класс dexm (его ставит dexm.js: выключатель
   включён, ширина экрана < 1024, открыт кабинет /crm или /lk). На компьютере класса
   нет и ни одно правило ниже не срабатывает. Логика денег, записи и прав не меняется —
   только раскладка экранов на телефоне. */
@media (max-width: 1023.98px) {

  /* ── Поля ввода 16 px: iPhone не приближает страницу при вводе ── */
  html.dexm input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),
  html.dexm select,
  html.dexm textarea { font-size: 16px !important; }

  /* ── Плашка экосистемы (Spaif Dex / AI / Касса / токены / язык): одна строка ── */
  html.dexm main > div.pt-4:has(> .shell-card) { padding-top: 8px !important; }
  html.dexm main > div.pt-4 > .shell-card.flex-wrap {
    flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden;
    padding-top: 4px !important; padding-bottom: 4px !important;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  html.dexm main > div.pt-4 > .shell-card.flex-wrap::-webkit-scrollbar { display: none; }
  html.dexm main > div.pt-4 > .shell-card.flex-wrap > * { flex-shrink: 0; }
  /* Кнопка ☰ в плашке больше не нужна: всё меню открывает «Меню» в нижней панели. */
  html.dexm main > div.pt-4 > .shell-card > button.iconbtn:first-child { display: none !important; }

  /* ── Шапка календаря: дата + значки в одну строку, кнопки — одной лентой ── */
  html.dexm header.relative:has([data-tour="new-booking"]) { margin-top: 8px !important; }
  html.dexm header.relative:has([data-tour="new-booking"]) > .shell-card {
    padding: 10px 12px !important;
  }
  html.dexm header.relative:has([data-tour="new-booking"]) > .shell-card > div { row-gap: 8px !important; }
  html.dexm header.relative:has([data-tour="new-booking"]) > .shell-card > div > .order-3 { order: 1 !important; }
  html.dexm header.relative:has([data-tour="new-booking"]) > .shell-card > div > .order-2 { order: 2 !important; }
  /* лента кнопок: главное (‹ Сегодня › + Запись) первым, остальное — прокруткой вбок */
  html.dexm div:has(> [data-tour="new-booking"]) {
    flex-wrap: nowrap !important; justify-content: flex-start !important;
    overflow-x: auto; overflow-y: hidden; gap: 6px !important;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  html.dexm div:has(> [data-tour="new-booking"])::-webkit-scrollbar { display: none; }
  html.dexm div:has(> [data-tour="new-booking"]) > * { flex-shrink: 0; }
  html.dexm div:has(> [data-tour="new-booking"]) > button:has(> svg.lucide-chevron-left) { order: -4; }
  html.dexm div:has(> [data-tour="new-booking"]) > button[title^="Сегодня"] { order: -3; }
  html.dexm div:has(> [data-tour="new-booking"]) > button:has(> svg.lucide-chevron-right) { order: -2; }
  html.dexm div:has(> [data-tour="new-booking"]) > [data-tour="new-booking"] { order: -1; }
  /* выпадашки «масштаб» и «часы» внутри ленты: не обрезаются прокруткой */
  html.dexm div:has(> [data-tour="new-booking"]) > div.relative { position: static !important; }
  html.dexm div:has(> [data-tour="new-booking"]) > div.relative > .absolute { right: 12px !important; }
  /* обёртка ленты: во всю ширину, без переноса */
  html.dexm div:has(> div:has(> [data-tour="new-booking"])) { flex-wrap: nowrap !important; }

  /* ── Плитки дня (Оборот, Выручка, Записей …): одна строка с прокруткой вбок ── */
  html.dexm .daystrip-a {
    display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; gap: 8px !important;
    margin-bottom: 8px !important; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  html.dexm .daystrip-a::-webkit-scrollbar { display: none; }
  html.dexm .daystrip-a > * { flex: 0 0 auto !important; min-width: 118px; padding-top: 8px !important; padding-bottom: 8px !important; }
  html.dexm .daystrip-a .daystrip-a__note { display: none !important; }

  /* ── Фильтр мастеров (чипы): одна строка с прокруткой вбок ── */
  html.dexm .card:has(> .flex > .chip) { margin-bottom: 8px !important; }
  html.dexm .card > .flex.flex-wrap:has(> .chip) {
    flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  html.dexm .card > .flex.flex-wrap:has(> .chip)::-webkit-scrollbar { display: none; }
  html.dexm .card > .flex.flex-wrap:has(> .chip) > * { flex-shrink: 0; }
  html.dexm .chip { min-height: 36px; }

  /* страница календаря/разделов: меньше пустых полей сверху */
  html.dexm main .pt-4.pb-8 { padding-top: 8px !important; }

  /* ── Окна (новая запись, карточка записи, оплата, выбор даты): лист снизу ── */
  html.dexm .fixed.inset-0.grid.place-items-center {
    place-items: end stretch !important; padding: 0 !important;
  }
  html.dexm .fixed.inset-0.grid.place-items-center > .card {
    max-width: none !important; width: 100% !important;
    max-height: 92dvh !important; border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important;
    border-top-left-radius: 20px !important; border-top-right-radius: 20px !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  html.dexm .fixed.inset-0.flex.items-center.justify-center {
    align-items: flex-end !important; padding: 0 !important;
  }
  html.dexm .fixed.inset-0.flex.items-center.justify-center > * {
    max-width: none !important; width: 100% !important; max-height: 92dvh !important;
    border-bottom-left-radius: 0 !important; border-bottom-right-radius: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* ── Нижняя панель: «Ещё» становится «Меню» (открывает полное меню разделов) ── */
  html.dexm nav.fixed.bottom-0 { padding-bottom: env(safe-area-inset-bottom, 0px); }
  html.dexm nav.fixed.bottom-0 > a,
  html.dexm nav.fixed.bottom-0 > button { min-height: 56px; }
  html.dexm nav.fixed.bottom-0 > button:last-child > span { font-size: 0 !important; }
  html.dexm nav.fixed.bottom-0 > button:last-child > span::after { content: "Меню"; font-size: 10px; }

  /* ── Выдвижное меню разделов: строки от 44 точек ── */
  html.dexm aside.fixed.inset-y-0 a,
  html.dexm .fixed.inset-y-0.left-0 a,
  html.dexm .fixed.inset-y-0.left-0 nav button { min-height: 44px; }

  /* ── Робот Spaif AI: без всплывашки, не поверх окон и меню ── */
  html.dexm .fixed.bottom-24.right-5.max-w-\[280px\] { display: none !important; }
  html.dexm button.fixed.bottom-20.right-3 { z-index: 45 !important; }
  html.dexm body:has(.fixed.inset-0.z-50) button.fixed.bottom-20.right-3,
  html.dexm body:has(.fixed.inset-0.z-\[60\]) button.fixed.bottom-20.right-3,
  html.dexm body:has(.fixed.inset-0.z-\[80\]) button.fixed.bottom-20.right-3,
  html.dexm body:has(.fixed.inset-0.z-40) button.fixed.bottom-20.right-3 { display: none !important; }
}
