/* ============================================================
   Раздел /arhive/: адаптив страницы до 1024px
   - бургер-меню слева для значков шапки (К, Р, ошибки, верификация,
     колокол, обновить кэш, тема) — разметка в index.html, поведение
     в js/archive-burger.js;
   - вкладки шапки, панели инструментов и счётчики переносятся,
     текст не мельче 11px.
   На экранах шире 1024px всё остаётся как было.
   Файл подключается последним, после 40-redmi-pad.css и
   45-upload-workspace.css: часть правил перебивает их !important.
   ============================================================ */

/* ---------- ПК: обёртка значков не влияет на раскладку шапки ---------- */
.arh-hdr-tools { display: contents; }
.arh-burger,
.arh-hdr-tools__head,
.arh-burger-overlay { display: none; }

@media (max-width: 1024px) {
  :root { --arh-hdr-h: 80px; }

  /* ---------- кнопка ☰ ---------- */
  .arh-burger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    background: var(--bg-card, #fff);
    color: var(--text-main, #0f172a);
    cursor: pointer;
  }
  .arh-burger svg { width: 20px; height: 20px; }
  .arh-burger[aria-expanded="true"] { border-color: var(--accent, #0f766e); color: var(--accent, #0f766e); }
  .arh-burger__dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px var(--bg-card, #fff);
  }
  .arh-burger__dot[hidden] { display: none; }

  /* ---------- выезжающая слева панель ---------- */
  .arh-hdr-tools {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: min(300px, 86vw);
    padding: 12px;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    white-space: normal;
    background: var(--bg-card, #fff);
    border-right: 1px solid var(--border, #e2e8f0);
    box-shadow: 8px 0 24px rgba(15, 23, 42, .18);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  .arh-hdr-tools.is-open {
    transform: none;
    visibility: visible;
    transition: transform .2s ease;
  }
  .arh-hdr-tools__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 0 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border, #e2e8f0);
  }
  .arh-hdr-tools__title {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent, #0f766e);
  }
  .arh-hdr-tools__close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: transparent;
    color: var(--text-main, #0f172a);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }
  .arh-burger-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: rgba(15, 23, 42, .4);
  }
  .arh-burger-overlay[hidden] { display: none; }

  /* пункты меню: те же кнопки шапки, только строкой «значок — подпись — счётчик»;
     display не трогаем — скрытые по роли кнопки остаются скрытыми */
  #arhHdrTools .notify-btn {
    flex: 0 0 auto;
    justify-content: flex-start !important;
    gap: 12px;
    width: 100% !important;
    height: 46px !important;
    min-height: 46px;
    padding: 0 12px !important;
    border-radius: 10px !important;
    transform: none !important;
    text-align: left;
  }
  #arhHdrTools .notify-btn::after {
    content: attr(data-label);
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    color: var(--text-main, #0f172a);
  }
  /* значки одной ширины, чтобы подписи стояли ровно (колокол 24px, остальные 16-20px) */
  #arhHdrTools .notify-btn > svg {
    flex: 0 0 20px;
    width: 20px !important;
    height: 20px !important;
  }
  #arhHdrTools .notify-btn > :is(#controlBadge, #wantedBadge, #errorsBadge, #verificationBadge, .notify-badge) {
    position: static !important;
    order: 2;
    top: auto !important;
    right: auto !important;
    margin-left: auto;
  }

  /* окно «Проблемы» колокола: под шапкой у левого края (кнопка теперь в меню) */
  #notifyPanel {
    top: calc(var(--arh-hdr-h) + 8px) !important;
    left: 8px !important;
    right: auto !important;
    max-height: calc(100vh - var(--arh-hdr-h) - 16px);
    overflow-y: auto;
  }

  /* ---------- шапка: вкладки прокручиваются вбок, а не уезжают за экран ---------- */
  header.ias-hdr > div.ias-hdr__in {
    gap: 10px !important;
    padding: 0 12px 0 10px !important;
  }
  header.ias-hdr .ias-hdr__in > nav {
    justify-content: flex-start !important;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  header.ias-hdr .ias-hdr__in > nav::-webkit-scrollbar { display: none; }
  header.ias-hdr .ias-hdr__in > nav > .header-pill {
    flex: 0 0 auto;
    padding: 7px 12px;
    font-size: 13px;
  }
  header.ias-hdr .ias-hdr__act { gap: 6px; }

  /* ---------- текст и панели инструментов ---------- */
  /* счётчики над группами и в других вкладках: подписи читаемые (было 5-9px).
     В :is() перечислены id: правила archive-summary-big.css, 21/22-tablet-portrait.css и 40-redmi-pad.css
     заданы по id с !important, класс их не перебивает. */
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #crossSummaryCards, #expelledSummaryCards, #transferStatsCards) {
    gap: 6px !important;
    overflow-x: visible !important;
  }
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #transferStatsCards) > .stat-card-mini {
    min-width: 0 !important;
    max-width: none !important;
    padding: 8px 6px !important;
  }
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #crossSummaryCards, #expelledSummaryCards, #transferStatsCards) .stat-card-mini__value {
    font-size: 20px !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere;
  }
  html body main.main .stat-card-mini__pct { font-size: 12px !important; }
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #crossSummaryCards, #expelledSummaryCards, #transferStatsCards) .stat-card-mini__label {
    font-size: 11px !important;
    line-height: 1.2 !important;
    letter-spacing: 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* строка над группами: кнопки и фильтры переносятся (было nowrap — страница растягивалась вбок) */
  #tabGroups .panel__header { flex-wrap: wrap !important; row-gap: 8px !important; }
  #tabGroups .panel__header > div {
    flex-wrap: wrap !important;
    flex-shrink: 1 !important;
    min-width: 0;
    row-gap: 6px;
  }
  #tabGroups .panel__header > div:last-child { margin-left: 0 !important; }
  #tabGroups .panel__header .vek-filter { flex-wrap: wrap; white-space: normal !important; }
  main.main .panel-nav-btn {
    white-space: normal !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
    padding: 7px 12px !important;
  }
  main.main .chip { font-size: 12px !important; }

  /* подвкладки «Аналитики» — вбок прокруткой, строки с кнопками выгрузки переносятся */
  #analyticsSubtabs {
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  #analyticsSubtabs > .header-pill { flex: 0 0 auto; }
  main.main .tab-content > .flex,
  main.main .analytics-sub > .flex { flex-wrap: wrap; row-gap: 8px; }
  main.main :is(.tab-content, .analytics-sub) > .flex > .btn { white-space: normal !important; }

  main.main .panel__title { font-size: 15px; overflow-wrap: anywhere; }

  /* мелкий текст из 20-tablet.css, 21/22-tablet-portrait.css (7-10px) — не меньше 11-12px.
     #yearFilter в :is() поднимает специфичность до уровня id: те правила заданы по id с !important */
  html body main.main :is(.btn, .chip, .panel-nav-btn, #yearFilter, #btnAllYears, #btnCurrentYear, #btnAddGroup, #btnUploadVkData) {
    font-size: 12px !important;
  }
  html body main.main #yearFilter { max-width: none !important; }
  html body main.main :is(.group-card__note, .group-card__meta, .panel__counter, .stat-card__label, #statsGrid .text-xs) {
    font-size: 12px !important;
  }
  html body main.main .group-card .btn-icon__label { font-size: 11px !important; letter-spacing: 0; }
  html body main.main .main-tab .tab-label { font-size: 11px !important; }
  html body main.main .student-person-btn.sp-header { font-size: 11px !important; }
}

@media (max-width: 768px) {
  :root { --arh-hdr-h: 56px; }
  .arh-burger { width: 38px; height: 38px; }

  /* счётчики — рядами по 4 */
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #transferStatsCards) {
    flex-wrap: wrap !important;
  }
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #transferStatsCards) > .stat-card-mini {
    flex: 1 1 calc(25% - 6px) !important;
  }
}

@media (max-width: 640px) {
  /* название раздела — в заголовке меню, в шапке место отдаётся вкладкам */
  html body header.ias-hdr > div.ias-hdr__in > a.ias-hdr__brand { display: none !important; }
  header.ias-hdr .ias-hdr__in > nav > .header-pill { padding: 6px 10px; gap: 5px; }

  main.main { padding: 10px !important; }
  main.main .panel { padding: 10px !important; }
  main.main .group-card__title { font-size: 18px; }
}

@media (max-width: 480px) {
  html body main.main :is(.stats-cards, #groupsSummaryCards, #registrySummaryCards, #transferStatsCards) > .stat-card-mini {
    flex-basis: calc(33.33% - 6px) !important;
  }
}
