/* DEC Web — телефон и планшет (WEB/MOBILE_DESIGN.md).
   Подключается <link media="(max-width: 1023px), (pointer: coarse)">, и КАЖДОЕ правило
   начинается с класса режима на <html> (mobile/early.js, mobile/env.js):
     .m-phone (< 600 px) · .m-tablet (600–1023 px) · .m-mobile (оба) · .m-touch (палец).
   На десктопе с мышью файл не применяется вовсе — его вёрстка не меняется ни на пиксель
   (сверка: tools/mobile_audit.py --desktop --baseline reports/mobile_audit/desktop-ref). */

html.m-mobile {
  --m-top-h: 52px;
  --m-nav-h: 58px;
  --m-safe-t: env(safe-area-inset-top, 0px);
  --m-safe-b: env(safe-area-inset-bottom, 0px);
  --m-tap: 44px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html.m-mobile body { height: 100dvh; -webkit-tap-highlight-color: transparent; }

/* ============================ сенсорный ввод (любая ширина) ============================ */
/* Поля мельче 16 px iOS зумит при фокусе — поднимаем всем полям ввода. */
html.m-touch input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
html.m-touch select,
html.m-touch textarea { font-size: 16px; }
html.m-touch .sub-tabs button,
html.m-touch .menu-btn,
html.m-touch .dt-toolbar button,
html.m-touch .module-toolbar button,
html.m-touch .btn-primary,
html.m-touch .btn-secondary,
html.m-touch .dialog-actions button { min-height: var(--m-tap); }
html.m-touch .sheet-tabs button,
html.m-touch .sheet-actions button,
html.m-touch .sheet-scroll { min-height: 40px; }
html.m-touch input[type="checkbox"], html.m-touch input[type="radio"] { width: 20px; height: 20px; }

/* Сенсор на десктопной раскладке (iPad в альбоме, 1024 px): меню шапки не влезает и на
   десктопе 1024 — переносим во вторую строку; рейка прокручивается, все разделы достижимы. */
html.m-touch:not(.m-mobile) .app-header { flex-wrap: wrap; row-gap: 2px; }
html.m-touch:not(.m-mobile) .menubar { flex-wrap: wrap; flex: 1 1 100%; order: 5; }
html.m-touch:not(.m-mobile) .header-user { order: 2; }
html.m-touch:not(.m-mobile) .nav-rail { overflow-y: auto; overscroll-behavior: contain; }
html.m-touch:not(.m-mobile) .nav-rail button { flex: none; }
/* Ступени плотности рейки (app.css, navRailFit.js) — для мыши: пальцу нужна крупная кнопка,
   поэтому на сенсоре всегда ступень 0 (значения — из app.css) и прокрутка. Полоса прокрутки
   не нужна — листают пальцем — и съедала бы ширину подписей. */
html.m-touch .nav-rail {
  --rail-pad: 8px; --rail-gap: 2px; --nav-pad: 6px; --nav-ico: 20px;
  --nav-label-gap: 3px; --nav-font: 9px; --nav-mark: 22px;
  scrollbar-width: none;
}
html.m-touch .nav-rail button small { display: block; }

/* ================================== планшет 600–1023 ================================== */
/* Шапка в две строки вместо обрезки; выпадающие меню остаются у своих пунктов. */
html.m-tablet .app-header { flex-wrap: wrap; row-gap: 2px; }
html.m-tablet .menubar { flex-wrap: wrap; flex: 1 1 100%; order: 5; }
html.m-tablet .header-user { order: 2; }
/* Рейка: все разделы достижимы — прокрутка по вертикали. */
html.m-tablet .nav-rail { overflow-y: auto; overscroll-behavior: contain; }
html.m-tablet .nav-rail button { flex: none; }
/* Схема: узкая панель атрибутов, холсту — остальное (библиотеку сворачивает app.js). */
html.m-tablet .attr-panel { width: 280px; }
/* Окна почти на весь экран. */
html.m-tablet dialog[open]:not(.busy-overlay) {
  max-width: calc(100vw - 16px) !important; min-width: 0 !important;
  max-height: calc(100dvh - 16px) !important;
}
html.m-tablet .search-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); resize: none; }
html.m-tablet .ru-modal-overlay > * { max-width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px) !important; }
html.m-tablet .auth-emergency { bottom: 64px; }

/* =================================== телефон < 600 =================================== */
/* Десктопная обвязка уходит: её заменяет оболочка mobile/shell.js. */
html.m-phone .app-header,
html.m-phone .nav-rail,
html.m-phone .sheet-bar,
html.m-phone .statusbar,
html.m-phone .auth-emergency,
html.m-phone #page-scheme .palette,
html.m-phone .scheme-minimap { display: none !important; }

/* --- верхняя строка --- */
html.m-phone .m-topbar {
  position: relative; z-index: 50; flex: none;
  display: flex; align-items: center; gap: 6px;
  min-height: calc(var(--m-top-h) + var(--m-safe-t));
  padding: var(--m-safe-t) 8px 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
html.m-phone .m-topbar[hidden], html.m-phone .m-bottomnav[hidden], html.m-phone .m-fabs[hidden] { display: none; }
html.m-phone .m-title {
  flex: 1 1 auto; min-width: 0; min-height: var(--m-tap);
  display: flex; align-items: center; gap: 4px; padding: 0 4px;
  border: none; background: none; color: var(--text); text-align: left;
  font-family: inherit; font-size: 18px; font-weight: 700; line-height: 1.2; cursor: pointer;
}
html.m-phone .m-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m-phone .m-chip {
  flex: 0 1 auto; max-width: 46vw; min-height: 44px;
  display: inline-flex; align-items: center; gap: 2px; padding: 0 8px 0 12px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--panel-2);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
html.m-phone .m-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m-phone .m-icon-btn {
  flex: none; width: var(--m-tap); height: var(--m-tap); display: grid; place-items: center;
  border: none; background: none; color: var(--text); border-radius: 50%; cursor: pointer;
}
html.m-phone .m-icon-btn svg { width: 24px; height: 24px; }
html.m-phone .m-topbar:not(.m-on-scheme) .m-scheme-menu { display: none; }
/* полоса загрузки вместо «Загрузка…» в строке статуса */
html.m-phone .m-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; overflow: hidden; }
html.m-phone .m-progress[hidden] { display: none; }
html.m-phone .m-progress span {
  position: absolute; top: 0; bottom: 0; width: 40%; background: var(--accent);
  animation: m-progress 1.1s ease-in-out infinite;
}
@keyframes m-progress { from { left: -40%; } to { left: 100%; } }
html.m-phone .m-offline {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 51;
  padding: 8px 12px; font-size: 14px; font-weight: 600; text-align: center;
  background: #fef3c7; color: #92400e; border-bottom: 1px solid #fcd34d;
}
html.m-phone .m-offline[hidden] { display: none; }

/* --- нижняя панель --- */
html.m-phone .m-bottomnav {
  flex: none; position: relative; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  min-height: calc(var(--m-nav-h) + var(--m-safe-b));
  padding-bottom: var(--m-safe-b);
  background: var(--panel); border-top: 1px solid var(--border);
}
html.m-phone .m-bottomnav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--m-nav-h); border: none; background: none; color: var(--muted);
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
html.m-phone .m-bottomnav button.active { color: var(--accent); }
html.m-phone .m-nav-ico svg { width: 24px; height: 24px; display: block; }

