:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --panel-soft: #f8fbfc;
  --line: #dbe4ea;
  --line-strong: #c7d3dc;
  --text: #172635;
  --muted: #647789;
  --brand: #0f766e;
  --brand-strong: #0a514c;
  --blue: #2563eb;
  --red: #c2410c;
  --green: #047857;
  --shadow: 0 10px 28px rgba(23, 38, 53, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }

.page-shell {
  width: min(1540px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 12px 0 42px;
  display: grid;
  gap: 14px;
}

.latest-grid,
.chart-stack,
.summary-grid {
  display: grid;
  gap: 12px;
}

.latest-card,
.summary-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.latest-card,
.summary-card {
  padding: 14px 16px;
}

.panel {
  padding: 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.latest-card span,
.latest-card small,
.summary-card span,
.section-meta span,
.records-table th,
.empty-box,
.toolbar-left {
  color: var(--muted);
}

.latest-card span,
.latest-card small,
.summary-card span {
  display: block;
}

.latest-card strong,
.summary-card strong {
  display: block;
  margin-top: 6px;
}

.latest-card small { margin-top: 6px; line-height: 1.55; }

.latest-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.latest-card h2,
.section-head h2 {
  margin: 0;
}

.latest-card strong {
  font-size: 28px;
}

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

.section-meta {
  display: grid;
  gap: 5px;
  justify-items: end;
  text-align: right;
}

.export-actions,
.form-actions,
.table-toolbar,
.pager,
.period-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.period-switch {
  justify-content: flex-end;
}

.period-chip,
.ghost-button,
.primary-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  padding: 0 14px;
  font-weight: 800;
}

.period-chip,
.ghost-button {
  background: var(--panel);
  color: var(--text);
}

.period-chip-active,
.primary-button {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.history-panel {
  display: grid;
  gap: 14px;
}

.query-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.query-form label {
  display: grid;
  gap: 6px;
}

.query-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.query-form input,
.query-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.form-actions {
  align-self: end;
}

.summary-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.summary-card strong {
  font-size: 18px;
  word-break: break-word;
}

.table-toolbar {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.toolbar-left {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-weight: 800;
}

.excel-wrap,
.table-wrap {
  overflow: auto;
}

.excel-wrap {
  max-height: 610px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.records-table,
.excel-table {
  width: 100%;
  border-collapse: collapse;
}

.records-table { min-width: 900px; }
.excel-table {
  min-width: 1280px;
  table-layout: fixed;
  font-size: 14px;
}

.records-table th,
.records-table td,
.excel-table th,
.excel-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.excel-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef5f5;
  color: var(--text);
  white-space: nowrap;
  user-select: none;
}

.excel-table td {
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.excel-table td:hover {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  outline-offset: -2px;
}

.sortable {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  min-height: 20px;
  font-weight: 900;
}

.filter-row th {
  top: 40px;
  background: #f7fbfb;
  padding: 8px;
}

.filter-input {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
}

.chart-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.chart-wrap {
  margin-top: 12px;
  overflow: hidden;
}
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: rgba(23, 38, 53, 0.1);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: middle;
}

.chart-axis-y {
  text-anchor: start;
}

.chart-line {
  fill: none;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-box {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.value-up { color: var(--red); font-weight: 900; }
.value-down { color: var(--green); font-weight: 900; }
.value-flat { color: var(--muted); font-weight: 900; }

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

  .query-form {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 18px, 1540px);
    padding-top: 10px;
  }

  .section-head,
  .table-toolbar {
    display: grid;
    justify-items: start;
    text-align: left;
  }

  .latest-grid,
  .summary-grid,
  .query-form,
  .chart-stack {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .section-meta {
    justify-items: start;
    text-align: left;
  }

  .period-switch {
    justify-content: flex-start;
  }
}
