:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #eef7f4;
  --ink: #1c2733;
  --muted: #657487;
  --line: #dce3ea;
  --line-strong: #c4d0dc;
  --teal: #0f766e;
  --teal-dark: #0d5f59;
  --blue: #2563eb;
  --green: #159447;
  --amber: #d97706;
  --red: #c2410c;
  --shadow: 0 12px 30px rgba(28, 39, 51, 0.08);
  --radius: 8px;
  --content: 1420px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 300px),
    var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

textarea {
  resize: vertical;
  min-height: 78px;
}

label {
  display: grid;
  gap: 7px;
  color: #314050;
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
  line-height: 1.28;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f8;
  color: #233244;
  font-weight: 800;
}

td {
  background: #fff;
}

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

.icon-sprite {
  display: none;
}

.icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.app-shell {
  width: min(var(--content), calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

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

.eyebrow {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.soft-button,
.primary-button,
.tab-button,
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 800;
  transition:
    transform 0.12s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

.soft-button {
  background: #fff;
  border-color: var(--line);
  color: #263546;
}

.soft-button:hover,
.tab-button:hover,
.icon-action:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.soft-button:active,
.primary-button:active,
.tab-button:active,
.icon-action:active {
  transform: translateY(0);
}

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

.primary-button:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.danger-ghost {
  color: var(--red);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.tab-button {
  width: 100%;
  background: #fff;
  color: #334155;
  border-color: var(--line);
}

.tab-button.active {
  background: #13251f;
  border-color: #13251f;
  color: #fff;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: grid;
  gap: 18px;
}

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

.metric-card,
.tool-panel,
.decision-band {
  background: var(--panel);
  border: 1px solid rgba(196, 208, 220, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 128px;
  padding: 15px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-card strong {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.decision-band {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.1), rgba(217, 119, 6, 0.08)),
    #fff;
}

.decision-main {
  display: grid;
  gap: 10px;
}

.decision-main h2 {
  font-size: clamp(22px, 3vw, 32px);
}

.decision-main p {
  max-width: 760px;
  color: #314050;
  line-height: 1.65;
}

.decision-list {
  display: grid;
  gap: 8px;
}

.decision-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  padding: 9px 12px;
  font-size: 13px;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #edf7f4;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.warn,
.tag.warn {
  background: #fff7ed;
  color: var(--amber);
}

.status-pill.danger,
.tag.danger {
  background: #fff1ed;
  color: var(--red);
}

.status-pill.good,
.tag.good {
  background: #ecfdf3;
  color: var(--green);
}

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

.tool-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.panel-title-row p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

canvas {
  width: 100%;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
}

.settings-panel {
  background:
    linear-gradient(180deg, rgba(238, 247, 244, 0.95), #fff 42%),
    #fff;
}

.compact-form,
.record-form {
  display: grid;
  gap: 12px;
}

.compact-form {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  align-items: end;
}

.record-form {
  grid-template-columns: repeat(5, minmax(160px, 1fr));
}

.wide-field {
  grid-column: span 3;
}

.form-submit {
  align-self: end;
  min-height: 44px;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.table-empty {
  min-width: 0;
}

.table-empty td {
  text-align: center;
  color: var(--muted);
  padding: 28px;
  white-space: normal;
}

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.note-cell {
  min-width: 220px;
  max-width: 320px;
  white-space: normal;
  line-height: 1.5;
}

.actions-cell {
  min-width: 112px;
}

.icon-action {
  width: 34px;
  min-height: 32px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: #304052;
}

.icon-action.delete {
  color: var(--red);
}

.filter-form {
  grid-template-columns: 150px repeat(2, minmax(150px, 1fr)) minmax(220px, 2fr) 110px;
}

.rules-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.static-table td {
  white-space: normal;
  line-height: 1.55;
}

.field-guide {
  display: grid;
  gap: 10px;
}

.field-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  padding: 12px;
}

.field-card h3 {
  margin-bottom: 6px;
  font-size: 15px;
}

.field-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100% - 44px));
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #13251f;
  color: #fff;
  padding: 10px 14px;
  box-shadow: 0 14px 36px rgba(19, 37, 31, 0.22);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  font-size: 14px;
  font-weight: 800;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

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

  .chart-grid,
  .decision-band,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .record-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .compact-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, var(--content));
    padding-top: 18px;
  }

  .app-header {
    display: grid;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions > * {
    flex: 1 1 120px;
  }

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

  .summary-grid,
  .record-form,
  .compact-form,
  .filter-form {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }

  .panel-title-row {
    display: grid;
  }

  .metric-card {
    min-height: 108px;
  }

  canvas {
    height: 260px;
  }
}