/* --- рабочая область --- */
html.m-phone .app-body { min-height: 0; }
html.m-phone .workspace { min-width: 0; }
html.m-phone main { min-height: 0; }

/* плавающие кнопки схемы */
html.m-phone .m-fabs {
  position: absolute; right: 12px; bottom: 12px; z-index: 20;
  display: flex; flex-direction: column; gap: 10px;
}
html.m-phone .m-fabs button {
  width: 48px; height: 48px; display: grid; place-items: center;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-md); cursor: pointer;
}
html.m-phone .m-fabs svg { width: 22px; height: 22px; }

/* --- атрибуты элемента: шторка снизу --- */
html.m-phone #page-scheme .attr-host {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  width: auto; height: min(66dvh, 620px); max-height: calc(100dvh - var(--m-top-h) - var(--m-safe-t));
  border: none; border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, .22);
  padding-bottom: var(--m-safe-b);
  transform: translateY(105%); transition: transform .22s ease, height .22s ease;
  visibility: hidden;
}
html.m-phone.m-attr-open #page-scheme .attr-host { transform: none; visibility: visible; }
html.m-phone.m-attr-open .m-fabs { display: none; }
html.m-phone.m-attr-full #page-scheme .attr-host { height: calc(100dvh - var(--m-top-h) - var(--m-safe-t)); }
html.m-phone .m-attr-bar { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 4px 6px 0; position: relative; }
html.m-phone .m-attr-bar[hidden] { display: none; }
html.m-phone .m-attr-bar .m-sheet-grip { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); }
html.m-phone .m-attr-expand, html.m-phone .m-sheet-x {
  width: var(--m-tap); height: var(--m-tap); border: none; background: none;
  font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; border-radius: 50%;
}
html.m-phone .attr-tab { min-height: var(--m-tap); font-size: 14px; }
html.m-phone .attr-title { font-size: 16px; }
html.m-phone .attr-table { font-size: 14px; }
html.m-phone .attr-table td, html.m-phone .attr-table th { padding-top: 6px; padding-bottom: 6px; }
html.m-phone .attr-table input, html.m-phone .attr-table select, html.m-phone .attr-table textarea {
  font-size: 16px; min-height: 40px;
}
html.m-phone .attr-panel button { min-height: 40px; }

/* --- шторки (shell.js openSheet) --- */
html.m-mobile .m-sheet-wrap { position: fixed; inset: 0; z-index: 2500; }
html.m-mobile .m-sheet-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, .45);
  opacity: 0; transition: opacity .2s ease;
}
html.m-mobile .m-sheet-wrap.open .m-sheet-backdrop { opacity: 1; }
html.m-mobile .m-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--panel); border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, .22);
  padding-bottom: var(--m-safe-b);
  transform: translateY(100%); transition: transform .22s ease;
}
html.m-mobile .m-sheet-wrap.open .m-sheet { transform: none; }
html.m-mobile .m-sheet.m-sheet-full { height: calc(100dvh - 12px - var(--m-safe-t)); max-height: none; }
html.m-mobile .m-sheet-grip {
  width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong);
  margin: 8px auto 0; flex: none;
}
html.m-mobile .m-sheet-head { display: flex; align-items: center; gap: 8px; padding: 2px 6px 4px 18px; flex: none; touch-action: none; }
html.m-mobile .m-sheet-head h2 { flex: 1; margin: 0; font-size: 18px; }
html.m-mobile .m-sheet-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 12px; }
html.m-mobile .m-sheet-body h3 {
  margin: 14px 18px 6px; font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
html.m-mobile .m-actions { display: flex; flex-direction: column; }
html.m-mobile .m-action, html.m-mobile .m-pick, html.m-mobile .m-section {
  display: flex; align-items: center; gap: 12px; min-height: 52px; width: 100%;
  padding: 10px 18px; border: none; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); text-align: left; font-family: inherit; font-size: 16px; font-weight: 500;
  cursor: pointer;
}
html.m-mobile .m-action small, html.m-mobile .m-pick small { margin-left: auto; color: var(--muted); font-size: 13px; }
html.m-mobile .m-action:disabled { opacity: .4; }
html.m-mobile .m-action.m-danger { color: var(--danger); }
html.m-mobile .m-actions-sep { height: 8px; background: var(--panel-2); }
html.m-mobile .m-pick.active, html.m-mobile .m-section.active { color: var(--accent); font-weight: 700; background: var(--accent-soft); }
html.m-mobile .m-pick.m-excluded span { text-decoration: line-through; opacity: .7; }
html.m-mobile .m-pick[hidden] { display: none; }
html.m-mobile .m-section > span:nth-child(2) { flex: 1; }
html.m-mobile .m-section svg:last-child { color: var(--muted); }
html.m-mobile .m-section-ico { display: grid; place-items: center; width: 32px; height: 32px; color: var(--accent); }
html.m-mobile .m-section-ico svg { width: 24px; height: 24px; }
html.m-mobile .m-filter {
  display: block; width: calc(100% - 36px); margin: 4px 18px 8px; min-height: 44px;
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px; font-size: 16px;
}
html.m-mobile .m-more-user { margin: 4px 18px 8px; color: var(--muted); font-size: 14px; }
html.m-mobile .m-install { padding: 4px 18px; font-size: 15px; line-height: 1.5; }

/* --- окна на весь экран --- */
html.m-phone dialog[open]:not(.busy-overlay) {
  width: 100vw !important; max-width: 100vw !important; min-width: 0 !important;
  height: 100dvh !important; max-height: 100dvh !important; margin: 0 !important;
  border-radius: 0 !important; resize: none !important;
  padding-top: var(--m-safe-t); padding-bottom: var(--m-safe-b);
  overflow: auto;
}
html.m-phone .dialog-form { padding: 14px 16px; }
html.m-phone .dialog-form label { font-size: 14px; }
html.m-phone .dialog-actions { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0; flex-wrap: wrap; }
html.m-phone .dialog-actions button { min-height: var(--m-tap); flex: 1 1 auto; }
html.m-phone .search-dlg-x, html.m-phone .dlg-close, html.m-phone [data-close] {
  min-width: var(--m-tap); min-height: var(--m-tap); font-size: 24px;
}
html.m-phone .search-dlg-controls { flex-direction: column; align-items: stretch; }
html.m-phone .search-dlg-controls select, html.m-phone .search-dlg-controls input { min-width: 0; width: 100%; min-height: 44px; }
html.m-phone .search-dlg-controls .search-dlg-check {
  height: auto; min-height: 44px; flex-direction: row; justify-content: flex-start; align-items: center; gap: 10px;
  font-size: 16px; white-space: normal;
}
html.m-phone .search-dlg-controls .search-dlg-check input { flex: none; width: 22px !important; height: 22px; min-width: 0; min-height: 0; }
html.m-phone .search-dlg-value-wrap { min-width: 0; }
/* свои оверлеи (.ru-modal-overlay: окна выбора, мастер РУ, карточки) — тоже на весь экран */
html.m-phone .ru-modal-overlay > * {
  width: 100vw !important; max-width: 100vw !important; min-width: 0 !important;
  height: 100dvh !important; max-height: 100dvh !important; border-radius: 0 !important;
  padding-top: var(--m-safe-t);
}

/* --- контекстные меню → меню действий снизу --- */
html.m-phone .context-menu {
  position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
  width: auto !important; min-width: 0 !important; max-height: 72dvh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 8px 0 calc(8px + var(--m-safe-b)); z-index: 3000;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, .25);
}
html.m-phone .context-menu button { min-height: 48px; font-size: 16px; padding: 10px 20px; }
html.m-phone .context-menu kbd { display: none; }

