/* Мобильная адаптация для экранов до 768px */
@media (max-width: 768px) {
  /* === ОБЩИЕ СТИЛИ === */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  body {
    font-size: 14px;
    overflow-x: hidden;
  }
  
  /* Увеличиваем размер шрифта для полей ввода (предотвращает зум на iOS) */
  input, select, textarea, button {
    font-size: 16px !important;
    min-height: 44px !important;
  }
  
  /* === ШАПКА САЙТА === */
  header {
    padding: 8px 12px !important;
    min-height: auto !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  header > div:first-child {
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    justify-content: center !important;
  }
  
  /* Логотип и название */
  header img {
    height: 32px !important;
  }
  
  header h1 {
    font-size: 1.1rem !important;
  }
  
  /* Кнопки меню - делаем компактнее */
  header button {
    padding: 6px 10px !important;
    font-size: 0.8rem !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  
  /* Информация о пользователе */
  header > div:last-child {
    width: 100% !important;
    justify-content: space-between !important;
    padding-top: 8px !important;
    border-top: 1px solid rgba(255,255,255,0.2) !important;
  }
  
  /* === СТРАНИЦА КОНТРОЛЛЕРОВ === */
  
  /* Вкладки */
  div[style*="border-bottom: 2px solid"] {
    flex-direction: column !important;
    gap: 8px !important;
  }
  
  div[style*="border-bottom: 2px solid"] button {
    width: 100% !important;
    padding: 12px !important;
  }
  
  /* Таблица контроллеров - превращаем в карточки */
  table {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
  }
  
  thead {
    display: none !important;
  }
  
  tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  tbody tr {
    display: block !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    padding: 16px !important;
    border: 1px solid #e0e0e0 !important;
    margin-bottom: 0 !important;
  }
  
  tbody td {
    display: block !important;
    text-align: left !important;
    padding: 6px 0 !important;
    border: none !important;
    font-size: 0.95rem !important;
  }
  
  /* Первая ячейка (SN) - делаем заголовком */
  tbody td:first-child {
    font-weight: bold !important;
    font-size: 1.1rem !important;
    color: #1a237e !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #eee !important;
    margin-bottom: 8px !important;
  }
  
  /* Последняя ячейка (Действия) - выравниваем по правому краю */
  tbody td:last-child {
    text-align: right !important;
    padding-top: 12px !important;
    border-top: 1px solid #eee !important;
    margin-top: 8px !important;
  }
  
  /* === ФОРМЫ ВВОДА === */
  
  /* Все grid-контейнеры с 2 колонками - делаем в 1 колонку */
  div[style*="gridTemplateColumns: '1fr 1fr'"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  /* Формы с 3 колонками - тоже в 1 колонку */
  div[style*="gridTemplateColumns: '1fr 1fr 1fr'"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  /* Поля ввода - на всю ширину */
  input, select {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Кнопки - на всю ширину */
  button {
    width: 100% !important;
    margin-top: 8px !important;
  }
  
  /* === КАРТА === */
  
  /* Контейнер карты - на всю ширину */
  .leaflet-container {
    height: 60vh !important;
    min-height: 400px !important;
  }
  
  /* Попап на карте */
  .leaflet-popup-content {
    margin: 12px !important;
    font-size: 14px !important;
  }
  
  /* === МОДАЛЬНЫЕ ОКНА === */
  
  div[style*="position: 'fixed'"] {
    padding: 16px !important;
  }
  
  div[style*="maxWidth: '800px'"] {
    width: 95% !important;
    max-width: 95% !important;
    padding: 16px !important;
  }
  
  /* === ПРОЧИЕ ЭЛЕМЕНТЫ === */
  
  /* Заголовки */
  h1, h2, h3 {
    font-size: 1.3rem !important;
  }
  
  h4, h5, h6 {
    font-size: 1.1rem !important;
  }
  
  /* Отступы */
  div[style*="padding: '24px'"] {
    padding: 16px !important;
  }
  
  div[style*="marginBottom: '24px'"] {
    margin-bottom: 16px !important;
  }
}

/* Очень маленькие экраны (до 480px) */
@media (max-width: 480px) {
  header button {
    font-size: 0.75rem !important;
    padding: 5px 8px !important;
  }
  
  tbody td:first-child {
    font-size: 1rem !important;
  }
}

/* Планшеты (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  header button {
    font-size: 0.85rem !important;
    padding: 7px 12px !important;
  }
}
