/* Мобильное приложение qisap (указание заказчика 18.11.2026): сайт на экране телефона и на экране «Домой».
   Файл подключается после app.css и общих правил не переписывает: здесь только экраны приложения («Сегодня»,
   карточка клиента, «Ещё»), нижние вкладки и то, что меняется на экране телефона (до 640 точек).
   Токены те же: --gap, --pad, --ctl-h; блочная схема та же — каждый объект отдельным блоком. */

/* ——— 1. экраны приложения: работают на любой ширине ——— */
.tabbar { display: none; }
.m-card > h3 { margin: 0 0 8px; }
.m-head > p { margin: 2px 0 0; color: var(--text-2); }
.m-list { display: flex; flex-direction: column; }
.m-row { font: inherit; color: inherit; text-align: left; text-decoration: none; width: 100%; min-height: 54px; box-sizing: border-box; padding: 8px 0; border: 0; border-top: 1px solid var(--border-subtle); background: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.m-row:first-child { border-top: 0; }
.m-row:hover { text-decoration: none; }
.m-row:hover .m-row-main b { color: var(--violet-700); }
.m-row > .icon:last-child { color: var(--text-3); }
.m-row.off { opacity: 0.5; }
.m-row-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--violet-50); color: var(--violet-700); display: grid; place-items: center; flex-shrink: 0; }
.m-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-row-main b { font-weight: 700; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.m-row-main small { color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; color: var(--text-3); }
.m-row-side small { font-size: 12px; }
.m-row .badge { flex-shrink: 0; }
.m-more { align-self: flex-start; margin-top: 4px; }
.m-card > .hint { margin: 8px 0 0; }
.m-card > .hint + .hint { margin-top: 4px; }
.m-acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap-sm); margin-top: 14px; }
.m-act { font: inherit; font-weight: 650; color: var(--violet-700); background: var(--violet-50); border: 1px solid var(--violet-100); border-radius: var(--r-el); height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; min-width: 0; }
.m-act:hover { background: var(--violet-100); }
.m-act span { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-risks { display: flex; flex-direction: column; gap: 10px; }
.m-risks .mon-risk { box-shadow: none; }
.m-risks .empty, .m-card > .empty, .m-list > .empty { padding: 16px 8px; }
.m-steps { margin: 8px 0 0; padding-left: 22px; line-height: 1.55; color: var(--text-2); }
/* сведения об уведомлениях на устройстве: «что — как сейчас», двумя столбцами */
.m-facts dl { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; font-size: 13px; line-height: 1.45; }
.m-facts dt { color: var(--text-2); }
.m-facts dd { margin: 0; overflow-wrap: anywhere; }
.m-install-hint { margin: 0; }
.m-crumb { display: flex; align-items: center; gap: 10px; min-height: var(--ctl-h); margin-bottom: var(--gap); padding: 4px 12px 4px 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); }
.m-crumb-back { display: inline-flex; align-items: center; gap: 2px; height: var(--ctl-h-sm); padding: 0 8px 0 2px; border-radius: 8px; font-weight: 650; }
.m-crumb-back:hover { background: var(--violet-50); text-decoration: none; }
.m-crumb b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-toolbar > input[type="search"] { flex: 1 1 200px; }

/* сообщение о новой версии: приложение с экрана «Домой» само не перезагружается */
.update-bar { position: fixed; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 70; max-width: 520px; margin: 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--violet-200); border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.update-bar > span { flex: 1 1 160px; font-weight: 650; }

