:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #101828;
  --muted: #667085;
  --subtle: #8a96a8;
  --border: #dbe3ed;
  --border-strong: #c9d3df;
  --navy: #1f396c;
  --navy-2: #2f4d82;
  --steel: #7399c5;
  --violet: #7b7da7;
  --soft-line: #e8eef5;
  --shadow: 0 18px 44px rgba(31, 57, 108, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1160px;
  background:
    linear-gradient(180deg, rgba(31, 57, 108, 0.08), rgba(244, 247, 251, 0) 260px),
    var(--bg);
  color: var(--ink);
  font-family:
    "Inter", "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

.app-shell {
  width: min(1360px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 26px 0 36px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0 18px;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  font-weight: 800;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 780;
}

.subtitle {
  margin-top: 9px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(31, 57, 108, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--navy);
  font-size: 13px;
  font-weight: 750;
}

.status-pill.muted {
  color: var(--muted);
  font-weight: 650;
}

.status-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 0 0 4px rgba(31, 57, 108, 0.12);
}

.control-panel {
  display: grid;
  grid-template-columns: 190px 230px 190px 160px 128px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(31, 57, 108, 0.06);
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.toggle-field {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

select,
button {
  height: 40px;
  border-radius: 7px;
  font: inherit;
}

select {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

select:focus {
  border-color: rgba(31, 57, 108, 0.62);
  box-shadow: 0 0 0 3px rgba(31, 57, 108, 0.11);
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding-top: 17px;
  cursor: pointer;
  white-space: nowrap;
}

.toggle-field input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #c8d2df;
  pointer-events: none;
  transition: background 160ms ease;
}

.toggle-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.22);
  transition: transform 160ms ease;
}

.toggle-field input:checked + .toggle-track {
  background: var(--navy);
}

.toggle-field input:checked + .toggle-track span {
  transform: translateX(16px);
}

button {
  border: none;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 780;
  cursor: pointer;
  box-shadow: 0 12px 20px rgba(31, 57, 108, 0.18);
}

button:hover {
  background: #172d56;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 260px 260px;
  gap: 14px;
  margin: 16px 0;
}

.decision-card,
.quality-card,
.ops-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.decision-card {
  min-height: 142px;
  padding: 21px 22px;
}

.decision-card h2 {
  font-size: 22px;
  color: var(--ink);
}

.decision-card p:last-child {
  margin-top: 14px;
  max-width: 760px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  font-weight: 600;
}

.decision-card p:last-child b {
  color: var(--navy);
  font-weight: 800;
}

.quality-card {
  min-height: 142px;
  padding: 20px 20px 18px;
}

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

.quality-card strong {
  display: block;
  margin-top: 15px;
  color: var(--navy);
  font-size: 44px;
  line-height: 1;
  font-weight: 820;
}

.quality-card small,
.ops-card small {
  display: block;
  margin-top: 11px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 680;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  min-height: 470px;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 15px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 20px;
  height: 3px;
  border-radius: 999px;
  display: inline-block;
}

.legend-pred {
  background: var(--navy);
}

.legend-actual {
  background: repeating-linear-gradient(
    90deg,
    var(--steel) 0 6px,
    transparent 6px 9px
  );
}

.legend-actual-solid {
  background: var(--steel);
  opacity: 0.72;
}

.chart-wrap {
  position: relative;
}

.total-wrap {
  margin-top: 8px;
}

#totalChart,
#shapeChart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

#totalChart {
  aspect-ratio: 520 / 320;
}

#shapeChart {
  aspect-ratio: 820 / 360;
}

.tooltip {
  position: absolute;
  min-width: 164px;
  pointer-events: none;
  transform: translate(-50%, -112%);
  border: 1px solid rgba(31, 57, 108, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 30px rgba(31, 57, 108, 0.14);
  padding: 10px 11px;
  color: var(--ink);
  font-size: 12px;
  z-index: 5;
}

.tooltip strong {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
}

.tooltip div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  line-height: 1.6;
  color: var(--muted);
}

.tooltip b {
  color: var(--ink);
}

.operations-section {
  margin-top: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 12px;
}

.section-heading p:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.operations-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.ops-card {
  min-height: 104px;
  padding: 16px 18px;
}

.ops-card strong {
  display: block;
  min-height: 35px;
  margin-top: 12px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
  font-weight: 820;
}

.segment-panel {
  min-height: 0;
}

.segment-stack {
  display: flex;
  height: 36px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--panel-soft);
}

.segment-stack div {
  min-width: 4px;
}

.segment-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.segment-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.segment-color {
  width: 8px;
  height: 48px;
  border-radius: 999px;
}

.segment-name {
  display: block;
  font-size: 13px;
  font-weight: 780;
}

.segment-period {
  display: block;
  margin-top: 4px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 650;
}

.segment-value {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

.segment-value strong {
  font-size: 18px;
  color: var(--navy);
}

.segment-value small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    min-width: 0;
  }

  .app-shell {
    width: calc(100vw - 16px);
    padding-top: 16px;
  }

  h1 {
    font-size: 25px;
  }

  .subtitle {
    font-size: 13px;
    line-height: 1.6;
  }

  .masthead,
  .panel-header,
  .section-heading {
    display: grid;
  }

  .status-group {
    justify-content: flex-start;
  }

  .control-panel,
  .summary-grid,
  .analysis-grid,
  .operations-grid,
  .segment-list {
    grid-template-columns: 1fr;
  }

  .control-panel {
    padding: 14px;
  }

  select,
  button {
    min-width: 0;
  }

  .toggle-field {
    padding-top: 0;
  }

  .decision-card,
  .quality-card,
  .ops-card,
  .panel {
    box-shadow: 0 12px 28px rgba(31, 57, 108, 0.07);
  }

  .decision-card p:last-child {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .quality-card strong {
    font-size: 38px;
  }

  .legend {
    flex-wrap: wrap;
    white-space: normal;
  }

  .panel {
    min-height: 0;
  }
}
