* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: #f0f2f5;
  color: #333;
  font-size: 14px;
  line-height: 1.6;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px max(24px, calc((100% - 1392px) / 2));
  background: linear-gradient(135deg, #1a3a5c, #2e6da4);
  color: #fff;
}

.app-header h1 {
  font-size: 22px;
  letter-spacing: 1px;
}

.app-header a {
  flex-shrink: 0;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.12);
  padding: 8px 16px;
  border-radius: 20px;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.tabs {
  display: flex;
  background: #fff;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 0;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: #f5f7fa;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.6;
  min-width: 0;
  font-family: inherit;
  color: #666;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #fff;
  color: #2e6da4;
  border-bottom-color: #2e6da4;
  font-weight: bold;
}

.tab-btn:hover:not(.active) {
  background: #eef2f7;
  color: #2e6da4;
}

.tab-panel {
  display: none;
  background: #fff;
  border-radius: 0 0 8px 8px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tab-panel.active {
  display: block;
}

/* Card */
.card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  min-width: 0;
}

.card-title {
  font-size: 15px;
  font-weight: bold;
  color: #1a3a5c;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.card-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: #2e6da4;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Form */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.form-group label {
  font-size: 12px;
  color: #666;
  font-weight: 500;
  line-height: 1.6;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  min-width: 0;
  min-height: var(--control-height, 44px);
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  line-height: 1.6;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2e6da4;
  box-shadow: 0 0 0 2px rgba(46,109,164,0.1);
}

.form-group input[type="number"] {
  width: 100%;
}

