/* mobile-v1.css — мобильная версия CRM: страницы, модальные окна, вход, выбор магазина */
:root{--m-bar:84px}
@media(max-width:768px){
  html{-webkit-text-size-adjust:100%}
  body{overflow-x:hidden}
  /* поля 16px — iOS не увеличивает страницу при фокусе */
  input:not([type=checkbox]):not([type=radio]),select,textarea,.form-control{font-size:16px!important}
  .form-control,select.form-control{min-height:44px}
  .btn{min-height:42px}
  .btn-sm{min-height:38px}
  .content{padding:12px 12px calc(var(--m-bar) + env(safe-area-inset-bottom))!important}
  /* карточки и заголовки */
  .card{border-radius:16px}
  .card-header{flex-wrap:wrap;gap:8px;padding:12px 14px!important}
  .card-body{padding:14px!important}
  .page-head,.page-header,.ph{flex-wrap:wrap;gap:10px}
  .page-head .btn,.page-header .btn{flex:1 1 auto}
  /* сетки в одну колонку */
  .stats{grid-template-columns:1fr 1fr!important;gap:10px!important}
  .form-row,.form-grid,.mdl-form-row,.grid-2,.grid-3,.row-2{grid-template-columns:1fr!important}
  /* таблицы — горизонтальная прокрутка, шапка не прыгает */
  .tbl-wrap{overflow-x:auto!important;-webkit-overflow-scrolling:touch;border-radius:14px}
  .tbl-wrap table{width:max-content;min-width:100%}
  .tbl-wrap th,.tbl-wrap td{white-space:nowrap}
  td .btn,td .btn-sm{min-height:34px}
  /* модальные окна — нижние шторки */
  .overlay{align-items:flex-end!important;padding:0!important}
  .overlay .modal,.overlay .modal-sm,.overlay .modal-lg{width:100vw!important;max-width:100vw!important;margin:0!important;max-height:92dvh!important;border-radius:20px 20px 0 0!important;display:flex;flex-direction:column;overflow:hidden}
  .overlay .modal-head{flex:0 0 auto;padding:14px 16px!important}
  .overlay .modal-body{flex:1 1 auto;min-height:0;overflow-y:auto!important;-webkit-overflow-scrolling:touch;padding:14px 16px!important}
  .overlay .modal-footer{flex:0 0 auto;padding:12px 16px calc(12px + env(safe-area-inset-bottom))!important;gap:8px;display:flex}
  .overlay .modal-footer .btn{flex:1;justify-content:center;height:46px}
  .overlay .modal-close{width:40px;height:40px}
  /* панель фильтров — шторка */
  .is-filter-drawer{left:0!important;right:0!important;top:auto!important;bottom:0!important;width:100%!important;max-height:90dvh;border-radius:22px 22px 0 0!important}

  /* ---- новые страницы ---- */
  .v3-hero{padding:16px!important;border-radius:18px!important;flex-direction:column;align-items:flex-start;gap:12px}
  .v3-hero h2,.v3-hero h1{font-size:1.2rem}
  .v3-hero-actions{width:100%;display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .v3-hero-actions .btn{justify-content:center}
  .v3-chips{overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}
  .v3-chip{flex:0 0 auto}
  /* категории */
  body.page-categories .ct-row{flex-wrap:wrap;gap:8px}
  body.page-categories .ct-actions{width:100%;justify-content:flex-end}
  body.page-categories .ct-children{margin-left:12px}
  /* счета */
  body.page-invoices .inv-list{grid-template-columns:1fr!important}
  body.page-invoices .inv-card-h{flex-wrap:wrap;gap:8px}
  body.page-invoices .inv-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;width:100%}
  body.page-invoices .inv-files-grid{grid-template-columns:1fr 1fr!important}
  /* контрагенты */
  body.page-contractors .ctr-grid{grid-template-columns:1fr!important}
  body.page-contractors .ctr-item-top{flex-wrap:wrap}
  body.page-contractors .ctr-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;width:100%}
  /* ИП/ООО */
  body.page-ip_ooo .ipooo-dialog{width:100vw!important;max-width:100vw!important;max-height:94dvh!important;border-radius:20px 20px 0 0!important}
  body.page-ip_ooo .ipooo-steps{overflow-x:auto}
  /* сотрудники */
  body.page-members .tm-row{flex-wrap:wrap;gap:12px;padding:14px!important}
  body.page-members .tm-actions{width:100%;display:grid;grid-template-columns:1fr 1fr;gap:8px}
  body.page-members .perm-modal{max-width:100vw!important}
  /* в наличии / все товары */
  :is(body.page-in_stock,body.page-all_products,body.page-all-products) .tbl-wrap{max-height:none!important}
}
@media(max-width:420px){
  .stats{grid-template-columns:1fr!important}
  .v3-hero-actions{grid-template-columns:1fr}
}

/* ---- вход и регистрация ---- */
@media(max-width:560px){
  .auth-wrap{padding:16px!important;align-items:flex-start!important;padding-top:max(24px,env(safe-area-inset-top))!important}
  .auth-card{width:100%!important;max-width:100%!important;padding:24px 18px!important;border-radius:22px!important;margin-top:44px}
  .auth-tabs{margin-bottom:18px}
  .auth-tab{min-height:44px;display:flex;align-items:center;justify-content:center}
  .auth-card .btn-lg{height:50px;font-size:16px}
  .auth-card .form-control{height:48px}
  .theme-btn{top:max(12px,env(safe-area-inset-top))!important;right:12px!important}
}

/* ---- выбор магазина / портал ---- */
@media(max-width:700px){
  .portal-cards{max-width:100%!important;gap:16px!important}
  .portal-card{aspect-ratio:16/11!important;border-radius:22px!important}
  .portal-cta{left:12px!important;right:12px!important;bottom:12px!important;padding:13px 14px!important;font-size:14px!important}
  .portal-card:hover{transform:none!important}
  .shop-grid{display:grid!important;grid-template-columns:1fr!important}
  .shop-card{width:100%!important}
}
@media(hover:none){.portal-card:hover{transform:none}.btn:hover{transform:none}}