/* --- выпадающие меню десктопа, если их всё же открыли (через «Ещё») --- */
html.m-phone .menu-drop button { min-height: 48px; font-size: 16px; }

/* --- под-вкладки: лента с прокруткой пальцем --- */
html.m-mobile .sub-tabs {
  flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 0 8px;
}
html.m-mobile .sub-tabs::-webkit-scrollbar { display: none; }
html.m-mobile .sub-tabs button { flex: none; white-space: nowrap; font-size: 15px; min-height: var(--m-tap); }

/* --- тосты и индикатор над нижней панелью --- */
html.m-phone .toast-container {
  top: auto; left: 8px; right: 8px; max-width: none;
  bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 8px);
}
html.m-phone .toast { font-size: 15px; }

/* --- вход --- */
html.m-phone .login-card { width: calc(100vw - 24px); padding: 24px 18px 18px; }
html.m-phone .login-card label { font-size: 14px; }
html.m-phone .login-card input { min-height: 48px; font-size: 16px; }
html.m-phone .login-submit { min-height: 48px; font-size: 16px; }
html.m-phone .login-reset { min-height: var(--m-tap); font-size: 14px; }
html.m-phone .login-hint { font-size: 13px; }

/* --- стартовый экран (список проектов) --- */
html.m-phone .start-grid { grid-template-columns: 1fr !important; }
html.m-phone .start-card { min-height: 56px; }

/* --- общие элементы разделов --- */
html.m-phone .module-toolbar { gap: 8px; }
html.m-phone .module-toolbar button, html.m-phone .dt-toolbar button { min-height: var(--m-tap); font-size: 15px; }
html.m-phone .muted { font-size: max(12px, 1em); }

