:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --ink: #20242c;
  --muted: #687081;
  --line: #d7dce6;
  --panel: #ffffff;
  --panel-soft: #eef3f8;
  --accent: #d83c4b;
  --accent-dark: #aa2431;
  --blue: #2f67b2;
  --green: #247a55;
  --shadow: 0 14px 40px rgba(32, 36, 44, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  white-space: nowrap;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.secondary-panel {
  margin-top: 18px;
}

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

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

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

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

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
}

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

.mode-tabs {
  grid-column: 1 / -1;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: min(420px, 100%);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mode-option {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option:has(input:checked) {
  background: var(--panel);
  color: var(--accent-dark);
  box-shadow: 0 1px 5px rgba(32, 36, 44, 0.08);
}

.is-hidden {
  display: none;
}

label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 103, 178, 0.16);
}

.hint {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.model-note {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.55;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  text-align: center;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.result-band {
  padding: 18px 0 0;
}

.status {
  min-height: 26px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

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

.metric {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

.summary-block {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  color: var(--ink);
  line-height: 1.65;
}

.summary-block:empty {
  display: none;
}

.summary-block b {
  color: var(--accent-dark);
}

.chart-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 520;
}

.site-footer {
  padding: 18px 0 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--green);
  font-weight: 800;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .tool-panel {
    padding: 16px;
  }

  h1 {
    font-size: 25px;
  }

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

@media (max-width: 540px) {
  .app-shell {
    padding: 8px;
  }

  .tool-panel {
    padding: 12px;
  }

  .secondary-panel {
    margin-top: 12px;
  }

  .title-row {
    align-items: center;
    margin-bottom: 14px;
  }

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

  .eyebrow {
    margin-bottom: 4px;
    font-size: 12px;
  }

  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 17px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .input-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mode-tabs {
    width: 100%;
  }

  .mode-option {
    min-height: 34px;
    font-size: 13px;
  }

  input,
  select {
    height: 42px;
  }

  .hint {
    font-size: 12px;
    line-height: 1.45;
  }

  .model-note {
    padding: 9px 10px;
    font-size: 12px;
    line-height: 1.5;
  }

  .form-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
    min-height: 40px;
    padding: 0 6px;
    font-size: 13px;
  }

  .metric {
    min-height: 64px;
    padding: 10px;
  }

  .metric span {
    font-size: 12px;
  }

  .metric strong {
    margin-top: 6px;
    font-size: 20px;
  }

  .status {
    min-height: auto;
    margin-bottom: 8px;
    font-size: 13px;
  }

  .summary-block {
    margin-top: 10px;
    padding: 11px 10px;
    font-size: 13px;
    line-height: 1.55;
  }

  .chart-wrap {
    margin-top: 10px;
    padding: 6px;
  }

  .site-footer {
    padding: 14px 0 6px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .form-actions {
    gap: 6px;
  }

  .primary-button,
  .ghost-button {
    padding: 0 4px;
    font-size: 12px;
  }

  .metric {
    padding: 9px;
  }

  .metric strong {
    font-size: 18px;
  }
}
