/* ═══ МОБИЛЬНЫЙ ВИД ════════════════════════════════════════════════════════
   Подключается ко всем, но действует только когда mobile.js повесил на <body>
   класс «m» — то есть в нашем приложении на телефоне или на узком сенсорном
   экране. На компьютере ни одно правило отсюда не срабатывает.

   Правила вида: один экран — одна задача; всё нажимаемое от 48px; список
   вместо сетки мелких кнопок; постоянные вкладки внизу, у большого пальца.
   Цвета берём из темы программы (переменные), чтобы смена темы работала. */

body.m { overscroll-behavior: none; }
body.m #app-screen {
  height: 100vh; height: 100dvh;           /* dvh — чтобы панель браузера не резала низ */
  display: flex; flex-direction: column;
}

/* ── Шапка ─────────────────────────────────────────────────────────────── */
body.m .m-head {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px;
  height: 56px; padding: 0 8px; background: var(--navbar);
  border-bottom: 1px solid var(--card);
  padding-top: env(safe-area-inset-top);
  height: calc(56px + env(safe-area-inset-top));
}
body.m .m-back {
  width: 40px; height: 40px; flex-shrink: 0; border: 0; background: transparent;
  color: var(--text); font-size: 30px; line-height: 1; cursor: pointer;
}
body.m .m-title {
  font-size: 15px; font-weight: 700; letter-spacing: 1px; color: var(--text);
  text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-left: 6px;
}
body.m .m-head-sp { flex: 1; }
body.m .m-tok {
  position: relative;
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 18px; border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 13px; font-weight: 700;
}
body.m .m-tok-ico { color: var(--acc2); }

/* ── Содержимое ────────────────────────────────────────────────────────── */
body.m .content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 12px 18px;
}
body.m .m-body { max-width: 100%; }

