:root {
  --bg: #f5f8fc;
  --panel: #ffffff;
  --line: #d9e4f2;
  --line-strong: #bdd1e6;
  --text: #22324d;
  --muted: #6f7f99;
  --teal: #0f7e78;
  --green: #14905f;
  --violet: #7c3ff2;
  --blue: #286ed6;
  --amber: #d78713;
  --red: #c54f45;
  --shadow: 0 18px 44px rgba(39, 63, 94, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background:
    linear-gradient(rgba(44, 110, 170, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(44, 110, 170, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.2;
}

.hero-copy,
.section-title p,
.source-label,
.summary-strip span,
.filters-grid span,
.compact p {
  color: var(--muted);
}

.hero-copy {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 16px;
}

.upload-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 460px;
}

.upload-button,
.ghost-button,
.text-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  cursor: pointer;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
  font-weight: 800;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ghost-button,
.text-button {
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  font-weight: 700;
}

.text-button {
  min-height: 36px;
  color: var(--teal);
  border-color: transparent;
}

.source-label {
  flex-basis: 100%;
  margin: 0;
  text-align: right;
  font-size: 13px;
}

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

.summary-strip div,
.kpi-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
}

.summary-strip div {
  padding: 16px 18px;
}

.summary-strip span,
.kpi-card span,
.filters-grid span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.summary-strip strong {
  display: block;
  font-size: 20px;
}

.panel {
  position: relative;
  min-width: 0;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(39, 63, 94, 0.05);
}

.filters-panel,
.chart-panel,
.insight-panel {
  margin-top: 18px;
}

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

.section-title p {
  margin-bottom: 0;
  font-weight: 650;
}

.section-title.compact {
  margin-bottom: 14px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
}

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

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

.kpi-card {
  padding: 18px;
}

.kpi-card strong {
  display: block;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.08;
}

.kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.metric-toggles {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 720px;
}

.metric-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.metric-toggle input {
  accent-color: var(--teal);
}

.metric-toggle.active {
  color: var(--text);
  border-color: var(--line-strong);
  background: #f6fbff;
}

.chart-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.trend-chart {
  display: block;
  width: 100%;
  min-width: 980px;
  height: 470px;
}

.axis-label {
  fill: #8798b4;
  font-size: 13px;
  font-weight: 700;
}

.chart-grid {
  stroke: #dce7f3;
  stroke-width: 1;
}

.chart-grid.minor {
  stroke: #edf2f8;
}

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

.series-line.dashed {
  stroke-dasharray: 9 7;
}

.series-point {
  stroke: #fff;
  stroke-width: 2;
}

.series-area {
  opacity: 0.14;
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  min-width: 220px;
  max-width: 300px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 13px;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 6px;
}

.chart-tooltip div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.insight-text {
  font-size: 19px;
  line-height: 1.55;
  font-weight: 800;
}

.risk-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.risk-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.risk-item strong {
  display: block;
  margin-bottom: 6px;
}

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

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 18px;
  min-width: 0;
}

.heatmap {
  display: grid;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.heat-row {
  display: grid;
  grid-template-columns: 68px repeat(24, minmax(24px, 1fr));
  gap: 4px;
  align-items: center;
  min-width: 740px;
}

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

.heat-cell {
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heat-hours {
  display: grid;
  grid-template-columns: 68px repeat(24, minmax(24px, 1fr));
  gap: 4px;
  min-width: 740px;
  color: #8798b4;
  font-size: 10px;
  font-weight: 800;
}

.rank-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f8;
}

.rank-item:last-child {
  border-bottom: 0;
}

.rank-index {
  color: var(--muted);
  font-weight: 900;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.rank-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rank-value {
  min-width: 110px;
  text-align: right;
  font-weight: 900;
}

.bar-track {
  width: 100%;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f8;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--teal);
}

.message-box {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid #f0c4bd;
  border-radius: 8px;
  background: #fff8f6;
  color: #8e2f25;
  font-weight: 800;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
}

@media (max-width: 1180px) {
  .filters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-grid,
  .summary-strip,
  .risk-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 720px);
    padding-top: 12px;
  }

  .hero {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .upload-panel {
    justify-content: stretch;
  }

  .upload-button,
  .ghost-button {
    flex: 1 1 150px;
  }

  .source-label {
    text-align: left;
  }

  .summary-strip,
  .filters-grid,
  .kpi-grid,
  .risk-list {
    grid-template-columns: 1fr;
  }

  .section-title {
    display: grid;
  }

  .metric-toggles {
    justify-content: flex-start;
  }

  .panel {
    padding: 18px;
  }

  .rank-item {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .rank-value {
    grid-column: 2;
    text-align: left;
  }
}

