/* Mobile MVP: отдельный каскад поверх desktop-интерфейса. */
.mobile-nav { display: none; }

@media (max-width: 767px) {
  :root {
    --mobile-nav-height: 68px;
    --mobile-edge: 10px;
  }

  html { overflow: hidden; background: var(--bg, #f6f7f9); }
  body {
    min-width: 0;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }

  button, a, input, select, textarea, summary { touch-action: manipulation; }
  input, select, textarea { font-size: 16px !important; }

  .layout {
    display: block;
    width: 100%;
    height: var(--mobile-viewport-height, 100dvh);
    min-width: 0;
  }

  .sidebar { display: none !important; }

  .workspace {
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 10px 10px calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 10px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .workspace.workspace--fullbleed {
    padding: 0 0 calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)) !important;
  }

  .workspace.workspace--fullbleed #content { height: 100% !important; }

  .mobile-nav {
    position: fixed;
    z-index: 400;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 5px max(5px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(5px, env(safe-area-inset-left));
    border-top: 1px solid #dfe3e8;
    background: rgba(255,255,255,.96);
    box-shadow: 0 -8px 28px rgba(15,23,42,.1);
    backdrop-filter: blur(16px);
  }

  .mobile-nav__item,
  body:not(.sidebar-expanded) .mobile-nav__item {
    position: relative;
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 56px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    padding: 5px 2px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #667085;
    font: inherit;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
  }

  .mobile-nav__item .icon { width: 21px; height: 21px; }
  .mobile-nav__item > span:not(.notification-button__icon) { display: block !important; white-space: nowrap; }
  .mobile-nav__item.is-active { background: #eff6ff; color: #1d4ed8; }
  .mobile-nav__item.is-active::before { display: none; }
  .mobile-nav__item:focus-visible { outline: 3px solid #bfdbfe; outline-offset: -2px; }
  .mobile-nav .notification-count { top: -6px; right: -8px; }
  body:has(dialog[open]) .mobile-nav { visibility: hidden; pointer-events: none; }

  /* Главная */
  .home-page { max-width: none; padding: 8px 0 20px; }
  .home-header { gap: 12px; margin-bottom: 14px; }
  .home-title { font-size: 24px; }
  .home-header__actions { gap: 8px; }
  .home-header__actions > * { min-height: 44px; }
  .home-stats, .home-grid, .home-extra-grid, .home-finance__metrics { grid-template-columns: 1fr !important; }
  .home-stat:nth-child(even) { border-left: 0 !important; }
  .home-stat + .home-stat { border-top: 1px solid var(--border); }
  .home-card { padding: 15px; border-radius: 14px; }
  .today-lesson { grid-template-columns: 72px minmax(0,1fr) 34px; padding: 11px 0; }
  .quick-actions { grid-template-columns: 1fr 1fr; }

  /* Уведомления становятся полноэкранным мобильным листом. */
  .notification-center,
  .home-attention-dialog {
    inset: auto 0 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: min(88dvh, 760px);
    max-height: 100dvh !important;
    margin: auto 0 0 !important;
    border-radius: 20px 20px 0 0 !important;
  }
  .notification-center__shell { height: 100%; }
  .notification-center__content { flex: 1; min-height: 0; }
  .notification-center__header { padding: 17px 15px 13px; }
  .notification-center__title-row { align-items: flex-start; flex-direction: column; }
  .notification-filters { max-width: 100%; overflow-x: auto; }
  .notification-card { grid-template-columns: 34px minmax(0,1fr); }
  .notification-card__actions { grid-column: 2; justify-self: start; }

  /* Общие справочники */
  .learning-page { min-height: auto; gap: 12px; }
  .learning-page .learning-page__header { align-items: stretch; flex-direction: column; gap: 10px; }
  .learning-page__title { font-size: 23px; }
  .learning-page .learning-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .learning-tab { justify-content: center; min-height: 42px; padding: 7px; }
  .learning-toolbar { align-items: stretch; flex-direction: column; padding: 10px; }
  .students .learning-toolbar__main,
  .feature-groups .learning-toolbar__main { display: grid !important; grid-template-columns: 1fr !important; width: 100%; }
  .learning-action, .learning-control { min-height: 44px; }
  .learning-action--primary { padding-inline: 13px; }
  .students .learning-toolbar .learning-search,
  .feature-groups .learning-toolbar .learning-search { width: 100% !important; min-width: 0 !important; max-width: none; }
  .students .learning-toolbar__main, .students .learning-toolbar__filters,
  .feature-groups .learning-toolbar__main, .feature-groups .learning-toolbar__filters { flex: 0 0 auto; align-content: start; }
  .students .learning-toolbar__filters,
  .feature-groups .learning-toolbar__filters {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100%;
  }
  .learning-toolbar__main > *, .learning-toolbar__filters > * { box-sizing: border-box; width: 100%; min-width: 0 !important; max-width: none; }
  .learning-toolbar__filters > :last-child { justify-self: stretch; }
  .learning-action--menu { width: 44px !important; justify-self: end; }
  .learning-more-menu__popover { right: 0 !important; left: auto !important; max-width: calc(100vw - 32px); }
  .learning-more-menu__columns-panel {
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    max-height: min(42dvh, 360px) !important;
    margin-top: 4px !important;
    box-shadow: none !important;
  }
  .learning-bulkbar { align-items: stretch; flex-direction: column; }
  .learning-inline-actions { align-items: stretch; flex-direction: column; }
  .learning-summary { min-height: 32px; }

  /* Таблицы учеников и групп на телефоне — карточки с приоритетными полями. */
  .students .learning-table-wrap,
  .feature-groups .learning-table-wrap { overflow: visible; border: 0; background: transparent; }
  .students .learning-table,
  .feature-groups .learning-table,
  .students .learning-table tbody,
  .feature-groups .learning-table tbody { display: block; width: 100%; }
  .students .learning-table thead,
  .feature-groups .learning-table thead { display: none; }
  .students .learning-table tbody,
  .feature-groups .learning-table tbody { display: grid; gap: 10px; }
  .students .learning-table tbody tr,
  .feature-groups .learning-table tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 9px 12px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--learning-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(15,23,42,.04);
  }
  .students .learning-table tbody td,
  .feature-groups .learning-table tbody td { display: none; padding: 0; border: 0; background: transparent !important; }
  .students .learning-table td[data-field="fio"],
  .feature-groups .learning-table td[data-field="title"] { display: block; min-width: 0; grid-column: 1; }
  .students .learning-table td[data-field="status"],
  .feature-groups .learning-table td[data-field="status"] { display: block; grid-column: 2; grid-row: 1; align-self: start; }
  .students .learning-table td[data-field="teacher"],
  .students .learning-table td[data-field="price"],
  .students .learning-table td[data-field="groups"],
  .feature-groups .learning-table td[data-field="teacher"],
  .feature-groups .learning-table td[data-field="price"],
  .feature-groups .learning-table td[data-field="students"] {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 88px minmax(0,1fr);
    gap: 8px;
    color: #344054;
    font-size: 12px;
  }
  .students .learning-table td[data-label]::before,
  .feature-groups .learning-table td[data-label]::before { content: attr(data-label); color: var(--learning-muted); font-size: 11px; }
  .students .learning-table td[data-field="select"] { display: block; position: absolute; top: 10px; right: 10px; opacity: 0; pointer-events: none; }
  .students .learning-table td[data-field="actions"],
  .feature-groups .learning-table td[data-field="actions"] { display: block; grid-column: 1 / -1; padding-top: 3px; }
  .learning-row-actions { justify-content: flex-end; }
  .learning-row-action--icon { width: 44px !important; height: 44px !important; }
  .learning-entity { min-width: 0; }
  .learning-avatar { width: 40px; height: 40px; flex-basis: 40px; }
  .learning-chip { min-height: 44px; padding-block: 8px; }

  /* Формы справочников */
  .learning-page dialog.modal,
  .students dialog.modal,
  .feature-groups dialog.modal {
    inset: 0 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    margin: 0 !important;
  }
  .learning-page dialog.modal > .modal__card,
  .learning-page dialog.modal > form.modal__card,
  .students .modal__card,
  .feature-groups .modal__card {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
    border: 0 !important;
    border-radius: 0 !important;
  }
  .learning-page .modal__header { flex: 0 0 auto; margin: 0; padding: max(14px, env(safe-area-inset-top)) 14px 12px; }
  .learning-page .modal__header h3 { font-size: 20px !important; }
  .learning-page .modal__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px !important; }
  .learning-page .modal__footer { flex: 0 0 auto; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .learning-entry-form__grid,
  .students .student-form__grid,
  .feature-groups .group-form__grid { grid-template-columns: 1fr !important; }
  .form-field--span2 { grid-column: auto !important; }
  .learning-entry-form__section { padding: 14px !important; }
  .student-group-selection__toolbar,
  .feature-groups .group-student-picker__toolbar { grid-template-columns: 1fr !important; padding: 12px !important; }
  .student-group-selection__table-wrap,
  .feature-groups .group-student-picker__table-wrap { overflow: auto; }

  /* Футер редактирования группы: все четыре действия остаются доступными. */
  .feature-groups form[data-role="edit-group-form"] > .modal__footer {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
  }
  .feature-groups form[data-role="edit-group-form"] > .modal__footer .modal__footer-spacer { display: none; }
  .feature-groups form[data-role="edit-group-form"] > .modal__footer .btn {
    width: 100%; min-width: 0; min-height: 44px; padding: 7px 8px; white-space: normal; line-height: 1.15;
  }

  /* Перенос данных использует более специфичные desktop-правила. */
  html.is-mobile-viewport .students.learning-page dialog.modal.learning-transfer-modal,
  html.is-mobile-viewport .feature-groups.learning-page dialog.modal.learning-transfer-modal,
  html.is-mobile-viewport .students.learning-page dialog.modal.learning-transfer-selection-modal,
  html.is-mobile-viewport .feature-groups.learning-page dialog.modal.learning-transfer-selection-modal {
    inset: 0 !important; width: 100vw !important; max-width: none !important;
    height: 100dvh !important; max-height: none !important; margin: 0 !important;
    overflow: hidden !important; border-radius: 0 !important;
  }
  html.is-mobile-viewport .students.learning-page dialog.modal.learning-transfer-modal > .learning-transfer.modal__card,
  html.is-mobile-viewport .feature-groups.learning-page dialog.modal.learning-transfer-modal > .learning-transfer.modal__card,
  html.is-mobile-viewport .students.learning-page dialog.modal.learning-transfer-selection-modal > .learning-transfer-selection.modal__card,
  html.is-mobile-viewport .feature-groups.learning-page dialog.modal.learning-transfer-selection-modal > .learning-transfer-selection.modal__card {
    width: 100% !important; height: 100dvh !important; max-height: none !important;
    min-width: 0 !important; padding: 0 !important; overflow: hidden !important;
    border: 0 !important; border-radius: 0 !important;
  }
  html.is-mobile-viewport .learning-page .learning-transfer > .modal__header,
  html.is-mobile-viewport .learning-page .learning-transfer-selection > .modal__header { gap: 10px !important; padding: max(14px, env(safe-area-inset-top)) 14px 12px !important; }
  html.is-mobile-viewport .learning-page .learning-transfer > .modal__header h3,
  html.is-mobile-viewport .learning-page .learning-transfer-selection > .modal__header h3 { font-size: 21px !important; }
  html.is-mobile-viewport .learning-page .learning-transfer__tabs { display: grid !important; grid-template-columns: 1fr 1fr; padding: 0 14px 12px; }
  html.is-mobile-viewport .learning-page .learning-transfer__tabs button { min-width: 0; }
  html.is-mobile-viewport .students.learning-page dialog.learning-transfer-modal .learning-transfer__body,
  html.is-mobile-viewport .feature-groups.learning-page dialog.learning-transfer-modal .learning-transfer__body {
    min-height: 0 !important; overflow-y: auto !important;
    -webkit-overflow-scrolling: touch; padding: 12px !important;
  }
  .learning-transfer__section { gap: 14px; padding: 14px; }
  .learning-transfer__section-head { gap: 10px; }
  .learning-transfer__scope,
  .learning-transfer__switches,
  .learning-transfer__format,
  .learning-transfer__strategy,
  .learning-transfer__preview-cards { grid-template-columns: 1fr !important; }
  .learning-transfer__scope button { text-align: left; }
  html.is-mobile-viewport .learning-page .learning-transfer > .modal__footer,
  html.is-mobile-viewport .learning-page .learning-transfer-selection > .modal__footer {
    display: grid !important; grid-template-columns: 1fr 1fr; min-height: 0;
    gap: 8px !important; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) !important;
  }
  html.is-mobile-viewport .learning-page .learning-transfer > .modal__footer .modal__footer-spacer { display: none; }
  html.is-mobile-viewport .learning-page .learning-transfer > .modal__footer .btn,
  html.is-mobile-viewport .learning-page .learning-transfer-selection > .modal__footer .btn { width: 100%; min-width: 0; padding-inline: 8px; }
  .learning-transfer-selection__toolbar { display: grid; grid-template-columns: 1fr; padding: 12px; }
  .learning-transfer-selection__toolbar select { width: 100%; min-width: 0; min-height: 44px; }
  .learning-transfer-selection__summary { align-items: flex-start; gap: 8px; padding: 2px 12px 10px; flex-direction: column; }
  .learning-transfer-selection__table-wrap { margin: 0 12px 12px; }

  /* Рабочее расписание: основной мобильный сценарий — день. */
  .ws-topbar { padding: 6px; }
  .ws-topbar__row {
    display: grid;
    grid-template-areas: "left right" "center center";
    grid-template-columns: minmax(0,1fr) auto;
    gap: 6px;
  }
  .ws-left { grid-area: left; }
  .ws-right { grid-area: right; justify-self: end; }
  .ws-center { grid-area: center; display: grid; grid-template-columns: auto minmax(0,1fr) auto; width: 100%; }
  .ws-titleBtn { min-width: 0; margin: 0 4px !important; padding-inline: 4px; }
  .ws-title, .ws-title__main, .ws-title__sub { min-width: 0; max-width: 100%; }
  .ws-title__main { font-size: 13px; }
  .ws-title__sub { font-size: 11px; }
  .ws-shell.is-lesson-navigation .ws-btn--lessonNeighbor { min-width: 44px; max-width: 92px; }
  .ws-topbar__row { gap: 5px; }
  .ws-left, .ws-right { gap: 4px; }
  .ws-center { justify-content: stretch; }
  .ws-titleBtn { min-width: 0; margin: 0 2px !important; padding-inline: 5px; }
  .ws-title__main { font-size: 12px; }
  .ws-title__sub { font-size: 10px; }
  .ws-btn, .ws-btn--icon { min-width: 40px; width: 40px; height: 40px; }
  .ws-view-tabs { display: flex !important; }
  .ws-view-tabs .ws-tab { min-width: 0; min-height: 40px; padding: 6px; font-size: 11px; }
  .ws-menu__item[data-menu="planning"],
  .ws-menu__item[data-menu="exceptions"] { display: none !important; }
  .ws-menu { right: 0; width: min(300px, calc(100vw - 20px)); }
  /* Desktop-календарь центрируется через left:50% + translateX(-50%).
     На телефоне он привязан к viewport, поэтому обе части desktop-схемы
     нужно сбросить атомарно — иначе половина календаря уезжает за экран. */
  html.is-mobile-viewport .ws-shell .ws-datePicker {
    position: fixed !important;
    inset: calc(54px + env(safe-area-inset-top)) 8px auto !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - 70px - env(safe-area-inset-bottom));
    overflow-y: auto;
    transform: none !important;
  }
  .ws-filterPanel { inset: 0 !important; width: 100% !important; border-radius: 0 !important; }
  .ws-filterChoices--two, .ws-filterChoices--statuses { grid-template-columns: 1fr !important; }
  .ws-filterPanel__footer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .wsd-view { padding-bottom: 4px; }
  .wsd-toolbar, .wsd-summary { flex-wrap: wrap; }
  .wsd-dialog, .wsl-dialog { width: 100vw !important; max-width: none !important; max-height: 100dvh !important; border-radius: 0 !important; }
  .wsl { padding-bottom: 150px !important; }
  .wsl-savebar {
    left: 8px !important; right: 8px !important;
    bottom: calc(68px + env(safe-area-inset-bottom)) !important;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 9px; border-radius: 14px;
  }
  .wsl-savebar[hidden] { display: none !important; }
  .wsl-savebar > span { grid-column: 1 / -1; margin: 0; font-size: 12px; }
  .wsl-savebar > button { min-width: 0; min-height: 44px; }

  /* Расчёты: мобильный сценарий от выбора месяца до оплаты ученика. */
  .finance { height: 100%; min-height: 0; padding-bottom: 0; overflow: hidden; }
  .finance-home, .finance-document {
    height: 100%; min-height: 0; overflow-x: hidden; overflow-y: auto;
    overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch;
  }
  .finance-home__header { padding: 18px 14px 15px; }
  .finance-home__header h1 { font-size: 24px; }
  .finance-home__content { width: auto; margin: 14px 12px 24px; }
  .finance-create-card { grid-template-columns: 1fr; gap: 14px; padding: 16px; border-radius: 16px; }
  .finance-create-card__copy { align-items: flex-start; }
  .finance-create-card__icon { width: 46px; height: 46px; flex-basis: 46px; }
  .finance-create-card__copy h2 { font-size: 19px; }
  .finance-period-picker, .finance-create-card__actions, .finance-create-card__actions .finance-btn { width: 100%; }
  .finance-period-picker { min-width: 0; justify-content: center; }
  .finance-create-card__actions .finance-btn { min-height: 46px; }
  .finance-create-card__hint { grid-column: auto; }
  .finance-recent { margin-top: 24px; }
  .finance-recent__heading { align-items: flex-start; gap: 10px; flex-direction: column; }
  .finance-recent__controls { width: 100%; justify-content: space-between; }
  .finance-recent__grid { grid-template-columns: 1fr; }
  .finance-recent-card { min-height: 132px; padding: 16px; }

  .finance-document .finance__topbar { align-items: stretch; gap: 10px; padding: 10px 12px; flex-direction: column; }
  .finance-document .finance__title-group { align-items: flex-start; min-width: 0; }
  .finance-document .finance__title-group > div { min-width: 0; }
  .finance-document .finance__topbar h1 { font-size: 19px; }
  .finance-document .finance__heading-line { align-items: flex-start; gap: 6px; flex-direction: column; }
  .finance-document .finance__top-actions { display: grid; grid-template-columns: 1fr 1fr auto; width: 100%; }
  .finance-document .finance__top-actions .finance-btn { width: 100%; min-width: 0; padding-inline: 7px; white-space: normal; }
  .finance-more { justify-self: end; }
  .finance-more__menu { position: fixed; top: auto; right: 10px; bottom: calc(72px + env(safe-area-inset-bottom)); width: min(280px, calc(100vw - 20px)); }

  .finance-document .finance__toolbar { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px 12px; }
  .finance__month-switcher, .finance__month-switcher strong,
  .finance-document .finance__toolbar > .finance-control { width: 100%; min-width: 0; }
  .finance__month-switcher { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; height: 44px; }
  .finance__month-switcher button { width: 44px; }
  .finance__month-switcher strong { min-width: 0; }
  .finance-document .finance__search { height: 44px; }
  .finance__status-filters { width: 100%; margin: 0; padding: 3px; overflow-x: auto; scrollbar-width: none; }
  .finance__status-filters button { min-width: max-content; min-height: 36px; flex: 1 0 auto; }

  .finance-document .finance__summary { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px; }
  .finance-document .finance-summary-card { min-height: 62px; padding: 10px; }
  .finance-document .finance-summary-card strong { font-size: 15px; overflow-wrap: anywhere; }
  .finance-document .finance__workspace { display: block; padding: 0 12px 16px; overflow: visible; }
  .finance-document .finance__status-line { padding: 0 2px 8px; }

  .finance .finance__table-wrap { min-height: 0; overflow: visible; border: 0; background: transparent; }
  .finance .finance__table, .finance .finance__table tbody { display: block; width: 100%; min-width: 0; }
  .finance .finance__table thead { display: none; }
  .finance .finance__table tbody { display: grid; gap: 10px; }
  .finance .finance__table tbody tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px; border: 1px solid var(--fin-border); border-radius: 15px; background: #fff; box-shadow: 0 3px 12px rgba(15,23,42,.04); }
  .finance .finance__table tbody tr.is-selected { border-color: #82aef3; background: #f5f9ff; }
  .finance .finance__table tbody td { display: grid; min-width: 0; gap: 3px; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .finance .finance__table tbody td[data-label]::before { content: attr(data-label); color: var(--fin-muted); font-size: 10px; font-weight: 700; }
  .finance .finance__table td[data-field="student"] { grid-column: 1 / -1; padding-right: 94px; }
  .finance .finance__table td[data-field="status"] { position: absolute; top: 12px; right: 12px; }
  .finance .finance__table td[data-field="actions"] { grid-column: 1 / -1; }
  .finance .finance__table td[data-field="actions"] .finance-row-action { width: 100%; min-height: 44px; }
  .finance .finance__table td[data-field="opening"],
  .finance .finance__table td[data-field="balance"] { text-align: left; }
  .finance .finance__table td[data-field="tax"] { display: none; }
  .finance .finance__table tbody tr:not([data-student-id]) { display: block; }
  .finance .finance__table tbody tr:not([data-student-id]) td { display: block; }
  .finance-balance { text-align: left; }

  .finance-detail { position: fixed; z-index: 1250; inset: 0; width: 100vw; height: 100dvh; overflow: auto; border: 0; border-radius: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .finance-detail__header { padding: max(14px, env(safe-area-inset-top)) 14px 12px; }
  .finance-detail__actions { top: 72px; display: grid; grid-template-columns: 1fr 1fr; padding: 10px 12px; }
  .finance-detail__actions .finance-btn { min-width: 0; min-height: 44px; white-space: normal; }
  .finance-detail__actions .finance-btn:first-child { grid-column: 1 / -1; }
  .finance-detail__body { padding: 14px 12px 24px; }
  .finance-calendar { min-width: 560px; }
  .finance-detail__section:first-child { overflow-x: auto; }
  .finance-ledger__row { grid-template-columns: 1fr auto; }
  .finance-ledger__row > span:first-child { grid-column: 1 / -1; color: var(--fin-muted); }

  .finance-dialog { inset: 0 !important; width: 100vw !important; max-width: none !important; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .finance-dialog > form { height: 100dvh; max-height: none; }
  .finance-dialog header { flex: 0 0 auto; gap: 10px; padding: max(14px, env(safe-area-inset-top)) 14px 12px; }
  .finance-dialog header h2 { font-size: 20px; }
  .finance-dialog__body { flex: 1 1 auto; min-height: 0; padding: 14px 12px; }
  .finance-dialog footer { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .finance-dialog footer .finance-btn { min-width: 0; min-height: 44px; padding-inline: 8px; white-space: normal; }
  .finance-form-grid, .finance-preview__grid, .finance-recalculation-summary { grid-template-columns: 1fr; }
  .finance-form-grid__wide, .finance-preview-card.is-wide { grid-column: auto; }
  .finance-year-calendar { grid-template-columns: 1fr 1fr; }
  .finance-period-suggestion { align-items: stretch; flex-direction: column; }
  .finance-period-suggestion .finance-btn { width: 100%; min-height: 44px; }
  .finance-year-heading { grid-template-columns: 44px 1fr 44px; }
  .finance-year-heading span { grid-column: 1 / -1; justify-self: start; }
  .finance-calculation-item { grid-template-columns: minmax(0,1fr) auto; gap: 9px 12px; padding: 13px; }
  .finance-calculation-item__date, .finance-calculation-item__teacher,
  .finance-calculation-item__stats { grid-column: 1; }
  .finance-calculation-item__status { grid-column: 2; grid-row: 1; width: auto; }
  .finance-calculation-item__arrow { grid-column: 2; grid-row: 2 / 4; align-self: center; }
  .finance-calculations-quarters { width: 100%; overflow-x: auto; }
  .finance-calculations-quarters button { min-width: max-content; }
  .finance-export-scope, .finance-export-formats, .finance-export-stats { grid-template-columns: 1fr !important; }
  .finance-export-formats label:last-child { grid-column: auto !important; }
  .finance-pdf-layout { grid-template-columns: 1fr !important; }
  .finance-pdf-preview { min-height: 360px; padding-inline: 16px; }
  .finance-payment-option { grid-template-columns: auto minmax(0,1fr) auto; }
  .finance-payment-option > span:nth-of-type(1) { grid-column: 2; }
  .finance-payment-option > span:nth-of-type(2) { grid-column: 2 / -1; }
  .finance-payment-option > strong { grid-column: 3; grid-row: 1; }
  .finance-recalculation-change { grid-template-columns: 1fr auto; }
  .finance-recalculation-change__kind { grid-column: 1 / -1; }
  .finance-field-tooltip { position: fixed; z-index: 1400; top: 50%; right: 18px; left: 18px; width: auto; transform: translateY(-50%); }
  .finance-field-help[aria-expanded="true"] + .finance-field-tooltip { transform: translateY(-50%); }

  body:has(.finance-detail:not([hidden])),
  body:has(.finance-dialog[open]) { overflow: hidden; }
  body:has(.finance-detail:not([hidden])) .mobile-nav,
  body:has(.finance-dialog[open]) .mobile-nav { visibility: hidden; pointer-events: none; }

  /* Карточки и профиль уже имеют собственные breakpoints; добавляем общую touch-базу. */
  .student-card button, .group-card button, #profile-page button,
  .student-card a, .group-card a, #profile-page a { min-height: 44px; }
  .student-card, .group-card { padding: 8px !important; }
  #profile-page .profile-content { padding-bottom: 20px !important; }
  #profile-page .cabinet-tabs { overflow-x: auto; scrollbar-width: none; }
  #profile-page .cabinet-tab { flex: 0 0 auto; min-height: 44px; }
  #profile-page .p-modal { padding: 0 !important; }
  #profile-page .p-modal__panel { width: 100% !important; max-height: 100dvh !important; border-radius: 0 !important; }

  /* Desktop-only блоки не являются частью мобильного MVP. */
  .default-schedule .ds-planner,
  .finance-calendar { touch-action: pan-x pan-y; }
}

@media (max-width: 420px) {
  .learning-action--menu { margin-left: auto; }
  .quick-actions { grid-template-columns: 1fr; }
  .mobile-nav__item { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav, .workspace, dialog { scroll-behavior: auto !important; }
}

/* Native dialog supplies focus containment, Escape and focus restoration. */
.mobile-more { width:min(420px, calc(100vw - 24px)); max-height:80dvh; padding:18px; border:1px solid #dfe3e8; border-radius:18px; color:#172033; background:#fff; }
.mobile-more::backdrop { background:rgba(15,23,42,.35); }
.mobile-more header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.mobile-more h2 { margin:0; font-size:20px; }
.mobile-more header button { width:44px; height:44px; border:0; border-radius:10px; background:#f1f5f9; color:#172033; font-size:24px; }
.mobile-more nav { display:grid; gap:8px; }
body .mobile-more .menu-item { display:flex; align-items:center; justify-content:flex-start; width:100%; min-height:48px; padding:12px; border:1px solid #dfe3e8; border-radius:10px; background:#f8fafc; color:#172033; text-align:left; font:inherit; }
.mobile-more button:focus-visible { outline:3px solid #93c5fd; outline-offset:2px; }
.mobile-more .notification-count { position:static; margin-left:8px; }

@media (max-width:767px) {
  /* Summary stays within the viewport while the detailed calendar scrolls sideways. */
  .ws-month { --month-summary-height:64px; }
  .ws-month .wsl-summary { position:sticky; top:0; left:0; width:100%; box-sizing:border-box; min-height:0; height:auto; display:flex; flex-wrap:wrap; align-items:center; gap:4px; padding:5px; }
  .ws-month .wsl-summary > div:not(.wsm-scaleControls) { min-width:0; padding:4px 6px; gap:3px; flex-wrap:nowrap; align-content:center; }
  .ws-month .wsl-summary strong { white-space:nowrap; font-size:14px; }
  .ws-month .wsm-scaleControls { margin-left:auto; justify-content:center; }
  .ws-month .wsm-scaleControls button { flex:0 0 32px; width:32px; min-width:32px; max-width:32px; height:32px; min-height:32px; max-height:32px; }
  .ws-month .wsm-weekdays { top:var(--month-summary-height); }
}

@media (max-width:767px) {
  .wsw-summary, .wsw-summaryStats { flex-wrap:wrap; gap:8px; }
  .wsw-scale { margin-left:auto; }
  .wsw-scale button { width:44px; height:40px; }
  .wsw-grid.is-lessons-only { grid-template-columns:repeat(var(--wsw-day-count,7), minmax(150px,1fr)); }
  .mobile-nav__item[data-action="open-mobile-more"] > span:first-child { font-size:21px; line-height:21px; }
}

/* A single compact toolbar; full period stays available to assistive technology. */
@media (max-width:767px) {
  .ws-shell .ws-topbar { padding:5px 4px; }
  .ws-shell .ws-topbar__row { display:flex; flex-wrap:nowrap; gap:4px; }
  .ws-shell .ws-left { display:none; }
  .ws-shell .ws-mobile-back { display:block; }
  .ws-shell .ws-center { display:flex; flex:1 1 0; min-width:0; width:auto; align-items:center; }
  .ws-shell .ws-right { flex:0 0 auto; gap:3px; }
  .ws-shell .ws-btn { flex:0 0 32px; min-width:32px; width:32px; height:34px; padding:0; }
  .ws-shell .ws-center > .ws-btn { flex:0 0 24px; width:24px; min-width:24px; }
  .ws-shell .ws-titleBtn { flex:1 1 0; min-width:0; padding:0 2px; margin:0!important; height:34px; }
  .ws-shell .ws-title__main, .ws-shell .ws-title__sub { display:none; }
  .ws-shell .ws-title__compact { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; font-weight:700; line-height:1.2; }
  .ws-shell .ws-view-tabs { height:34px; }
  .ws-shell .ws-view-tabs .ws-tab { min-height:0; height:100%; padding:0 4px; font-size:10px; line-height:1; display:flex; align-items:center; justify-content:center; }
  .ws-shell.is-lesson-navigation .ws-view-tabs { display:none!important; }
  .ws-shell.is-lesson-navigation .ws-left { display:flex; }
  .ws-shell.is-lesson-navigation .ws-btn--lessonNeighbor { min-width:24px; max-width:24px; overflow:hidden; }
}
@media (max-width:767px) {
  .ws-shell.is-lesson-navigation .ws-btn--lessonNeighbor { display:inline-flex; align-items:center; justify-content:center; font-size:18px; }
  .ws-shell.is-lesson-navigation .ws-btn--lessonNeighbor > * { display:none; }
  .ws-shell.is-lesson-navigation [data-action="prev"]::before { content:"‹"; }
  .ws-shell.is-lesson-navigation [data-action="next"]::before { content:"›"; }
}

/* Help controls retain their circular shape instead of the generic 44px button height. */
@media (max-width: 767px) {
  body .finance-field-help-wrap, body .finance-field-help-wrap .finance-field-help,
  #profile-page .finance-field-help-wrap .finance-field-help {
    box-sizing: border-box; width: 22px; min-width: 22px; max-width: 22px;
    height: 22px; min-height: 22px; max-height: 22px; flex: 0 0 22px;
    padding: 0; border-radius: 50%; line-height: 1; align-self: center;
  }
}
