:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #667085;
  --line: #d0d7e2;
  --panel: #ffffff;
  --page: #eef3f8;
  --blue: #1f77b4;
  --blue-dark: #1f4e79;
  --blue-soft: #dbeefd;
  --green: #267a52;
  --red: #b94c43;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

button.primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

button.secondary {
  color: var(--blue-dark);
  background: #f8fbff;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 34px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.view-tabs {
  display: flex;
  gap: 8px;
  max-width: 1180px;
  margin: 18px auto 0;
  padding: 0 24px;
}

.tab-button {
  min-width: 128px;
  border-color: transparent;
  color: var(--blue-dark);
  background: #dfeefa;
  font-weight: 700;
}

.tab-button.active {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

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

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

h1 {
  margin-bottom: 6px;
  font-size: 26px;
  line-height: 1.2;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
}

.header-actions,
.mini-actions,
.section-head,
.subsection-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  flex-shrink: 0;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 28px;
}

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

.inputs-panel,
.result-panel {
  padding: 24px;
}

.view-page[hidden] {
  display: none !important;
}

.section-head,
.subsection-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  color: var(--blue-dark);
}

h3 {
  margin: 28px 0 12px;
  font-size: 16px;
  color: var(--blue-dark);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-width: 64px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 2px solid rgba(31, 119, 180, 0.18);
  border-color: var(--blue);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#directTable {
  min-width: 820px;
}

#loadTable {
  min-width: 560px;
}

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

th {
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

tbody th {
  color: var(--ink);
  background: #f5f9fd;
}

.input-table input {
  text-align: center;
}

#directTable th:first-child,
#directTable td:first-child {
  width: 190px;
}

#directTable th:nth-child(2),
#directTable td:nth-child(2) {
  width: 72px;
}

#directTable th:nth-child(n + 3),
#directTable td:nth-child(n + 3) {
  width: 86px;
}

#loadTable th:first-child,
#loadTable td:first-child {
  width: 58px;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.large-action {
  min-width: 160px;
  min-height: 42px;
  font-weight: 700;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
}

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

.result-card {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}

.result-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.result-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.result-card.accent {
  border-color: #a9d7be;
  background: #f3fbf6;
}

.result-card.accent strong {
  color: var(--green);
}

.chart-frame {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

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

.output-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 22px;
}

.output-table {
  font-size: 13px;
}

.output-table td {
  background: #fff;
}

.output-table tr:nth-child(even) td {
  background: #f8fbff;
}

.error {
  border: 1px solid #f0b4ae;
  border-radius: 8px;
  padding: 12px;
  color: #8c2f27;
  background: #fff3f1;
}

@media print {
  body {
    min-width: 0;
    background: #fff;
  }

  .app-header,
  .view-tabs,
  .inputs-panel,
  .section-head button,
  .subsection-head,
  .status {
    display: none !important;
  }

  .app-shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  .panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .result-panel {
    padding: 0;
  }

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

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

  .chart-frame,
  .result-card,
  table {
    break-inside: avoid;
  }
}

@media (max-width: 820px) {
  .app-header,
  .section-head,
  .subsection-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header,
  .view-tabs,
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .header-actions,
  .mini-actions,
  .result-actions {
    flex-wrap: wrap;
  }

  .settings-grid,
  .cards,
  .output-grid {
    grid-template-columns: 1fr;
  }
}