/* --- «Доступна новая версия» (mobile/pwa.js; воркер включается только на телефоне/планшете/сенсоре) --- */
html.m-mobile .pwa-update, html.m-touch .pwa-update {
  position: fixed; left: 8px; right: 8px; z-index: 5500;
  bottom: calc(var(--m-nav-h, 0px) + env(safe-area-inset-bottom, 0px) + 8px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 12px;
  background: var(--rail); color: #fff; font-size: 15px; box-shadow: var(--shadow-lg);
}
html.m-mobile .pwa-update button, html.m-touch .pwa-update button {
  min-height: 40px; padding: 0 16px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 15px;
}

/* ======================= таблицы карточками (tables.js, телефон и планшет) ======================= */
html.m-mobile .dt-m-toolbar { display: block; padding: 8px 12px 6px; }
html.m-mobile .dt-m-searchrow { display: flex; gap: 8px; }
html.m-mobile .dt-m-toolbar .dt-m-search {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border-radius: 10px; font-size: 16px;
}
html.m-mobile .dt-m-filter-btn {
  flex: none; min-height: 44px; padding: 0 14px; border: 1px solid var(--border-strong);
  border-radius: 10px; background: var(--panel); color: var(--text); font-size: 15px; font-weight: 600;
}
html.m-mobile .dt-m-filter-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
html.m-mobile .dt-m-strip {
  display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; overflow-x: auto;
  padding: 8px 0 2px; scrollbar-width: none; overscroll-behavior-x: contain;
}
html.m-mobile .dt-m-strip::-webkit-scrollbar { display: none; }
html.m-mobile .dt-m-strip > * { flex: none; }
html.m-mobile .dt-m-strip .dt-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
html.m-mobile .dt-m-strip button { white-space: nowrap; }
html.m-mobile .dt-scroll.dt-cards { padding: 8px 10px 16px; background: var(--bg); }
html.m-mobile .dt-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow-sm);
}
html.m-mobile .dt-card[hidden], html.m-mobile .dt-m-group[hidden] { display: none; }
html.m-mobile .dt-card.clickable { cursor: pointer; }
html.m-mobile .dt-card.dt-row-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft-2); }
html.m-mobile .dt-card-head { display: flex; align-items: flex-start; gap: 10px; }
html.m-mobile .dt-card-lead { flex: none; display: flex; align-items: center; min-height: 24px; }
html.m-mobile .dt-card-title { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
html.m-mobile .dt-card-actions { flex: none; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
html.m-mobile .dt-card-actions button { min-width: 44px; min-height: 44px; font-size: 15px; }
html.m-mobile .dt-card-sub { margin-top: 2px; font-size: 14px; overflow-wrap: anywhere; }
html.m-mobile .dt-card-fields {
  display: grid; grid-template-columns: minmax(84px, 38%) 1fr; gap: 4px 10px; margin: 8px 0 0; font-size: 14px;
}
html.m-mobile .dt-card-field { display: contents; }
html.m-mobile .dt-card-field dt { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
html.m-mobile .dt-card-field dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
html.m-mobile .dt-card-field dd[class] { justify-self: start; padding: 0 6px; border-radius: 6px; }
html.m-mobile .dt-card-empty { color: var(--border-strong); }
html.m-mobile .dt-card-more { margin-top: 6px; }
html.m-mobile .dt-card-more summary {
  min-height: 40px; display: flex; align-items: center; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 14px;
}
html.m-mobile .dt-card-edit dd input {
  width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px;
}
html.m-mobile .dt-m-more-rows {
  display: block; width: 100%; min-height: 48px; margin: 4px 0;
  border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--panel);
  color: var(--accent); font-weight: 600; font-size: 15px;
}
html.m-mobile .dt-m-empty { text-align: center; color: var(--muted); padding: 32px 12px; font-size: 15px; }
html.m-mobile .dt-m-group {
  display: flex; align-items: center; gap: 8px; min-height: 44px; margin: 6px 0;
  padding: 8px 10px 8px calc(10px + var(--lvl, 0) * 14px);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  font-weight: 600; font-size: 15px; cursor: pointer;
}
html.m-mobile .dt-m-group-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
html.m-mobile .dt-m-group-name small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
html.m-mobile .dt-m-group .dt-group-count { color: var(--muted); font-size: 13px; }
html.m-mobile .dt-m-group .dt-group-add { min-width: 40px; min-height: 40px; }
/* «Колонки» и выпадашки фильтров — шторкой снизу (из ленты кнопок не вылезают) */
html.m-mobile .dt-cols-menu, html.m-mobile .dt-msel-menu {
  position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
  max-height: 70dvh; overflow-y: auto; z-index: 2600; background: var(--panel);
  border-radius: 16px 16px 0 0; padding: 8px 12px calc(12px + var(--m-safe-b));
  box-shadow: 0 -10px 30px rgba(15, 23, 42, .25);
}
html.m-mobile .dt-cols-menu.hidden, html.m-mobile .dt-msel-menu.hidden { display: none; }
html.m-mobile .dt-cols-menu label, html.m-mobile .dt-msel-menu label { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; }
html.m-mobile .dt-cols-menu button { min-height: 44px; }
/* шторка «Фильтры и сортировка» */
html.m-mobile .dt-m-sheet { padding: 0 18px; }
html.m-mobile .dt-m-sheet h3 { margin: 16px 0 4px; }
html.m-mobile .dt-m-row { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 14px; color: var(--muted); }
html.m-mobile .dt-m-row input, html.m-mobile .dt-m-row select {
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--text); background: var(--panel);
}
html.m-mobile .dt-m-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; }
html.m-mobile .dt-m-sel { border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; max-height: 40dvh; overflow-y: auto; }
html.m-mobile .dt-m-sel legend { font-size: 14px; color: var(--muted); padding: 0 4px; }
html.m-mobile .dt-m-sel label { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; }
html.m-mobile .dt-m-sheet-actions { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 0; background: var(--panel); }
html.m-mobile .dt-m-sheet-actions button { flex: 1; min-height: 48px; font-size: 16px; }
/* статус-цвета ячеек (cellClass) — в таблице они заданы для table.dt td.…, в карточке — поле */
html.m-mobile .dt-card-field dd.cell-vor-ok, html.m-mobile .dt-card-field dd.pc-ok { background: #d1e7dd; }
html.m-mobile .pc-head:has([data-pc="document-audit"]), html.m-mobile .pc-list > .pc-head { flex-wrap: wrap; }
html.m-mobile .pc-head:has([data-pc="document-audit"]) .pc-title { flex: 1 1 65%; }
html.m-mobile .pnra { margin: 4px 0; padding: 8px; }
html.m-mobile .pnra-toolbar label, html.m-mobile .pnra-form-inline label, html.m-mobile .pnra-uploads label { display: grid; width: 100%; margin: 4px 0; }
html.m-mobile .pnra-archive, html.m-mobile .pnra-finding, html.m-mobile .pnra-document { padding: 6px; }
html.m-mobile .pnra-table { min-width: 430px; }
html.m-mobile .pnra-dialog { box-sizing: border-box; padding: 10px; width: 96vw; }
html.m-mobile .dt-card-field dd.cell-vor-warn, html.m-mobile .dt-card-field dd.pc-warn { background: #fff6bf; }
html.m-mobile .dt-card-field dd.cell-vor-bad, html.m-mobile .dt-card-field dd.pc-bad { background: #f8d7da; }
html.m-mobile .dt-card-field dd.pc-info { background: #dbe9fb; }

/* Разделы на телефоне прокручиваются страницей целиком, а не рамками внутри: дочерним
   блокам возвращаем естественную высоту (в app.css у них min-height: 0 под раскладку
   «на весь экран» с внутренней прокруткой). Схема — исключение: там холст. */
html.m-mobile main > .page:not(#page-scheme) { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
html.m-mobile main > .page:not(#page-scheme) * { min-height: auto; }
html.m-mobile main > .page:not(#page-scheme) .dt-scroll { max-height: none; flex: none; }
/* панель таблицы, вынесенная модулем в свой контейнер (toolbarHost: «Документация» и др.),
   на телефоне занимает всю строку и не вылезает за край */
html.m-mobile .docs-dt-toolbar,
html.m-mobile :has(> .dt-m-toolbar) { display: block; flex: 1 1 100%; min-width: 0; max-width: 100%; }
html.m-mobile .dt-m-toolbar { min-width: 0; max-width: 100%; }
html.m-mobile .module-toolbar { flex-wrap: wrap; }

/* ===================== схема пальцем (scheme/canvas.js, _bindTouch) ===================== */
/* Жесты ведёт сам сайт: браузер не должен ни зумить страницу, ни прокручивать её под пальцем. */
html.m-touch #page-scheme .canvas-host, html.m-touch .scheme-svg { touch-action: none; }
html.m-touch .scheme-svg { -webkit-touch-callout: none; }

/* ===================== правка схемы пальцем (режим «Редактировать») ===================== */
html.m-mobile .m-edit-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  display: flex; gap: 6px; padding: 8px 8px; overflow-x: auto; scrollbar-width: none;
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 14px rgba(15, 23, 42, .10);
}
html.m-mobile .m-edit-bar[hidden] { display: none; }
html.m-mobile .m-edit-bar::-webkit-scrollbar { display: none; }
html.m-mobile .m-edit-bar button {
  flex: none; min-height: 44px; padding: 0 12px; white-space: nowrap;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--panel);
  color: var(--text); font-size: 15px; font-weight: 600;
}
html.m-mobile .m-edit-bar button[data-e="done"] { background: var(--accent); border-color: var(--accent); color: #fff; }
html.m-mobile .m-edit-bar button[data-e="delete"] { color: var(--danger); }
html.m-mobile .m-edit-bar button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
html.m-mobile #page-scheme.touch-edit .m-fabs { bottom: 74px; }
/* в правке рамка листа подсвечена — видно, что касания меняют схему */
html.m-touch #page-scheme.touch-edit .canvas-host { box-shadow: inset 0 0 0 3px #f59e0b; }

/* планшет и сенсор без телефонной оболочки: переключатель правки пальцем на холсте */
html.m-touch .m-touch-edit-toggle {
  position: absolute; right: 12px; bottom: 12px; z-index: 20;
  min-height: 44px; padding: 0 14px; border-radius: 22px;
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow-md);
}
html.m-touch .m-touch-edit-toggle[hidden] { display: none; }
html.m-touch .m-touch-edit-toggle.active { background: #f59e0b; border-color: #f59e0b; color: #fff; }

/* PDF в окне: ссылка «Открыть в просмотрщике телефона» над iframe (mobile/openFile.js) */
html.m-mobile .m-open-file, html.m-touch .m-open-file {
  display: flex; align-items: center; justify-content: center; min-height: 44px; margin: 0 0 8px;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft);
  color: var(--accent); font-weight: 700; font-size: 15px; text-decoration: none;
}

/* --- «Задачи»: доска в одну колонку; статус меняется полем «Статус» в карточке --- */
html.m-mobile .tsk-board { grid-template-columns: 1fr !important; }
html.m-mobile .tasks-head { flex-wrap: wrap; }
html.m-mobile .tasks-head h3 { flex: 1 1 auto; }
html.m-mobile .tasks-head .tsk-search { flex: 1 1 100%; order: 5; min-height: 44px; }
html.m-mobile .tasks-head button { min-height: var(--m-tap); }
html.m-mobile .tasks-detail { position: fixed; inset: 0; z-index: 5; width: auto !important; max-width: none !important; }

/* планшет: карточки в две колонки (заголовки групп и «Показать ещё» — на всю ширину) */
html.m-tablet .dt-scroll.dt-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; align-content: start; }
html.m-tablet .dt-scroll.dt-cards > :not(.dt-card) { grid-column: 1 / -1; }

/* --- доводка разделов (этап 6) --- */
/* «Оборудование → Перечень» и проектный КЖ на десктопе прокручиваются внутри таблицы (overflow:
   hidden у под-страницы) — на телефоне это обрезало карточки: прокручивается страница. */
html.m-mobile #page-equipment .sub-page[data-sub="list"],
html.m-mobile #page-cables .sub-page[data-sub="project"] { overflow: visible; }
html.m-mobile #page-equipment .sub-page[data-sub="list"] .eq-mode,
html.m-mobile #page-equipment .sub-page[data-sub="list"] .eq-table { flex: 0 0 auto; min-height: auto; }
/* три режима «Обновления» шире экрана: лента режимов прокручивается вбок в пределах строки */
html.m-mobile #page-equipment .ta-mode-tabs { max-width: 100%; }
/* лента под-вкладок с прокруткой вбок не должна сжиматься по высоте (у прокручиваемого
   блока min-height: auto = 0) */
html.m-mobile .sub-tabs { flex-shrink: 0; }
/* «Документация»: пустая панель просмотра PDF не торчит за край; открытая — на весь экран */
html.m-mobile .docs-viewer:not(.open) { display: none; }
html.m-phone .docs-viewer.open { position: fixed; inset: 0; z-index: 70; width: auto; padding-top: var(--m-safe-t); background: var(--panel); }
html.m-phone .docs-viewer-close { min-width: var(--m-tap); min-height: var(--m-tap); font-size: 24px; }
/* атрибуты элемента: подписи и мелкие кнопки панели — читаемо */
html.m-phone .attr-panel td, html.m-phone .attr-panel th { font-size: 14px; }
html.m-phone .attr-panel button { font-size: 14px; min-width: 40px; }
html.m-phone .attr-title-row .btn-add-attr { min-height: 40px; font-size: 14px; }
/* кнопки строк таблиц (просмотр, правка, →) и панелей разделов — палец */
html.m-phone .row-actions button, html.m-phone .row-actions a { min-height: 40px; min-width: 44px; font-size: 14px; }
html.m-phone .module-toolbar .btn-secondary, html.m-phone .module-toolbar .btn-primary { min-height: var(--m-tap); }
html.m-phone .sub-tabs button { min-height: var(--m-tap); }
/* в правке схемы тосты выше панели правки — не перекрывают её кнопки */
html.m-phone.m-editing .toast-container { bottom: calc(var(--m-nav-h) + var(--m-safe-b) + 74px); }

/* ============ окно поиска на телефоне: форма в две строки, результатам — весь экран ============
   Строка 1 — поле запроса, «Поиск», крестик; строка 2 — атрибут и «Искать на главной».
   Заголовок и подписи «Атрибут»/«Значение» скрыты: смысл в подсказке поля и в первом пункте
   списка («— любой атрибут —»). Живой поиск идёт по мере ввода, «Поиск» — для одного символа. */
html.m-phone #dlg-search .dialog-form { position: relative; padding: 8px 10px 0; height: 100%; }
html.m-phone #dlg-search .search-dlg-head { position: absolute; top: 8px; right: 8px; z-index: 2; }
html.m-phone #dlg-search .search-dlg-head h3 { display: none; }
html.m-phone #dlg-search .search-dlg-x { width: 44px; height: 44px; font-size: 24px; }
html.m-phone #dlg-search .search-dlg-controls {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px;
  grid-template-areas: "val run" "attr chk"; align-items: center; margin: 0 0 6px;
}
html.m-phone #dlg-search .search-dlg-controls > label { font-size: 0; gap: 0; margin: 0; min-width: 0; }
html.m-phone #dlg-search .search-dlg-value-wrap { grid-area: val; }
html.m-phone #dlg-search .search-dlg-controls > label:first-child { grid-area: attr; }
html.m-phone #dlg-search #search-dlg-value { min-height: 44px; padding: 8px 12px; font-size: 16px; }
html.m-phone #dlg-search #search-dlg-attr { min-height: 44px; padding: 4px 8px; font-size: 16px; color: var(--muted); }
html.m-phone #dlg-search #search-dlg-run { grid-area: run; min-height: 44px; padding: 0 14px; margin-right: 52px; }
html.m-phone #dlg-search .search-dlg-controls .search-dlg-check {
  grid-area: chk; font-size: 14px; min-height: 44px; gap: 6px; white-space: nowrap; color: var(--muted);
}
html.m-phone #dlg-search .search-dlg-summary {
  margin: 0 0 2px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* результаты: панель таблицы — одной строкой (поиск по таблице здесь дублировал бы запрос) */
html.m-phone #dlg-search .search-dlg-results { display: flex; flex-direction: column; }
html.m-phone #dlg-search .search-dlg-results > .muted { font-size: 14px; margin: 8px 2px; }
html.m-phone #dlg-search .dt-m-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 2px 0 6px; background: transparent; border: none;
}
html.m-phone #dlg-search .dt-m-searchrow { order: 2; flex: none; }
html.m-phone #dlg-search .dt-m-search { display: none; }
html.m-phone #dlg-search .dt-m-strip { order: 1; flex: 1 1 auto; min-width: 0; padding: 0; }
html.m-phone #dlg-search .dt-m-filter-btn, html.m-phone #dlg-search .dt-m-strip button { min-height: 44px; padding: 0 12px; font-size: 14px; }
html.m-phone #dlg-search .search-dlg-results .dt-scroll.dt-cards {
  flex: 1 1 auto; height: auto; min-height: 0; max-height: none;
  padding: 2px 0 calc(12px + var(--m-safe-b)); background: transparent;
}
html.m-phone #dlg-search .dt-card { padding: 10px 12px; margin-bottom: 6px; }
html.m-phone #dlg-search .dt-card-fields { margin-top: 4px; }
html.m-phone #dlg-search .dt-card-more summary { min-height: 44px; }

