/* ALLTRACE BY CRM / Telegram iOS mobile header geometry
 * Scoped to the actual authenticated admin shell.
 * Stable single row, no horizontal scroll/cropped actions.
 * No Telegram-native safe-area overrides.
 */
@media (max-width: 767.98px) {
  [data-admin-shell] > header {
    box-sizing: border-box;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between;
    gap: 8px !important;
    min-width: 0;
    width: 100%;
    height: 60px !important;
    min-height: 60px !important;
    max-height: 60px !important;
    padding: 0 12px !important;
    border-bottom: 1px solid var(--ui-border, #334155);
    overflow: visible;
    isolation: isolate;
  }
  /* Left: menu and the official, compact ALLTRACE logo. */
  [data-admin-shell] > header > div:first-child {
    display: flex !important;
    align-items: center;
    gap: 6px !important;
    flex: 0 1 auto !important;
    width: auto !important;
    min-width: 0;
    max-width: 168px;
    overflow: visible;
  }
  [data-admin-shell] > header button[aria-label="Открыть меню"] {
    display: grid !important;
    place-items: center;
    flex: 0 0 36px !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    margin: 0 !important;
    padding: 6px !important;
    border-radius: 9px;
  }
  [data-admin-shell] > header button[aria-label="Открыть меню"] svg {
    display: block; width: 21px; height: 21px;
  }
  [data-admin-shell] > header a[aria-label="Учебка — на рабочий стол"] {
    display: flex !important;
    align-items: center;
    flex: 0 1 auto !important;
    width: 126px !important;
    min-width: 0 !important;
    max-width: 126px !important;
    height: 40px !important;
    overflow: hidden;
    border-radius: 8px;
  }
  [data-admin-shell] > header .alltrace-admin-header-logo {
    display: block;
    width: 126px;
    max-width: 100%;
    height: 36px;
    object-fit: contain;
    object-position: left center;
    flex: 0 1 auto;
  }
  /* No second scrollable row of large desktop shortcuts inside the header.
     Those pages remain available through main CRM navigation. */
  [data-admin-shell] > header > div:nth-child(3) {
    display: none !important;
  }
  /* Right action cluster must never be clipped by legacy mobile guard. */
  [data-admin-shell] > header > div:last-child {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
    gap: 3px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    scrollbar-width: none;
    padding: 0 !important;
  }
  [data-admin-shell] > header #alltrace-theme-control {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    flex: 0 0 31px;
    width: 31px !important;
    height: 34px !important;
    min-width: 31px;
    min-height: 34px;
    margin: 0;
    padding: 0;
    border-radius: 9px;
  }
  [data-admin-shell] > header #alltrace-theme-control svg {
    display:block; width: 19px; height: 19px;
  }
  [data-admin-shell] > header a[aria-label="Чат"] {
    box-sizing: border-box;
    display: grid; place-items: center;
    flex: 0 0 33px;
    width: 33px !important;
    height: 34px !important;
    min-width: 33px;
    min-height: 34px;
    padding: 3px !important;
    border-radius: 9px;
  }
  [data-admin-shell] > header a[aria-label="Чат"] > span {
    line-height: 1;
    font-size: 21px !important;
  }
  [data-admin-shell] > header button[title="Уведомления"] {
    box-sizing: border-box;
    display: grid; place-items: center;
    width: 33px !important;
    height: 34px !important;
    min-width: 33px;
    min-height: 34px;
    padding: 3px !important;
    border-radius: 9px;
  }
  [data-admin-shell] > header button[title="Уведомления"] > span:first-child {
    font-size: 21px !important;
    line-height: 1 !important;
  }
  [data-admin-shell] > header button[title="Сменить кабинет"] {
    display: grid; place-items: center;
    width: 32px !important;
    min-width: 32px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 3px !important;
    border-radius: 9px;
  }
  [data-admin-shell] > header > div:last-child > div:last-child > button {
    box-sizing: border-box;
    display: grid;
    place-items: center;
    width: 37px !important;
    min-width: 37px;
    height: 37px !important;
    min-height: 37px;
    padding: 2px !important;
    gap: 0 !important;
    border-radius: 11px;
  }
  [data-admin-shell] > header > div:last-child > div:last-child > button > span:not(:first-child) {
    display: none !important;
  }
  [data-admin-shell] > header > div:last-child > div:last-child > button > span:first-child {
    display: grid;
    place-items: center;
    flex: 0 0 31px;
    width: 31px !important;
    min-width: 31px;
    height: 31px !important;
    border-radius: 10px;
    font-size: 11px;
  }
  /* Dropdowns remain accessible on top of the CRM dashboard. */
  [data-admin-shell] > header > div:last-child > div {
    flex-shrink: 0;
    overflow: visible;
  }
}
@media(max-width:359.98px) {
  [data-admin-shell] > header {padding-inline:9px !important; gap:5px !important;}
  [data-admin-shell] > header > div:first-child { gap:4px !important;max-width:140px;}
  [data-admin-shell] > header button[aria-label="Открыть меню"] {
    width:32px !important;min-width:32px !important;flex-basis:32px !important;height:34px !important;
  }
  [data-admin-shell] > header a[aria-label="Учебка — на рабочий стол"] {
    width:103px !important;max-width:103px !important;height:34px !important;
  }
  [data-admin-shell] > header .alltrace-admin-header-logo {
    width:103px;height:31px;
  }
  [data-admin-shell] > header > div:last-child {gap:1px !important;}
  [data-admin-shell] > header #alltrace-theme-control {width:27px !important;flex-basis:27px;min-width:27px;}
  [data-admin-shell] > header a[aria-label="Чат"] {width:29px !important;min-width:29px;flex-basis:29px;}
  [data-admin-shell] > header button[title="Уведомления"] {width:29px !important;min-width:29px;}
  [data-admin-shell] > header > div:last-child > div:last-child > button {width:33px !important;min-width:33px;}
  [data-admin-shell] > header > div:last-child > div:last-child > button > span:first-child {
    width:29px !important;min-width:29px;height:29px !important;flex-basis:29px;
  }
}
/* Official ALLTRACE wordmark is white; give it a consistent restrained dark
   brand plate in both CRM color schemes so it never disappears on white. */
@media (max-width:767.98px) {
 [data-admin-shell] > header a[aria-label="Учебка — на рабочий стол"] {
   padding:2px 3px;
   background:#152320;
   border:1px solid rgba(142,194,158,.16);
   border-radius:8px;
 }
 [data-admin-shell] > header .alltrace-admin-header-logo {
   width:120px;
   height:34px;
   object-position:center;
 }
}
@media (max-width:359.98px) {
 [data-admin-shell] > header .alltrace-admin-header-logo {width:96px;height:29px;}
}