.form-grid, .score-config-grid { display: grid; gap: 20px; align-items: end; }
.score-config-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.form-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-section { min-width: 0; padding: 16px; border: 1px solid #dbe4ef; border-radius: 10px; background: #fff; }
.form-section legend { font-size: 13px; font-weight: 600; color: #23496e; padding: 0 8px; }
.form-grid .form-group { align-self: stretch; }
.form-grid .form-group label { flex: 1; }
.form-grid .form-group label small { display: block; font-size: 11px; }
.form-block { margin-bottom: 20px; }
.strategy-select { width: min(100%, 560px); }
.search-range-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; margin: 24px 0 16px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.scenario-form-grid { grid-template-columns: 1.5fr 1.2fr 1fr 1fr; }
.scenario-form-actions { grid-column: 1 / -1; justify-content: flex-end; }
.bidder-name-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 64px; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #e2e8f0; }
.bidder-name-row:last-child { border-bottom: 0; }
.bidder-name-row input { min-width: 0; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; background: #fff; }

/* Buttons */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  min-height: var(--control-height, 44px);
  line-height: 1.6;
  transition: all 0.2s;
}

.btn-primary {
  background: #2e6da4;
  color: #fff;
}

.btn-primary:hover {
  background: #245a8a;
}

.btn-success {
  background: #16a34a;
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  padding: 5px 10px;
  font-size: 12px;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-warning {
  background: #d97706;
  color: #fff;
}

.btn-warning:hover {
  background: #b45309;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* Table */
.table-wrap {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: #1a3a5c;
  color: #fff;
  padding: 14px 12px;
  text-align: center;
  font-weight: 500;
  white-space: nowrap;
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: center;
  line-height: 1.7;
}

th small { display: block; margin-top: 4px; font-size: 11px; font-weight: normal; opacity: .8; }
.table-scroll-hint { display: none; font-size: 12px; color: #64748b; margin: 0 0 12px; }
.table-scroll-hint-wide { display: block; }
.bidder-input-table, .predict-input-table, .composite-score-table, .optimization-detail-table, .scenario-compare-table { table-layout: fixed; }
.bidder-input-table { min-width: 740px; }
.predict-input-table { min-width: 440px; }
.composite-score-table { min-width: 1200px; }
.optimization-detail-table { min-width: 1080px; }
.scenario-compare-table { min-width: 1200px; }
.bidder-input-table td:nth-child(2), .predict-input-table td:first-child,
.composite-score-table td:nth-child(2), .optimization-detail-table td:first-child,
.scenario-compare-table td:nth-child(-n+2) { text-align: left; overflow-wrap: anywhere; }
.composite-score-table td:nth-child(n+3), .scenario-compare-table td:nth-child(n+3),
.optimization-detail-table td:nth-child(n+2) { font-variant-numeric: tabular-nums; }
.composite-score-table td:not(:nth-child(2)), .scenario-compare-table td:nth-child(n+3):not(:nth-child(6)):not(:nth-child(9)) { white-space: nowrap; }
.composite-score-table td:first-child { white-space: normal; }
.scenario-compare-table td:nth-child(9) { white-space: normal; overflow-wrap: anywhere; }
.scenario-compare-table .btn { padding: 8px; min-height: 36px; }
.composite-score-table th, .optimization-detail-table th, .scenario-compare-table th { white-space: normal; }
.table-input { width: 100%; min-width: 0; min-height: 42px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font: inherit; font-variant-numeric: tabular-nums; }
.scenario-total-cell .rank-bar { display: block; max-width: 100%; margin: 0 0 8px; height: 6px; }
.table-wrap:focus-visible { outline: 2px solid #2e6da4; outline-offset: 3px; }

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

tr:hover td {
  background: #eff6ff;
}

tr.my-row td {
  background: #fef9c3 !important;
  font-weight: bold;
}

tr.rank-1 td {
  background: #dcfce7 !important;
}

tr.rank-1 td:first-child::after {
  content: ' 🏆';
}

/* Weight sum indicator */
.weight-sum {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-block;
  margin-left: 8px;
}

.weight-sum.ok {
  background: #dcfce7;
  color: #16a34a;
}

.weight-sum.err {
  background: #fee2e2;
  color: #dc2626;
}

/* Strategy params */
.strategy-params {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 12px;
  margin-top: 10px;
}

.strategy-params .form-row {
  margin-bottom: 0;
}

/* Highlight / Badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}

.badge-blue {
  background: #dbeafe;
  color: #1e40af;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge-yellow {
  background: #fef9c3;
  color: #854d0e;
}

/* Result panel */
.result-section {
  margin-top: 20px;
}

.result-title {
  font-size: 16px;
  font-weight: bold;
  color: #1a3a5c;
  margin-bottom: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.bid-validity-status {
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  color: #166534;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.bid-validity-status.warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.bid-validity-status strong {
  font-weight: 700;
}

.price-input-invalid,
.score-input-invalid {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
}

.score-reason {
  color: #166534;
  font-weight: 600;
}

.predict-result-head {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(0, 1.3fr);
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: #fff;
}

.predict-meta-label {
  display: block;
  margin-bottom: 8px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}

.predict-benchmark-value {
  display: block;
  color: #173b5d;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.predict-method-block { min-width: 0; padding-left: 24px; border-left: 1px solid #e2e8f0; }
.predict-method-block strong { color: #334b63; font-size: 14px; font-weight: 600; line-height: 1.8; }
.predict-rule-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; margin: 20px 0 28px; }
.predict-rule-single { grid-template-columns: minmax(0, 1fr); }
#predict-result-box .predict-rule-layout > .ws-scale { margin: 0; padding: 16px 20px; background: #fff; border-color: #e2e8f0; line-height: 1.8; }
#predict-result-box .predict-rule-layout > .ws-scale strong { font-size: 13px; font-weight: 600; }
#predict-result-box .predict-rule-layout > .ws-scale p { margin-top: 10px; color: #64748b; font-size: 12px; line-height: 1.9; }
#predict-result-box .predict-rule-layout > .ws-scale-check { background: #fff8e8; border-color: #e8c87a; }
#predict-result-box .predict-rule-layout > .ws-scale-check p { color: #79520d; }
#predict-result-box .predict-rule-layout > .ws-trace { margin: 0; padding: 16px 20px; border: 1px solid #e2e8f0; background: #f8fafc; line-height: 1.8; }
#predict-result-box .ws-trace summary { overflow-wrap: anywhere; }
#predict-result-box .ws-trace p { line-height: 1.9; }
.predict-table-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px 24px; margin-bottom: 16px; }
.predict-participants { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; line-height: 1.7; }
.predict-participants strong { font-size: 14px; font-weight: 600; color: #334b63; }
.predict-participants span, .predict-sort-status { color: #64748b; font-size: 12px; line-height: 1.8; }
.predict-sort-status { text-align: right; }
.predict-sort-status span { display: block; color: #8895a5; }
.predict-scroll-hint { display: none; color: #64748b; font-size: 12px; line-height: 1.6; margin-bottom: 10px; }
#predict-result-box .predict-table-wrap { border: 1px solid #dbe4ef; border-radius: 8px; background: #fff; }
.predict-score-table { table-layout: fixed; min-width: 900px; }
.predict-col-rank { width: 11%; }.predict-col-name { width: 28%; }.predict-col-price { width: 17%; }.predict-col-deviation { width: 14%; }.predict-col-score { width: 14%; }.predict-col-contribution { width: 16%; }
.predict-score-table th { padding: 16px; font-size: 13px; line-height: 1.6; }
.predict-score-table th small { display: block; margin-top: 4px; color: #c4d4e4; font-size: 11px; font-weight: normal; line-height: 1.5; }
.predict-score-table td { padding: 14px 16px; line-height: 1.7; }
.predict-score-table th:nth-child(2), .predict-score-table td:nth-child(2) { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.predict-score-table th:nth-child(n+3), .predict-score-table td:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }
.predict-score-table td:nth-child(n+3) { white-space: nowrap; }
.predict-table-wrap:focus-visible { outline: 2px solid #2e6da4; outline-offset: 3px; }

.table-sort-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 2px 4px;
}

.table-sort-btn span {
  color: #94a3b8;
  display: inline-block;
  min-width: 12px;
}

.table-sort-btn.active,
.table-sort-btn.active span,
.table-sort-btn:hover,
.table-sort-btn:focus-visible {
  color: #fff7ae;
}

.table-sort-btn:focus-visible {
  outline: 2px solid #fff7ae;
  outline-offset: 2px;
  border-radius: 3px;
}

@media (max-width: 1000px) {
  .predict-scroll-hint { display: block; }
}

@media (max-width: 760px) {
  .predict-result-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 18px;
  }
  .predict-benchmark-value { font-size: 22px; }
  .predict-method-block { padding: 16px 0 0; border-left: 0; border-top: 1px solid #e2e8f0; }
  .predict-rule-layout { grid-template-columns: minmax(0, 1fr); margin: 16px 0 24px; gap: 12px; }
  .predict-table-toolbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .predict-sort-status { text-align: left; }
  .predict-sort-status span { display: inline; margin-left: 10px; }
}

.summary-card {
  background: linear-gradient(135deg, #1a3a5c, #2e6da4);
  color: #fff;
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.summary-card .label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.summary-card .value {
  font-size: 24px;
  font-weight: bold;
}

.summary-card .sub {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

.summary-card.highlight {
  background: linear-gradient(135deg, #15803d, #16a34a);
}

.summary-card.warn {
  background: linear-gradient(135deg, #b45309, #d97706);
}

/* Section header */
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: bold;
  color: #1a3a5c;
  padding: 12px 4px;
  border-bottom: 2px solid #2e6da4;
  margin-bottom: 20px;
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #2e6da4;
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  flex-shrink: 0;
}

.section-desc {
  font-size: 12px;
  font-weight: normal;
  color: #888;
  margin-left: 4px;
}

/* Optimize panel */
.optimize-result {
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  color: #fff;
  border-radius: 8px;
  padding: 24px;
  margin-top: 24px;
}

.optimize-result h3 {
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

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

.optimize-item {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  min-width: 0;
  overflow-wrap: anywhere;
}

.optimize-item .oi-label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.optimize-item .oi-value {
  font-size: 20px;
  font-weight: bold;
}

/* Range slider for sensitivity */
.sensitivity-chart {
  width: 100%;
  overflow-x: auto;
}

.sensitivity-chart table td {
  font-size: 13px;
  padding: 12px 16px;
}
.sensitivity-chart table { min-width: 620px; }

.rank-bar {
  display: inline-block;
  height: 14px;
  background: #2e6da4;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

/* Scenario compare */
.scenario-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.scenario-chip {
  background: #dbeafe;
  border: 1px solid #93c5fd;
  color: #1e40af;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.scenario-chip.active {
  background: #1e40af;
  color: #fff;
  border-color: #1e40af;
}

.note {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
  line-height: 1.8;
}

.divider {
  height: 1px;
  background: #e5e7eb;
  margin: 16px 0;
}

.flex-end {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 1100px) {
  .score-config-grid { grid-template-columns: minmax(0, 1fr); }
  .scenario-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-range-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-range-grid .form-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .optimize-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .app-header { padding: 20px; gap: 16px; }
  .app-header h1 { font-size: 20px; }
  .container { padding: 16px; }
  .tab-panel { padding: 20px; }
  .card { padding: 20px; }
  .table-scroll-hint { display: block; }
}

@media (max-width: 600px) {
  .app-header { padding: 20px 16px; }
  .app-header h1 { font-size: 18px; letter-spacing: 0; }
  .app-header a { padding: 6px 10px; font-size: 12px; }
  .container { padding: 12px; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-btn { padding: 12px 6px; font-size: 13px; }
  .tab-panel { padding: 16px; }
  .card { padding: 16px; margin-bottom: 20px; }
  .card-title { font-size: 14px; }
  .weight-sum { margin-left: 0; }
  .form-grid-three, .search-range-grid, .scenario-form-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .form-section { padding: 12px; }
  .form-grid-three .form-group { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 12px; }
  .preset-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bidder-name-row { grid-template-columns: 36px minmax(0, 1fr) 52px; gap: 8px; }
  .bidder-name-row input { padding: 10px 8px; font-size: 13px; }
  .form-actions, .flex-end { align-items: stretch; }
  .form-actions .btn, .flex-end .btn { flex: 1 1 160px; }
  .section-desc { flex-basis: 100%; margin-left: 32px; }
  .optimize-result { padding: 20px; }
  .optimize-grid { grid-template-columns: minmax(0, 1fr); }
}

input.my-bid {
  border-color: #2e6da4;
  background: #eff6ff;
}
