:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #1f2328;
  --muted: #667085;
  --line: #d9e0ea;
  --line-strong: #b8c2d2;
  --teal: #0c8b73;
  --coral: #d85a43;
  --indigo: #4b63d9;
  --amber: #b98412;
  --violet: #8757c6;
  --rose: #c74875;
  --cyan: #087f98;
  --olive: #688b32;
  --shadow: 0 18px 45px rgba(31, 35, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(238, 243, 239, 0.88), rgba(245, 247, 250, 0) 360px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(12, 139, 115, 0.16);
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 14px;
  z-index: 10;
  transform: translateY(-64px);
  border-radius: 6px;
  background: var(--ink);
  color: #ffffff;
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 160ms ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid rgba(12, 139, 115, 0.35);
  outline-offset: 2px;
}

.app-header,
.global-filter-shell,
main {
  width: min(1480px, calc(100% - 40px));
  margin-inline: auto;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: calc(32px + env(safe-area-inset-top)) 0 18px;
}

.global-filter-shell {
  margin-bottom: 28px;
}

.global-filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(128px, 148px) minmax(148px, 170px) minmax(148px, 170px) auto;
  align-items: end;
  gap: 12px;
  border: 1px solid rgba(184, 194, 210, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 16px;
  box-shadow: var(--shadow);
}

.global-filter-heading {
  align-self: center;
  min-width: 0;
}

.global-filter-heading .eyebrow {
  margin-bottom: 4px;
}

.global-filter-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

#global-filter-status {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  text-align: right;
}

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

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

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

