:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #67728a;
  --border: #dbe2ee;
  --blue: #2563eb;
  --green: #0f9f6e;
  --orange: #e58a00;
  --red: #dc3d4a;
  --purple: #7c3aed;
  --teal: #0891b2;
  --shadow: 0 16px 40px rgba(25, 35, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.ghost-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.ghost-link:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.page-nav[hidden] {
  display: none;
}

.page-nav {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.page-nav-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
}

.page-nav-panel {
  position: absolute;
  top: 72px;
  right: 32px;
  width: min(420px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 96px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.page-nav-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.page-nav-search {
  display: block;
  padding: 14px 18px 10px;
}

.page-nav-search span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.page-nav-search input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

.page-nav-search input:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 235, 0.14);
}

.page-nav-list {
  max-height: 430px;
  overflow-y: auto;
  padding: 6px 10px 14px;
}

.page-nav-group + .page-nav-group {
  margin-top: 8px;
}

.page-nav-group h3 {
  margin: 8px 8px 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: 0;
}

.page-nav-group-list {
  display: grid;
  gap: 4px;
}

.page-nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.page-nav-item:hover,
.page-nav-item.is-current {
  background: #eff6ff;
}

.page-nav-title {
  font-size: 16px;
  font-weight: 800;
}

.page-nav-desc {
  color: var(--muted);
  font-size: 13px;
}

.page-nav-desc {
  grid-column: 1 / -1;
}

.page-nav-current {
  align-self: start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.page-nav-empty {
  padding: 18px 12px;
  color: var(--muted);
  font-size: 14px;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px 32px 36px;
}

.filter-panel,
.chart-card,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-panel {
  padding: 18px;
}

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

.status-text,
.chart-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.chart-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.filter-field {
  min-width: 0;
}

.filter-field label {
  display: block;
  margin-bottom: 6px;
  color: #3f4b61;
  font-size: 13px;
  font-weight: 700;
}

.filter-field select,
.filter-field input {
  width: 100%;
  min-height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
}

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

.multi-search {
  position: relative;
  width: 100%;
  min-width: 0;
}

.multi-search-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.multi-search-button span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-search-button:hover,
.multi-search-button[aria-expanded="true"] {
  border-color: var(--blue);
}

.multi-search-arrow {
  flex: 0 0 auto;
  color: var(--muted);
}

.multi-search-panel {
  position: absolute;
  z-index: 45;
  top: calc(100% + 6px);
  left: 0;
  width: min(340px, 92vw);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

.chart-control .multi-search-panel {
  right: 0;
  left: auto;
}

.multi-search-input-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.multi-search-input {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

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

.multi-search-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0 7px;
  color: var(--muted);
  font-size: 12px;
}

.multi-search-clear {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
}

.multi-search-options {
  max-height: 230px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
}

.multi-search-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  cursor: pointer;
}

.multi-search-option:hover {
  background: #eff6ff;
}

.multi-search-option input {
  flex: 0 0 auto;
  width: 14px;
  min-height: 14px;
  margin-top: 2px;
  padding: 0;
}

.multi-search-empty {
  padding: 14px 8px;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-field {
  min-height: 60px;
}

.check-options {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}

.check-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}

.check-options input {
  width: 14px;
  min-height: 14px;
  padding: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.metric-card {
  padding: 16px;
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 18px;
}

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

.chart-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.chart-control select {
  min-height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
}

.chart-control .multi-search {
  width: 190px;
}

.chart-control .multi-search-button {
  min-height: 32px;
  font-size: 13px;
}

.chart-host {
  position: relative;
  width: 100%;
  min-height: 420px;
  margin-top: 14px;
  overflow: hidden;
}

.chart-host svg {
  display: block;
  width: 100%;
  height: 420px;
}

.chart-host-tall {
  min-height: 480px;
  overflow-x: hidden;
  overflow-y: auto;
}

.chart-host-tall svg {
  min-height: 420px;
  height: auto;
}

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

.compact-chart {
  min-height: 360px;
}

.compact-chart svg {
  height: 360px;
}

.table-section {
  margin-top: 16px;
}

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

.table-heading h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.table-host {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.table-host table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-host th,
.table-host td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf1f7;
  text-align: left;
  white-space: nowrap;
}

.table-host th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #3f4b61;
  font-weight: 700;
}

.table-host th:first-child,
.table-host td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #ffffff;
  min-width: 150px;
}

.table-host th:first-child {
  z-index: 3;
  background: #f8fafc;
}

.pivot-table {
  min-width: 900px;
}

.pivot-table th,
.pivot-table td {
  min-width: 128px;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

.table-sort-button span {
  color: var(--blue);
  font-weight: 800;
}

.table-host th:not(:first-child),
.table-host td:not(:first-child) {
  text-align: right;
}

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

.chart-empty {
  display: grid;
  min-height: 420px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.axis-label {
  fill: #657089;
  font-size: 12px;
}

.legend-label {
  fill: #2f3b52;
  font-size: 12px;
}

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

.axis-line {
  stroke: #cfd7e6;
  stroke-width: 1;
}

.hover-line {
  display: none;
  stroke: #94a3b8;
  stroke-width: 1.1;
  stroke-dasharray: 5 5;
  pointer-events: none;
}

[data-tooltip] {
  cursor: crosshair;
}

.chart-mark {
  transition: opacity 120ms ease, filter 120ms ease, stroke-width 120ms ease;
}

.chart-host.is-hovering .chart-mark {
  opacity: 0.22;
}

.chart-host.is-hovering .chart-line {
  opacity: 0.26;
}

.chart-host.is-hovering .mark-active,
.chart-host.is-hovering .total-line,
.chart-host.is-hovering .total-point.mark-active {
  opacity: 1;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.16));
}

.chart-host.is-hovering .chart-line.mark-active {
  stroke-width: 3.2;
}

.chart-point.mark-active,
.total-point.mark-active {
  stroke: #ffffff;
  stroke-width: 2;
}

.total-line {
  opacity: 0.88;
}

.total-bar {
  mix-blend-mode: multiply;
}

.chart-hotspot {
  fill: transparent;
  pointer-events: all;
  stroke: transparent;
}

.chart-tooltip {
  position: fixed;
  z-index: 30;
  display: none;
  max-width: min(440px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 24px));
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid #40516a;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.96);
  color: #edf4ff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.24);
  font-size: 13px;
  line-height: 1.6;
  pointer-events: none;
}

.chart-tooltip.is-visible {
  display: block;
}

.tooltip-title {
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 700;
}

.tooltip-summary {
  margin-top: 6px;
  color: #dbeafe;
  font-weight: 700;
}

.tooltip-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  white-space: nowrap;
}

.tooltip-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: 7px;
  border-radius: 999px;
}

.tooltip-value {
  font-weight: 700;
}

@media (max-width: 1200px) {
  .filter-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 18px 16px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .page-nav-panel {
    top: 18px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: calc(100vh - 36px);
  }

  .app-shell {
    padding: 18px;
  }

  .filter-grid,
  .metric-grid,
  .chart-grid,
  .split-chart {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .chart-heading {
    flex-direction: column;
    gap: 6px;
  }

  .status-text,
  .chart-meta {
    text-align: left;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 22px;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .chart-card,
  .filter-panel,
  .metric-card {
    padding: 14px;
  }
}
