:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #e6eaf2;
  --accent: #d94848;
  --blue: #376fc6;
  --green: #138a55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

header {
  padding: 28px 32px 12px;
  max-width: 1320px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.25;
}

header p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
  font-size: clamp(14px, 3.5vw, 16px);
}

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 32px 40px;
}

.scope-bar {
  margin: 8px 0 4px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(22, 34, 51, 0.04);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
  align-items: stretch;
}

.grid > .card.metric {
  min-width: 0;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-top: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(22, 34, 51, 0.06);
}

.card + .card,
.two + .card,
.note + .two {
  margin-top: 14px;
}

.metric .k {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  min-height: calc(2.9em + 4px + 1.35em);
}

.metric .k-sub {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
  min-height: 1.35em;
}

.metric .v {
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
  direction: ltr;
  text-align: right;
  flex-shrink: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

label {
  font-size: 14px;
  color: var(--muted);
}

select,
input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  background: #fff;
  font-size: 14px;
  min-height: 40px;
}

select {
  max-width: 100%;
}

input[type="search"] {
  flex: 1;
  min-width: 140px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #172033;
  color: #fff;
  cursor: pointer;
}

.map-card {
  margin-bottom: 16px;
}

.map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.map-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.map-wrap {
  position: relative;
  height: min(52vh, 480px);
  min-height: 280px;
  direction: ltr;
  background: #f0f4fa;
  border-radius: 12px;
  overflow: hidden;
}

#europeMap {
  display: block;
  width: 100%;
  height: 100%;
}

.map-wrap .country {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.map-wrap .country:hover {
  stroke: #172033;
  stroke-width: 1.2;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
  direction: ltr;
}

.map-legend-gradient {
  width: 160px;
  height: 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.map-legend-ticks {
  display: flex;
  justify-content: space-between;
  width: 160px;
  font-size: 11px;
}

.map-legend-hint {
  flex: 1 1 200px;
  text-align: right;
  direction: rtl;
}

.map-error {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.chartbox {
  height: 560px;
  position: relative;
  direction: ltr;
}

.chartbox-side {
  height: 430px;
}

svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: #111827;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  max-width: 260px;
  transform: translate(-50%, -110%);
  display: none;
  z-index: 4;
  direction: ltr;
  text-align: left;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  align-items: center;
  direction: ltr;
  justify-content: flex-start;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  direction: ltr;
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  color: #475467;
  z-index: 1;
  font-weight: 600;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  background: #f1f5f9;
  color: #172033;
}

th.sortable::after {
  content: " ⇅";
  font-size: 10px;
  color: #94a3b8;
  font-weight: 400;
}

th.sortable.sort-asc::after {
  content: " ↑";
  color: #d94848;
}

th.sortable.sort-desc::after {
  content: " ↓";
  color: #d94848;
}

.tablewrap {
  max-height: 520px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  line-height: 1.65;
  font-size: 14px;
}

.note em {
  font-style: normal;
  font-weight: 600;
}

.two {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two {
    grid-template-columns: 1fr;
  }

  .chartbox {
    height: 430px;
  }

  .chartbox-side {
    height: 380px;
  }
}

@media (max-width: 600px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .grid > .card.metric {
    min-height: 0;
  }

  .metric .v {
    font-size: 24px;
  }

  header,
  .wrap {
    padding-left: 16px;
    padding-right: 16px;
  }

  header {
    padding-top: 20px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls label,
  .controls select,
  .controls input {
    width: 100%;
  }

  .check-label {
    width: 100%;
  }

  .chartbox {
    height: 360px;
  }

  .chartbox-side {
    height: 320px;
  }

  .tablewrap {
    max-height: 420px;
  }

  th,
  td {
    font-size: 12px;
    padding: 7px 8px;
  }
}
