:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #f4f6f8;
  color: #1f2933;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  background: #ffffff;
  border-bottom: 1px solid #d9e0e8;
  flex-wrap: wrap;
}

h1, h2, p { margin: 0; }
h1 { font-size: 24px; letter-spacing: 0; }
h2 { font-size: 16px; letter-spacing: 0; }
.topbar p, .section-head span { color: #657386; font-size: 13px; margin-top: 6px; }

button, .file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1px solid #b8c4d0;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2933;
  padding: 0 14px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
button:hover, .file-button:hover { background: #eef3f7; }
.file-button input { display: none; }
.actions, .import-row { display: flex; gap: 10px; flex-wrap: wrap; }

.layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(460px, 0.82fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}
.workspace { display: grid; gap: 18px; }

.panel {
  background: #ffffff;
  border: 1px solid #d9e0e8;
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}
.sticky { position: sticky; top: 16px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.with-gap { margin-top: 20px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
label {
  display: grid;
  gap: 6px;
  color: #4f5d6b;
  font-size: 13px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #c6d0dc;
  border-radius: 6px;
  background: #ffffff;
  color: #111827;
  font: inherit;
  padding: 8px 10px;
  min-height: 34px;
}
textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
  margin-top: 10px;
}

.category-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.category-card {
  border: 1px solid #dde4ec;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}
.category-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.category-title strong { font-size: 14px; }
.category-title span {
  display: block;
  margin-top: 3px;
  color: #7a8795;
  font-size: 12px;
}
.scheme-table {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.scheme-head, .scheme-row {
  display: grid;
  grid-template-columns: 60px minmax(150px, 1fr) minmax(118px, 0.58fr);
  align-items: center;
  gap: 10px;
}
.scheme-head {
  color: #64748b;
  font-size: 12px;
  padding: 0 2px;
}
.scheme-row input { min-height: 34px; padding: 6px 8px; }
.period-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #102033;
}
.period-sharp { background: #ffe4df; }
.period-peak { background: #ffeec7; }
.period-flat { background: #ddefff; }
.period-valley { background: #dbf4e7; }
.period-deep { background: #e7e4ff; }
.range-status {
  min-height: 20px;
  margin-top: 10px;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}
.range-status.ok {
  background: #eaf7f0;
  color: #1f7a4d;
}
.range-status.error {
  background: #fff1ef;
  color: #b42318;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #d9e0e8;
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  border-bottom: 1px solid #e7edf3;
  padding: 8px;
  text-align: right;
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
thead th { background: #f0f4f8; color: #334155; font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td input, td select { min-width: 72px; padding: 5px 7px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.metric {
  border: 1px solid #dde4ec;
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}
.metric span { display: block; color: #64748b; font-size: 12px; }
.metric strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 19px;
  line-height: 1.2;
}

canvas {
  width: 100%;
  height: 320px;
  border: 1px solid #d9e0e8;
  border-radius: 8px;
  background: #ffffff;
}
.result-wrap { margin-top: 12px; }
.calc-note {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: #5f6d7b;
  font-size: 13px;
  line-height: 1.55;
}

.col-hidden { display: none !important; }

.mode-hint {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #1e40af;
  line-height: 1.5;
}

.validation-box {
  border: 1px solid;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.validation-box.error {
  background: #fff1ef;
  border-color: #fbbeb6;
  color: #b42318;
}
.validation-box.warning {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}
.validation-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.validation-list li {
  padding: 2px 0;
}
.validation-error::before {
  content: "⚠ ";
}
.validation-warning::before {
  content: "ℹ ";
}

@media (max-width: 1280px) {
  .layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 900px) {
  .form-grid, .category-editor { grid-template-columns: 1fr; }
  .scheme-head, .scheme-row { grid-template-columns: 64px minmax(160px, 1fr) minmax(110px, 0.5fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .layout { padding: 12px; }
  .metrics { grid-template-columns: 1fr; }
  .scheme-head { display: none; }
  .scheme-row { grid-template-columns: 1fr; align-items: stretch; }
  h1 { font-size: 20px; }
}

.project-grid {
  align-items: end;
}

.auto-import-row {
  align-items: center;
}

.tou-update-row {
  margin-bottom: 16px;
}

.tou-update-row select {
  width: min(160px, 100%);
  min-height: 40px;
}

.data-link {
  color: #0f766e;
  font-size: 13px;
  text-decoration: none;
}

.data-link:hover {
  text-decoration: underline;
}

.primary-action {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
  font-weight: 600;
}

.primary-action:hover {
  background: #115e59;
  border-color: #115e59;
}

button:disabled,
.file-button:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.66;
}

@media (max-width: 980px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

#monthTable input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

#monthTable input[type="number"]::-webkit-outer-spin-button,
#monthTable input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.monthly-import-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  margin-top: 12px;
  margin-bottom: 12px;
}

.monthly-import-row .file-button {
  height: 36px;
}

.monthly-import-row .import-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 36px;
  white-space: nowrap;
}

.calc-note strong {
  display: block;
  margin-bottom: 6px;
}

.calc-note ol {
  margin: 0;
  padding-left: 20px;
}

.calc-note li + li {
  margin-top: 5px;
}

#loadCurveStatus {
  color: #526173;
  font-size: 13px;
  margin-bottom: 8px;
}

@media (max-width: 760px) {
  .monthly-import-row { flex-wrap: wrap; }
  .monthly-import-row .import-hint { flex-basis: 100%; line-height: 1.5; white-space: normal; }
}

