:root {
  color-scheme: light dark;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Microsoft YaHei", sans-serif;
  background-color: #f7f9fc;
  color: #1a1d23;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: auto; /* 允许水平滚动以适应超宽内容 */
}

main {
  flex: 1;
  width: min(1200px, 95vw);
  margin: 0 auto 48px;
}

.app-header {
  background: linear-gradient(135deg, #0f62fe, #3d8bfd);
  color: #fff;
  padding: 32px clamp(16px, 5vw, 64px);
  text-align: center;
}

.app-header h1 {
  margin: 0 0 12px;
  font-weight: 600;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.app-header p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.9;
}

.toolbar {
  margin: 32px 0 24px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15, 66, 118, 0.1);
  padding: 24px;
}

.toolbar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

button,
.link-button {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button {
  background-color: #eef2ff;
  color: #2b3a67;
}

button:hover,
.link-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(39, 78, 169, 0.18);
}

button.primary {
  background-color: #0f62fe;
  color: #fff;
}

.link-button {
  background-color: #d4e1ff;
  color: #113c8a;
}

.toolbar-note {
  margin: 0;
  color: #4a5568;
  font-size: 0.9rem;
}

#statusMessage {
  margin-top: 12px;
  min-height: 1.2em;
  font-size: 0.9rem;
  color: #0f5132;
}

.section {
  margin-bottom: 32px;
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.08);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: #1f2a46;
}

.section-header .section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead {
  background: #eef4ff;
  color: #1a2758;
}

thead th {
  padding: 10px;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
}

td[data-label="产量"] input,
td[data-label="【实际产量】"] span {
  min-width: 60px; /* 从140px减少到60px */
  max-width: 80px;
}

tbody tr:last-child td {
  border-bottom: none;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 0.92rem;
  box-sizing: border-box;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
}

.delete-row-btn {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
  font-size: 1.2rem; /* 增大emoji的大小 */
  padding: 6px 12px; /* 调整内边距以适应emoji */
  min-width: 40px; /* 设置最小宽度 */
}

.section-description {
  margin: 0 0 16px;
  color: #4b5563;
  font-size: 0.9rem;
}

.object-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.object-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: #374151;
}

/* 货币输入框包装器 */
.money-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.money-input {
  flex: 0 1 100px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
}

.money-unit-select {
  flex: 0 0 70px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  background-color: #2d3748;
  color: #ffffff;
  cursor: pointer;
}

.money-unit-select-header {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  background-color: #2d3748;
  color: #ffffff;
  cursor: pointer;
}

.money-display {
  flex: 0 1 auto;
  min-width: 120px;
  padding: 8px 12px;
  background-color: #eff6ff;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-weight: 500;
  font-size: 0.9rem;
}

/* 计算显示字段 */
.calculated-field {
  display: block;
  padding: 8px 12px;
  background-color: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  color: #15803d;
  font-weight: 500;
  font-size: 0.9rem;
}

/* 带计算按钮的输入容器 */
.calculated-input-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

.calculated-input {
  flex: 1;
  min-width: 60px;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
}

.calc-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 1.1rem;
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.calc-btn:hover {
  background-color: #bfdbfe;
  transform: scale(1.05);
}

.calc-btn:active {
  transform: scale(0.95);
}

/* Select 下拉框样式 */
select {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  background-color: #2d3748;
  color: #ffffff;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: #0f62fe;
  box-shadow: 0 0 0 2px rgba(15, 98, 254, 0.1);
}

select option {
  background-color: #2d3748;
  color: #ffffff;
}

/* 快速选择下拉框样式 */
.quick-select-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quick-select {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  background-color: #2d3748;
  color: #ffffff;
  cursor: pointer;
  min-width: 80px;
}

.quick-select-input {
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 80px;
  box-sizing: border-box;
}

/* 首年市场单量的数量输入框 */
.section[data-section-key="firstYearMarketOrders"] input[type="number"] {
  min-width: 100px;
}

/* 调整section容器的最大宽度，让超宽表格有更多空间 */
main {
  flex: 1;
  width: min(1400px, 95vw); /* 从1200px增加到1400px */
  margin: 0 auto 48px;
}