/* ============ атрибуты элемента на телефоне: компактно (mobile/shell.js, decorateAttrs) ============
   Шапка одна: KKS + тип, «Сохранить», «⋯», «×»; вкладки ниже; поля — сеткой в две колонки
   без рамок (рамка — при касании), пустые атрибуты скрыты. */
html.m-phone #page-scheme .attr-host { height: min(72dvh, 640px); }
html.m-phone .m-attr-bar {
  justify-content: flex-start; gap: 0; min-height: 44px; padding: 0 0 0 12px;
  border-bottom: 1px solid var(--border); touch-action: none;   /* свайп шапки — наш, не прокрутка браузера */
}
html.m-phone .m-attr-bar .m-sheet-grip { top: 2px; margin: 0; height: 4px; z-index: 4; }
html.m-phone .m-attr-bar .m-attr-expand, html.m-phone .m-attr-bar .m-sheet-x { width: 44px; height: 44px; font-size: 20px; }
/* Шапка — одной строкой: KKS жирно, тип следом мельче; не влезает — сначала ужимается тип. */
html.m-phone .m-attr-head { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; line-height: 1.2; padding-top: 4px; }
html.m-phone .m-attr-name { flex: 0 1 auto; min-width: 0; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m-phone .m-attr-type { flex: 0 100 auto; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m-phone .m-attr-type:empty { display: none; }
html.m-phone .attr-title-row { display: none; }
html.m-phone .attr-panel .attr-tab { min-height: 44px; font-size: 13px; padding: 0 4px; }
html.m-phone .attr-panel .attr-table-wrap { padding: 0; }
html.m-phone .attr-panel .attr-table td { padding: 0; font-size: 14px; }
html.m-phone .attr-panel .attr-table tr.attr-section td { padding: 8px 12px 4px; font-size: 12px; font-weight: 700; color: var(--text); background: var(--panel-2); }
html.m-phone .attr-panel .attr-table tr.attr-slot-head td { padding: 8px 12px 2px; font-size: 11px; }
/* Поля — сеткой в две колонки. На всю ширину (.m-wide, ставит decorateAttrs) — длинное
   значение или подпись, многострочное поле, поле с кнопками, заголовки разделов.
   dense: короткое поле занимает дыру перед широким. Черта между колонками — фоном сетки,
   широкие строки её закрывают. */
html.m-phone .attr-panel .attr-tab-user .attr-table { display: block; }
html.m-phone .attr-panel .attr-tab-user .attr-table > tbody {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-flow: row dense;
  background: linear-gradient(var(--border), var(--border)) 50% 0 / 1px 100% no-repeat;
}
html.m-phone .attr-panel .attr-tab-user .attr-table tr {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0;
  border-bottom: 1px solid var(--border);
}
html.m-phone .attr-panel .attr-tab-user .attr-table tr.m-wide { grid-column: 1 / -1; background: var(--panel); }
html.m-phone .attr-panel .attr-tab-user .attr-table tr[hidden],
html.m-phone .attr-panel .attr-tab-user .attr-table tr.m-empty { display: none; }
html.m-phone.m-attr-empty-shown .attr-panel .attr-tab-user .attr-table tr.m-empty:not([hidden]) { display: flex; }
html.m-phone .attr-panel .attr-tab-user .attr-table td { display: block; width: auto; min-width: 0; }
/* Подпись лежит поверх верхней части поля и пропускает касания: поле занимает всю ячейку
   (44 px), палец попадает в него в любом месте. Подпись в одну строку; не влезает в
   половину экрана — строка идёт на всю ширину (decorateAttrs). */
html.m-phone .attr-panel .attr-tab-user .attr-table td:first-child:not([colspan]) {
  position: absolute; z-index: 1; left: 0; top: 0; max-width: 100%; pointer-events: none;
  padding: 4px 10px 0; font-size: 12px; font-weight: 500; line-height: 14px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html.m-phone .attr-panel .attr-tab-user .attr-table td:first-child:not([colspan]):empty { display: none; }
html.m-phone .attr-panel .attr-tab-user .attr-table td:last-child:not([colspan]) { padding: 0 4px; }
/* в ячейке нет поля ввода (только кнопка или текст) — содержимое под подписью */
html.m-phone .attr-panel .attr-tab-user .attr-table tr.m-nofield td:first-child:not(:empty) + td { padding: 18px 10px 4px; }
html.m-phone .attr-panel .attr-table input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
html.m-phone .attr-panel .attr-table select,
html.m-phone .attr-panel .attr-table textarea {
  display: block; width: 100%; height: 44px; min-height: 44px; padding: 18px 6px 2px;
  font-size: 16px; line-height: 20px; color: var(--text);
  border: 1px solid transparent; border-radius: 6px; background-color: transparent; box-shadow: none;
}
html.m-phone .attr-panel .attr-table textarea { height: auto; resize: none; }
html.m-phone .attr-panel .attr-table textarea[rows="1"] { height: 44px; overflow: hidden; }
html.m-phone .attr-panel .attr-table input:focus, html.m-phone .attr-panel .attr-table select:focus,
html.m-phone .attr-panel .attr-table textarea:focus { border-color: var(--accent); background-color: #fff; box-shadow: none; }
/* список — своя стрелка: родная на iOS не слушается отступов */
html.m-phone .attr-panel .attr-table select {
  appearance: none; -webkit-appearance: none; padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px bottom 12px; background-size: 12px 8px;
}
/* Поле с кнопками (ID ПНР «П/Р/Подс.», РД, Этапка, Тип_марка, кабель «К»): кнопки —
   сегменты на всю высоту ячейки, 44×44. :where — чтобы «нажатые» состояния кнопок
   (.attr-pnr-hl.active и т. п.) из app.css не перебивались. */
html.m-phone .attr-panel .attr-tab-user .attr-table td:last-child > span { gap: 0; align-items: stretch; }
html.m-phone :where(.attr-panel .attr-table td:not([colspan])) button:not(.attr-strand-add) {
  min-height: 44px; min-width: 44px; padding: 0 8px; margin: 0;
  border: none; border-left: 1px solid var(--border); border-radius: 0;
  background: transparent; color: var(--accent); font-size: 15px; font-weight: 600;
}
html.m-phone .attr-panel .attr-table .attr-color input[type="color"] {
  flex: none; align-self: flex-start; width: 24px; height: 22px; min-height: 0; margin: 18px 0 0 6px;
}
html.m-phone .attr-panel .attr-table .attr-strand-add { min-height: 40px; font-size: 14px; }
/* «Сохранить» и «⋯» — в шапке, слева от «×» (как «Готово» в шторках iOS): не уходят под
   клавиатуру и не занимают строку внизу. Ряд остаётся на своём месте в разметке панели —
   блокировки и «режим просмотра» (.hidden) работают как прежде; в шапку он поставлен
   положением. Пока ряд виден, «⤢» в шапке не нужен — он в «⋯» (и свайп шапки вверх). */
html.m-phone #page-scheme .attr-host .attr-actions {
  position: absolute; z-index: 3; top: 0; right: 44px; height: 44px;
  display: flex; align-items: stretch; gap: 0; margin: 0; padding: 0; border: none; background: none;
}
html.m-phone .attr-actions > button:not(.btn-save-attrs):not(.m-attr-more) { display: none; }
/* кнопка — 44 px по высоте, а «таблетка» внутри — 32 px: прозрачная рамка + фон по padding-box */
html.m-phone .attr-actions .btn-save-attrs {
  flex: none; min-height: 44px; padding: 0 14px; font-size: 15px; font-weight: 600;
  border-style: solid; border-width: 9px 0 3px; border-radius: 12px;   /* сверху место под ручку шторки */
  border-color: transparent !important; background-clip: padding-box !important;   /* app.css — с !important */
}
html.m-phone .attr-actions .m-attr-more {
  flex: none; width: 44px; min-height: 44px; padding: 0; font-size: 22px; line-height: 1;
  border: none; border-radius: 0; background: none; color: var(--muted);
}
html.m-phone #page-scheme .attr-host:has(.attr-tab-user:not(.hidden) .attr-actions:not(.hidden)) .m-attr-head { margin-right: 152px; }
html.m-phone #page-scheme .attr-host:has(.attr-tab-user:not(.hidden) .attr-actions:not(.hidden)) .m-attr-expand { display: none; }
html.m-phone .attr-hint { min-height: 0; padding: 0 16px; font-size: 13px; }
html.m-phone .attr-hint:not(:empty) { padding: 4px 16px 6px; }

/* --- «График» (модуль «Планирование»): на телефоне и планшете — просмотр и ввод факта,
   полная правка графика — «удобнее на ПК» (PLANNING_PLAN.md §4.11). Панели — столбиком. --- */
html.m-mobile .plg-portfolio-body, html.m-mobile .plg-acts-layout, html.m-mobile .plg-cals-layout,
html.m-mobile .plg-members-layout { flex-direction: column; overflow-y: auto; }
html.m-mobile .plg-tab-body { overflow-y: auto; }
html.m-mobile .plg-folders, html.m-mobile .plg-wbs, html.m-mobile .plg-cal-list {
  flex: none; max-height: 32vh; border-right: none; border-bottom: 1px solid var(--border);
}
html.m-mobile .plg-card, html.m-mobile .plg-orgs { flex: none; border-left: none; border-top: 1px solid var(--border); }
html.m-mobile .plg-acts, html.m-mobile .plg-portfolio-list, html.m-mobile .plg-members { flex: none; }
html.m-mobile .plg-table-wrap { flex: none; max-height: 60vh; }
html.m-mobile .plg-toolbar { flex-wrap: wrap; }
html.m-mobile .plg-pane-head { flex-wrap: wrap; }
html.m-mobile .plg-search { flex: 1 1 160px; width: auto; max-width: none; }
html.m-mobile .plg-links-tab .plg-link-add { flex-wrap: wrap; }
html.m-mobile .plg-statusbar { flex-wrap: wrap; gap: 4px 12px; }
html.m-phone .plg-table { table-layout: auto; }
html.m-phone .plg-table colgroup { display: none; }
html.m-phone .plg-acts-table th:nth-child(n+5), html.m-phone .plg-acts-table td:nth-child(n+5),
html.m-phone .plg-projects th:nth-child(n+3):not(:last-child), html.m-phone .plg-projects td:nth-child(n+3):not(:last-child),
html.m-phone .plg-links-table th:nth-child(2), html.m-phone .plg-links-table td:nth-child(2),
html.m-phone .plg-links-table th:nth-child(6), html.m-phone .plg-links-table td:nth-child(6) { display: none; }
html.m-phone .plg-grid3, html.m-phone .plg-form-grid { grid-template-columns: 1fr; }
/* цели касания — не меньше 44 px (с #page-planning: правило «потомкам min-height: auto»
   выше держит id в :not() и иначе перебивает) */
html.m-touch #page-planning .plg-icon-btn { min-width: 44px; height: 44px; font-size: 16px; }
html.m-touch #page-planning :is(.plg-folder, .plg-wbs-node, .plg-cal-item, .plg-actions button, .plg-tabs button,
  .plg-toolbar .btn-primary, .plg-toolbar .btn-secondary, .plg-pane-head .btn-primary, .plg-pane-head .btn-secondary,
  .plg-card-actions button, .plg-link-add button, .plg-exc-add button, .plg-org-add button) { min-height: 44px; }
html.m-touch #page-planning .plg-link { min-height: 44px; display: inline-flex; align-items: center; }
/* --- «График» → Гант (этапы 4–5): страница прокручивается целиком (шапку можно увести вверх),
   сам Гант — высотой в экран; на телефоне — таблица одной колонкой имён, шкала пальцами,
   карточка — лист снизу, меню — лист действий; панель инструментов — одной строкой. --- */
html.m-mobile #page-planning .plg-gantt { flex: 1 1 auto; min-width: 0; width: 100%; height: calc(100dvh - var(--m-top-h) - var(--m-nav-h) - var(--m-safe-b)); min-height: 420px; }
html.m-tablet #page-planning .plg-gantt { height: calc(100dvh - 120px); }
html.m-mobile #page-planning .plg-gantt :is(.plg-split, .plg-pane-grid, .plg-pane-tl, .plg-tl, .plg-tl-scroll, .plg-grid,
  .plg-grid-body, .plg-card-main, .plg-card-left, .plg-card-body, .plg-why-list) { min-height: 0; }
html.m-mobile #page-planning .plg-gtb { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
html.m-mobile #page-planning .plg-gtb > * { flex: none; }
html.m-phone #page-planning .plg-pane-grid { width: 42vw !important; }
html.m-phone #page-planning :is(.plg-grid-head-in, .plg-grid-inner) { width: 100% !important; }
html.m-phone #page-planning :is(.plg-gc.c-name, .plg-gh.c-name) { width: 100% !important; }
html.m-phone #page-planning .plg-card-panel { position: fixed; left: 0; right: 0; bottom: calc(var(--m-nav-h) + var(--m-safe-b)); z-index: 40;
  height: auto !important; max-height: 70dvh; border-top: none; border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgba(15, 23, 42, .18); }
