:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --panel: #ffffff;
  --ink: #161922;
  --muted: #677086;
  --line: #e5dfd6;
  --red: #9c1730;
  --red-soft: #f4e2e6;
  --blue: #2563eb;
  --blue-soft: #e4ecff;
  --green: #0f9f7a;
  --green-soft: #dcf5ed;
  --gold: #b78219;
  --gold-soft: #f7ecd1;
  --shadow: 0 18px 45px rgba(38, 31, 21, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 290px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1460px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 38px 0 28px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 4px 26px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.05;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
}

.header-actions,
.filter-row,
.chip-group,
.segmented,
.view-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.plain-button,
.chip,
.segmented button,
.view-tabs button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 9px 14px;
  font-weight: 700;
}

.primary-button {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.ghost-button,
.plain-button {
  color: var(--muted);
}

.chip.active,
.segmented button.active,
.view-tabs button.active {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

.filters,
.table-section,
.charts article,
.insight-band {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  padding: 20px 24px 22px;
}

.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-toolbar h2 {
  margin: 0;
  font-size: 18px;
}

.filter-grid {
  display: grid;
  gap: 14px;
}

.primary-filter-grid {
  grid-template-columns: minmax(260px, 1.25fr) repeat(2, minmax(150px, 0.5fr));
}

.secondary-filter-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  margin-top: 16px;
}

label span,
.filter-label {
  display: block;
  margin-bottom: 8px;
  color: #51596c;
  font-size: 13px;
  font-weight: 800;
}

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

input:focus,
select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--blue);
}

.filter-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: start;
  margin-top: 14px;
}

.filter-label {
  width: auto;
  margin-bottom: 0;
  padding-top: 10px;
}

.chip {
  color: #4f586d;
}

.advanced-filters {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.advanced-filters summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  color: #333b4d;
  font-weight: 900;
}

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

.advanced-filters summary::after {
  content: "+";
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--red);
  background: #fff;
}

.advanced-filters[open] summary::after {
  content: "-";
}

.advanced-filters summary small {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-top: 20px;
}

.metric-card {
  min-height: 128px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 15px 34px rgba(36, 31, 22, 0.08);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 12px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 44px;
  line-height: 1;
}

.accent-blue {
  border-left-color: var(--blue);
}

.accent-green {
  border-left-color: var(--green);
}

.accent-gold {
  border-left-color: var(--gold);
}

.insight-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 22px;
  margin-top: 20px;
  padding: 22px 24px;
}

.insight-band h2,
.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

#answerText {
  margin: 10px 0 0;
  color: #363d4d;
  font-size: 16px;
  line-height: 1.7;
}

.mini-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.split-card {
  padding: 14px;
  border-radius: 8px;
  background: #f8f7f4;
  border: 1px solid var(--line);
}

.split-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 18px;
  margin-top: 20px;
}

.charts article {
  padding: 22px 24px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-heading span,
#tableMeta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px minmax(120px, 1fr) 90px;
  align-items: center;
  gap: 12px;
}

.bar-label {
  color: #333b4d;
  font-weight: 800;
}

.bar-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe7df;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.compact .bar-fill {
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.bar-value {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.view-tabs {
  margin-top: 22px;
}

.view-tabs button {
  min-width: 112px;
}

.table-section {
  margin-top: 14px;
  padding: 22px 24px 24px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #ede8e0;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.45;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #faf8f4;
  color: #4c566b;
  font-weight: 900;
}

tbody tr:hover {
  background: #fbfaf6;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0 4px 4px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #1749b4;
  font-weight: 800;
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

.tag.green {
  background: var(--green-soft);
  color: #08745b;
}

.tag.gold {
  background: var(--gold-soft);
  color: #815b0c;
}

.muted {
  color: var(--muted);
}

footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 1080px) {
  .primary-filter-grid,
  .secondary-filter-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-grid,
  .charts,
  .insight-band {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 24px, 1460px);
    padding-top: 22px;
  }

  .masthead,
  .filter-toolbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-filter-grid,
  .secondary-filter-grid,
  .summary-grid,
  .charts,
  .insight-band,
  .mini-split {
    grid-template-columns: 1fr;
  }

  .filter-label {
    width: 100%;
    padding-top: 0;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 56px minmax(100px, 1fr) 70px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .filters,
  .view-tabs,
  .header-actions {
    display: none;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .table-wrap {
    overflow: visible;
  }
}