/* ——— 2. экран телефона ——— */
@media (max-width: 640px) {
  :root { --gap: 12px; --pad: 14px; }
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
  /* поле со шрифтом мельче 16 айфон при вводе увеличивает вместе со всей страницей */
  input, select, textarea, textarea.plain, .combo input { font-size: 16px; }

  /* каркас на телефоне: окно прокручивается целиком, панели разделов нет — вместо неё нижние вкладки */
  .shell { display: block; height: auto; min-height: 100vh; }
  .body { display: block; padding: 12px max(12px, env(safe-area-inset-right)) 28px max(12px, env(safe-area-inset-left)); }
  .stage { overflow: visible; margin: 0; padding: 0; }
  .rail, .rail-menu { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--glass); border-top: 1px solid var(--border); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .tab { height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 10px; color: var(--text-3); font-size: 11.5px; font-weight: 500; text-decoration: none; min-width: 0; }
  .tab:hover { text-decoration: none; }
  .tab.active { background: var(--brand-tint); color: var(--accent-fg); }
  .tab-icon { position: relative; display: block; }
  .tab-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-count { position: absolute; top: -5px; left: 13px; min-width: 17px; box-sizing: border-box; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center; }
  .shell { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* верхняя полоса остаётся на месте при прокрутке: организация, монитор и учётная запись всегда под рукой.
     Инструменты фирмы, поиск функций и ряд открытых окон на телефоне не показываются: к разделам ведут нижние вкладки */
  .top { position: sticky; top: 0; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto; min-height: 54px; column-gap: 8px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .top-tools, .top-find, .wtabs, .gw { display: none; }
  .org-pick { flex: 1 1 auto; min-width: 0; }
  .org-pick select { font-size: 16px; }
  .top-right { gap: 8px; }
  .page-head h1 { font-size: 19px; }
  /* у раздела, открытого с экрана «Ещё», название уже стоит в строке возврата */
  .m-crumb + * > .page-head > h1 { display: none; }
  .m-crumb + * > .page-head > .page-actions { margin-left: 0; }

  /* монитор (задачи, переписка, риск-монитор) занимает весь экран */
  .monitor { position: fixed; inset: 0; width: auto; height: auto; z-index: 35; border: 0; border-radius: 0; box-shadow: none; padding-bottom: env(safe-area-inset-bottom); }
  .monitor-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  .monitor-head .icon-btn { width: 40px; height: 40px; }

  /* плитки — по две в ряд */
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 14px; }
  .stat-icon { margin-bottom: 6px; }
  .stat-label { font-size: 13.5px; }
  .stat-value { font-size: 21px; }

  /* панель действий: отбор — в две колонки, поиск и главное действие — во всю ширину */
  .toolbar > .spacer { display: none; }
  .toolbar > .seg:first-child { flex: 1 1 100%; }
  .toolbar > .seg:first-child button { flex: 1 1 0; padding: 0 6px; }
  .toolbar > select { flex: 1 1 140px; min-width: 0; }
  .toolbar > .combo { flex: 1 1 200px; min-width: 0; }
  /* итоги с подписью («Весь счёт-фактура —», «Доля организации —»): подпись — своей строкой, суммы под ней */
  .totals > .muted:first-child { flex-basis: 100%; }
  .toolbar > input[type="search"], .toolbar > input[type="text"] { flex: 1 1 100%; min-width: 0 !important; }
  .toolbar > .btn.primary { flex: 1 1 100%; }
  .m-toolbar > input[type="search"] { flex: 1 1 100%; }

  /* окна: диалог выезжает снизу, окно сбоку — во весь экран; всё учитывает нижнюю полосу телефона */
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel, .modal-panel.small { width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .drawer-panel, .drawer-panel.wide { width: 100vw; padding: calc(14px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom)); }
  /* шапка окна закреплена и закрывает собой верхнее поле окна: при `top: 0` она вставала ниже поля, и в полосе над ней
     был виден прокручиваемый текст */
  .drawer-head { position: sticky; top: calc(-14px - env(safe-area-inset-top)); z-index: 1; background: var(--surface); margin-top: calc(-14px - env(safe-area-inset-top)); padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: 8px; margin-bottom: 8px; }
  .toasts { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .account-menu { position: fixed; top: calc(58px + env(safe-area-inset-top)); right: 12px; left: 12px; width: auto; max-width: none; }
  .side-menu { top: calc(58px + env(safe-area-inset-top)); left: 12px; right: 12px; width: auto; }
  .actions { flex-wrap: wrap; }

  /* переписка: лента занимает экран до поля ответа */
  .msg-feed { max-height: none; min-height: 40vh; }
  .msg-b { max-width: 88%; }

  /* формы — в одну колонку */
  .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .form-grid > .span2 { grid-column: auto; }
}

/* ——— 3. приложение с экрана «Домой»: ничего лишнего от страницы браузера ——— */
html.installed body { -webkit-touch-callout: none; }
html.installed .gate { padding-top: calc(5vh + env(safe-area-inset-top)); }
