/* Телефон.
   1) Режим приложения (.in-app): страницы сайта внутри телефонного приложения /m/. Боковое меню
      раздела выезжает панелью снизу, сверху — полоса «Назад» и название, снизу — меню приложения.
   2) Узкий экран без приложения: широкие таблицы прокручиваются вбок, формы и отборы — в столбик.
   Цвета — только переменные темы «Кобальт» (portal/css/cobalt.css). */

:root {
  --app-bar-h: 56px;
  --app-tabs-h: 64px;
}

/* ================= Режим приложения ================= */

.app-bar {
  position: fixed;
  z-index: 60;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(var(--app-bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 6px 0;
  border-bottom: 1px solid var(--page-line);
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
}

.app-bar__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--page-text);
  cursor: pointer;
}
.app-bar__icon:active,
.app-bar__icon[aria-expanded="true"] { background: var(--hover-bg); color: var(--accent-hi); }
.app-bar__icon:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* «Полная версия сайта»: на телефоне — значок, на широком экране — со словами */
.app-bar__full { text-decoration: none; }
.app-bar__label { display: none; }
@media (min-width: 761px) {
  .app-bar__full {
    display: flex;
    gap: 8px;
    align-items: center;
    width: auto;
    padding: 0 14px;
    font-size: 0.875rem;
    font-weight: 600;
  }
  .app-bar__label { display: inline; }
}

.app-bar__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.app-bar__group { color: var(--page-muted); font-size: 0.75rem; font-weight: 600; }
.app-bar__title {
  overflow: hidden;
  color: var(--page-text);
  font-size: 1.0625rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-tabs {
  position: fixed;
  z-index: 60;
  inset: auto 0 0;
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  height: calc(var(--app-tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--page-line);
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
}

.app-tabs__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--page-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-decoration: none;
}
.app-tabs__item.is-active { color: var(--accent-hi); }
.app-tabs__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

.app-tabs__badge {
  position: absolute;
  top: 7px;
  left: calc(50% + 5px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.app-scrim {
  position: fixed;
  z-index: 65;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
}

.app-locked,
.app-locked body { overflow: hidden; }

/* Каркас: место под полосу сверху и меню снизу */
.in-app .shell {
  display: block;
  min-height: 100vh;
  padding: calc(var(--app-bar-h) + env(safe-area-inset-top) + 8px) 10px
    calc(var(--app-tabs-h) + env(safe-area-inset-bottom) + 18px);
}
.in-app .shell .workspace { min-width: 0; }
.in-app .shell .page { padding: 12px 2px 0; }

/* Меню раздела: панель снизу по кнопке в полосе */
.in-app .shell .sidebar {
  position: fixed;
  z-index: 70;
  inset: auto 0 0;
  top: auto;
  height: auto;
  max-height: 80vh;
  max-height: 80dvh;
  overflow: auto;
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--pop-bg);
  visibility: hidden;
  transform: translateY(104%);
  transition: transform 0.22s ease, visibility 0s linear 0.22s;
  overscroll-behavior: contain;
}
.in-app .shell .sidebar.is-open {
  visibility: visible;
  transform: none;
  transition: transform 0.22s ease;
}
.in-app .shell .sidebar::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin: -6px auto 12px;
  border-radius: 2px;
  background: var(--glass-line-strong);
}
.in-app .shell .sidebar .logo,
.in-app .shell .sidebar .account,
.in-app .shell .menu__back { display: none; }
.in-app .shell .menu { margin-top: 0; }

/* Верхняя строка сайта: в приложении остаются только вкладки стран, одной лентой */
.in-app .shell .topbar {
  position: static;
  min-height: 0;
  margin-bottom: 4px;
  padding: 6px;
  border-radius: 14px;
}
.in-app .shell .topbar:not(:has(.country-tabs)) { display: none; }
.in-app .topbar__search,
.in-app .topbar__end { display: none; }
.in-app .shell .country-tabs {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.in-app .shell .country-tabs::-webkit-scrollbar { display: none; }
.in-app .country-tab { flex: none; }

/* В приложении страница появляется сразу: без подъёма слоёв, роста черты под заголовком и плиток в объёме */
.in-app .shell .page > *,
.in-app .shell .page h1::after,
.in-app .shell .tiles > li,
.in-app .shell .cards > li,
.in-app .shell .table tbody tr,
.in-app .shell .notice { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .in-app .shell .sidebar,
  .in-app .shell .sidebar.is-open { transition: none; }
}

/* ================= Узкий экран: и в приложении, и в браузере телефона ================= */

@media (max-width: 760px) {
  .page h1 { font-size: 1.375rem; line-height: 1.25; }
  .page .head { flex-direction: column; align-items: stretch; gap: 10px; }

  /* Таблицы шире экрана прокручиваются вбок внутри своего блока, страница остаётся на месте */
  .page table { max-width: 100%; }
  .page .list,
  .page .table-wrap,
  .page .sheet,
  .page .calc-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Строки поиска и отборов — в столбик, поля во всю ширину */
  .page form:is(.memo-filter, .filters, .filter) { flex-direction: column; align-items: stretch; }
  .page form:is(.memo-filter, .filters, .filter) :is(input, select, label) { width: 100%; max-width: none; }
  .page .list-bar { flex-wrap: wrap; gap: 8px; }
  .page .list-search { flex: 1 1 100%; }

  /* Карточки-счётчики — по две в ряд */
  .page .memo-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Окна (portal/js/windows.js) — во весь экран */
  .window { inset: 0 !important; width: auto !important; height: auto !important; border-radius: 0 !important; }
}