.app-footer {
  margin-top: auto;
  background: #0f172a;
  color: #f8fafc;
  text-align: center;
  padding: 18px 12px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.app-footer a {
  color: #93c5fd;
}

/* 页尾设置模块 */
.footer-settings {
  width: 100%;
  max-width: 600px;
}

.settings-toggle-btn {
  background-color: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.settings-toggle-btn:hover {
  background-color: #334155;
}

.settings-panel {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  text-align: left;
}

.settings-panel h3 {
  margin: 0 0 12px 0;
  font-size: 1rem;
  color: #f8fafc;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-content label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #e2e8f0;
  font-size: 0.9rem;
}

.settings-content input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.settings-content select {
  flex: 1;
  max-width: 200px;
}

/* 批量计算按钮 */
.calc-all-btn {
  background-color: #10b981;
  color: #ffffff;
  border: 1px solid #059669;
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 12px;
}

.calc-all-btn:hover {
  background-color: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 紧凑模式 */
body.compact-mode tbody td {
  padding: 4px 8px;
}

body.compact-mode input,
body.compact-mode select {
  padding: 4px 6px;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .toolbar {
    padding: 18px;
  }

  .section {
    padding: 18px;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  }

  tbody td {
    border-bottom: none;
    padding: 6px 0;
  }

  tbody td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    color: #1f2937;
  }
}

/* 生产线表格特殊样式 - 字体缩小，列宽优化 */
.section[data-section-key="productionLines"] table tbody tr td input,
.section[data-section-key="productionLines"] table tbody tr td select {
  font-size: 0.85rem;
  padding: 6px 4px;
  min-width: 50px; /* 减小最小宽度 */
}

.section[data-section-key="productionLines"] table thead th {
  font-size: 0.85rem;
  padding: 10px 4px;
}

/* 生产线的产量和实际产量列更窄 */
.section[data-section-key="productionLines"] td[data-label="产量"] input,
.section[data-section-key="productionLines"] td[data-label="【实际产量】"] span {
  min-width: 50px;
  max-width: 70px;
}

/* 初始资产负债特殊样式 */
.section[data-section-key="initialBalanceSheet"] {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #0ea5e9;
  box-shadow: 0 12px 36px rgba(14, 165, 233, 0.2);
}

.section[data-section-key="initialBalanceSheet"] .section-header h2 {
  color: #0369a1;
  font-size: 1.5rem;
}

/* 对象字段容器样式 */
.object-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 0;
}

.object-field-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.object-field-wrapper > span {
  font-weight: 600;
  color: #1e293b;
  font-size: 1rem;
}

.object-input-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.object-input-container .input-with-unit {
  display: flex;
  align-items: center;
  gap: 12px;
}

.object-money-input {
  max-width: 200px;
  padding: 10px 12px;
  font-size: 1.1rem;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  flex: 1;
}

.money-unit-select {
  max-width: 100px;
  padding: 8px 10px;
  font-size: 0.95rem;
  border: 2px solid #10b981;
  border-radius: 6px;
  background-color: #10b981;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.money-unit-select:hover {
  background-color: #059669;
  border-color: #059669;
}

.money-unit-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

.money-formatted {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background-color: #f1f5f9;
  border-radius: 8px;
  border-left: 4px solid #0ea5e9;
}

.formatted-number {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f172a;
  font-family: 'Consolas', 'Monaco', monospace;
  letter-spacing: 1px;
}

.chinese-number {
  font-size: 0.95rem;
  color: #64748b;
  font-weight: 500;
}

/* 单位选择器（表头） */
.money-unit-select-header {
  padding: 4px 8px;
  font-size: 0.85rem;
  border: 2px solid #10b981;
  border-radius: 4px;
  background-color: #10b981;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.money-unit-select-header:hover {
  background-color: #059669;
  border-color: #059669;
}

.money-unit-select-header:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

/* 快速选择容器 */
.quick-select-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 快速选择下拉框 */
.quick-select {
  padding: 6px 8px;
  font-size: 0.9rem;
  border: 2px solid #0ea5e9;
  border-radius: 4px;
  background-color: #0ea5e9;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
}

.quick-select:hover {
  background-color: #0284c7;
  border-color: #0284c7;
}

.quick-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.3);
}

/* 快速选择输入框 */
.quick-select-input {
  padding: 6px 8px;
  font-size: 0.9rem;
  border: 2px solid #0ea5e9;
  border-radius: 4px;
  min-width: 60px;
}

/* 显示字段（如编号） */
.display-field {
  font-weight: 600;
  color: #0369a1;
  font-size: 1rem;
  display: inline-block;
  padding: 4px 8px;
  background-color: #e0f2fe;
  border-radius: 4px;
  min-width: 40px;
  text-align: center;
}

/* 多选下拉框样式 */
.multiselect-container {
  position: relative;
  min-width: 200px;
}

.multiselect-display {
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #f9f9f9;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.multiselect-display:hover {
  border-color: #2196f3;
  background-color: #f5f5f5;
}

.multiselect-tag {
  display: inline-flex;
  align-items: center;
  background-color: #e3f2fd;
  border: 1px solid #2196f3;
  border-radius: 3px;
  padding: 3px 6px;
  margin: 2px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multiselect-remove {
  color: #f44336;
  font-weight: bold;
  margin-left: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.multiselect-remove:hover {
  color: #d32f2f;
}

.multiselect-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}

.multiselect-option {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  transition: background-color 0.15s ease;
  user-select: none;
}

.multiselect-option:hover {
  background-color: #f0f9ff;
}

.multiselect-option input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  margin: 0;
}

.multiselect-option label {
  cursor: pointer;
  flex: 1;
  margin: 0;
}

.multiselect-option input[type="checkbox"]:checked + label {
  color: #2196f3;
  font-weight: 500;
}

