:root {
  color-scheme: light;
  --bg: #f6f8f5;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #162026;
  --muted: #657174;
  --line: #cfd9d2;
  --line-strong: #9badb3;
  --teal: #167d7f;
  --teal-dark: #0f595b;
  --amber: #c47723;
  --red: #b4554c;
  --green: #4c8b57;
  --blue: #385f8d;
  --shadow: 0 18px 38px rgba(28, 44, 40, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(22, 125, 127, 0.07), transparent 360px),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

button,
select,
input {
  font: inherit;
}

.app-header,
main,
footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: flex-end;
  padding: 34px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.18;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 4.8vw, 3.2rem);
}

h2 {
  font-size: clamp(1.18rem, 2.2vw, 1.55rem);
}

.lead {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.header-facts {
  display: grid;
  gap: 8px;
  min-width: 280px;
}

.header-facts span {
  display: block;
  padding: 8px 12px;
  border-left: 4px solid var(--teal);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

main {
  display: grid;
  gap: 20px;
  padding-bottom: 36px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(420px, 1.55fr);
  gap: 20px;
  align-items: start;
}

.controls,
.result-board,
.chart-section,
.tables,
.conclusion-section {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.controls,
.result-board {
  padding: 20px;
}

.section-heading {
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  border: 0;
  padding: 0;
}

.field span,
.field legend {
  color: var(--ink);
  font-weight: 700;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

input[type="range"] {
  accent-color: var(--teal);
}

.range-field small {
  color: var(--muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button,
.tabs button {
  min-height: 40px;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--line-strong);
}

.segmented button.active,
.tabs button.active {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.status {
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(22, 125, 127, 0.12);
  color: var(--teal-dark);
  font-weight: 700;
}

.status.warn {
  background: rgba(196, 119, 35, 0.14);
  color: #7a4a0d;
}

.status.risk {
  background: rgba(180, 85, 76, 0.14);
  color: #8d2c25;
}

.status.good {
  background: rgba(76, 139, 87, 0.14);
  color: #2e6b39;
}

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

.metric {
  min-height: 122px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  align-content: space-between;
}

.metric span,
.verdict span {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong,
.verdict strong {
  display: block;
  margin: 4px 0;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.verdict {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.bar {
  height: 12px;
  margin: 10px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe7e1;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  max-width: 125%;
  background: linear-gradient(90deg, var(--amber), var(--teal));
  transition: width 200ms ease;
}

.verdict p {
  margin: 0;
}

.chart-section,
.tables,
.conclusion-section {
  padding: 20px;
}

.chart-wrap {
  min-height: 390px;
}

#curveChart {
  display: block;
  width: 100%;
  min-height: 390px;
}

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

.axis line,
.grid line {
  stroke: var(--line);
}

.axis path {
  stroke: var(--line-strong);
}

.fan-curve {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
}

.leak-curve {
  fill: none;
  stroke: var(--amber);
  stroke-width: 3;
}

.target-line {
  stroke: var(--red);
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.target-marker {
  fill: var(--red);
}

.work-marker {
  fill: var(--teal);
  stroke: #fff;
  stroke-width: 2;
}

.chart-label {
  fill: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

.chart-sub {
  fill: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.legend i {
  display: inline-block;
}

.fan-line,
.leak-line {
  width: 24px;
  height: 3px;
}

.fan-line {
  background: var(--teal);
}

.leak-line {
  background: var(--amber);
}

.target-dot,
.work-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.target-dot {
  background: var(--red);
}

.work-dot {
  background: var(--teal);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
}

.table-panel {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: var(--surface);
}

th,
td {
  border: 1px solid var(--line);
  padding: 10px 11px;
  vertical-align: middle;
  text-align: left;
}

th {
  background: #e9f0eb;
  color: var(--ink);
  font-weight: 700;
}

td {
  color: #263238;
}

td.numeric,
th.numeric {
  text-align: right;
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background: #fbfcfa;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.tag.good {
  background: rgba(76, 139, 87, 0.14);
  color: #2e6b39;
}

.tag.warn {
  background: rgba(196, 119, 35, 0.16);
  color: #7a4a0d;
}

.tag.risk {
  background: rgba(180, 85, 76, 0.15);
  color: #8d2c25;
}

.tag.limit {
  background: rgba(56, 95, 141, 0.14);
  color: #254b78;
}

.conclusion-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.conclusion-card {
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.conclusion-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.conclusion-card p {
  margin: 0;
  color: var(--muted);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 0 0 26px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 920px) {
  .app-header,
  .workspace {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
    align-items: start;
  }

  .header-facts {
    min-width: 0;
  }

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

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

@media (max-width: 620px) {
  .app-header,
  main,
  footer {
    width: min(100% - 20px, 1180px);
  }

  .controls,
  .result-board,
  .chart-section,
  .tables,
  .conclusion-section {
    padding: 14px;
  }

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

  .result-head,
  footer {
    display: grid;
  }

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

  .conclusion-card {
    min-height: 0;
  }

  .chart-wrap,
  #curveChart {
    min-height: 330px;
  }

  table {
    min-width: 760px;
  }
}
