/* FR-T4 (TZ v10): тёмная тема — все надписи панели контраст ≥4,5:1 (WCAG AA).
   Замер: qa/dark_contrast_check.py (qa/probes/out/dark_contrast.json). */

/* style.css:171-181 держит color:#000 !important на всей панели — в тёмной
   теме это чёрное на тёмном. Перекрываем тем же important с большей
   специфичностью (body.dark-theme + последний в каскаде). */
body.dark-theme .controls-container,
body.dark-theme .controls-container label,
body.dark-theme .controls-container h4,
body.dark-theme .controls-container span,
body.dark-theme .controls-container small,
body.dark-theme .controls-container .layer-name,
body.dark-theme .controls-container .points-text,
body.dark-theme .controls-container .poi-type-list,
body.dark-theme .controls-container .layer-group-header,
body.dark-theme .controls-container .control-item label {
  color: #f0f4f8 !important;
}

/* Легаси: style.css:226 красил тёмную панель в белый, слой-строки держали
   белый фон (.layer-control-item). Сводим к тёмной поверхности. */
body.dark-theme .layer-control-item {
  background: transparent;
  border-bottom-color: #3b4a5d;
}
body.dark-theme #layer-controls-panel,
body.dark-theme .layer-main-info {
  background: #1e293b;
  color: #f0f4f8;
}

/* Каталог формулы-дока: фон был белым при белом тексте из тёмной темы */
body.dark-theme #formula-dock,
body.dark-theme #formula-dock .fd-body,
body.dark-theme #fd-body {
  background: #1e293b;
  color: #f0f4f8;
}
body.dark-theme .fd-head { background: #16202e; color: #cbd5e1; }
body.dark-theme .fd-hint { color: #cbd5e1; }
body.dark-theme .fd-x { background: #243244; color: #e2e8f0; border-color: #45566d; }

/* Тёмные блоки .floor: чёрные подписи → светлые */
body.dark-theme .tr-lab,
body.dark-theme .ps-title,
body.dark-theme .ps-lead,
body.dark-theme .who-title,
body.dark-theme .who-pct,
body.dark-theme .fly-hint,
body.dark-theme .weight-sum,
body.dark-theme .preset-recipe,
body.dark-theme .panel-caption-ctx {
  color: #e8eef5 !important;
}

/* Сводки секций: тёмная плашка под светлым текстом независимо от родителя */
body.dark-theme .controls-container summary {
  background: #1e293b;
  color: #f0f4f8;
}

/* Чипы POI: белый текст был на светло-зелёной подложке */
body.dark-theme .poi-quick-lab,
body.dark-theme #poi-quick-bar .poi-quick-lab {
  color: #ffffff;
  background: #2b3542;
}
body.dark-theme .poi-quick-title {
  color: #ffffff;
  background: #2b3542;
}

/* Шапка окна меню (.win-head) и кнопка поиска: светлые остатки */
body.dark-theme .controls-container > .win-head,
body.dark-theme .win-title {
  background: #16202e;
  color: #e2e8f0;
  border-bottom-color: #3b4a5d;
}
body.dark-theme .controls-container b,
body.dark-theme .controls-container i,
body.dark-theme .controls-container p,
body.dark-theme .controls-container div,
body.dark-theme .controls-container .panel-note {
  color: #f0f4f8 !important;
}
body.dark-theme #address-search-button {
  background: #0d47a1;
  color: #ffffff;
}

/* ── ТЗ-23 З3 (11.11.2026): остатки светлой темы, найденные матрицей из 12 кадров ──
   Замер: tools/z3_theme_matrix.py, qa/logs/*-z3/z3_matrix_evidence.json (зоны по
   собственному фону, а не по фону родителя). */

/* Панель «Вещи на борту» в «Еде»: kit.css держит свои токены (--bg-surface:#fff),
   а menu-type.css:20 force'ит белый текст — получались белые буквы по белому.
   Правлю токены, а не каждое правило: внутренности панели уже сидят на var(). */
body.dark-theme #ih-kit-panel {
  --bg-surface: #151B20;
  --text-primary: #ECF0F2;
  --text-secondary: #A5AFB6;
  --text-muted: #A5AFB6;
  --border: #2A3238;
  --border-muted: #2A3238;
  --bg-muted: #1B222A;
  --bg-accent: #12291B;
  --bg-track: rgba(255,255,255,.14);
  --line: rgba(255,255,255,.16);
  background: #151B20 !important;
  border-color: #2A3238 !important;
}
/* kit.css красит эти куски литералами, токенты их не накрывают */
body.dark-theme #ih-kit-panel .ih-kit-p { background: #1B222A; color: #B7E3B9; border-color: #2A3238; }
body.dark-theme #ih-kit-panel .ih-kit-p.is-on { background: #2E7D32; color: #FFFFFF; }
body.dark-theme #ih-kit-panel .ih-kit-hint { color: #A5AFB6; }
body.dark-theme #ih-kit-panel .food-tbl th,
body.dark-theme #ih-kit-panel .food-tbl td,
body.dark-theme #ih-kit-panel .ih-kit-tbl th,
body.dark-theme #ih-kit-panel .ih-kit-tbl td,
body.dark-theme #ih-kit-panel .ih-kit-table td { border-bottom-color: #2A3238; }
body.dark-theme #ih-kit-panel .ih-kit-win-head { border-bottom-color: #2A3238; }
body.dark-theme #ih-kit-panel .ih-kit-side { border-right-color: #2A3238; }