html.m-phone #page-planning .plg-card-panel.full { top: var(--m-top-h); max-height: none; }
html.m-phone #page-planning .plg-card-resizer { display: none; }
html.m-phone #page-planning .plg-card-top { flex-wrap: wrap; padding: 10px 12px 6px; }
html.m-phone #page-planning .plg-card-title { flex-wrap: wrap; }
html.m-phone #page-planning .plg-card-main { position: relative; }
html.m-phone #page-planning .plg-gen { flex-direction: column; gap: 8px; padding: 6px 12px 12px; }
html.m-phone #page-planning .plg-kv-col { flex: none; width: 100%; }
html.m-phone #page-planning :is(.plg-gen-form .plg-grid2, .plg-status-grid) { grid-template-columns: 1fr 1fr; }
html.m-phone #page-planning .plg-why { position: absolute; inset: 0; z-index: 3; flex: none; border-left: none; }
html.m-phone #page-planning .plg-toasts { position: fixed; bottom: calc(var(--m-nav-h) + 12px); }
html.m-phone #page-planning .plg-ctx.touch { left: 8px !important; right: 8px; top: auto !important; bottom: calc(var(--m-nav-h) + 8px); min-width: 0; }
html.m-phone #page-planning .plg-ctx kbd { display: none; }
html.m-phone #page-planning .plg-pop { position: fixed; left: 8px; right: 8px; top: var(--m-top-h); width: auto; }
html.m-phone #page-planning .plg-gsb > span:not(.plg-spacer):not(.plg-sync) { display: none; }
html.m-touch #page-planning :is(.plg-tb, .plg-chip-btn, .plg-seg button, .plg-ctab, .plg-ctx > button, .plg-why-btn,
  .plg-dd-menu > button, .plg-card-btns button, .plg-toast-btn, .plg-gsearch) { min-height: 44px; }
