:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #1e2726;
  --muted: #66736f;
  --line: #d9e2df;
  --teal: #0f766e;
  --blue: #24495a;
  --warm: #cf7f3a;
  --shadow: 0 14px 34px rgba(34, 54, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  padding: 24px 18px;
  overflow-y: auto;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand-logo {
  display: block;
  width: min(210px, 80%);
  margin: 0 auto 24px;
}

.tab-list {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.tab-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}

.tab-button[hidden],
.panel[hidden] {
  display: none !important;
}

.tab-button:hover {
  border-color: var(--teal);
}

.tab-button.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.control-group {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.control-group[hidden],
.toggle-row[hidden] {
  display: none;
}

.control-group label,
.toggle-row {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin-bottom: 20px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.download-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  background: var(--warm);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

.download-link:hover {
  color: #ffffff;
  filter: brightness(0.95);
}

.workspace {
  margin-left: 280px;
  min-height: 100vh;
  padding: 24px 28px 40px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.2;
}

.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.scorecard-shell {
  min-height: 320px;
}

.scorecard-shell .ui.cards {
  align-items: stretch;
}

.scorecard-shell .ui.card,
.scorecard-shell .ui.cards > .card {
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scorecard-shell .smallheader {
  overflow-wrap: anywhere;
}

.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#linePanel.chart-panel {
  background: #f5f3ee;
  border-color: #d8d4cb;
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(48, 44, 36, 0.09);
}

.chart {
  width: 100%;
  min-height: 620px;
}

.chart-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #dce5e2;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.chart-note span {
  white-space: nowrap;
}

.chart-note strong {
  color: var(--ink);
  font-weight: 800;
}

#scatterPanel .chart-note {
  justify-content: center;
  min-height: 24px;
  padding: 2px 18px 0;
  border: 0;
  background: transparent;
  color: #77746c;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

#scatterPanel.chart-panel {
  background: #f5f3ee;
  border-color: #d8d4cb;
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(48, 44, 36, 0.09);
}

#scatterChart {
  position: relative;
  isolation: isolate;
  background: #f5f3ee;
}

.scatter-transition-snapshot {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: block;
  pointer-events: auto;
  will-change: opacity;
}

.scatter-chart-heading {
  margin: 0;
  padding: 16px 18px 0;
  color: #1c1c1a;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.scatter-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 18px;
  min-height: 42px;
  padding: 8px 18px 6px;
}

.scatter-legend-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--legend-text-color);
  padding: 3px 0;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 240ms ease;
}

.scatter-legend-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 0.8px solid #55534f;
  border-radius: 50%;
  background: var(--legend-color);
  transform: scale(1);
  transition: background-color 240ms ease, border-color 240ms ease, transform 240ms ease;
}

.scatter-legend-button[aria-pressed="false"] {
  color: #8c8981;
}

.scatter-legend-button[aria-pressed="false"] .scatter-legend-dot {
  border-color: #8c8981;
  background: #8c8981;
  transform: scale(0.68);
}

.scatter-legend-button[aria-busy="true"] {
  cursor: progress;
}

.scatter-legend-button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 4px;
  border-radius: 2px;
}

#lineChart {
  position: relative;
  min-height: 460px;
}

.daily-trend-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 30;
  min-width: 112px;
  padding: 9px 11px;
  border: 1px solid #1c1c1a;
  border-radius: 4px;
  background: rgba(245, 243, 238, 0.97);
  box-shadow: 0 10px 28px rgba(28, 28, 26, 0.14);
  color: #1c1c1a;
  font-size: 11px;
  line-height: 18px;
  pointer-events: none;
  will-change: transform;
}

.daily-trend-tooltip[hidden] {
  display: none;
}

.daily-trend-tooltip-date {
  margin-bottom: 3px;
  font-weight: 700;
}

.daily-trend-tooltip-row {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  column-gap: 9px;
}

.daily-trend-tooltip-row > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.daily-trend-tooltip-marker {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
}

.daily-trend-draw-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}

.daily-trend-draw-segment {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  transition: clip-path 1100ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: clip-path;
}

.daily-trend-draw-front {
  z-index: 2;
  overflow: visible;
  transition: none;
  will-change: auto;
}

.daily-trend-draw-segment svg {
  display: block;
  overflow: visible;
}

.map-panel {
  background: #f5f3ee;
  border-color: #d8d4cb;
  border-radius: 20px;
  box-shadow: 0 22px 54px rgba(48, 44, 36, 0.11);
}

.map-editorial-header {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: end;
  gap: 32px;
  padding: 26px 32px 10px;
}

.map-title-block {
  min-width: 0;
}

.map-kicker {
  margin: 0 0 6px;
  color: #0f766e;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.map-editorial-header h2 {
  margin: 0;
  color: #1c1c1a;
  font-size: 1.72rem;
  font-weight: 720;
  line-height: 1.18;
}

.map-summary-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(108px, auto));
  margin: 0;
}

