:root {
  /* NM-115: высота шапки — число, а не следствие содержимого: от него считается карта. */
  --nm-header: 64px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #253b43;
  background: #f7f8f5;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid #146b9e; outline-offset: 3px; }
[hidden] { display: none !important; }
/* NM-115: шапка в одну строку ровно в --nm-header: слева название, справа дни. */
.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: var(--nm-header); padding: 0 24px; border-bottom: 1px solid #dce2dd;
}
.eyebrow { margin: 0 0 8px; font-size: 11px; font-weight: 650; letter-spacing: .14em; }
h1 { font-size: clamp(18px, 2vw, 22px); margin: 0; font-weight: 600; letter-spacing: -.035em; }
.day-navigation { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
#nm-day { min-width: 100px; text-align: center; font-variant-numeric: tabular-nums; }
.day-arrow {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  width: 32px; height: 32px; border: 1px solid #c8d2cd; border-radius: 50%;
  background: white; color: #253b43; font-size: 18px;
}
.day-arrow[aria-disabled="true"] { opacity: .3; cursor: default; }
/* NM-106: header across the top, narrow panel left of a map that owns the rest of the window. */
/* NM-188: третья колонка auto — карточка ячейки; закрытая ([hidden]) места не занимает. */
main { display: grid; grid-template-columns: 340px 1fr auto;
  height: calc(100vh - var(--nm-header)); height: calc(100dvh - var(--nm-header)); }
/* min-height: 0 — иначе grid-элемент растёт под контент вместо своей прокрутки. */
/* NM-115: отступы панели ужаты, чтобы легенда высот влезла в окно 1400×900 без прокрутки. */
.map-panel { display: flex; flex-direction: column; gap: 12px; padding: 12px;
  min-height: 0; overflow-y: auto; border-right: 1px solid #dce2dd; }
.panel-note { margin: 0; color: #637579; font-size: 12px; }
.filters { display: flex; flex-direction: column; gap: 10px; padding: 0; }
.filter-group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.filter-label { font-size: 12px; color: #637579; margin-right: 4px; }
.chip { display: inline-block; padding: 6px 10px; border: 1px solid #c8d2cd;
  border-radius: 20px; text-decoration: none; color: #52696d; background: white; font-size: 13px; }
.chip.active { background: #e0ede8; border-color: #607e71; color: #254a3e; }
a.chip:hover { border-color: #253b43; }
.summary { padding: 0; }
.summary dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0; }
.summary dt { font-size: 12px; color: #637579; }
.summary dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary p { margin: 8px 0 0; font-size: 12px; color: #637579; }
/* NM-165: свод здоровья дня — сразу за сводкой, по её образцу; отклонение цветом. */
.health { padding: 0; }
.health .health-state { margin: 0; font-size: 13px; font-weight: 600; }
.health ul { display: flex; flex-direction: column; gap: 4px; list-style: none;
  padding: 0; margin: 4px 0 0; font-size: 12px; color: #637579; }
.health li[data-status="alert"] { color: #c1121f; }
.map { position: relative; min-height: 430px; overflow: hidden; background: #e8ede7; }
#nm-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.maplibregl-ctrl-group button.nm-region-control { width: auto; padding: 0 10px; font-size: 12px; }
/* NM-222: линейка — кнопки с подписью, как «Вся область»; включённая подсвечена. */
/* NM-227: «Метка» и «Убрать все метки» — такие же кнопки с подписью, как у линейки. */
.maplibregl-ctrl-group button.nm-ruler-button,
.maplibregl-ctrl-group button.nm-mark-button { width: auto; padding: 0 10px; font-size: 12px;
  color: #253b43; }
.maplibregl-ctrl-group button.nm-ruler-button[aria-pressed="true"],
.maplibregl-ctrl-group button.nm-mark-button[aria-pressed="true"] { background-color: #e0ede8;
  color: #254a3e; font-weight: 600; }
/* NM-227: флажок метки — кнопка-маркер, нижний край древка стоит в точке; подпись над ним. */
.nm-mark { display: flex; flex-direction: column; align-items: center; padding: 0; border: 0;
  background: none; color: #253b43; }
.nm-mark-name { max-width: 160px; margin-bottom: 2px; padding: 1px 5px; overflow: hidden;
  border-radius: 4px; background: #fffffff0; font: 600 12px system-ui, sans-serif;
  white-space: nowrap; text-overflow: ellipsis; box-shadow: 0 1px 4px #253b4340; }
.nm-mark-pin { position: relative; width: 16px; height: 22px; }
.nm-mark-pin::before { content: ""; position: absolute; left: 1px; bottom: 0; width: 2px;
  height: 22px; background: #253b43; }
.nm-mark-pin::after { content: ""; position: absolute; left: 3px; top: 0; width: 13px;
  height: 10px; background: #d81b8f; clip-path: polygon(0 0, 100% 50%, 0 100%); }
/* NM-227: меню метки — одно на карту, под точкой флажка. */
.nm-mark-menu { display: flex; flex-direction: column; gap: 2px; min-width: 170px; max-width: 240px;
  padding: 6px; border: 1px solid #dce2dd; border-radius: 8px; background: white;
  font-size: 13px; box-shadow: 0 8px 24px #253b4330; }
.nm-mark-action { padding: 6px 8px; border: 0; border-radius: 6px; background: none;
  color: #253b43; text-align: left; }
.nm-mark-action:hover { background: #f0f3ef; }
.nm-mark-note { margin: 4px 2px 0; color: #7a0c14; font-size: 12px; }
.nm-ruler-label { pointer-events: none; padding: 1px 5px; border-radius: 4px; background: #fffffff0;
  color: #7a0c14; font: 600 12px system-ui, sans-serif; white-space: nowrap;
  box-shadow: 0 1px 4px #253b4340; }
.nm-ruler-label.nm-ruler-total { color: white; background: #c1121f; }
.airport-label { pointer-events: none; color: #253b43; font: 650 12px system-ui, sans-serif;
  text-shadow: -1px -1px 2px white, 1px 1px 2px white, 0 0 4px white; }
.map-ready .map-attribution { display: none; }
.density-legend { display: flex; align-items: center; gap: 8px; }
.density-gradient { width: 120px; height: 10px; border-radius: 5px;
  background: linear-gradient(to right, var(--density-gradient)); }
/* NM-138: ползунок часа и легенда шума — рядом с прежними легендами и подсказками панели. */
.noise-panel { display: flex; flex-direction: column; gap: 10px; }
.noise-hour { display: flex; align-items: center; gap: 8px; margin: 0;
  font-size: 12px; color: #637579; }
.noise-hour input[type="range"] { flex: 1; min-width: 0; accent-color: #607e71; }
#nm-noise-hour-label { font-variant-numeric: tabular-nums; white-space: nowrap; }
.noise-legend span { width: 12px; height: 12px; border-radius: 2px; }
/* NM-221: ползунок «Прозрачность слоёв» — подпись над ним на всю ширину панели,
   подписи краёв «почти не видно» и «как сейчас» по краям под ним. */
.layer-opacity { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px;
  margin: 0; font-size: 12px; color: #637579; }
.layer-opacity label, .layer-opacity input[type="range"] { flex: 1 1 100%; min-width: 0; }
.layer-opacity input[type="range"] { margin: 0; accent-color: #607e71; }
/* NM-188: карточка выбранной ячейки — правая колонка рядом с картой; карта свою
   ширину и высоту сохраняет, закрытие ([hidden]) возвращает место карте. */
.noise-card { width: 320px; padding: 12px 14px; min-height: 0; overflow-y: auto;
  border-left: 1px solid #dce2dd; background: white; font-size: 12px; }
.noise-card h2 { margin: 0 24px 8px 0; font-size: 15px; overflow-wrap: anywhere; }
.noise-card p { margin: 4px 0; }
.noise-card .noise-card-line { display: flex; align-items: center; gap: 6px; }
#nm-close-noise-card { float: right; width: 24px; height: 24px; border: 0;
  background: #f0f3ef; border-radius: 50%; font-size: 16px; line-height: 1; color: #253b43; }
#nm-noise-colour { display: inline-block; width: 12px; height: 12px; border-radius: 2px;
  background: #8ce99a; }
#nm-noise-counts, #nm-noise-worst-hour { font-variant-numeric: tabular-nums; }
/* NM-189: таблица всех часов выбранной ячейки — внутри карточки, шире неё не растёт:
   горизонтальная прокрутка своя, карточка и карта ширину не меняют. */
.noise-table-scroll { overflow-x: auto; margin: 6px 0; }
#nm-noise-table { border-collapse: collapse; font-size: 11px;
  font-variant-numeric: tabular-nums; }
#nm-noise-table caption { margin-bottom: 4px; text-align: left; color: #253b43; }
#nm-noise-table th, #nm-noise-table td { padding: 2px 6px; font-weight: 400;
  text-align: right; white-space: nowrap; }
#nm-noise-table thead th { border-bottom: 1px solid #c8d2cd; }
#nm-noise-table tfoot th, #nm-noise-table tfoot td { border-top: 1px solid #c8d2cd;
  font-weight: 600; }
#nm-noise-table th[scope="row"], #nm-noise-table thead th:first-child { text-align: left; }
/* NM-187: заголовок часа и подпись полосы — нативные кнопки: доступны с клавиатуры
   (Enter/Space дают обычный click), выглядят как прежний текст таблицы. */
#nm-noise-table th button { padding: 0; border: 0; background: none; font: inherit;
  color: inherit; text-align: inherit; white-space: nowrap; }
/* NM-187: пороги полосы читаются без мыши: текст связан с кнопкой через
   aria-describedby, а при клавиатурном фокусе показывается подсказкой в самой
   шапке — строкой в потоке, а не всплывающим слоем, чтобы прокрутка таблицы её
   не обрезала. */
.noise-band-help { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
#nm-noise-table thead button:focus-visible + .noise-band-help {
  position: static; display: block; width: max-content; max-width: 220px; height: auto;
  margin: 4px 0 2px; padding: 6px 8px; overflow: visible; clip: auto; clip-path: none;
  white-space: normal; text-align: left;
  background: #253b43; color: white; border-radius: 6px; font-weight: 400; }
/* NM-213: в режиме «модель» клетка — сумма и в скобках факт по реальным трекам;
   скобка вторична к сумме — серым и мельче основного числа. */
.noise-fact { font-size: 0.85em; color: #6a7370; }
/* NM-185: выбранный час таблицы — видимая рамка поверх сохранённого цвета строки;
   цвет строки рамкой не перекрашивается. */
#nm-noise-table tr[aria-current="time"] th,
#nm-noise-table tr[aria-current="time"] td { box-shadow: inset 0 0 0 2px #146b9e; }
#nm-noise-count-mode-line { display: flex; align-items: center; gap: 6px; }
#nm-noise-count-mode { font: inherit; }
.map-status { position: absolute; z-index: 3; pointer-events: none; top: 16px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 180px); margin: 0; padding: 12px 18px;
  border: 1px solid #d5dfd5; border-radius: 8px; background: #fffffff5; font-size: 14px; }
/* NM-116: строки карточки объединены, поэтому окно сжато вдвое — 260 px и плотные отступы;
   ниже 12 px шрифт не опускается, иначе карточку не прочитать. */
.flight-card { position: absolute; z-index: 3; left: 24px; bottom: 64px; width: 260px;
  max-width: calc(100% - 48px); max-height: calc(100% - 96px); overflow: auto;
  padding: 12px 14px; background: #fff; border: 1px solid #dce2dd; border-radius: 12px;
  font-size: 12px; box-shadow: 0 8px 32px #253b4320; }
.flight-card h2 { margin: 0 24px 8px 0; font-size: 15px; overflow-wrap: anywhere; }
#nm-close-card { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px;
  border: 0; background: #f0f3ef; border-radius: 50%; font-size: 16px; line-height: 1;
  color: #253b43; }
.flight-card dl { display: grid; grid-template-columns: 96px 1fr; gap: 5px 10px;
  font-size: 12px; margin: 0; }
.flight-card dt { color: #637579; }
/* NM-116: высота выбранной вершины стоит в самой карточке вместо второго окна на карте. */
.flight-point { margin: 8px 0 0; font-size: 13px; color: #405f65;
  font-variant-numeric: tabular-nums; }
#nm-only-flight { margin-top: 8px; padding: 4px 10px; font-size: 12px; }
.flight-card dd { margin: 0; overflow-wrap: anywhere; }
.map-attribution { position: absolute; bottom: 0; left: 0; padding: 4px 8px;
  background: #fffffff0; font-size: 11px; }
.map-attribution a { color: #405f65; }
.legend { display: flex; flex-direction: column; gap: 8px; list-style: none; padding: 0; margin: 0;
  font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend span { display: inline-block; width: 22px; height: 3px; background: var(--source-colour); }
.legend .unscheduled-key { background: repeating-linear-gradient(to right,
  var(--source-colour) 0 6px, transparent 6px 11px); }
/* NM-108: the altitude legend is one gradient bar with the band edges written under it. */
#nm-altitude-legend { gap: 4px; }
#nm-altitude-legend li { display: block; }
#nm-altitude-legend .altitude-gradient { display: block; width: 100%; height: 10px;
  border-radius: 5px; background: linear-gradient(to right, var(--altitude-gradient)); }
#nm-altitude-legend .altitude-marks { display: flex; justify-content: space-between;
  color: #637579; font-variant-numeric: tabular-nums; }
#nm-altitude-legend b { font-weight: 400; }
.no-script { margin: 0; font-size: 12px; }
/* NM-106: too narrow for two columns — the map stays on top, the panel slides under it. */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: 1fr auto;
    height: auto; min-height: calc(100vh - var(--nm-header));
    min-height: calc(100dvh - var(--nm-header)); }
  .map { order: 1; }
  .map-panel { order: 2; max-height: 42vh;
    border-right: 0; border-top: 1px solid #dce2dd; }
  /* NM-187: на телефоне карточка закреплена снизу окна на всю ширину и не выше
     половины окна — верх карты остаётся видимым; шапка и действия не прокручиваются,
     своя прокрутка обеих осей — только у области таблицы. */
  .noise-card { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
    width: 100%; max-height: 50vh; max-height: 50dvh;
    display: flex; flex-direction: column;
    border-left: 0; border-top: 1px solid #dce2dd; }
  .noise-table-scroll { flex: 1 1 auto; min-height: 0; overflow: auto;
    overscroll-behavior: contain; }
  /* NM-187: область таблицы не сжимается ниже читаемой высоты — иначе на низком
     экране строки часов исчезают вовсе; если строки карточки над ней не влезают
     вместе с ней в половину окна, прокручивается сама карточка (overflow-y выше). */
  .noise-card .noise-table-scroll { min-height: 8rem; }
  /* NM-187: на низком экране (телефон лёжа, низкое окно) второстепенные строки
     карточки уступают место таблице: центр и сведения о прогоне читаются на
     высоком экране и в широкой раскладке. Правило вложено в блок 900 px —
     обходчики стилей NM-106/NM-115 читают единственный блок этой ширины. */
  @media (max-height: 700px) {
    .noise-card .eyebrow, #nm-noise-card-centre, #nm-noise-card-run { display: none; }
  }
}
@media (max-width: 640px) {
  /* NM-115: и на телефоне шапка остаётся одной строкой той же высоты — ужимаются отступы. */
  .page-header { padding: 0 12px; gap: 8px; }
  .day-navigation { gap: 8px; }
  #nm-day { min-width: 92px; }
  main { min-height: calc(100vh - var(--nm-header));
    min-height: calc(100dvh - var(--nm-header)); }
  .map-status { left: 12px; transform: none; width: auto; max-width: calc(100% - 140px); }
  .flight-card { left: 12px; bottom: 64px; max-width: calc(100% - 24px); }
}
/* NM-222: на телефоне (узкий экран или палец) кнопки карты — 44×44 px, под палец;
   ноутбук с мышью остаётся на 29 px MapLibre. Правый столбик не доходит до карточки
   полёта слева и до карточки ячейки снизу. */
@media (max-width: 640px), (pointer: coarse) {
  .maplibregl-ctrl-group button { width: 44px; height: 44px; }
  .maplibregl-ctrl-group button .maplibregl-ctrl-icon { background-size: 36px 36px; }
  .maplibregl-ctrl-group button.nm-region-control,
  .maplibregl-ctrl-group button.nm-ruler-button,
  .maplibregl-ctrl-group button.nm-mark-button { width: auto; min-width: 44px; font-size: 13px; }
  /* NM-227: пункты меню метки — под палец. */
  .nm-mark-action { min-height: 44px; }
}