html.m-touch #page-planning .plg-tb.icon-only { width: 44px; }

/* «График» на телефоне: «Нарушения технологии» — лист снизу (на десктопе — правая панель) */
html.m-phone .plg-tech-sheet { position: fixed; left: 0; right: 0; bottom: 0; height: 70vh; z-index: 40; display: flex; box-shadow: 0 -6px 24px rgba(15, 23, 42, .18); }
html.m-phone .plg-tech-sheet .plg-tech-drawer { width: 100%; min-width: 0; }

/* «График», этап 8: окна актуализации, базовых планов, форматов, печати и отчётов — в одну колонку */
html.m-phone .plg-io-dialog { width: 100vw; max-width: 100vw; max-height: 100vh; margin: 0; border-radius: 0; }
html.m-phone .plg-io-body { padding: 12px; max-height: 100vh; }
html.m-phone .plg-print-grid { grid-template-columns: 1fr; }
html.m-phone .plg-up-table table, html.m-phone .plg-cmp-table, html.m-phone .plg-rp-table { min-width: 720px; }

/* «График» → «Легенда»: на телефоне образец над пояснением, одна колонка. */
html.m-phone .plg-legend { padding: 6px 10px 20px; }
html.m-phone .plg-lg-grid { grid-template-columns: minmax(0, 1fr); }
html.m-phone .plg-lg-item { flex-direction: column; }
html.m-phone .plg-lg-sample { width: auto; max-width: 100%; }
html.m-phone .plg-lg-mark { width: 100%; justify-content: flex-start; }
html.m-phone .plg-lgs-sample { width: 100%; }
html.m-phone .plg-lg-tabs { margin: 0 -10px 4px; padding-left: 10px; top: -6px; }

/* --- «АСУ ТП»: на телефоне и планшете раздел прокручивается страницей целиком; журнал —
   таблица с прокруткой вбок внутри своей рамки (колонки по ширине не сжимаются в ноль);
   на телефоне плитки — столбиком, заголовок раздела — в верхней панели оболочки. --- */
