:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-soft: #f4f5f7;
  --surface-muted: #eef1f4;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2429;
  --muted: #6b7280;
  --brand: #e33f32;
  --brand-soft: #fff2f0;
  --blue-soft: #eff6ff;
  --green-soft: #eefbf3;
  --amber-soft: #fff7ed;
  --danger-soft: #fff5f5;
  --green: #23794b;
  --blue: #2563eb;
  --amber: #c67d00;
  --shadow: 0 20px 40px rgba(17, 24, 39, 0.04);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font: "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(227, 63, 50, 0.08), transparent 28%),
    linear-gradient(180deg, #fbfbfc 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 18px 0;
  backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(229, 231, 235, 0.95);
}

.topbar-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(227, 63, 50, 0.18);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-copy h1,
.section-heading h3,
.hero-copy h2 {
  margin: 0;
}

.eyebrow,
.section-kicker,
.hero-label {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.brand-copy h1 {
  font-size: 22px;
}

.topbar-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-chip,
.legend-chip,
.pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.meta-chip {
  background: var(--brand-soft);
  color: var(--brand);
}

.ghost-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.ghost-button:hover {
  border-color: rgba(227, 63, 50, 0.28);
  color: var(--brand);
  background: var(--brand-soft);
}

.dashboard {
  max-width: 1560px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-card,
.detail-card,
.summary-card,
.action-card {
  padding: 24px;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 24px;
  margin-bottom: 22px;
  align-items: stretch;
}

.hero-copy h2 {
  margin-top: 10px;
  font-size: 34px;
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.hero-text {
  max-width: 760px;
  margin: 18px 0 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--muted);
}

.hero-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.hero-method {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 0%, #fbfbfc 100%);
  border: 1px solid var(--border);
}

.hero-method h4 {
  margin: 0;
  font-size: 14px;
}

.hero-method p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-self: stretch;
  align-content: stretch;
  grid-auto-rows: 1fr;
}

.hero-note {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 0%, #fbfbfc 100%);
  border: 1px solid var(--border);
  min-height: 112px;
}

.hero-note strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  line-height: 1.1;
}

.hero-note p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hero-region-note {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at top right, rgba(227, 63, 50, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 242, 240, 0.92) 0%, rgba(255, 255, 255, 1) 62%);
  border-color: rgba(227, 63, 50, 0.16);
}

.hero-region-note::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(227, 63, 50, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(227, 63, 50, 0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  mask-image: linear-gradient(135deg, rgba(0, 0, 0, 0.45), transparent 78%);
  pointer-events: none;
}

.hero-region-note > * {
  position: relative;
  z-index: 1;
}

.hero-stats .hero-region-note:nth-child(2) {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(239, 246, 255, 0.9) 0%, rgba(255, 255, 255, 1) 62%);
}

.hero-stats .hero-region-note:nth-child(3) {
  background:
    radial-gradient(circle at top right, rgba(35, 121, 75, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(238, 251, 243, 0.9) 0%, rgba(255, 255, 255, 1) 62%);
}

.hero-stats .hero-region-note:nth-child(4) {
  background:
    radial-gradient(circle at top right, rgba(198, 125, 0, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 247, 237, 0.9) 0%, rgba(255, 255, 255, 1) 62%);
}

.hero-region-head,
.hero-region-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hero-region-name {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

.hero-region-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  flex-wrap: wrap;
}

.summary-card {
  margin-bottom: 20px;
}

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

.section-heading h3 {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.2;
}

.section-note {
  color: var(--muted);
  font-size: 13px;
  padding-top: 6px;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
}

.legend-high,
.risk-high {
  background: var(--danger-soft);
  color: var(--brand);
}

.legend-mid,
.risk-mid {
  background: var(--amber-soft);
  color: var(--amber);
}

.legend-low,
.risk-low {
  background: var(--green-soft);
  color: var(--green);
}

.region-head,
.focus-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

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

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

th,
td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f7f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

tbody tr:last-child td {
  border-bottom: none;
}

.district-queue {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.district-selection-state {
  margin-top: 14px;
}

.district-region-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.region-tab {
  appearance: none;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, #fbfbfc 100%);
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.region-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(227, 63, 50, 0.22);
}

.region-tab.is-active {
  border-color: rgba(227, 63, 50, 0.36);
  background: linear-gradient(180deg, #fff7f6 0%, #fff 100%);
  box-shadow: 0 14px 28px rgba(227, 63, 50, 0.08);
}

.region-tab-name {
  display: block;
  font-size: 14px;
  font-weight: 800;
}

.region-tab-meta {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.district-card {
  width: 100%;
  appearance: none;
  text-align: left;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 0%, #fbfbfc 100%);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.district-card:hover {
  transform: translateY(-1px);
  border-color: rgba(227, 63, 50, 0.22);
}

.district-card.is-selected {
  border-color: rgba(227, 63, 50, 0.38);
  background: linear-gradient(180deg, #fff7f6 0%, #fff 100%);
  box-shadow: 0 18px 32px rgba(227, 63, 50, 0.08);
}

.district-card-top,
.district-card-title,
.district-card-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.district-card-title strong {
  display: block;
  font-size: 16px;
}

.district-card-title span:last-child {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.district-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.district-card-foot {
  margin-top: 14px;
  align-items: center;
}

.district-foot-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding-top: 2px;
}

.queue-tip {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.compact-bar {
  margin-top: 10px;
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  margin-right: 10px;
}

.inline-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-bar-track {
  flex: 1;
  min-width: 90px;
  height: 8px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: hidden;
}

.inline-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(227, 63, 50, 0.78), rgba(227, 63, 50, 0.28));
}

.score-text,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.top-query-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-query-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.explain-list,
.focus-list {
  display: grid;
  gap: 14px;
}

.focus-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.explain-item,
.focus-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 0%, #fbfbfc 100%);
  border: 1px solid var(--border);
}

.explain-index {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 800;
}

.explain-item h4,
.focus-item h4 {
  margin: 0;
  font-size: 15px;
}

.explain-item p,
.focus-item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.focus-item {
  grid-template-columns: 1fr;
  min-height: 168px;
}

.focus-item-head strong {
  font-size: 16px;
}

.focus-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

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

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

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

.action-card {
  margin-top: 22px;
}

.detail-divider {
  height: 1px;
  margin: 24px 0;
  background: linear-gradient(90deg, transparent 0%, var(--border) 12%, var(--border) 88%, transparent 100%);
}

.detail-state {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.detail-table-wrap {
  max-height: 900px;
}

.query-cell strong {
  display: block;
  font-size: 15px;
}

.query-cell span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.status-chip {
  display: inline-flex;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.empty-state,
.loading-state,
.error-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
}

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

  .hero-methods {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .topbar-inner,
  .dashboard {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar-inner {
    flex-wrap: wrap;
  }

  .topbar-meta {
    width: 100%;
    justify-content: space-between;
  }

  .hero-copy h2 {
    font-size: 28px;
  }

  .hero-stats,
  .hero-methods,
  .focus-list {
    grid-template-columns: 1fr;
  }

  .district-region-tabs,
  .district-queue {
    grid-template-columns: 1fr;
  }

  .district-card-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}
