:root.mobile-host {
  --mobile-gutter: 10px;
  --mobile-control-height: 42px;
}

:root.mobile-host body {
  min-width: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  font-size: 13px;
  -webkit-text-size-adjust: 100%;
}

:root.mobile-host .app-shell {
  display: block;
  min-height: 100vh;
  height: auto;
}

:root.mobile-host .topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 6px 8px;
  min-height: 0;
  padding: 7px var(--mobile-gutter);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(31, 41, 55, .08);
}

:root.mobile-host .brand {
  min-width: 42px;
  width: 42px;
  height: 42px;
  justify-content: center;
  border-radius: 9px;
}

:root.mobile-host .brand-mark { margin-left: 0; }
:root.mobile-host .brand-title { display: none; }
:root.mobile-host .app-page-title { align-self: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
:root.mobile-host .userbar { gap: 4px; }
:root.mobile-host .userbar #userInfo { display: none; }
:root.mobile-host .userbar button { min-height: 36px; padding: 7px 9px; }
:root.mobile-host .backlog { grid-column: 1 / -1; grid-row: 2; display: flex; min-width: 0; overflow: hidden; }
:root.mobile-host .backlog button { min-height: 38px; max-width: 68%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root.mobile-host .backlog span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:root.mobile-host .main-nav {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  order: 3;
  width: calc(100% + 2 * var(--mobile-gutter));
  margin: 0 calc(-1 * var(--mobile-gutter));
  padding: 2px var(--mobile-gutter) 1px;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

:root.mobile-host .main-nav a {
  flex: 0 0 auto;
  min-width: auto;
  min-height: 38px;
  padding: 8px 11px;
  border-radius: 9px;
  white-space: nowrap;
  font-size: 12px;
}

:root.mobile-host .main-nav-toggle { display: none; }
:root.mobile-host .tracker-section,
:root.mobile-host .dailies-section,
:root.mobile-host .admin-section,
:root.mobile-host .profile-section { min-height: calc(100vh - 110px); overflow: visible; }
:root.mobile-host .tracker-page { height: auto; min-height: calc(100vh - 110px); }
:root.mobile-host .tracker-layout { display: block; min-height: 0; }
:root.mobile-host .tracker-sidebar { border: 0; border-bottom: 1px solid var(--line); padding: var(--mobile-gutter); }
:root.mobile-host .tracker-sidebar .sidebar-heading { margin-bottom: 6px; }
:root.mobile-host .tracker-search,
:root.mobile-host .tracker-filter,
:root.mobile-host .tracker-date-preset { margin-top: 9px; }
:root.mobile-host .tracker-search input,
:root.mobile-host .multi-select-button,
:root.mobile-host .tracker-date-preset input { min-height: var(--mobile-control-height); }
:root.mobile-host .tracker-content { display: block; min-height: 0; padding: var(--mobile-gutter); overflow: visible; }
:root.mobile-host .tracker-tabs-row { align-items: center; gap: 8px; flex-wrap: wrap; }
:root.mobile-host .tracker-tabs { flex: 1 1 100%; margin: 0 0 4px; }
:root.mobile-host .tracker-tabs button { flex: 1 1 0; min-width: 0; min-height: 40px; }
:root.mobile-host .tracker-result-count { padding: 3px 0 8px; }
:root.mobile-host .tracker-table-wrap { max-width: 100%; max-height: 62vh; }
:root.mobile-host .tracker-table th,
:root.mobile-host .tracker-table td { padding: 9px 8px; }
:root.mobile-host .tracker-pagination { flex-wrap: wrap; gap: 8px; padding: 9px 0 0; }
:root.mobile-host .tracker-pagination label { flex: 1 1 100%; }
:root.mobile-host .tracker-export { margin-left: 0; min-height: 40px; }

:root.mobile-host .dailies-content,
:root.mobile-host .vacations-section,
:root.mobile-host .admin-section,
:root.mobile-host .profile-section { padding: var(--mobile-gutter); }
:root.mobile-host .daily-controls-row { grid-template-columns: 1fr; gap: 9px; padding: 8px 0; }
:root.mobile-host .daily-department-picker { order: 1; }
:root.mobile-host .daily-member-add { order: 2; grid-auto-flow: row; }
:root.mobile-host .week-controls { order: 3; display: flex; flex-wrap: wrap; justify-content: flex-start; }
:root.mobile-host .daily-table-wrap { max-width: 100%; max-height: calc(100vh - 235px); overflow: auto; }
:root.mobile-host .daily-table { min-width: 860px; }
:root.mobile-host .daily-table thead th { top: 0; }
:root.mobile-host .daily-task-card { font-size: 13px; }

:root.mobile-host .vacations-layout,
:root.mobile-host .departments-admin-layout,
:root.mobile-host .admin-grid { display: block; }
:root.mobile-host .vacations-card,
:root.mobile-host .admin-card { margin-bottom: 10px; }
:root.mobile-host .vacation-form,
:root.mobile-host .vacation-row,
:root.mobile-host .admin-form,
:root.mobile-host .user-profile-fields,
:root.mobile-host .cron-task-form,
:root.mobile-host .profile-password-form { grid-template-columns: 1fr; }
:root.mobile-host .vacation-calendar { overflow-x: auto; }
:root.mobile-host .users-table-wrap,
:root.mobile-host .permissions-table-wrap { max-width: calc(100vw - 2 * var(--mobile-gutter)); }
:root.mobile-host .admin-tabs { gap: 4px; margin: 0 0 9px; padding-bottom: 3px; }
:root.mobile-host .admin-tab { min-height: 38px; padding: 8px 10px; }
:root.mobile-host .admin-block-heading { display: block; }
:root.mobile-host .admin-block-actions { justify-content: flex-start; margin-top: 8px; }
:root.mobile-host .profile-readonly-grid { grid-template-columns: 1fr; }
:root.mobile-host .profile-password-form h2,
:root.mobile-host .profile-password-form .hint { grid-column: auto; }
:root.mobile-host .telegram-settings-grid { grid-template-columns: 1fr 1fr; }

:root.mobile-host dialog {
  width: calc(100vw - 20px);
  max-width: calc(100vw - 20px);
  max-height: calc(100vh - 20px);
  margin: auto;
}

:root.mobile-host .daily-task-dialog form,
:root.mobile-host .tracker-issue-dialog { padding: 13px; }
:root.mobile-host .tracker-issue-dialog-body dl { grid-template-columns: 1fr; gap: 3px; }
:root.mobile-host .tracker-issue-dialog-body dd { margin-bottom: 7px; }
:root.mobile-host .daily-task-dialog form { gap: 9px; }
:root.mobile-host .daily-task-dialog input,
:root.mobile-host .daily-task-dialog textarea,
:root.mobile-host .create-user-dialog input,
:root.mobile-host button { min-height: 40px; }

@media (min-width: 700px) {
  :root.mobile-host .main-nav { grid-column: 2; grid-row: 1; width: auto; margin: 0; padding: 0; }
  :root.mobile-host .backlog { grid-column: 1 / -1; }
}

:root.mobile-host {
  --mobile-gutter: clamp(8px, 2.6vw, 14px);
  --mobile-control-height: 42px;
}

:root.mobile-host body {
  min-width: 320px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-x: none;
  -webkit-text-size-adjust: 100%;
}

:root.mobile-host button,
:root.mobile-host a,
:root.mobile-host input,
:root.mobile-host select,
:root.mobile-host textarea {
  touch-action: manipulation;
}

:root.mobile-host .app-shell {
  display: block;
  height: auto;
  min-height: 100svh;
}

:root.mobile-host .topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  grid-template-areas:
    "brand title user"
    "nav nav nav"
    "backlog backlog backlog";
  gap: 6px 8px;
  min-height: 0;
  padding: 7px var(--mobile-gutter);
  background: var(--panel);
  box-shadow: 0 2px 12px rgba(31, 41, 55, .08);
}

:root.mobile-host .brand { grid-area: brand; }
:root.mobile-host .app-page-title { grid-area: title; align-self: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
:root.mobile-host .userbar { grid-area: user; min-width: 0; gap: 4px; }
:root.mobile-host .userbar #userInfo { display: none; }
:root.mobile-host .userbar button { min-height: 38px; padding: 7px 9px; }
:root.mobile-host .main-nav {
  grid-area: nav;
  display: flex;
  width: calc(100% + 2 * var(--mobile-gutter));
  min-width: 0;
  margin: 0 calc(-1 * var(--mobile-gutter));
  padding: 2px var(--mobile-gutter) 1px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
:root.mobile-host .main-nav a { scroll-snap-align: start; flex: 0 0 auto; min-width: auto; min-height: 40px; padding: 9px 12px; border-radius: 9px; white-space: nowrap; font-size: 12px; }
:root.mobile-host .main-nav-toggle { display: none; }
:root.mobile-host .backlog { grid-area: backlog; display: flex; min-width: 0; overflow: hidden; }
:root.mobile-host .backlog button { min-height: 40px; max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root.mobile-host .backlog span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

:root.mobile-host #trackerSection,
:root.mobile-host #dailiesSection,
:root.mobile-host #vacationsSection,
:root.mobile-host #adminSection,
:root.mobile-host #notificationsSection,
:root.mobile-host #profileSection {
  min-height: calc(100svh - 104px);
  height: auto;
  overflow: visible;
}

:root.mobile-host .tracker-page,
:root.mobile-host .tracker-layout {
  height: auto;
  min-height: 0;
  overflow: visible;
}

:root.mobile-host .tracker-layout { display: flex; flex-direction: column; }
:root.mobile-host .tracker-sidebar { flex: 0 0 auto; max-height: none; overflow: visible; padding: var(--mobile-gutter); border-right: 0; border-bottom: 1px solid var(--line); }
:root.mobile-host .tracker-sidebar .tracker-search,
:root.mobile-host .tracker-sidebar .tracker-filter { margin-top: 10px; }
:root.mobile-host .tracker-search input,
:root.mobile-host .multi-select-button,
:root.mobile-host .tracker-date-preset input { min-height: var(--mobile-control-height); }
:root.mobile-host .multi-select-menu { max-height: min(45svh, 280px); }
:root.mobile-host .tracker-content { display: flex; flex-direction: column; min-height: 0; padding: var(--mobile-gutter); overflow: visible; }
:root.mobile-host .tracker-tabs-row { align-items: center; flex-wrap: wrap; gap: 6px 8px; }
:root.mobile-host .tracker-tabs { flex: 1 1 100%; margin: 0 0 3px; }
:root.mobile-host .tracker-tabs button { flex: 1 1 0; min-width: 0; min-height: 42px; }
:root.mobile-host .tracker-result-count { padding: 2px 0 8px; }
:root.mobile-host .tracker-table-wrap { flex: 0 0 auto; width: 100%; height: clamp(300px, calc(100svh - 370px), 620px); max-height: none; overflow: auto; -webkit-overflow-scrolling: touch; }
:root.mobile-host .tracker-table { min-width: 1120px; }
:root.mobile-host .tracker-table th,
:root.mobile-host .tracker-table td { padding: 9px 8px; }
:root.mobile-host .tracker-pagination { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 9px 0 0; }
:root.mobile-host .tracker-pagination-pages { grid-column: 1 / -1; justify-content: flex-start; max-width: 100%; overflow-x: auto; padding-bottom: 2px; }
:root.mobile-host .tracker-export { grid-column: 1 / -1; width: 100%; min-height: 42px; margin-left: 0; }

:root.mobile-host .dailies-layout,
:root.mobile-host .dailies-content { height: auto; min-height: calc(100svh - 104px); overflow: visible; }
:root.mobile-host .dailies-content { padding: var(--mobile-gutter); }
:root.mobile-host .daily-controls-row { grid-template-columns: 1fr; gap: 9px; padding: 8px 0; align-items: stretch; }
:root.mobile-host .daily-departments-list { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
:root.mobile-host .dailies-content .daily-department-item { flex: 0 0 auto; min-width: min(180px, 48vw); min-height: 40px; }
:root.mobile-host .daily-member-add { grid-template-columns: minmax(0, 1fr) auto; grid-auto-flow: initial; align-items: end; }
:root.mobile-host .daily-member-add button { width: auto; min-width: 92px; min-height: 42px; }
:root.mobile-host .week-controls { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 6px; justify-content: stretch; }
:root.mobile-host .week-controls > button { min-height: 42px; }
:root.mobile-host .week-controls > button:nth-child(1) { grid-column: 1; grid-row: 1; }
:root.mobile-host .week-controls > button:nth-child(2) { grid-column: 2; grid-row: 1; }
:root.mobile-host .week-controls > button:nth-child(3) { grid-column: 3; grid-row: 1; }
:root.mobile-host .week-controls > strong { grid-column: 1 / -1; grid-row: 2; margin-left: 0; overflow-wrap: anywhere; text-align: center; white-space: normal; }
:root.mobile-host .daily-table-wrap { width: 100%; height: clamp(280px, calc(100svh - 300px), 640px); max-height: none; overflow: auto; -webkit-overflow-scrolling: touch; }
:root.mobile-host .daily-table { min-width: 760px; }
:root.mobile-host .daily-table thead th:first-child { width: 110px; }
:root.mobile-host .daily-table td { min-width: 130px; }
:root.mobile-host .daily-task-list { gap: 4px; padding: 2px; }
:root.mobile-host .daily-task-card { padding: 6px; font-size: 12px; }
:root.mobile-host .daily-add-task { min-height: 42px; }
:root.mobile-host .daily-vacation-card { min-height: 42px; padding: 4px; }
:root.mobile-host .daily-vacation-icon { width: 42px; height: 42px; margin-right: -7px; }
:root.mobile-host .daily-member-name { margin: 4px; padding: 6px 4px; font-size: 12px; }

:root.mobile-host .admin-section { height: auto; min-height: calc(100svh - 104px); overflow: visible; padding: var(--mobile-gutter); }
:root.mobile-host .admin-grid { display: block; }
:root.mobile-host .admin-card { margin-bottom: 10px; }
:root.mobile-host .admin-block-heading { display: flex; flex-direction: column; gap: 8px; margin-bottom: 9px; }
:root.mobile-host .admin-block-actions { display: grid; grid-template-columns: 1fr; justify-content: stretch; width: 100%; }
:root.mobile-host .admin-block-actions button { width: 100%; min-height: 42px; }
:root.mobile-host .user-list-toolbar { display: grid; gap: 8px; align-items: stretch; }
:root.mobile-host .user-list-toolbar .user-search { max-width: none; }
:root.mobile-host .active-users-filter { margin: 0; }
:root.mobile-host .users-table-wrap,
:root.mobile-host .permissions-table-wrap { max-width: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
:root.mobile-host .vacation-form,
:root.mobile-host .vacation-row,
:root.mobile-host .cron-task-form,
:root.mobile-host .profile-password-form { grid-template-columns: 1fr; }
:root.mobile-host .vacation-actions,
:root.mobile-host .telegram-actions { flex-wrap: wrap; }
:root.mobile-host .vacation-actions button,
:root.mobile-host .telegram-actions button { flex: 1 1 150px; min-height: 42px; }
:root.mobile-host .vacation-calendar-panel { padding: 7px; }
:root.mobile-host .vacation-calendar-day { min-height: 54px; padding: 3px; }
:root.mobile-host .vacation-calendar-marker { font-size: 8px; }
:root.mobile-host .notifications-list .user-row { grid-template-columns: 1fr; }
:root.mobile-host .telegram-settings-grid { grid-template-columns: 1fr; }
:root.mobile-host .notify-permission > div { align-items: stretch; flex-direction: column; }
:root.mobile-host .notify-permission button { min-height: 42px; }

:root.mobile-host dialog {
  width: calc(100vw - 16px);
  max-width: calc(100vw - 16px);
  max-height: calc(100svh - 16px);
  margin: 8px auto;
  overflow: auto;
  border-radius: 13px;
}
:root.mobile-host .daily-task-dialog form { max-height: calc(100svh - 26px); overflow-y: auto; padding: 14px 12px 12px; }
:root.mobile-host .daily-task-dialog input,
:root.mobile-host .daily-task-dialog textarea,
:root.mobile-host .daily-task-dialog select,
:root.mobile-host .tracker-issue-dialog input,
:root.mobile-host .create-user-dialog input,
:root.mobile-host .create-user-dialog select { min-height: 42px; }
:root.mobile-host .daily-task-ticket-results { max-height: 170px; }
:root.mobile-host .daily-task-ticket-results button { min-height: 42px; }
:root.mobile-host .tracker-issue-dialog { padding: 13px 12px; }
:root.mobile-host .tracker-issue-dialog-body dl { grid-template-columns: 1fr; gap: 3px; margin: 13px 0; }
:root.mobile-host .tracker-description { max-height: 48svh; padding: 9px; }
:root.mobile-host .tracker-issue-dialog-actions { flex-wrap: wrap; gap: 8px; }
:root.mobile-host .tracker-issue-dialog-actions a { width: 100%; margin-right: 0; }
:root.mobile-host .create-user-dialog { padding: 15px 12px; }
:root.mobile-host .create-user-dialog .admin-form { grid-template-columns: 1fr; }
:root.mobile-host .create-user-dialog .roles-box { grid-column: auto; grid-template-columns: 1fr 1fr; }

@media (max-width: 420px) {
  :root.mobile-host .topbar { gap: 5px 6px; }
  :root.mobile-host .app-page-title { font-size: 14px; }
  :root.mobile-host .main-nav a { padding-right: 10px; padding-left: 10px; font-size: 11px; }
  :root.mobile-host .tracker-table { min-width: 1040px; }
  :root.mobile-host .daily-table { min-width: 700px; }
  :root.mobile-host .daily-table td { min-width: 118px; }
  :root.mobile-host .daily-table thead th:first-child { width: 100px; }
  :root.mobile-host .daily-task-card { font-size: 11px; }
  :root.mobile-host .create-user-dialog .roles-box { grid-template-columns: 1fr; }
}
