* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #1a1a2e; color: #e0e0e0; height: 100vh; display: flex; flex-direction: column; }
#header { background: #16213e; border-bottom: 1px solid #0f3460; padding: 8px 16px; display: flex; align-items: center; gap: 24px; flex-shrink: 0; z-index: 1000; flex-wrap: wrap; position: relative; }
#header h1 { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; }
#map-period { font-size: 10px; color: #78909c; font-weight: 400; letter-spacing: 0.4px; margin-top: 2px; white-space: nowrap; }
#header .stats-group { display: flex; gap: 0; }
.stats-divider { width: 1px; background: #0f3460; margin: 0 12px; align-self: stretch; }
.stat-block { display: flex; gap: 16px; }
.stat-item { text-align: center; min-width: 54px; }
.stat-val { font-size: 16px; font-weight: 700; color: #4fc3f7; line-height: 1; }
.stat-val.rev { color: #a5d6a7; }
.stat-val.filtered.rev { color: #81c784; }
.stat-val.filtered { color: #ffd54f; }
.stat-label { font-size: 9px; color: #78909c; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-label.filtered { color: #b0a060; }
#main { display: flex; flex: 1; overflow: hidden; position: relative; }
#map { flex: 1; }
#panel { width: 272px; background: #16213e; border-left: 1px solid #0f3460; display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; position: relative; z-index: 950; }
.panel-section { padding: 10px 12px; border-bottom: 1px solid #0f3460; display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-section.ps-collapsed { flex: 0 0 auto; }
.panel-section.ps-collapsed .ps-body { display: none; }
.panel-section.ps-collapsed .ps-chevron { transform: rotate(-90deg); }
.panel-title { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #78909c; margin-bottom: 7px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; user-select: none; flex-shrink: 0; }
.panel-title:hover { color: #b0bec5; }
.ps-chevron { font-size: 8px; color: #546e7a; transition: transform 0.18s; display: inline-block; margin-left: auto; }
.ps-body { display: flex; flex-direction: column; min-height: 0; flex: 1; overflow: hidden; }
.filter-scroll-wrap { flex: 1; min-height: 0; overflow-y: auto; }
.filter-scroll { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; }
.filter-item { display: flex; align-items: center; gap: 7px; padding: 4px 7px; border-radius: 5px; cursor: pointer; transition: background 0.12s; user-select: none; }
.filter-item:hover { background: rgba(255,255,255,0.06); }
.filter-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.25); transition: opacity 0.12s; }
.filter-item.inactive .filter-dot { opacity: 0.2; }
.filter-item.inactive .filter-name { opacity: 0.3; }
.filter-name { font-size: 11px; color: #cfd8dc; flex: 1; word-break: break-word; line-height: 1.35; }
.filter-vol { font-size: 10px; color: #78909c; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.filter-sparkline { display: block; }
.btn-row { display: flex; gap: 5px; margin-top: 7px; }
.btn-sm { flex: 1; padding: 4px 7px; font-size: 10px; border: 1px solid #0f3460; background: transparent; color: #90a4ae; border-radius: 4px; cursor: pointer; transition: all 0.12s; text-transform: uppercase; letter-spacing: 0.4px; }
.btn-sm:hover { background: #0f3460; color: #fff; }
.brand-item { display: flex; align-items: center; gap: 6px; padding: 3px 7px; border-radius: 5px; cursor: pointer; user-select: none; transition: background 0.12s; }
.brand-item:hover { background: rgba(255,255,255,0.05); }
.brand-check { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid #546e7a; background: transparent; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.12s; }
.brand-check.on { background: #4fc3f7; border-color: #4fc3f7; }
.brand-check.on::after { content: ''; display: block; width: 6px; height: 4px; border-left: 1.5px solid #000; border-bottom: 1.5px solid #000; transform: rotate(-45deg) translateY(-1px); }
.brand-check.partial { border-color: #E8820C; background: transparent; }
.brand-check.partial::after { content: ''; display: block; width: 6px; height: 2px; background: #E8820C; transform: none; border: none; }
.brand-item.inactive .brand-name { opacity: 0.3; }
.brand-name { font-size: 11px; color: #cfd8dc; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-vol { font-size: 10px; color: #78909c; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#top-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; min-height: 0; padding: 10px 6px 10px 12px; width: calc(100% - 12px); box-sizing: border-box; }
.top-item { display: flex; align-items: center; gap: 7px; padding: 5px 7px; background: rgba(255,255,255,0.03); border-radius: 5px; border: 1px solid rgba(255,255,255,0.04); cursor: pointer; transition: background 0.12s; flex-shrink: 0; }
.top-item:hover { background: rgba(79,195,247,0.1); }
.top-rank { font-size: 11px; font-weight: 700; color: #4fc3f7; width: 18px; text-align: center; flex-shrink: 0; }
.top-name { font-size: 11px; color: #eceff1; flex: 1; line-height: 1.3; }
.top-bar-wrap { width: 50px; flex-shrink: 0; }
.top-bar { height: 3px; border-radius: 2px; background: #4fc3f7; }
.top-val { font-size: 10px; color: #78909c; margin-top: 2px; text-align: right; }
.nd-title { font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.nd-section { margin-bottom: 8px; }
.nd-section-title { font-size: 10px; text-transform: uppercase; color: #78909c; letter-spacing: 1px; margin-bottom: 4px;
  cursor: pointer; display: flex; align-items: center; gap: 5px; user-select: none; padding: 3px 5px;
  border-radius: 4px; transition: background 0.12s; }
.nd-section-title:hover { background: rgba(255,255,255,0.06); }
.nd-section-title .nd-chevron { font-size: 8px; color: #546e7a; transition: transform 0.18s; display: inline-block; margin-left: auto; }
.nd-section.collapsed .nd-chevron { transform: rotate(-90deg); }
.nd-section-body { overflow: hidden; transition: max-height 0.2s ease, opacity 0.2s; max-height: 10000px; opacity: 1; }
.nd-section.collapsed .nd-section-body { max-height: 0; opacity: 0; pointer-events: none; }
.nd-route-group { margin-bottom: 4px; }
.nd-route-header { font-size: 10px; cursor: pointer; display: flex; align-items: center; gap: 0;
  padding: 2px 4px; border-radius: 3px; color: #90caf9; font-weight: 700; user-select: none; }
.nd-rh-name { flex: 1; padding-right: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nd-rh-qty  { width: 44px; text-align: right; color: #4fc3f7; font-variant-numeric: tabular-nums; padding-right: 4px; }
.nd-rh-vol  { width: 40px; text-align: right; color: #90a4ae; font-variant-numeric: tabular-nums; padding-right: 4px; }
.nd-rh-rev  { width: 56px; text-align: right; color: #a5d6a7; font-variant-numeric: tabular-nums; padding-right: 4px; }
.nd-route-header:hover { background: rgba(21,101,192,0.18); }
.nd-route-header .nd-chevron { font-size: 8px; color: #546e7a; transition: transform 0.18s; display: inline-block; margin-left: auto; }
.nd-route-group.collapsed .nd-chevron { transform: rotate(-90deg); }
.nd-route-body { overflow: hidden; transition: max-height 0.18s ease, opacity 0.18s; max-height: 10000px; opacity: 1; }
.nd-route-group.collapsed .nd-route-body { max-height: 0; opacity: 0; pointer-events: none; }
.nd-row { display: flex; justify-content: space-between; font-size: 11px; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.nd-dest { color: #cfd8dc; flex: 1; }
.nd-vol { color: #4fc3f7; font-weight: 600; white-space: nowrap; margin-left: 5px; }
.nd-qty { color: #90a4ae; font-size: 10px; white-space: nowrap; margin-left: 5px; }
.nd-close { float: right; cursor: pointer; color: #78909c; font-size: 15px; line-height: 1; background: none; border: none; padding: 0; }
.nd-close:hover { color: #fff; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 2px; }
.leaflet-popup-content-wrapper { background: rgba(22,33,62,0.97); border: 1px solid #0f3460; border-radius: 8px; color: #e0e0e0; box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
.leaflet-popup-tip { background: #16213e; }
.leaflet-popup-content { margin: 10px 14px; font-size: 12px; }
.nd-brand-tbl { width: 100%; border-collapse: collapse; font-size: 10px; margin-top: 4px; table-layout: fixed; }
.nd-brand-tbl th { background: rgba(79,195,247,0.12); color: #90a4ae; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; padding: 3px 5px; text-align: left; border-bottom: 1px solid #0f3460; }
.nd-brand-tbl th:nth-child(3), .nd-brand-tbl th:nth-child(4), .nd-brand-tbl th:nth-child(5) { text-align: right; }
.nd-brand-tbl td:nth-child(3), .nd-brand-tbl td:nth-child(4), .nd-brand-tbl td:nth-child(5) { text-align: right; }
.nd-brand-tbl td { padding: 2px 5px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: top; }
.nd-brand-tbl tr:last-child td { border-bottom: none; }
.nd-route-cell { color: #78909c; font-style: italic; font-size: 10px; }
.nd-sku-tbl { width: 100%; border-collapse: collapse; font-size: 9px; margin-top: 4px; table-layout: fixed; }
.nd-sku-tbl th { background: rgba(79,195,247,0.12); color: #90a4ae; font-weight: 600; text-transform: uppercase; padding: 3px; text-align: left; border-bottom: 1px solid #0f3460; }
.nd-sku-tbl td { padding: 3px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: top; word-wrap: break-word; }
.nd-sku-tbl td:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nd-sku-tbl th:nth-child(3), .nd-sku-tbl th:nth-child(4), .nd-sku-tbl th:nth-child(5), .nd-sku-tbl th:nth-child(6),
.nd-sku-tbl td:nth-child(3), .nd-sku-tbl td:nth-child(4), .nd-sku-tbl td:nth-child(5), .nd-sku-tbl td:nth-child(6) { text-align: right; }
#dl-btn { position: fixed; bottom: 20px; right: 272px; z-index: 9999; background: #01579b; color: #fff; border: none; border-radius: 6px; padding: 9px 16px; font-size: 12px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 12px rgba(0,0,0,0.4); transition: background 0.15s; display: flex; align-items: center; gap: 7px; }
#dl-btn:hover { background: #0277bd; }
#dl-btn svg { flex-shrink: 0; }
/* ── Toolbar ── */
#toolbar { position: fixed; bottom: 20px; left: 10px; z-index: 9998; display: flex; gap: 7px; flex-wrap: wrap; max-width: calc(100vw - 282px); }
.tb-btn { background: rgba(22,33,62,0.92); color: #90a4ae; border: 1px solid #0f3460; border-radius: 6px; padding: 7px 12px; font-size: 11px; cursor: pointer; display: flex; align-items: center; gap: 6px; backdrop-filter: blur(4px); transition: all 0.15s; white-space: nowrap; }
.tb-btn:hover { background: #0f3460; color: #fff; }
.tb-btn.active { background: #1565c0; color: #fff; border-color: #1976d2; }
/* ── Side panels wrapper ── */
#side-panels-wrap { position: fixed; bottom: 65px; left: 10px; z-index: 9997; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; pointer-events: none; }
#side-panels-wrap > * { pointer-events: all; }
/* ── Time slider panel ── */
#slider-panel { position: relative; transition: min-width 0.2s; background: rgba(22,33,62,0.95); border: 1px solid #0f3460; border-radius: 8px; padding: 12px 16px; min-width: 460px; width: fit-content; display: none; backdrop-filter: blur(4px); }
#slider-panel .sp-title { font-size: 11px; color: #78909c; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
#slider-panel .sp-month { font-size: 14px; font-weight: 700; color: #4fc3f7; }
.sp-range-wrap { position: relative; margin-bottom: 4px; }
.sp-range-labels { display: flex; justify-content: space-between; font-size: 11px; color: #4fc3f7; font-weight: 700; margin-bottom: 4px; }
.sp-dual-wrap { position: relative; height: 28px; }
.sp-range-input { position: absolute; width: 100%; height: 4px; background: transparent; -webkit-appearance: none; appearance: none; pointer-events: none; outline: none; top: 50%; transform: translateY(-50%); z-index: 1; }
#range-to { z-index: 2; }
.sp-range-input::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #4fc3f7; cursor: pointer; pointer-events: all; border: 2px solid #16213e; box-shadow: 0 0 4px rgba(79,195,247,0.6); }
.sp-range-input::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #4fc3f7; cursor: pointer; pointer-events: all; border: 2px solid #16213e; }
#range-from::-webkit-slider-thumb { background: #81d4fa; }
#range-from::-moz-range-thumb { background: #81d4fa; }
#slider-panel .sp-ticks { position: relative; display: block; align-items: flex-start; height: 28px; margin-top: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: #0f3460 transparent; padding: 0 22px 4px 22px; box-sizing: border-box; }
#slider-panel .sp-ticks span { flex: 0 0 auto; cursor: pointer; padding: 2px 4px; border-radius: 3px; font-size: 9px; color: #546e7a; white-space: nowrap; transition: background 0.12s, color 0.12s; }
#slider-panel .sp-ticks span:hover { background: rgba(79,195,247,0.18); color: #4fc3f7; }
#slider-panel .sp-ticks span.sp-tick-active { background: #1565c0; color: #fff; }
#slider-panel .sp-ticks::-webkit-scrollbar { height: 4px; }
#slider-panel .sp-ticks::-webkit-scrollbar-track { background: transparent; }
#slider-panel .sp-ticks::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 2px; }

#slider-panel .sp-stats { display: flex; gap: 16px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #0f3460; }
#slider-panel .sp-stat { text-align: center; }
#slider-panel .sp-val { font-size: 14px; font-weight: 700; color: #4fc3f7; }
#slider-panel .sp-lbl { font-size: 9px; color: #78909c; text-transform: uppercase; }
/* ── Compare panel ── */
#compare-panel { position: relative; transition: min-width 0.2s; background: rgba(22,33,62,0.95); border: 1px solid #0f3460; border-radius: 8px; padding: 12px 16px; min-width: 340px; width: fit-content; display: none; backdrop-filter: blur(4px); }
#compare-panel .cp-title { font-size: 11px; color: #78909c; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; }
.side-panel-collapsed .side-panel-body { display: none !important; }
.side-panel-collapsed { min-width: 0 !important; padding: 8px 10px !important; }
.side-panel-header { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; margin-bottom: 8px; gap: 8px; }
.side-panel-header:hover .sp-collapse-btn { color: #4fc3f7; }
.sp-collapse-btn { color: #78909c; font-size: 13px; line-height: 1; flex-shrink: 0; transition: transform 0.2s; }
.side-panel-collapsed .sp-collapse-btn { transform: rotate(180deg); }
.cp-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.cp-label { font-size: 11px; width: 60px; flex-shrink: 0; }
.cp-label.a { color: #4fc3f7; }
.cp-label.b { color: #ff9800; }
.cp-select { flex: 1; background: #0f3460; border: 1px solid #1565c0; color: #cfd8dc; border-radius: 4px; padding: 4px 7px; font-size: 11px; }
#cp-apply { width: 100%; margin-top: 6px; padding: 6px; background: #1565c0; color: #fff; border: none; border-radius: 5px; cursor: pointer; font-size: 11px; font-weight: 600; transition: background 0.15s; }
#cp-apply:hover { background: #1976d2; }
.cp-legend { display: flex; gap: 16px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #0f3460; font-size: 10px; }
.cp-legend-item { display: flex; align-items: center; gap: 5px; }
.cp-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
/* ── Draggable floating popup ── */

.float-popup {
  position: fixed;
  z-index: 10000;
  background: rgba(18,28,52,0.97);
  border: 1px solid #1565c0;
  border-radius: 8px;
  min-width: 420px;
  max-width: 700px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  font-size: 11px;
  color: #cfd8dc;
  user-select: none;
  resize: horizontal;
  overflow: hidden;
}

.fp-header {
  background: #0d1f3c;
  border-radius: 8px 8px 0 0;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: move;
  border-bottom: 1px solid #1565c0;
  min-height: 34px;
  box-sizing: border-box;
}

.fp-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.fp-title-main {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-title-meta {
  font-size: 9px;
  color: #78909c;
  font-weight: 400;
  white-space: nowrap;
}

.fp-title-status {
  color: #80cbc4;
}

.fp-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

.fp-toggle,
.fp-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  cursor: pointer;
  user-select: none;
  line-height: 1;
}

.fp-toggle {
  font-size: 13px;
  color: #78909c;
  padding: 0;
}

.fp-close {
  font-size: 14px;
  color: #4fc3f7;
  padding: 0;
}

.fp-toggle:hover,
.fp-close:hover {
  color: #ffffff;
}

.fp-body {
  padding: 8px 10px;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  user-select: text;
  -webkit-user-select: text;
  box-sizing: border-box;
}

/* ── Статус-фильтр ────────────────────────────────────────── */
.status-filter-wrap { padding: 7px 12px; border-bottom: 1px solid #0f3460; flex-shrink: 0; }
.status-filter-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #78909c; font-weight: 600; margin-bottom: 5px; }
.status-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.status-pill { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px; border-radius: 12px; border: 1px solid #263a5a; background: transparent; color: #78909c; font-size: 10px; cursor: pointer; user-select: none; transition: all 0.15s; white-space: nowrap; }
.status-pill:hover { border-color: #4fc3f7; color: #cfd8dc; }
.status-pill.active { background: #1a3a6e; border-color: #1976d2; color: #e3f2fd; }
.status-pill .sp-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
/* ── Панель Артикулов (Шаг 1) ── */
.articles-panel { position: absolute; top: 80px; left: 0; height: calc(100% - 200px); width: 32px; background: rgba(22,33,62,0.95); backdrop-filter: blur(4px); border-right: 1px solid #0f3460; z-index: 900; transition: width 200ms ease; overflow: hidden; display: flex; flex-direction: column; box-shadow: 2px 0 8px rgba(0,0,0,0.3); border-radius: 0 8px 8px 0; }
.articles-panel--expanded { width: 320px; top: 8px !important; height: calc(100% - 80px) !important; }
.ap-collapsed-view { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px; height: auto; padding: 12px 0; cursor: pointer; color: #78909c; }
.articles-panel--expanded .ap-collapsed-view { display: none; }
.ap-vertical-text { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 10px; letter-spacing: 2px; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.ap-arrow { font-size: 10px; }
.ap-expanded-view { display: none; flex-direction: column; height: 100%; width: 320px; padding: 12px; box-sizing: border-box; overflow: hidden; }
.articles-panel--expanded .ap-expanded-view { display: flex; }
.ap-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.ap-title { font-size: 10px; color: #78909c; text-transform: uppercase; font-weight: 600; letter-spacing: 1px; }
.ap-close-btn { color: #78909c; font-size: 10px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.ap-close-btn:hover { color: #4fc3f7; }
.ap-search-wrap { display: flex; align-items: center; background: #0f3460; border: 1px solid #1565c0; border-radius: 4px; padding: 4px 8px; margin-bottom: 8px; gap: 6px; }
.ap-search-icon { color: #546e7a; font-size: 11px; }
.ap-search-input { flex: 1; background: transparent; border: none; color: #cfd8dc; font-size: 11px; outline: none; }
.ap-search-input::placeholder { color: #546e7a; }
.ap-search-clear { color: #546e7a; font-size: 12px; cursor: pointer; }
.ap-search-clear:hover { color: #ff9800; }
.articles-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; max-height: 120px; overflow-y: auto; padding-right: 4px; }
.articles-dropdown { flex: 1; min-height: 0; overflow-y: auto; margin-bottom: 8px; border: 1px solid #0f3460; border-radius: 4px; background: rgba(0,0,0,0.1); }
.ap-btn-row { display: flex; gap: 6px; margin-top: 4px; flex-shrink: 0; }
/* CSS дополнения Шаг 2 и 3 */
.ap-brand-group.collapsed .ap-bg-body { max-height: 0 !important; padding: 0 !important; border: none; }
.ap-brand-group.collapsed .ap-bg-chevron { transform: rotate(-90deg); }
.ap-toast { position: absolute; top: 12px; right: 12px; background: rgba(22,33,62,0.98); border: 1px solid #4fc3f7; color: #fff; padding: 8px 12px; font-size: 11px; border-radius: 6px; z-index: 10000; opacity: 0; transition: opacity 0.3s; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
.ap-toast.show { opacity: 1; }
/* ── Шаг 7: Animations & UI Polish ── */
@keyframes statFade { 0% { opacity: 0; } 100% { opacity: 1; } }
.stat-fade { animation: statFade 0.15s ease-out; }
@keyframes chipEnter { 0% { opacity: 0; transform: translateY(-5px); } 100% { opacity: 1; transform: translateY(0); } }
.chip-item { animation: chipEnter 0.2s ease-out forwards; }
#toolbar, #side-panels-wrap, .leaflet-left { transition: transform 200ms ease !important; }
#main.ap-expanded #toolbar,
#main.ap-expanded #side-panels-wrap,
#main.ap-expanded .leaflet-left { transform: translateX(320px); }


/* === База знаний === */
#kb-panel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11000;
  background: rgba(18,28,52,0.97);
  border: 1px solid #1565c0;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
  display: none;
  flex-direction: column;
  width: 640px;
  max-width: 92vw;
  min-width: 320px;
  min-height: 200px;
  max-height: 82vh;
  resize: both;
  overflow: hidden;
  font-size: 13px;
  color: #cfd8dc;
}
#kb-panel.kb-visible { display: flex; }
#kb-header {
  background: #0d1f3c;
  border-radius: 10px 10px 0 0;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: move;
  border-bottom: 1px solid #1565c0;
  flex-shrink: 0;
  user-select: none;
  gap: 8px;
  position: relative;
  z-index: 1; 
}
#kb-header-title { font-size: 12px; font-weight: 700; color: #fff; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-header-btn { color: #78909c; background: none; border: none; font-size: 14px; line-height: 1; cursor: pointer; padding: 0 4px; transition: color 0.15s; }
.kb-header-btn:hover { color: #4fc3f7; }
#kb-body { overflow-y: auto; flex: 1; padding: 12px 14px; scrollbar-width: thin; scrollbar-color: #0f3460 transparent; cursor: default;}
#kb-body::-webkit-scrollbar { width: 4px; }
#kb-body::-webkit-scrollbar-track { background: transparent; }
#kb-body::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 2px; }
.kb-section { border: 1px solid rgba(255,255,255,0.07); border-radius: 7px; margin-bottom: 8px; overflow: hidden; background: rgba(255,255,255,0.02); }
.kb-section-header { display: flex; align-items: center; padding: 8px 10px; cursor: pointer; user-select: none; gap: 8px; background: rgba(21,101,192,0.12); transition: background 0.15s; }
.kb-section-header:hover { background: rgba(21,101,192,0.22); }
.kb-section-num { font-size: 10px; font-weight: 700; color: #4fc3f7; background: rgba(79,195,247,0.12); border-radius: 4px; padding: 2px 6px; flex-shrink: 0; min-width: 22px; text-align: center; }
.kb-section-title { font-size: 12px; font-weight: 700; color: #e3f2fd; flex: 1; }
.kb-chevron { font-size: 9px; color: #546e7a; transition: transform 0.18s; flex-shrink: 0; }
.kb-section.kb-open .kb-chevron { transform: rotate(90deg); }
.kb-section-body {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  opacity: 0;
  padding: 0;
  min-height: 0;
}
.kb-section-body > * {
  overflow: hidden;
  min-height: 0;
}
.kb-section.kb-open .kb-section-body {
  grid-template-rows: 1fr;
  opacity: 1;
}
.kb-section-body-inner {
  padding: 10px;
}
.kb-section-body p { margin-bottom: 7px; line-height: 1.6; color: #b0bec5; font-size: 12px; }
.kb-section-body strong { color: #e3f2fd; }
.kb-section-body ul, .kb-section-body ol { margin: 6px 0 7px 14px; }
.kb-section-body li { margin-bottom: 3px; color: #b0bec5; font-size: 12px; line-height: 1.55; }
.kb-section-body h4 { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: #78909c; font-weight: 600; margin: 10px 0 5px; }
.kb-section-body code { background: rgba(79,195,247,0.1); color: #80cbc4; border-radius: 3px; padding: 1px 5px; font-family: 'Consolas', monospace; font-size: 10px; }
.kb-section-body blockquote { border-left: 2px solid #1565c0; margin: 7px 0; padding: 4px 10px; color: #90a4ae; background: rgba(21,101,192,0.07); border-radius: 0 4px 4px 0; font-size: 11px; }
.kb-tbl { width: 100%; border-collapse: collapse; font-size: 10px; margin: 7px 0; }
.kb-tbl th { background: rgba(79,195,247,0.12); color: #90a4ae; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; padding: 4px 6px; text-align: left; border-bottom: 1px solid #0f3460; }
.kb-tbl td { padding: 3px 6px; border-bottom: 1px solid rgba(255,255,255,0.04); color: #b0bec5; vertical-align: top; }
.kb-tbl tr:last-child td { border-bottom: none; }
.kb-tbl td:first-child { color: #4fc3f7; font-weight: 600; white-space: nowrap; }
.kb-steps { counter-reset: kb-step; margin: 6px 0; }
.kb-steps li { counter-increment: kb-step; list-style: none; padding-left: 26px; position: relative; margin-bottom: 5px; color: #b0bec5; font-size: 12px; }
.kb-steps li::before { content: counter(kb-step); position: absolute; left: 0; top: 0; background: #1565c0; color: #fff; font-size: 9px; font-weight: 700; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; line-height: 1; }
.kb-badge { display: inline-block; background: rgba(79,195,247,0.12); color: #4fc3f7; border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 700; margin-right: 4px; }
.kb-badge.green { background: rgba(46,125,50,0.2); color: #a5d6a7; }
.kb-badge.orange { background: rgba(230,126,34,0.15); color: #ffcc80; }
#kb-overlay { position: fixed; inset: 0; z-index: 10999; display: none; background: rgba(0,0,0,0.3); }
#kb-overlay.kb-visible { display: block; }

/* ── Loading overlay ─────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: #1a1a2e;
  display: flex; align-items: center; justify-content: center;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── PWA install prompt ──────────────────────────────────────────────────── */
#pwa-install {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: #16213e; border: 1px solid #1565c0; border-radius: 8px;
  padding: 10px 16px; font-size: 12px; color: #cfd8dc;
  display: flex; align-items: center; gap: 10px; z-index: 9990;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