/* Чипы топбара: view_tabs.js доклеивает «background:#fff;color:#1b5e20» —
   на тёмной полосе оставались два белых прямоугольника. */
body.dark-theme #menu-collapse,
body.dark-theme #basemap-theme-toggle,
body.dark-theme .topbar-tool {
  background: #1B222A !important;
  color: #CFE3D2 !important;
  border-color: #3C4A57 !important;
}

/* Переключатель шкал «Мир/Экран»: modules/color_scale.js пишет фон и цвет
   инлайном, поэтому только !important. */
body.dark-theme #scale-mode {
  background: #151B20 !important;
  color: #ECF0F2 !important;
  border-color: #A5AFB6 !important;
}
body.dark-theme #scale-mode #scale-nums { color: #ECF0F2 !important; }
body.dark-theme #scale-mode button {
  background: #1B222A; color: #CFE3D2; border: 1px solid #3C4A57; border-radius: 4px; padding: 2px 8px;
}

/* Легенда: style.css:1507 держит .legend-toggle color:#333 — на тёмной плашке
   легенды (#424444) замер даёт 1.29:1, заголовок «Легенда баллов» нечитаем. */
body.dark-theme .legend-toggle,
body.dark-theme .legend.collapsed .legend-toggle,
body.dark-theme .legend .legend-toggle {
  color: #ECF0F2 !important;
}
body.dark-theme .legend { border-color: #3C4A57 !important; }

/* Чипы объектов: style.css:1478 красит блок в кремовый #eef6ee с чёрным
   текстом — светлый остров внутри тёмного пульта. */
body.dark-theme #poi-quick-bar {
  background: #1B222A !important;
  border-color: #3C4A57 !important;
  color: #ECF0F2 !important;
}

/* Поля ввода и селекторы пульта: по умолчанию белые. */
body.dark-theme .controls-container input,
body.dark-theme .controls-container select,
body.dark-theme #islands-overlay select.col-search,
body.dark-theme #islands-overlay-head select.col-search {
  background: #1B222A !important;
  color: #ECF0F2 !important;
  border-color: #3C4A57 !important;
}

/* Таблица островов: контейнер тёмный, но AG Grid сам красит себя токентами
   ag-theme-material (белый), а islands_tab.js доклеивает в <head>
   #islands-overlay .ov-btn{background:#f1f5f9!important} и
   .ag-paging-panel{background:#f8fafc}. Правлю токенты темы + специфичнее
   рантаймового стиля: без этого ru/dark/islands был meanLum=101, dark=65 %. */
body.dark-theme .ag-theme-material {
  --ag-background-color: #151B20;
  --ag-foreground-color: #ECF0F2;
  --ag-data-color: #ECF0F2;
  --ag-header-background-color: #1B222A;
  --ag-header-foreground-color: #CFE3D2;
  --ag-header-cell-hover-background-color: #22303A;
  --ag-header-cell-moving-background-color: #1B222A;
  --ag-border-color: #2A3238;
  --ag-row-border-color: #2A3238;
  --ag-odd-row-background-color: #171E24;
  --ag-row-hover-color: #22303A;
  --ag-selected-row-background-color: #274156;
  --ag-control-panel-background-color: #1B222A;
  --ag-side-bar-background-color: #1B222A;
  --ag-disabled-foreground-color: #8C979E;
  --ag-chip-background-color: #22303A;
  --ag-secondary-foreground-color: #A5AFB6;
  --ag-input-disabled-background-color: #1B222A;
  --ag-range-selection-border-color: #5C8AA0;
  --ag-checkbox-checked-color: #2E7D32;
  --ag-checkbox-unchecked-color: #3C4A57;
}
body.dark-theme .ag-root-wrapper,
body.dark-theme .ag-paging-panel,
body.dark-theme .ag-panel-container,
body.dark-theme #islands-overlay {
  background: #151B20 !important;
  color: #ECF0F2 !important;
  border-color: #2A3238 !important;
}
body.dark-theme #islands-overlay-head {
  background: #1B222A !important;
  border-bottom-color: #2A3238 !important;
  color: #ECF0F2 !important;
}
body.dark-theme #islands-overlay .ov-btn,
body.dark-theme #islands-overlay .win-min,
body.dark-theme #islands-overlay .win-max,
body.dark-theme #islands-overlay .win-x {
  background: #22303A !important;
  color: #CFE3D2 !important;
  border-color: #3C4A57 !important;
}
body.dark-theme #isl-hl-legend {
  background: #3A2E15 !important;
  color: #F0C674 !important;
}