/* ── Список разделов и пунктов ─────────────────────────────────────────── */
body.m .m-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--card); border-radius: 14px; overflow: hidden;
  background: var(--card);
}
body.m .m-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 62px; padding: 12px 14px; text-align: left;
  background: var(--navbar); border: 0; border-bottom: 1px solid var(--card);
  color: var(--text); font-size: 15px; cursor: pointer;
}
body.m .m-item:last-child { border-bottom: 0; }
body.m .m-item:active { background: var(--card2); }
body.m .m-item-ic {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); color: var(--acc2); font-size: 15px;
}
body.m .m-item-txt { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
body.m .m-item-name {
  font-size: 14.5px; font-weight: 600; letter-spacing: .6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.m .m-item-hint {
  font-size: 11.5px; color: var(--muted); letter-spacing: .2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.m .m-item-tag {
  align-self: flex-start; margin-top: 2px; padding: 1px 7px; border-radius: 8px;
  background: var(--red, #E0484D); color: #fff; font-size: 9px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
}
body.m .m-item-go { color: var(--muted); font-size: 19px; flex-shrink: 0; }
/* Закрытый раздел не прячем — мастер должен видеть, что можно докупить. */
body.m .m-item.locked .m-item-name,
body.m .m-item.pconly .m-item-name { color: var(--muted); }

body.m .m-group {
  color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: 2px;
  margin: 18px 4px 8px;
}

/* ── Настройки: язык и тема ────────────────────────────────────────────── */
body.m .m-chips { display: flex; flex-wrap: wrap; gap: 8px; }
body.m .m-chip {
  display: flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; background: var(--navbar); border: 1px solid var(--card);
  color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 1px;
}
body.m .m-chip.active { color: var(--accent); border-color: var(--acc2); }
body.m .m-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
body.m .m-foot {
  margin: 20px 4px 0; color: var(--muted); font-size: 11.5px; line-height: 1.6;
}

/* ── Нижние вкладки ────────────────────────────────────────────────────── */
body.m .m-tabs {
  flex-shrink: 0; display: flex; background: var(--navbar);
  border-top: 1px solid var(--card);
  padding-bottom: env(safe-area-inset-bottom);
}
body.m .m-tab {
  position: relative; flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: 58px; color: var(--muted);
}
body.m .m-tab-ic { font-size: 17px; line-height: 1; }
body.m .m-tab-lb { font-size: 10.5px; letter-spacing: .4px; }
body.m .m-tab.active { color: var(--accent); }
body.m .m-badge {
  position: absolute; top: 8px; right: 50%; transform: translateX(18px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--red, #E0484D); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ── Формы и таблицы внутри инструментов ───────────────────────────────── */
body.m .tool-body, body.m .tool-body.wide { max-width: 100%; }
body.m input, body.m select, body.m textarea { font-size: 16px; }   /* иначе экран «прыгает» */
body.m .field input { padding: 14px 42px 14px 38px; }
body.m .btn { min-height: 48px; border-radius: 12px; }
body.m table.data { display: block; overflow-x: auto; white-space: nowrap; }
body.m .menu-row { gap: 10px; }
body.m .card-btn { flex: 1 1 100%; height: 50px; font-size: 13px; }

/* Окна поверх экрана — снизу, во всю ширину: так до них дотягивается палец. */
body.m .sheet, body.m .modal, body.m .dlg {
  width: 100%; max-width: 100%; border-radius: 18px 18px 0 0;
}

/* Плашка «Тариф не выбран» на телефоне вставала поверх нижних вкладок —
   поднимаем её над ними и растягиваем по ширине экрана. */
body.m .pay-bar {
  left: 10px; right: 10px; transform: none; width: auto; max-width: none;
  bottom: calc(70px + env(safe-area-inset-bottom));
}

/* ═══ ВНУТРЕННОСТИ РАЗДЕЛОВ НА ТЕЛЕФОНЕ ═══════════════════════════════════
   Разделы рисовались колонками: слева список, справа работа. На экране
   шириной 390px две колонки превращаются в две узкие полосы, в которых
   ничего не прочитать. Правило одно: колонки становятся ЭТАЖАМИ, боковые
   панели — во всю ширину, а то, что было фиксированной ширины, тянется. */

/* ── Форум и личные сообщения ──────────────────────────────────────────── */
/* Список тем и переписка — два отдельных экрана: сначала выбираешь тему,
   потом читаешь. Возврат — стрелкой «‹», она уже есть в шапке переписки. */
/* На компьютере форум растянут на всю область отрицательными полями
   (margin: -22px -30px) — под отступы .content там. На телефоне отступы
   другие (12px), из-за чего форум уезжал за левый край экрана. */
body.m .fx-wrap {
  flex-direction: column; gap: 0; height: 100%;
  margin: -12px -12px -18px; width: auto;
}
body.m .fx-side {
  width: 100%; flex: 1; min-height: 0; border-right: 0;
}
body.m .fx-main { display: none; flex: 1; min-height: 0; }
body.m .fx-wrap.fx-reading .fx-side { display: none; }
body.m .fx-wrap.fx-reading .fx-main { display: flex; }


/* ── Разделы с боковой панелью (ADB, ECU EDITOR) ───────────────────────── */
body.m .adb-wrap, body.m .adb-two, body.m .dsh-work,
body.m .e83-grid, body.m .soh-main, body.m .fm {
  display: flex; flex-direction: column; gap: 12px;
}
/* ECU EDITOR: дерево ECU слева (420px) и рабочая область справа — на телефоне
   этажами, дерево ограничиваем по высоте, иначе до работы надо листать минуту. */
body.m .ee-root { flex-direction: column; }
body.m .adb-side, body.m .ee-side {
  width: 100%; border-right: 0;
}
/* На телефоне карточка списка идёт сверху, во всю ширину */
body.m .adb-side { margin: 0 0 12px; align-self: stretch; overflow: visible; }
body.m .ee-side { max-height: 45vh; }
body.m .ee-tree { font-size: 13px; }
body.m .ee-branch, body.m .ee-leaf { padding: 11px 6px; }
body.m .adb-grid, body.m .dsh-meters {
  grid-template-columns: 1fr;                 /* minmax(270..320px) не влезал */
}
body.m .dsh-grid, body.m .stg-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px;
}
body.m .dsh-search { width: 100%; height: 44px; font-size: 16px; }
body.m .dsh-panel, body.m .stg-list, body.m .stg-work { max-width: 100%; }
body.m .soh-inputs, body.m .soh-metrics { grid-template-columns: 1fr; }
body.m .link-grid { grid-template-columns: repeat(2, 1fr); }
body.m .e83-actions .btn { min-width: 0; flex: 1 1 100%; }
body.m .adb-select, body.m .ctl-body .adb-select { max-width: 100%; min-width: 0; }
body.m .ctl-body .adb-range, body.m .adb-range { max-width: 100%; }
body.m .avatr-field { min-width: 0; }
body.m .apk-stat { max-width: 100%; text-align: left; }
body.m .adb-info { max-width: 100%; }

/* Пары «название — значение» (свойства дампа, сведения об устройстве):
   колонка в 110px оставляла значению 60px, переносим значение под ключ. */
body.m .tp-row { flex-direction: column; gap: 2px; }
body.m .tp-k { width: auto; }

/* Всплывающие панели, привязанные к кнопке: на телефоне ширина 230–268px
   вылезала за край, если кнопка была справа. */
body.m .settings-pop, body.m .set-pop {
  width: auto; min-width: 0; max-width: calc(100vw - 20px);
  left: 10px; right: 10px;
}

/* AI-панель занимала правую треть экрана — на телефоне это весь экран. */
body.m .ai-dock-panel { top: 0; bottom: 0; right: 0; width: 100%; max-width: 100%; }
body.m .ai-dock.open .ai-dock-tab { right: 0; }
body.m .ai-hello { max-width: 100%; }
body.m .ai-input { font-size: 16px; }

/* Кошелёк и окна покупки. */
body.m .wal-sum { font-size: 30px; }
body.m .vip-lock { padding: 28px 16px; max-width: 100%; }
body.m .vip-lock .pay-btn { max-width: 100%; }

/* Формы инструментов: поле в 130px под короткое значение (VIN-часть, адрес)
   на телефоне лучше во всю ширину — иначе в него не попасть пальцем. */
body.m .field-narrow { max-width: 100%; }
body.m .form-row { flex-direction: column; align-items: stretch; gap: 10px; }
body.m .res-box, body.m .result { max-width: 100%; overflow-x: auto; }

/* ── Ряды внутри инструментов ──────────────────────────────────────────────
   Половина инструментов расставляет поля строкой прямо в коде
   (style="display:flex"), а такие правила ни один класс не перебьёт. Поэтому
   целимся в сам атрибут style и разрешаем этим строкам переноситься: поле
   занимает всю ширину, кнопки встают парами под ним. Иначе на экране 390px
   поле ввода сжималось в полоску шириной с палец, а кнопки не помещались. */
body.m .content [style*="display:flex"] {
  flex-wrap: wrap !important;
  gap: 10px !important;
  align-items: stretch !important;
}
body.m .content [style*="display:flex"] > input,
body.m .content [style*="display:flex"] > select,
body.m .content [style*="display:flex"] > textarea {
  flex: 1 1 100% !important; width: 100% !important; min-width: 0 !important;
}
body.m .content [style*="display:flex"] > button,
body.m .content [style*="display:flex"] > .btn {
  flex: 1 1 calc(50% - 5px) !important; min-width: 0 !important;
  padding-left: 10px !important; padding-right: 10px !important;
  white-space: normal; line-height: 1.25;
}
/* Ширины вида width:340px, заданные в коде под ноутбук. */
body.m .content [style*="width:"] { max-width: 100% !important; }
body.m .content label[style*="width"] { width: auto !important; }
/* Подписанные поля (label + input) внутри таких строк — тоже во всю ширину:
   иначе они держат заданные в коде 320–340px и справа остаётся пустая полоса. */
body.m .content [style*="display:flex"] > label {
  flex: 1 1 100% !important; width: 100% !important; max-width: 100% !important;
}


/* Форум во весь экран: у страницы убираем поля и прокрутку, листается только
   лента сообщений — иначе при наборе ответа уезжала вся страница целиком. */
body.m .content.content-chat { padding: 0; overflow: hidden; }
body.m .content.content-chat .fx-wrap { margin: 0; height: 100%; }

/* DASHBOARD: список моделей и рабочая область идут этажами, обоим даём всю
   ширину. Высоту списка ограничиваем экраном, иначе до «перетащите дамп»
   пришлось бы листать сотни строк. */
body.m .dsh-side, body.m .dsh-panel, body.m .dsh-work > * { width: 100%; max-width: 100%; }
body.m .dsh-list { max-height: 46vh; }
body.m .dsh-row { min-height: 46px; }

/* ═══════════════════════════════════════════════════════════════════════════
   ВИД КАК НА САЙТЕ (atech-system.com, css/min.css)
   Тёмно-серый фон, плашки без рамок со скруглением, шрифт Inter, крупные
   заголовки. Фирменный красный — только на главной кнопке и отметках.
   Переменные задаём на body.m: они перекрывают тему программы (её ставит
   applyTheme на корень), поэтому на телефоне вид всегда один — как на сайте.
   ═══════════════════════════════════════════════════════════════════════════ */
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

body.m {
  /* Цвета берём из ВЫБРАННОЙ темы (applyTheme ставит их на :root) — так на
     телефоне работают те же темы, что в программе на компьютере. Здесь только
     мобильная раскладка: шрифт Inter, крупные скругления и производный тон
     --mut2 (второй серый), которого в темах нет. */
  --mut2: color-mix(in srgb, var(--muted) 70%, var(--bg));
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 16px; --r-s: 12px;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
}
body.m #app-screen, body.m .content { background: var(--bg); }
/* Моноширинный шрифт программы оставляем только цифрам и кодам (HEX, ключи). */
body.m .content, body.m .m-head, body.m .m-tabs,
body.m .btn, body.m button, body.m input, body.m select, body.m textarea,
body.m label, body.m .status-line, body.m .section-title, body.m .group-label {
  font-family: var(--sans); letter-spacing: 0;
}

/* ── Шапка: полупрозрачная, как у сайта ─────────────────────────────────── */
body.m .m-head {
  background: rgba(30, 30, 30, .86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
body.m .m-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; text-transform: none; }
body.m .m-back { font-size: 32px; font-weight: 300; }
body.m .m-tok {
  border: 0; background: var(--card); border-radius: 999px; height: 34px; padding: 0 14px;
  font-weight: 600; font-size: 14px;
}
body.m .m-tok-ico { color: var(--acc2); font-size: 11px; }

/* ── Главная: приветствие, поиск-«пилюля», сетка плашек ─────────────────── */
body.m .content { padding: 16px 16px 24px; }
body.m .m-hello { padding: 6px 2px 14px; }
body.m .m-hello-t { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
body.m .m-hello-s { color: var(--muted); font-size: 14px; margin-top: 2px; }
body.m .m-search {
  width: 100%; height: 48px; padding: 0 20px; margin: 0 0 16px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
body.m .m-search::placeholder { color: var(--mut2); }
body.m .m-search:focus { outline: none; border-color: var(--muted); }

body.m .m-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { body.m .m-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { body.m .m-grid { grid-template-columns: repeat(4, 1fr); } }
body.m .m-box {
  position: relative; display: flex; flex-direction: column; align-items: flex-start;
  gap: 4px; min-height: 124px; padding: 16px; text-align: left; cursor: pointer;
  background: var(--card); border: 0; border-radius: var(--r); color: var(--text);
  transition: background .15s, transform .12s;
}
body.m .m-box:active { background: var(--card2); transform: scale(.98); }
body.m .m-box-ic { color: var(--text); margin-bottom: auto; line-height: 0; }
body.m .m-box-name { font-size: 15px; font-weight: 600; margin-top: 14px; }
body.m .m-box-hint { font-size: 12px; color: var(--muted); line-height: 1.35; }
body.m .m-box-flag {
  position: absolute; top: 12px; right: 12px; font-size: 10px; font-weight: 700;
  color: var(--muted); background: var(--bg); border-radius: 999px; padding: 3px 8px;
}
body.m .m-box.locked, body.m .m-box.pconly { opacity: .55; }
body.m .m-empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 32px 0; }

/* ── Раздел: инструменты плашками, как модели на сайте ──────────────────── */
body.m .m-group {
  color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em;
  margin: 22px 2px 10px; text-transform: uppercase;
}
body.m .m-group:first-child { margin-top: 4px; }
body.m .m-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { body.m .m-tiles { grid-template-columns: repeat(3, 1fr); } }
body.m .m-tile {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 60px; padding: 12px 10px; border: 0; border-radius: var(--r-s);
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 600;
  text-align: center; line-height: 1.25; cursor: pointer; transition: background .15s;
}
body.m .m-tile:active { background: var(--card2); }
body.m .m-tile-tag {
  position: absolute; top: -6px; right: -4px; padding: 2px 7px; border-radius: 999px;
  background: var(--acc2); color: #fff; font-size: 9px; font-weight: 700; text-transform: uppercase;
}

/* ── Списки «Ещё» ─────────────────────────────────────────────────────────── */
body.m .m-list { border: 0; background: transparent; gap: 8px; border-radius: 0; }
body.m .m-item {
  background: var(--card); border: 0; border-radius: var(--r-s); min-height: 60px;
}
body.m .m-item:active { background: var(--card2); }
body.m .m-item-name { letter-spacing: 0; font-size: 15px; }
body.m .m-chip { background: var(--card); border: 1px solid transparent; border-radius: 999px; color: var(--muted); }
body.m .m-chip.active { color: var(--text); border-color: var(--muted); }

/* ── Нижние вкладки ──────────────────────────────────────────────────────── */
body.m .m-tabs {
  background: rgba(30, 30, 30, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255, 255, 255, .06);
}
body.m .m-tab { color: var(--mut2); min-height: 60px; gap: 4px; }
body.m .m-tab-ic { line-height: 0; }
body.m .m-tab-ic svg { width: 24px; height: 24px; }
body.m .m-tab-lb { font-size: 11px; font-weight: 500; letter-spacing: 0; }
body.m .m-tab.active { color: var(--text); }
body.m .m-tab.active .m-tab-ic { color: var(--acc2); }
body.m .m-badge { background: var(--acc2); top: 6px; }

/* ── Внутри инструментов: поля и кнопки как на сайте ─────────────────────── */
body.m label { color: var(--muted); font-size: 13px; font-weight: 500; }
body.m input, body.m select, body.m textarea {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-s);
  color: var(--text); min-height: 48px; padding: 12px 14px;
}
body.m input:focus, body.m select:focus, body.m textarea:focus { outline: none; border-color: var(--muted); }
body.m .btn {
  border-radius: var(--r-s); min-height: 48px; font-weight: 600; font-size: 14px; letter-spacing: 0;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
/* Главная кнопка — фирменная красная, как «Оставить заявку» на сайте. */
body.m .btn.primary { background: var(--acc2); border-color: var(--acc2); color: #fff; }
body.m .btn.primary:active { filter: brightness(.92); }
body.m .card-btn, body.m .link-card {
  background: var(--card); border: 0; border-radius: var(--r-s); color: var(--text);
  font-weight: 600; font-size: 14px;
}
body.m .status-line { color: var(--muted); font-size: 13px; }
body.m .section-title { color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
body.m .tool-header { font-size: 17px; letter-spacing: 0; text-transform: none; }
body.m table.data th, body.m table.data td { border-color: var(--border); }
body.m table.data th, body.m table.data td.rowlabel { background: var(--bg); }

/* Окна (кошелёк, новости, оплата) — выезжают снизу, как листы в iOS/Android. */
body.m .sheet-overlay { align-items: flex-end; padding: 0; bottom: var(--kb, 0px); }
body.m .sheet {
  width: 100%; max-width: 100%; max-height: 88vh; border: 0;
  max-height: calc(var(--vvh, 100dvh) * .88);
  border-radius: 22px 22px 0 0; background: var(--card);
  padding-bottom: env(safe-area-inset-bottom);
}
body.m .sheet-top { background: none; }

/* Общий стиль красит кнопки действий цветом --accent с !important, а на
   телефоне --accent белый — кнопки становились белыми без надписи. */
body.m .adb-hero-btn, body.m .cs-run, body.m .fm-copy {
  background: var(--acc2) !important; color: #fff !important; border: 0;
}

/* ── Экран входа: как кабинет на сайте ───────────────────────────────────
   Карточка во всю ширину без рамки и тени, поля и кнопка крупные, главная
   кнопка «Войти» — фирменная красная. */
body.m #login-screen {
  min-height: 100vh; min-height: 100dvh; height: auto; align-items: flex-start;
  padding: calc(40px + env(safe-area-inset-top)) 18px 24px; overflow-y: auto;
}
body.m .auth-card {
  width: 100%; max-width: 420px; margin: 0 auto; padding: 0;
  background: none; border: 0; box-shadow: none;
}
body.m .login-logo-img { height: 56px; margin-bottom: 26px; }
body.m .auth-tabs { background: var(--card); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
body.m .auth-tab { min-height: 42px; border-radius: 999px; font-size: 14px; font-weight: 600; letter-spacing: 0; }
body.m .auth-pill { border-radius: 999px; background: var(--card2) !important; }
body.m .field input {
  min-height: 52px; border-radius: var(--r-s); background: var(--card); border: 1px solid var(--border);
}
body.m .auth-submit {
  min-height: 54px; border-radius: var(--r-s); font-size: 16px; letter-spacing: .02em;
  background: var(--acc2) !important; border: 0; color: #fff !important;
}
body.m .login-remember { font-size: 14px; color: var(--muted); }
body.m .google-btn { min-height: 52px; border-radius: var(--r-s); background: var(--card); border: 1px solid var(--border); }
body.m #login-screen .auth-card {
  background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important;
}
body.m .auth-card form { gap: 12px; }
body.m .field-ic { top: 50%; transform: translateY(-50%); left: 16px; font-size: 15px; }
body.m .field input { padding: 0 48px 0 46px !important; }
body.m .field-eye { top: 50%; transform: translateY(-50%); right: 8px; font-size: 16px; padding: 10px; }
body.m .login-remember { display: flex; align-items: center; gap: 10px; text-transform: none; margin: 4px 2px; }
body.m .login-remember input { min-height: 0; width: 20px; height: 20px; padding: 0; }

/* ═══ ECU EDITOR НА ТЕЛЕФОНЕ ═══════════════════════════════════════════════
   Редактор рисовался под ноутбук: дерево ECU слева, справа поля и кнопки в
   строке высотой ровно 120px, а сама страница без прокрутки (overflow:hidden
   ставит buildEcuEditor). На телефоне всё это сжималось: кнопки в узкую
   колонку, поля налезали друг на друга. Здесь раскладываем сверху вниз:
   дерево → название → поля → кнопки 2×2 → журнал → таблица DTC, и
   разрешаем странице прокручиваться. */
body.m .content:has(.ee-root) { overflow-y: auto !important; padding: 0 !important; }
body.m .ee-root { flex-direction: column; height: auto; min-height: 100%; }
body.m .ee-side {
  width: 100%; max-height: 42vh; padding: 12px 14px; border-right: 0;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
body.m .ee-banner { font-size: 12px; }
body.m .ee-right { padding: 14px 14px 8px; }
body.m .ee-title { font-size: 17px; margin-bottom: 10px; }
/* строка «поля + кнопки» с жёсткой высотой 120px */
body.m .ee-right > div[style*="height:120px"] {
  height: auto !important; flex-direction: column !important; gap: 12px !important;
}
body.m .ee-right [style*="width:280px"] { width: 100% !important; gap: 8px !important; }
/* «ECU: [поле]», «ID: [поле]» — подпись и поле в одну строку */
body.m .ee-right [style*="width:280px"] > div {
  flex-wrap: nowrap !important; align-items: center !important;
}
body.m .ee-right [style*="width:280px"] > div > input { flex: 1 1 auto !important; width: auto !important; }
body.m .ee-lbl { font-size: 12px; min-width: 36px; }
/* кнопки действий — сеткой 2×2 во всю ширину */
body.m .ee-right .ee-cta {
  flex: 1 1 calc(50% - 5px) !important; min-height: 46px; border-radius: var(--r-s);
  font-size: 14px; font-weight: 600;
}
body.m .ee-log { min-height: 72px; max-height: 140px; border-radius: var(--r-s); font-size: 12px; }
body.m .ee-search { width: 100% !important; min-height: 44px; border-radius: var(--r-s); }
body.m .ee-x { width: 44px; height: 44px; border-radius: var(--r-s); }
/* таблица DTC: высота по экрану, листается внутри */
body.m .ee-right [style*="flex:1;min-height:0"] { min-height: 55vh; }
body.m .ee-table { font-size: 13px; }
body.m .ee-table td { padding: 10px 8px; }
body.m .ee-bottom {
  position: sticky; bottom: 0; height: auto; min-height: 44px; padding: 6px 10px; z-index: 2;
}
body.m .ee-bottom .ee-sec { min-height: 34px !important; height: auto !important; border-radius: 999px; }
body.m .ee-status { font-size: 12px; }
/* Поиск ECU и кнопки «найти / очистить» — одной строкой, кнопки квадратные. */
body.m .ee-side > div[style*="display:flex"] { flex-wrap: nowrap !important; }
body.m .ee-side > div[style*="display:flex"] > input { flex: 1 1 auto !important; width: auto !important; }
body.m .ee-side > div[style*="display:flex"] > .ee-x { flex: 0 0 48px !important; width: 48px; height: 48px; }

/* ECU EDITOR по шагам (см. mEcuEditorSteps в mobile.js): на экране либо
   выбор ECU, либо работа — не оба сразу. */
body.m .ee-root.m-ee-pick > :nth-child(2) { display: none !important; }
body.m .ee-root.m-ee-work > :nth-child(1) { display: none !important; }
body.m .ee-root.m-ee-pick .ee-side { max-height: none; min-height: 100%; border-bottom: 0; }
body.m .ee-root.m-ee-pick .ee-tree { max-height: none; overflow: visible; font-size: 15px; }
body.m .ee-root.m-ee-pick .ee-branch, body.m .ee-root.m-ee-pick .ee-leaf {
  padding: 13px 8px; border-radius: 10px; white-space: normal;
}
body.m .ee-root.m-ee-pick .ee-leaf.active { background: var(--acc2); }
body.m .m-ee-hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 2px 2px 10px; }
body.m .m-ee-change {
  display: inline-flex; align-items: center; align-self: flex-start; margin: 12px 14px 0;
  min-height: 38px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 600;
}
body.m .m-logo { height: 24px; width: auto; display: block; }
/* Надпись «A-TECH EDITOR» в редакторе лишняя: название раздела уже в шапке. */
body.m .ee-banner { display: none; }
body.m .m-logo { height: 30px; }
/* Строка «Поиск: [поле] [×]  Файл: [имя]» — сеткой: поиск с крестиком в
   одну строку, имя файла отдельной строкой, подписи над полями. */
body.m .ee-right div[style*="margin-bottom:8px"] {
  display: grid !important; grid-template-columns: 1fr 48px; gap: 6px 8px !important;
  align-items: center !important;
}
body.m .ee-right div[style*="margin-bottom:8px"] > .ee-lbl { grid-column: 1 / -1; margin: 4px 0 0 !important; }
body.m .ee-right div[style*="margin-bottom:8px"] > .ee-search { grid-column: 1; }
body.m .ee-right div[style*="margin-bottom:8px"] > .ee-x { grid-column: 2; width: 48px !important; height: 48px; }
body.m .ee-right div[style*="margin-bottom:8px"] > .ee-ro { grid-column: 1 / -1; width: 100% !important; }
/* Ссылки на сайт и соцсети в «Ещё» — такие же строки, как пункты меню. */
body.m .m-link { text-decoration: none; color: var(--text); }
body.m .m-item .m-item-ic { background: var(--bg); color: var(--text); width: 40px; height: 40px; border-radius: 12px; line-height: 0; }
body.m .m-item .m-item-ic svg { width: 22px; height: 22px; }


/* Шапку и вкладки прячем только в ПЕРЕПИСКЕ (у неё своя шапка со стрелкой).
   Форма «Задать вопрос» и выбор собеседника своей стрелки не имеют — там
   шапка программы остаётся, и её «‹» возвращает к списку вопросов. */
body.m:has(.fx-wrap.fx-reading) .m-head,
body.m:has(.fx-wrap.fx-reading) .m-tabs { display: flex; }
body.m:has(.fx-wrap.fx-reading .fx-head) .m-head,
body.m:has(.fx-wrap.fx-reading .fx-head) .m-tabs { display: none; }
body.m:has(.fx-wrap.fx-reading) .m-back { display: flex !important; }

/* Панель «✎ 🗑» в углу сообщения на телефоне не показываем — её заменяет
   меню по долгому нажатию (внизу экрана, крупные кнопки). */
body.m .fx-tools { display: none; }
body.m .fx-bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.m .fx-text { -webkit-user-select: text; user-select: text; }
.m-sheet-ov {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; animation: atFadeUp .15s ease both;
}
.m-sheet {
  width: 100%; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.m-sheet-btn {
  min-height: 54px; border: 0; border-radius: 14px; background: var(--card); color: var(--text);
  font-family: var(--sans); font-size: 16px; font-weight: 600;
}
.m-sheet-btn.danger { color: var(--red, #e5484d); }
.m-sheet-btn.cancel { background: var(--bg); color: var(--muted); margin-top: 4px; }

/* ═══ HEX НА ТЕЛЕФОНЕ ══════════════════════════════════════════════════════
   8 байт в строке (buildHex), файлы друг под другом. Кнопки — сеткой по три,
   поля поиска и перехода — на всю строку. */
body.m .hex-bar {
  display: grid !important; grid-template-columns: repeat(6, 1fr); gap: 8px !important;
  margin-bottom: 10px !important;
}
body.m .hex-bar > * { grid-column: span 2; min-width: 0 !important; }
body.m .hex-bar > .btn { min-height: 44px; padding: 0 6px !important; font-size: 13px; }
body.m .hex-bar > input { width: 100% !important; min-height: 44px; font-size: 16px; }
/* Порядок на телефоне (в коде кнопки идут строкой под ноутбук):
   Файл 1 · Файл 2 · Сравнить / Сохр. 1 · Сохр. 2 · Sync / ◄ Diff · Diff ►
   / [поиск] Найти / [адрес] GO */
body.m .hex-bar > :nth-child(1)  { order: 1; }
body.m .hex-bar > :nth-child(3)  { order: 2; }
body.m .hex-bar > :nth-child(5)  { order: 3; }
body.m .hex-bar > :nth-child(2)  { order: 4; }
body.m .hex-bar > :nth-child(4)  { order: 5; }
body.m .hex-bar > :nth-child(13) { order: 6; }
body.m .hex-bar > :nth-child(6)  { order: 7; grid-column: span 3; }
body.m .hex-bar > :nth-child(7)  { order: 8; grid-column: span 3; }
body.m .hex-bar > :nth-child(8)  { order: 9; grid-column: span 4; }
body.m .hex-bar > :nth-child(9)  { order: 10; }
body.m .hex-bar > :nth-child(10) { display: none; }       /* подпись «GOTO:» */
body.m .hex-bar > :nth-child(11) { order: 11; grid-column: span 4; }
body.m .hex-bar > :nth-child(12) { order: 12; }
body.m .hex-panes { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }

/* HEX читаемее: крупнее шрифт, воздух между строк, адрес приглушён, различия
   не только красным текстом, но и фоновой подсветкой — их видно сразу. */
body.m .hex-rows { font-size: 14px !important; }
body.m .hex-off { color: var(--mut2); }
body.m .hex-asc { color: var(--acc2); }
body.m .hex-pane .hb { padding: 2px 1px; border-radius: 3px; }
body.m .hex-pane .hd { background: color-mix(in srgb, var(--red) 22%, transparent); color: #fff !important; border-radius: 3px; }
body.m .hex-pane .ha.hd { background: color-mix(in srgb, var(--red) 22%, transparent); color: #fff !important; }

body.m .hex-pane { height: 46vh; min-height: 280px; flex: none !important; }
body.m .hex-pane > div:last-child { border-radius: 12px; border-color: var(--border) !important; }
body.m .hex-pane .status-line { font-size: 12.5px; padding: 4px 2px !important; }
body.m .hex-pane .hb { padding: 1px 0; }
body.m .hex-status { margin: 4px 2px 0; font-size: 12.5px; letter-spacing: 0; text-transform: none; white-space: pre-wrap; }

/* ═══ BATTERY (SOH) НА ТЕЛЕФОНЕ ════════════════════════════════════════════
   Поля ввода — одной плашкой с крупным числом (без рамки-в-рамке), результат:
   батарея и процент рядом, под ними три показателя во всю ширину и шкала
   состояния, у которой подписи не налезают друг на друга. */
body.m .soh-wrap { gap: 12px; }
body.m .soh-inputs { grid-template-columns: 1fr 1fr; gap: 10px; }
body.m .soh-go { grid-column: 1 / -1; min-height: 52px; }
body.m .soh-field {
  padding: 14px 14px 12px; border-radius: var(--r); border: 0; background: var(--card); gap: 4px;
}
body.m .soh-field i { font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
body.m .soh-field small { font-size: 11.5px; letter-spacing: 0; }
body.m .soh-input input {
  background: transparent !important; border: 0 !important; padding: 0 !important; min-height: 0;
  font-size: 26px; font-weight: 700; width: 100%; color: var(--text);
}
body.m .soh-input u { font-size: 14px; }
body.m .soh-main {
  display: flex !important; flex-direction: column; gap: 16px;
  padding: 18px 16px; border-radius: var(--r); border: 0; background: var(--card);
}
body.m .soh-dial { gap: 22px; justify-content: center; }
body.m .soh-dial svg { width: 110px; height: auto; }
body.m .soh-pct { font-family: var(--sans); font-size: 44px; letter-spacing: -.02em; }
body.m .soh-cap { letter-spacing: .08em; font-size: 12px; }
body.m .soh-side { width: 100%; gap: 14px; }
body.m .soh-metrics { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; width: 100%; }
body.m .soh-metric {
  padding: 10px 10px; border-radius: 12px; border: 0; background: var(--bg); min-width: 0;
}
body.m .soh-metric i { font-size: 11px; letter-spacing: 0; text-transform: none; }
body.m .soh-metric b { font-family: var(--sans); font-size: 17px; letter-spacing: -.01em; }
body.m .soh-scale { width: 100%; }
body.m .soh-legend { font-size: 11px; letter-spacing: 0; gap: 4px; }
body.m .soh-legend > * { white-space: nowrap; }

/* Кружок темы в «Ещё»: тонкая обводка, чтобы белый кружок был виден на
   тёмном фоне и наоборот. */
body.m .m-theme .m-dot { border: 1px solid color-mix(in srgb, var(--text) 30%, transparent); }

/* WIRING: ссылки-плитки крупнее и в два столбца, чтобы попадать пальцем. */
body.m .link-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
body.m .link-card { min-height: 52px; display: flex; align-items: center; font-size: 13px; padding: 10px 12px; }
body.m .m-ver { color: var(--muted); font-size: 12px; text-align: center; padding: 18px 0 4px; opacity: .7; }
/* На телефоне полосу обновления поднимаем под шапку и растягиваем. */
body.m .uiupd { top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; transform: none; justify-content: center; }

/* Панель тарифа от кнопки баланса — на телефоне пошире и по правому краю */
/* Панель тарифа на телефоне: отдельно от кнопки, на всю ширину под шапкой */
body.m .settings-pop.plans-pop.m-fixed {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); bottom: auto;
  left: 10px; right: 10px; width: auto; max-width: none; z-index: 950;
  transform-origin: top center;
}
body.m .plans-pop .set-theme { padding: 11px 12px; font-size: 13px; }
body.m .plans-pop .set-title { font-size: 10.5px; }

/* ═══ ЭКРАН ВХОДА НА ТЕЛЕФОНЕ (2026-10-04) — как в M-ALI ═══
   Тёмная шапка бренда сверху, форма на карточке, которая наезжает снизу. */
body.m #login-screen {
  flex-direction: column; align-items: stretch; padding: 0; overflow-y: auto;
  min-height: 100vh; min-height: 100dvh;
}
body.m #login-screen .auth-brand {
  flex: 0 0 auto; justify-content: flex-start;
  padding: calc(34px + env(safe-area-inset-top)) 26px 62px;
}
body.m #login-screen .ab-logo { width: 180px; margin-left: -4px; }
body.m #login-screen .ab-sub { font-size: 12px; letter-spacing: 6px; }
body.m #login-screen .ab-bar { width: 44px; margin-top: 16px; }
body.m #login-screen .ab-tag { font-size: 14px; margin-top: 12px; color: var(--muted); }
body.m #login-screen .ab-mods, body.m #login-screen .ab-foot { display: none; }
body.m #login-screen .auth-side {
  flex: 1 0 auto; display: block; margin-top: -30px; position: relative; z-index: 1;
  background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .18);
}
body.m #login-screen .auth-card { width: 100%; max-width: 460px; margin: 0 auto; }
body.m #login-screen .auth-hello { margin-bottom: 20px; }
body.m #login-screen .auth-hello h2 { font-size: 24px; }
body.m #login-screen .auth-tabs { border-radius: 14px; }
body.m #login-screen .auth-pill { border-radius: 10px; background: var(--card2) !important; }
body.m #login-screen .field input { min-height: 54px; border-radius: 14px; }
body.m #login-screen .auth-submit {
  min-height: 56px; border-radius: 14px; font-size: 16px;
  background: #E30613 !important; color: #fff !important;
}
body.m #login-screen .ab-logo { width: 160px; margin-left: 0; }
body.m #login-screen .ab-sub { margin-top: 10px; }
body.m #login-screen { background: var(--bg); }
body.m #login-screen .auth-brand { background: var(--navbar); }
body.m #login-screen .auth-side { background: var(--bg); }
body.m #login-screen .auth-brand {
  background: radial-gradient(520px 340px at 15% 20%, rgba(227, 6, 19, .14), rgba(227, 6, 19, 0) 75%), var(--navbar);
}
body.m #login-screen .auth-brand {
  background: radial-gradient(700px 420px at 15% 20%, rgba(227, 6, 19, .07), rgba(227, 6, 19, 0) 80%), var(--navbar);
}
body.m #login-screen .auth-brand {
  background: radial-gradient(700px 420px at 15% 20%, rgba(227, 6, 19, .12), rgba(227, 6, 19, .04) 80%), var(--navbar);
}
body.m #login-screen .auth-brand {
  background: radial-gradient(800px 500px at 15% 20%,
    rgba(227, 6, 19, .08) 0%, rgba(227, 6, 19, .045) 30%, rgba(227, 6, 19, .015) 60%, rgba(227, 6, 19, 0) 90%),
    var(--navbar);
}
body.m #login-screen .auth-brand {
  background: radial-gradient(ellipse 120% 140% at -25% -20%, rgba(227, 6, 19, .10), rgba(227, 6, 19, 0) 100%), var(--navbar);
}
body.m .adb-svc-grid { grid-template-columns: 1fr 1fr; }
body.m .adb-svc-btn { min-height: 58px; }

/* ── Светлые темы (Light, Mono): верх/низ — БЕЛОЕ матовое стекло ──────────
   У .m-head и .m-tabs фон жёстко тёмный (rgba(30,30,30,…)), поэтому на белой
   теме строка статуса (вверху) и панель навигации (внизу) оставались тёмными.
   Эти панели через env(safe-area-inset-*) красят и системные полосы, поэтому
   делаем их белыми — тогда весь экран на теме Mono действительно белый. */
html.light body.m .m-head {
  background: rgba(255, 255, 255, .82);
  border-bottom-color: rgba(0, 0, 0, .08);
}
html.light body.m .m-tabs {
  background: rgba(255, 255, 255, .88);
  border-top-color: rgba(0, 0, 0, .08);
}

/* ── Apple-глубина на светлых темах (Light, Mono) ────────────────────────
   Белые карточки на белом фоне сливались — добавляем мягкую тень и чуть
   больше воздуха, как в iOS. Тёмные темы не трогаем. */
html.light body.m .m-box,
html.light body.m .m-tile,
html.light body.m .m-item,
html.light body.m .m-tok {
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .05);
}
html.light body.m .m-box:active,
html.light body.m .m-tile:active,
html.light body.m .m-item:active { box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }

/* ═══════════════════════════════════════════════════════════════════════
   МОБИЛЬНЫЙ APPLE-ПРОХОД v2 — размеры, отступы, радиусы, типографика.
   Только внешний вид (без изменения разметки/логики). Переопределяет значения
   выше за счёт порядка в файле. Крупнее цели для пальца, больше воздуха, мягче
   формы — как в iOS. ═══════════════════════════════════════════════════════ */

/* 1 · Главная: крупнее иконки и воздух, мягче плашки */
body.m .m-grid { gap: 14px; }
body.m .m-box { min-height: 134px; padding: 18px; border-radius: 20px; }
body.m .m-box-ic { font-size: 26px; }
body.m .m-box-ic svg { width: 28px; height: 28px; }
body.m .m-box-name { font-size: 16px; margin-top: 16px; letter-spacing: -.01em; }
body.m .m-hello { padding: 8px 2px 16px; }
body.m .m-hello-t { font-size: 30px; }

/* 2 · Разделы: плашки инструментов крупнее и читаемее */
body.m .m-tiles { gap: 10px; }
body.m .m-tile { min-height: 68px; border-radius: 16px; font-size: 15px; padding: 14px 12px; }

/* 3 · Списки (ADB/Ещё): ряды iOS с крупной целью */
body.m .m-item { min-height: 58px; border-radius: 14px; padding: 0 14px; }
body.m .m-item-name { font-size: 16px; }

/* 4 · Страницы инструментов: поля и кнопки — единый радиус, комфортная высота */
body.m input, body.m select, body.m textarea { min-height: 50px; border-radius: 12px; }
body.m .btn, body.m .card-btn, body.m .link-card { border-radius: 12px; }
body.m .btn { min-height: 50px; font-size: 15px; }
body.m .btn.primary { min-height: 54px; font-weight: 700; font-size: 16px; }

/* 5 · Шапка и нижние вкладки: iOS-пропорции */
body.m .m-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
body.m .m-tab { min-height: 56px; }
body.m .m-tab-ic svg { width: 25px; height: 25px; }
body.m .m-tab-lb { font-size: 10.5px; font-weight: 500; }
