:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #eef1f4;
}
* { box-sizing: border-box; }
html, body, #app, #map { width: 100%; height: 100%; margin: 0; }
#map { position: absolute; inset: 0; background: #e9edf0; }

.panel {
  position: absolute;
  z-index: 1000;
  left: 35px;
  top: 12px;
  width: min(473px, calc(100vw - 36px));
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  box-shadow: 0 10px 35px rgba(0,0,0,.16);
  backdrop-filter: blur(8px);
}
.panel-title {
  display:flex; justify-content:space-between; align-items:flex-start;
  padding: 15px 16px 10px; border-bottom:1px solid #e6e8eb;
}
h1 { font-size: 20px; margin:0 0 2px; }
#yearLabel { display: none; }
.controls { padding: 12px 16px 16px; }
.control-row, .tables { display:flex; gap:8px; margin-bottom:10px; }
button {
  border:1px solid #ccd2d8; background:#fff; color:#26313b;
  border-radius:8px; padding:8px 11px; cursor:pointer; font-size:13px;
}
button:hover { background:#f2f5f7; }
button.primary { background:#1e6fe8; color:#fff; border-color:#1e6fe8; }
.icon-btn { border:0; background:transparent; font-size:20px; padding:2px 6px; }
.years { display:grid; grid-template-columns: repeat(7,1fr); gap:5px; margin: 10px 0; }
.years button { padding:6px 3px; font-size:12px; }
.years button.active { background:#26313b; color:#fff; border-color:#26313b; }
.range-wrap { display:grid; grid-template-columns:auto 1fr; gap:10px; align-items:center; margin: 12px 0; }
input[type=range] { width:100%; }
.legend { border-top:1px solid #e6e8eb; padding-top:10px; font-size:12px; color:#59636d; }
.legend > div { display:flex; align-items:center; gap:8px; margin:5px 0; }
.line { display:inline-block; width:32px; border-top:2px solid #e4572e; }
.line.thick { border-top-width:8px; }
.hint { line-height:1.35; margin-top:8px; }
.tables button { flex:1; }
.table-panel { border-top:1px solid #e6e8eb; padding-top:10px; margin-top:8px; }
.table-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.table-scroll { max-height:320px; overflow:auto; border:1px solid #e1e4e8; border-radius:8px; }
table { width:100%; border-collapse:collapse; font-size:12px; background:#fff; }
th, td { padding:7px 8px; border-bottom:1px solid #edf0f2; text-align:left; white-space:nowrap; }
th { position:sticky; top:0; background:#f7f8f9; z-index:1; }
.status { color:#68737e; font-size:12px; margin-top:10px; line-height:1.4; }
.hidden { display:none; }

.leaflet-control-attribution { font-size:10px; }
@media (max-width: 600px) {
  .panel { left:8px; top:8px; width:calc(100vw - 16px); }
}

.region-popup { font-size: 14px; line-height: 1.45; font-weight: 600; min-width: 120px; }


/* Version 3 UI */
.actions, .table-tabs, .chart-tabs { display:flex; gap:8px; margin:8px 0; }
.actions button, .table-tabs button, .chart-tabs button { flex:1; }
.tables-panel, .charts-panel { margin-top:8px; }
.charts-panel { padding-bottom:16px; }
.section-title { font-weight:700; margin:8px 0; }
.chart-wrap { height:280px; position:relative; }
.region-popup { font-weight:600; }

.total-row td { font-weight: 700; border-top: 2px solid #333; }


/* v11 menu and map mode */
.panel.collapsed {
  width: auto;
  min-width: 0;
  overflow: visible;
}
.panel.collapsed .panel-title {
  border-bottom: 0;
  padding-bottom: 12px;
}
.panel.collapsed .controls {
  display: none;
}
.control-section {
  border-bottom: 1px solid #e6e8eb;
  padding-bottom: 9px;
  margin-bottom: 10px;
}
.control-title {
  font-size: 12px;
  font-weight: 700;
  color: #5f6973;
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.actions button, .map-tabs button {
  flex: 1;
}
.map-legend {
  margin-top: 10px;
  border-top: 1px solid #e6e8eb;
  padding-top: 10px;
  font-size: 12px;
}
.map-legend-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.map-legend-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 7px;
  margin: 5px 0;
}
.map-legend-swatch {
  width: 18px;
  height: 12px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 2px;
}
.flow-disabled .leaflet-overlay-pane {
  /* Actual visibility is controlled by the Leaflet layer below. */
}

.year-navigation{display:flex;align-items:center;gap:6px}.year-navigation .years{flex:1}
.year-arrow{min-width:32px;height:30px;padding:0 8px;font-size:18px;line-height:1}
.year-info,.chart-total{margin-top:8px;padding-top:7px;border-top:1px solid #e6e8eb;font-size:12.5px;font-weight:600;color:#4e5964}
.chart-total{margin-bottom:20px;}

#animationBtn{min-width:150px;}

.chart-legend .legend-marker,.chart-legend .legend-color,.chart-legend .legend-swatch,
.legend-marker,.legend-color {
  width:10px!important;height:10px!important;min-width:10px!important;min-height:10px!important;
  border-radius:0!important;
}

.chart-wrap {
  display:flex;
  flex-direction:column;
  align-items:stretch;
}
.chart-wrap canvas {
  order:1;
}
.chart-wrap .chart-total {
  order:2;
}
.chart-wrap .chart-legend,
.chart-wrap .legend,
.chart-wrap .pie-legend {
  order:3;
  width:100%;
  margin-top:10px;
}

.chart-wrap .chartLegend{order:3;width:100%;margin-top:10px;}

.chart-wrap .legend{order:3;width:100%;margin-top:10px;}

/* Заголовок панели: флаги слева/справа от названия */
.panel-heading-row { display:flex; align-items:center; gap:8px; }
.panel-heading-row h1 { margin:0; }
.flag {
  display:inline-block; flex:none;
  width:31px; height:21px;
  border:1px solid rgba(0,0,0,.18); border-radius:2px;
}
/* Флаг России: бело-сине-красный */
.flag-ru {
  background: linear-gradient(to bottom,
    #ffffff 0 33.34%,
    #0039a6 33.34% 66.67%,
    #d52b1e 66.67% 100%);
}
/* Флаг Российской империи: чёрно-жёлто-белый */
.flag-empire {
  background: linear-gradient(to bottom,
    #000000 0 33.34%,
    #ffd700 33.34% 66.67%,
    #ffffff 66.67% 100%);
}

/* Подпись автора справа внизу */
.author-badge {
  position: absolute;
  z-index: 1000;
  right: 60px;
  bottom: 3px;
  padding: 6px 11px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  font-size: 12px;
  color: #26313b;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0,0,0,.14);
}
.author-badge:hover { text-decoration: underline; }

/* Кнопка донатов — над подписью автора, справа внизу */
.donate-badge {
  position: absolute;
  z-index: 1000;
  left: 20px;
  bottom: 3px;
  padding: 6px 11px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  font-size: 12px;
  color: #26313b;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.14);
}
.donate-badge:hover { background: #f2f5f7; }
.donate-badge.copied { color: #1e6fe8; border-color: #1e6fe8; }