h1,
h2,
h3 {
  text-wrap: balance;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(22px, 2.5vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.lede,
.section-copy {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  text-wrap: pretty;
}

.control-stack {
  display: flex;
  align-items: end;
  justify-content: end;
  gap: 12px;
}

.control-group {
  min-width: 0;
}

.control-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.controls {
  display: inline-grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 4px;
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.06);
}

.range-controls {
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  min-width: 228px;
}

.dimension-controls {
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  min-width: 128px;
}

.range-button,
.dimension-button,
.legend-button {
  cursor: pointer;
  border-radius: 6px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.range-button,
.dimension-button {
  min-height: 40px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.range-button:hover,
.dimension-button:hover {
  background: #f2f5f7;
  color: var(--ink);
}

.range-button:focus-visible,
.dimension-button:focus-visible,
.legend-button:focus-visible {
  outline: 3px solid rgba(12, 139, 115, 0.28);
  outline-offset: 2px;
}

.range-button[aria-pressed="true"],
.dimension-button[aria-pressed="true"] {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(31, 35, 40, 0.16);
}

.summary-band,
.trend-overview,
.weekly-table-section,
.methodology-section,
.metric-section {
  margin: 18px 0 24px;
}

.section-heading {
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-card,
.chart-card {
  border: 1px solid rgba(184, 194, 210, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 132px;
  padding: 18px;
}

.summary-card .label-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.summary-card .label {
  min-width: 0;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.summary-card .region-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--teal);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 850;
}

.summary-card .value {
  margin-bottom: 10px;
  font-size: clamp(24px, 2.8vw, 38px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.summary-card .delta,
.trend-badge {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.summary-analysis {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.summary-analysis p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-wrap: pretty;
}

.summary-analysis .summary-analysis-title {
  color: var(--ink);
  font-weight: 850;
}

.delta.is-up,
.trend-badge.is-up {
  color: var(--teal);
}

.delta.is-down,
.trend-badge.is-down {
  color: var(--coral);
}

.weekly-table-card {
  overflow: hidden;
  border: 1px solid rgba(184, 194, 210, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.weekly-filter-bar,
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 14px;
}

.table-toolbar .filter-count {
  align-self: end;
}

.table-count-bar {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  padding: 11px 14px;
  text-align: right;
  font-size: 12px;
  font-weight: 750;
}

.trend-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  border: 1px solid rgba(184, 194, 210, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(31, 35, 40, 0.06);
}

.trend-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 4px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef2f5;
  padding: 4px;
}

.trend-tab-button {
  min-height: 38px;
  cursor: pointer;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.trend-tab-button:hover {
  color: var(--ink);
}

.trend-tab-button[aria-selected="true"] {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(31, 35, 40, 0.12);
}

.trend-tab-button:focus-visible {
  outline: 3px solid rgba(12, 139, 115, 0.28);
  outline-offset: 2px;
}

.filter-field {
  display: grid;
  min-width: 148px;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-field select,
.filter-field input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
}

.filter-field select:focus-visible,
.filter-field input:focus-visible,
.filter-clear-button:focus-visible {
  outline: 3px solid rgba(12, 139, 115, 0.28);
  outline-offset: 2px;
}

.filter-clear-button {
  min-height: 38px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fb;
  color: var(--ink);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 800;
}

.filter-clear-button:hover {
  border-color: var(--line-strong);
  background: #eef3ef;
}

.filter-count {
  margin: 0 0 8px auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.weekly-table-wrap {
  overflow: auto;
  max-height: 620px;
}

.weekly-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  line-height: 1.35;
}

.weekly-table th,
.weekly-table td {
  min-width: 112px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 9px 10px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.weekly-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7faf8;
  color: var(--ink);
  font-weight: 850;
}

.weekly-table thead tr:first-child th {
  top: 0;
}

.weekly-table thead tr:nth-child(2) th {
  top: 38px;
}

.weekly-table .table-group {
  border-bottom-color: var(--line-strong);
  color: var(--teal);
  text-align: center;
}

.weekly-table .text-cell {
  text-align: left;
}

.weekly-table .sticky-col {
  position: sticky;
  z-index: 3;
  background: #ffffff;
}

.weekly-table th.sticky-col {
  z-index: 5;
  background: #f7faf8;
}

.weekly-table .week-col {
  left: 0;
  min-width: 72px;
  width: 72px;
}

.weekly-table .date-col {
  left: 72px;
  min-width: 112px;
  width: 112px;
}

.weekly-table .region-col {
  left: 184px;
  min-width: 82px;
  width: 82px;
  border-right-color: var(--line-strong);
}

.weekly-table tbody tr:hover td {
  background: #f8fbfa;
}

.weekly-table tbody tr:hover .sticky-col {
  background: #f8fbfa;
}

.weekly-table .empty-value {
  color: var(--muted);
}

.weekly-table .empty-row {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

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

.methodology-card {
  overflow: hidden;
  border: 1px solid rgba(184, 194, 210, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.methodology-summary {
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
  list-style: none;
}

.methodology-summary::-webkit-details-marker {
  display: none;
}

.methodology-summary::before {
  content: "+";
  display: inline-grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--teal);
  font-weight: 900;
}

.methodology-card[open] .methodology-summary::before {
  content: "-";
}

.methodology-summary:focus-visible {
  outline: 3px solid rgba(12, 139, 115, 0.28);
  outline-offset: -3px;
}

.methodology-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.methodology-note {
  margin: 0;
  border-top: 1px solid var(--line);
  background: #f8fbfa;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.55;
}

.methodology-list {
  display: grid;
  gap: 0;
}

.methodology-item {
  display: grid;
  grid-template-columns: minmax(160px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 13px 16px;
}

.methodology-item h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.methodology-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.chart-sections {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.metric-section {
  padding-top: 4px;
}

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

.region-grid.single-region-grid {
  grid-template-columns: minmax(0, 1fr);
}

.chart-card {
  min-width: 0;
  padding: 18px;
}

.chart-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  min-height: 52px;
}

.region-label {
  margin-bottom: 6px;
}

.trend-badge {
  border-radius: 999px;
  background: #f1f4f8;
  padding: 7px 10px;
  white-space: nowrap;
}

.legend-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.legend-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-action {
  min-height: 32px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 750;
}

.legend-action:hover {
  border-color: var(--line-strong);
  background: #f7f9fb;
}

.legend-action:focus-visible {
  outline: 3px solid rgba(12, 139, 115, 0.28);
  outline-offset: 2px;
}

.legend {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.legend-group {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.legend-category {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.legend-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.legend-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 750;
}

.legend-button:hover {
  border-color: var(--line-strong);
  background: #f7f9fb;
}

.legend-button[aria-pressed="false"] {
  color: var(--muted);
  opacity: 0.55;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--swatch);
}

.legend-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-shell {
  position: relative;
  width: 100%;
  height: 310px;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(245, 247, 250, 0.8), rgba(255, 255, 255, 0.95)),
    #ffffff;
}

.chart-shell svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.grid-line {
  stroke: #e5ebf1;
  stroke-width: 1;
}

.axis-line {
  stroke: var(--line-strong);
  stroke-width: 1.2;
}

.series-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-line.is-primary {
  stroke-width: 3.4;
}

.hover-line {
  stroke: rgba(31, 35, 40, 0.32);
  stroke-width: 1;
  stroke-dasharray: 4 5;
}

.hover-point {
  fill: #ffffff;
  stroke: currentColor;
  stroke-width: 2.2;
}

.tooltip {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: min(310px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(31, 35, 40, 0.12);
  padding: 12px;
  pointer-events: none;
}

.tooltip-date {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.tooltip-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
}

.tooltip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tooltip-value {
  color: var(--ink);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.min-w-0 {
  min-width: 0;
}

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

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

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

@media (max-width: 760px) {
  .app-header,
  .global-filter-shell,
  main {
    width: min(100% - 24px, 1480px);
  }

  .app-header {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding-top: calc(24px + env(safe-area-inset-top));
  }

  .control-stack {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .controls {
    width: 100%;
    min-width: 0;
  }

  .weekly-filter-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .global-filter-bar,
  .table-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  #global-filter-status {
    grid-column: auto;
    text-align: left;
  }

  .trend-filter-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-field,
  .filter-count,
  .filter-clear-button {
    width: 100%;
    min-width: 0;
  }

  .legend-toolbar {
    align-items: stretch;
  }

  .legend-actions {
    width: 100%;
  }

  .legend-action {
    flex: 1 1 120px;
  }

  .legend-group {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .legend-category {
    margin-top: 0;
  }

  .filter-count {
    margin: 0;
  }

  .trend-tabs {
    display: grid;
    width: 100%;
  }

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

  .methodology-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .chart-card {
    padding: 14px;
  }

  .chart-card-header {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .trend-badge {
    justify-self: start;
  }

  .chart-shell {
    height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .skip-link,
  .range-button,
  .dimension-button,
  .trend-tab-button,
  .filter-clear-button,
  .legend-button {
    transition-duration: 0.01ms;
  }
}
