/* ============================================================
   Мобильная версия (смартфоны, планшеты).
   Подключается только при ширине <= 820px ИЛИ на устройствах
   с грубым указателем (touch). Ничего не отменяет в style.css,
   только переопределяет под мобильный layout.
   ============================================================ */

html, body {
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 100%;
  padding: max(12px, env(safe-area-inset-top))
           max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom))
           max(12px, env(safe-area-inset-left));
  font-size: 15px;
}

h1 {
  font-size: 20px;
  margin-bottom: 12px;
}

section {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
}

h2 {
  font-size: 16px;
  margin: 0 0 10px 0;
}

/* Поля ввода делаем крупнее под палец */
input[type="text"], input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;   /* 16px — чтобы iOS не зумил при фокусе */
  min-width: 0;
  margin-left: 0;
}

/* Блок авторизации — в столбик */
.auth-row {
  flex-direction: column;
  gap: 10px;
}
.auth-field {
  flex: 1 1 auto;
  min-width: 0;
}

/* Строка загрузки — в столбик, крупные кнопки */
.upload-row {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.upload-row > * {
  width: 100%;
}
.upload-row .ttl-field {
  justify-content: space-between;
}
.ttl-field select {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 16px;
  padding: 10px 12px;
}

button {
  padding: 12px 16px;
  font-size: 16px;
  border-radius: 8px;
  min-height: 44px;   /* палец */
}

/* Карточка незавершённой загрузки — в столбик */
.resume-row {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.resume-row-actions {
  justify-content: stretch;
}
.resume-row-actions button {
  flex: 1 1 auto;
}

/* Панели — всегда в столбик */
.panels {
  grid-template-columns: 1fr !important;
}

/* Заголовок панели с кнопкой «Скачать все» — в столбик */
.panel-head {
  flex-direction: column;
  align-items: stretch;
}
.panel-head .download-all {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
}

/* Таблицы превращаем в карточки */
.files-table { font-size: 14px; }
.files-table thead { display: none; }
.files-table colgroup { display: none; }

.files-table,
.files-table tbody,
.files-table tr,
.files-table td {
  display: block;
  width: 100%;
}

.files-table tbody tr {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid #eef0f3;
  border-radius: 8px;
  background: #fafbfc;
}
.files-table tbody tr:last-child { margin-bottom: 0; }
.files-table tbody tr:hover { background: #f5f9ff; }

.files-table tbody td {
  border: none;
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  overflow-wrap: anywhere;
}

.files-table tbody td::before {
  content: attr(data-label);
  color: #6b7280;
  font-size: 12px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.files-table td.cell-actions {
  display: block;
  padding-top: 8px;
}
.files-table td.cell-actions::before { display: none; }
.files-table td.cell-actions .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.files-table td.cell-actions .actions button {
  flex: 1 1 auto;
  min-width: 120px;
}

/* Карточка скачивания — компактнее */
.download-card {
  padding: 10px 12px;
}
.download-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.download-actions button {
  flex: 1 1 auto;
}

/* Модалки — почти на всю ширину, кнопки на всю ширину */
.modal-window,
.modal-window-wide {
  width: min(560px, 96vw);
  max-height: 92vh;
}
.modal-head h3 { font-size: 16px; }
.modal-foot {
  flex-direction: column-reverse;
  gap: 8px;
}
.modal-foot button {
  width: 100%;
}

.modal-input {
  font-size: 16px;
  padding: 12px 14px;
}

/* Панель sys — в столбик */
.sys-toolbar {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.sys-toolbar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sys-toolbar-actions button {
  width: 100%;
}

/* Поля параметров — в столбик */
.config-row {
  grid-template-columns: 1fr !important;
  gap: 4px;
}
.config-row input,
.config-row select {
  font-size: 16px;
  padding: 10px 12px;
}