:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --paper: #ffffff;
  --wash: #f4f7fb;
  --navy: #243447;
  --teal: #0f766e;
  --red: #a33d3d;
  --gold: #b7791f;
  --green: #2f855a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px 32px;
  color: #fff;
  background: var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  min-height: auto;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand:hover {
  background: transparent;
  border-color: transparent;
}

.brand span {
  color: #c9d3df;
  font-size: 13px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--red), var(--teal));
  border-radius: 7px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-switch button {
  min-height: 34px;
  padding: 6px 10px;
  color: #edf2f7;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.lang-switch button.active {
  color: var(--navy);
  background: #ffffff;
}

.tabs a,
button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}

.tabs a {
  color: #edf2f7;
}

.tabs a:hover,
button:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 32px;
  align-items: end;
  padding: 10px 0 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 860px;
  margin-bottom: 12px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.lede {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric,
.chart-box,
.detail-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 92px;
  padding: 14px;
}

.metric b {
  display: block;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.filters {
  position: sticky;
  top: var(--header-height, 72px);
  z-index: 900;
  display: grid;
  grid-template-columns: 120px 82px 82px repeat(4, minmax(120px, 1fr)) minmax(170px, 1.3fr) 78px;
  gap: 10px;
  align-items: end;
  padding: 14px;
  background: rgba(244, 247, 251, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.filter-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-group input,
.filter-group select {
  width: 100%;
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
}

.filter-actions button,
#downloadCsv,
.pager button {
  width: 100%;
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.workspace {
  margin-top: 22px;
  padding: 24px 0 0;
  scroll-margin-top: var(--section-offset, 190px);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section-head > p {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}

.map-period-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.map-date { display: grid; gap: 4px; }
.map-date > span { color: var(--muted); font-size: 13px; }
.map-date > strong { font-size: 22px; }
.map-periods { display: flex; padding: 0; margin: 0; list-style: none; }
.map-periods li { display: grid; gap: 3px; padding: 8px 22px; border-bottom: 3px solid var(--line); color: var(--muted); }
.map-periods li.active { border-color: var(--teal); color: var(--teal); }
.map-periods strong { font-size: 17px; }
.map-periods span { font-size: 12px; }
.map-surface { position: relative; min-width: 0; }
.map-surface #map { height: 610px; background: #dcecef; }
.map-load-status { position: absolute; inset: 0; z-index: 500; display: grid; place-content: center; gap: 14px; background: #edf3f5; border: 1px solid var(--line); border-radius: 8px; }
.map-load-status[hidden] { display: none; }
.map-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.map-footer p { margin: 0; }
.map-legend { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.map-legend span:first-child { margin-right: 8px; }
.map-legend i { width: 17px; height: 12px; background: #e3c9c8; }
.map-legend i:nth-of-type(2) { background: #cb9c9c; }
.map-legend i:nth-of-type(3) { background: #b77676; }
.map-legend i:nth-of-type(4) { background: #a33d3d; }
.map-source { font-size: 12px; line-height: 1.7; color: var(--muted); margin-top: 14px; }
.map-source a { color: var(--teal); }
.map-unmapped { margin-top: 14px; font-size: 13px; color: var(--muted); }
.map-unmapped summary { cursor: pointer; }
.map-unmapped ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 24px; padding: 12px 0; list-style: none; }
.map-unmapped li { display: flex; justify-content: space-between; gap: 10px; }
.map-identity-note { border-left: 2px solid var(--teal); padding-left: 10px; font-size: 13px; }

@media (max-width: 680px) {
  .map-period-bar { align-items: stretch; flex-direction: column; gap: 14px; }
  .map-periods { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .map-periods li { padding: 8px 4px; }
  .map-periods span { font-size: 10px; }
  .map-surface #map { height: 360px; min-height: 360px; }
  .map-layout .detail-panel { min-height: 180px; }
}

#map {
  min-height: 610px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dde6ef;
  overflow: hidden;
  contain: paint;
}

.detail-panel {
  min-height: 610px;
  padding: 18px;
  overflow: auto;
}

.detail-panel p,
.detail-panel li {
  color: var(--muted);
  line-height: 1.45;
}

.detail-panel h4 {
  margin: 22px 0 2px;
  color: var(--muted);
  font-size: 16px;
}

.detail-panel ul {
  margin: 2px 0 0;
  padding-left: 18px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-box {
  padding: 16px;
  min-height: 340px;
}

.chart-box canvas {
  display: block;
  width: 100%;
  height: 280px;
  max-height: 280px;
}

.chart-wide {
  grid-column: 1 / -1;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.timeline-title-row {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 100%;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.timeline-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.timeline-controls select {
  min-width: 92px;
  height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
}

.timeline-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.timeline-date {
  color: var(--red);
  font-weight: 800;
}

.timeline-item p {
  margin-bottom: 4px;
}

.timeline-item small {
  color: var(--muted);
}

.table-wrap {
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  contain: inline-size;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.source-cell {
  max-width: 300px;
  color: var(--muted);
}

.about-section {
  padding-bottom: 20px;
}

.about-content {
  width: 100%;
  max-width: none;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.about-content h3 {
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1.2;
}

.about-content h1 {
  font-size: 32px;
  line-height: 1.15;
}

.about-content h2 {
  margin-top: 20px;
  margin-bottom: 8px;
  font-size: 20px;
}

.about-content h4 {
  margin: 24px 0 8px;
  font-size: 16px;
}

.about-content p {
  color: var(--muted);
  line-height: 1.65;
}

.about-content table {
  width: 100%;
  min-width: 0;
}

.about-content th,
.about-content td {
  font-size: 14px;
}

[data-lang-block] {
  display: none;
}

[data-lang-block].active {
  display: block;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}

.pager > div {
  display: flex;
  gap: 8px;
}

.pager button {
  width: auto;
}

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

@media (max-width: 1100px) {
  .hero,
  .map-layout,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    scroll-margin-top: var(--section-offset, 24px);
  }

  .detail-panel,
  #map {
    min-height: 440px;
  }
}

@media (max-width: 680px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .tabs {
    width: 100%;
    justify-content: flex-start;
  }

  .lang-switch {
    width: 100%;
  }

  main {
    padding: 18px 16px 36px;
  }

  .hero {
    gap: 18px;
  }

  h1 {
    font-size: 36px;
  }

  h2 {
    font-size: 22px;
  }

  .metrics,
  .filters,
  .timeline {
    grid-template-columns: 1fr;
  }

  .section-head,
  .pager {
    align-items: flex-start;
    flex-direction: column;
  }

  .timeline-title-row {
    gap: 8px;
    flex-wrap: nowrap;
  }

  .timeline-controls {
    gap: 8px;
  }

  .timeline-controls label span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .timeline-controls select {
    min-width: 66px;
    width: 66px;
    padding: 6px;
  }

  .timeline-controls label:last-child select {
    min-width: 86px;
    width: 86px;
  }

  #map {
    min-height: 360px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    padding: 10px 0;
    border-bottom: 1px solid #edf0f5;
  }

  td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 7px 12px;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .source-cell {
    max-width: none;
  }

  .about-content table {
    display: table;
  }

  .about-content thead {
    display: table-header-group;
  }

  .about-content tbody {
    display: table-row-group;
  }

  .about-content tr {
    display: table-row;
    padding: 0;
  }

  .about-content th,
  .about-content td {
    display: table-cell;
    width: auto;
  }

  .about-content td::before {
    content: none;
  }
}