html.m-mobile .asutp-root, html.m-mobile .asutp-body, html.m-mobile .asutp-journal { overflow: visible; }
html.m-mobile .asutp-table-wrap { flex: none; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
html.m-mobile .asutp-table { min-width: 980px; }
html.m-mobile .asutp-col-who { width: 100px; }
html.m-mobile .asutp-col-table, html.m-mobile .asutp-col-field { width: 120px; }
html.m-mobile .asutp-col-row { width: 64px; }
html.m-mobile .asutp-col-reason { width: 180px; }
html.m-phone .asutp-head { flex-wrap: wrap; row-gap: 0; padding: 0; }
html.m-phone .asutp-title { display: none; }
html.m-phone .asutp-context { order: -1; flex: 1 0 100%; margin: 0; padding: 8px 12px 0; white-space: normal; }
html.m-phone .asutp-body { padding: 10px; }
html.m-phone .asutp-layers { padding: 4px; }
html.m-phone .asutp-stats { flex-direction: column; }
html.m-phone .asutp-stats .asutp-stat { flex: none; }
html.m-phone .asutp-jr-bar, html.m-phone .asutp-jr-more { flex-wrap: wrap; }
/* цели касания — 44 px (с #page-asutp: правило «потомкам min-height: auto» выше держит id) */
html.m-touch #page-asutp :is(.asutp-tabs button, .asutp-btn) { min-height: var(--m-tap); }

/* --- «АСУ ТП», этап 8-A: реестр, каналы ДУ, ИК и уставки, защиты, ПНР, окна. ---
   Список и деталь («Каналы ДУ», «ИК и уставки», «Защиты») — друг под другом; таблицы без своей
   рамки прокручиваются вбок в карточке; матрицы (защиты → механизмы, готовность ПНР) — вбок
   с закреплённой первой колонкой; схемы и шкала уставок — вбок в своей карточке. --- */
html.m-mobile .asutp-card:has(> .asutp-table, > .asutp-du-svg, > .asutp-ik-svg) { overflow-x: auto; overscroll-behavior-x: contain; }
html.m-mobile .asutp-ik-cols .asutp-table, html.m-mobile .asutp-pnr-points { min-width: 0; }
html.m-mobile .asutp-obj-history .asutp-table { min-width: 720px; }
html.m-mobile .asutp-matrix { width: max-content; min-width: 100%; table-layout: auto; }
html.m-mobile .asutp-matrix thead th:first-child { position: sticky; left: 0; z-index: 3; }
html.m-mobile .asutp-matrix .asutp-matrix-row { z-index: 2; box-shadow: 1px 0 0 var(--border); }
html.m-mobile .asutp-matrix-cell { min-width: 30px; }
html.m-mobile .asutp-pnr-grid { width: max-content; min-width: 100%; table-layout: auto; }
html.m-mobile .asutp-pnr-grid :is(th, td).asutp-pnr-sub { position: sticky; left: 0; z-index: 2; max-width: 150px; box-shadow: 1px 0 0 var(--border); }
html.m-mobile .asutp-pnr-grid td.asutp-pnr-sub { background: var(--panel); white-space: normal; }
html.m-mobile .asutp-pnr-grid .asutp-pnr-total td.asutp-pnr-sub { background: var(--panel-2); }
html.m-mobile .asutp-pnr-grid th.asutp-pnr-sub { z-index: 3; }

html.m-phone .asutp-du { grid-template-columns: minmax(0, 1fr); }
html.m-phone .asutp-du-list { position: static; max-height: 38dvh; }
html.m-phone .asutp-du-know { grid-template-columns: minmax(0, 1fr); }
html.m-phone .asutp-du-svg, html.m-phone .asutp-ik-svg { min-width: 640px; max-width: none; }
html.m-phone .asutp-reg-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
html.m-phone .asutp-reg-search, html.m-phone .asutp-reg-feeder, html.m-phone .asutp-conn-filter,
html.m-phone .asutp-conn-rd, html.m-phone .asutp-pnr-q, html.m-phone .asutp-fill-dialog .asutp-reg-bar input { width: 100%; flex: 1 1 100%; }
html.m-phone .asutp-reg-bar, html.m-phone .asutp-refs-actions, html.m-phone .asutp-prot-filters { flex-wrap: wrap; gap: 8px; }
html.m-phone .asutp-prot-filters select { flex: 1 1 45%; }
html.m-phone .asutp-pnr-stages { flex-wrap: wrap; gap: 6px; }
html.m-phone .asutp-pnr-list { max-height: none; }
html.m-phone .asutp-du-title { flex-wrap: wrap; }
html.m-phone .asutp-prot-dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
html.m-phone .asutp-prot-dl dt { margin-top: 6px; font-size: 12px; }

/* окна: поля — в один столбец, отступы меньше */
html.m-phone :is(.asutp-obj-dialog, .asutp-refs-dialog, .asutp-fill-dialog, .asutp-assemble) { padding: 12px; }
html.m-phone :is(.asutp-obj-grid, .asutp-refs-form) { grid-template-columns: minmax(0, 1fr); }
html.m-phone .asutp-obj-field.wide2 { grid-column: auto; }
html.m-phone .asutp-assemble-body { padding: 12px; }
html.m-phone .asutp-obj-history, html.m-phone .asutp-refs-list, html.m-phone .asutp-fill-list,
html.m-phone .asutp-assemble-list { max-height: 40dvh; }

/* цели касания — не мельче 40 px: поля, строки списков, ячейки готовности, ссылки в таблицах, кнопки окон.
   Окна «АСУ ТП» рисуются и внутри #page-asutp (правило «потомкам min-height: auto» выше), и в body —
   поэтому оба адреса и лишний класс в начале (перебить по весу). */
html.m-mobile.m-touch :is(#page-asutp, .asutp-obj-dialog, .asutp-refs-dialog, .asutp-fill-dialog, .asutp-assemble)
  :is(input:not([type="checkbox"]), select) { height: auto; min-height: 40px; }
html.m-mobile.m-touch :is(#page-asutp, .asutp-obj-dialog, .asutp-refs-dialog, .asutp-fill-dialog, .asutp-assemble)
  :is(.asutp-btn, .dialog-actions button, .asutp-du-item, .asutp-pnr-cell, .asutp-reg-card, .asutp-link, .asutp-linkbtn, .asutp-pnr-chk) { min-height: 40px; }
html.m-mobile.m-touch :is(.asutp-link, .asutp-linkbtn) { display: inline-flex; align-items: center; }
html.m-mobile.m-touch :is(#page-asutp, .asutp-obj-dialog, .asutp-refs-dialog, .asutp-fill-dialog, .asutp-assemble)
  .asutp-table input[type="checkbox"] { width: 22px; height: 22px; }

/* Выбор БД/версии в шапке — только на компьютере; здесь — «Проект и версия» (shell.js). */
html.m-mobile .header-project { display: none !important; }

html.m-mobile .kj-report { padding: 6px; }
html.m-mobile .kj-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.m-mobile .kj-updated { margin-left: 0; }
html.m-mobile .kj-row-details { grid-template-columns: 1fr; }
html.m-mobile .kj-document { grid-template-columns: 20px 1fr; }
html.m-mobile .kj-document > span:last-child { grid-column: 2; }
html.m-touch .kj-report button, html.m-touch .kj-report summary { min-height: 40px; }
html.m-mobile .kj-workspace { flex-direction: column; overflow: auto; }
html.m-mobile .kj-nodes { width: auto; max-height: 260px; min-height: 220px; }
html.m-mobile .kj-node-content { flex: none; min-height: 450px; }
html.m-mobile .kj-node-header h3 { font-size: 14px; }

html.m-phone .eqc-columns, html.m-tablet .eqc-columns { grid-template-columns: 1fr; flex: none; }
html.m-phone .eqc-columns > section, html.m-tablet .eqc-columns > section { overflow: visible; }
html.m-phone .eqc-dialog { padding: 12px; }