.map-summary-list > div {
  min-width: 0;
  padding: 0 18px;
  border-left: 1px solid #d4d0c7;
}

.map-summary-list > div:last-child {
  padding-right: 0;
}

.map-summary-list dt {
  margin: 0;
  color: #8c8981;
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-summary-list dd {
  margin: 5px 0 0;
  color: #2e2d29;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.map-note {
  margin: 7px 0 0;
  color: #8c8981;
  font-size: 0.72rem;
  font-weight: 550;
  line-height: 1.4;
}

.map-chart {
  position: relative;
  width: calc(100% - 36px);
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
}

.map-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.map-chart svg.is-dragging {
  cursor: grabbing;
}

.map-sphere {
  fill: #e9ece7;
  stroke: #cac7be;
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}

.map-country {
  stroke: #f5f3ee;
  stroke-width: 0.72;
  vector-effect: non-scaling-stroke;
}

.map-country.is-hovered {
  stroke: #1c1c1a;
  stroke-width: 1.45;
}

.map-country-marker {
  stroke: #f5f3ee;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.map-country-marker.is-hovered {
  stroke: #1c1c1a;
  stroke-width: 1.8;
}

.map-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 154px;
  padding: 9px 11px;
  border: 1px solid #393833;
  border-radius: 4px;
  background: rgba(245, 243, 238, 0.98);
  box-shadow: 0 12px 30px rgba(28, 28, 26, 0.16);
  color: #1c1c1a;
  font-size: 0.72rem;
  line-height: 1.32;
  pointer-events: none;
}

.map-tooltip-country {
  font-size: 0.82rem;
  font-weight: 760;
}

.map-tooltip-date {
  margin-top: 1px;
  color: #77746c;
}

.map-tooltip-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid #d8d4cb;
}

.map-tooltip-row strong {
  font-weight: 760;
  white-space: nowrap;
}

.map-scale {
  display: grid;
  grid-template-columns: auto minmax(210px, 440px) auto;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 0 auto;
  color: #77746c;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.map-scale-ramp {
  display: block;
  width: 100%;
  height: 10px;
  border: 1px solid rgba(57, 56, 51, 0.2);
  background: linear-gradient(
    90deg,
    #3158a5 0%,
    #2f7fc1 10%,
    #2da5bb 20%,
    #5dbc91 30%,
    #9dce68 40%,
    #d6d957 50%,
    #f1c54c 60%,
    #f2a543 70%,
    #ec733c 80%,
    #dc4537 90%,
    #b92732 100%
  );
}

.map-timeline {
  width: min(980px, calc(100% - 64px));
  margin: 14px auto 0;
  padding: 12px 0 19px;
  border-top: 1px solid rgba(178, 172, 160, 0.5);
}

.map-timeline-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
  color: #77746c;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-timeline-heading output {
  color: #1c1c1a;
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}

.map-date-control {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 12px;
  color: #8c8981;
  font-size: 0.66rem;
  font-weight: 600;
}

.map-date-control input {
  --map-progress: 100%;
  width: 100%;
  height: 3px;
  margin: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  appearance: none;
  background: linear-gradient(
    to right,
    #285763 0,
    #285763 var(--map-progress),
    #d4d0c7 var(--map-progress),
    #d4d0c7 100%
  );
  cursor: pointer;
}

.map-date-control input::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid #f5f3ee;
  border-radius: 50%;
  appearance: none;
  background: #285763;
  box-shadow: 0 0 0 1px #285763;
}

.map-date-control input::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid #f5f3ee;
  border-radius: 50%;
  background: #285763;
  box-shadow: 0 0 0 1px #285763;
}

.error-box {
  padding: 20px;
  border: 1px solid #e5b9a9;
  border-radius: 8px;
  background: #fff4ef;
  color: #763d2b;
  font-weight: 700;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    margin-left: 0;
    padding: 20px 14px 32px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-text {
    text-align: left;
  }

  .map-editorial-header {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 18px 14px 8px;
    text-align: center;
  }

  .map-editorial-header h2 {
    font-size: 1.34rem;
  }

  .map-summary-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid #d4d0c7;
    padding-top: 12px;
  }

  .map-summary-list > div {
    padding: 0 8px;
  }

  .map-summary-list > div:first-child {
    border-left: 0;
  }

  .map-summary-list > div:last-child {
    padding-right: 8px;
  }

  .map-summary-list dd {
    font-size: 0.76rem;
  }

  .map-chart {
    width: calc(100% - 16px);
  }

  .map-scale {
    grid-template-columns: auto minmax(120px, 1fr) auto;
    width: calc(100% - 28px);
    gap: 7px;
    font-size: 0.6rem;
  }

  .map-scale-ramp {
    height: 9px;
  }

  .map-timeline {
    width: calc(100% - 28px);
    margin-top: 11px;
    padding-bottom: 15px;
  }

  .map-date-control {
    gap: 7px;
    font-size: 0.6rem;
  }

  .chart-note span {
    white-space: normal;
  }
}
