:root {
  color-scheme: light;
  --blue-900: #0b2d57;
  --blue-800: #123d73;
  --blue-700: #0f5fb8;
  --blue-600: #1976d2;
  --blue-100: #eaf4ff;
  --blue-050: #f5faff;
  --ink: #152033;
  --muted: #61718a;
  --line: #d7e4f5;
  --line-strong: #aec8e8;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --danger: #b42318;
  --success: #147a46;
  --shadow: 0 18px 50px rgba(18, 61, 115, 0.08);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(234, 244, 255, 0.92), rgba(255, 255, 255, 0.78) 34%),
    #ffffff;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 34px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

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

h1 {
  font-size: 24px;
  line-height: 1.2;
  color: var(--blue-900);
}

h2 {
  font-size: 16px;
  color: var(--blue-900);
}

h3 {
  font-size: 15px;
  color: var(--blue-900);
}

.topbar-status {
  border: 1px solid var(--line-strong);
  color: var(--blue-800);
  background: var(--blue-050);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px 34px 34px;
}

.control-panel,
.result-area {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  align-self: start;
  padding: 20px;
  position: sticky;
  top: 98px;
}

.panel-section + .panel-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.panel-section h2 {
  margin-bottom: 14px;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input[type="number"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
}

.wide-field {
  margin-top: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--blue-050);
  border-radius: 8px;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--blue-800);
  cursor: pointer;
}

.segmented input:checked + span {
  background: #ffffff;
  border-color: var(--line-strong);
  box-shadow: 0 7px 18px rgba(18, 61, 115, 0.1);
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 110px;
  padding: 18px;
  border: 1px dashed var(--blue-600);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, var(--blue-050));
  text-align: center;
  cursor: pointer;
}

.upload-zone.dragging {
  background: #e1f0ff;
  border-color: var(--blue-800);
}

.upload-zone input {
  display: none;
}

.upload-title {
  color: var(--blue-800);
  font-size: 15px;
  font-weight: 800;
}

.upload-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.file-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: 300px;
  overflow: auto;
  padding-right: 2px;
}

.file-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 82px 32px;
  gap: 9px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.file-chip {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(11, 45, 87, 0.2);
}

.file-name {
  min-width: 0;
}

.file-name strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.file-row input {
  min-height: 34px;
  padding: 6px 8px;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--blue-800);
  cursor: pointer;
}

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

.empty-state,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.primary-action,
.secondary-action,
.download-action {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  margin-top: 20px;
  color: #ffffff;
  background: var(--blue-700);
}

.primary-action:hover {
  background: var(--blue-800);
}

.primary-action:disabled,
.download-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-action {
  margin-top: 10px;
  color: var(--blue-800);
  border-color: var(--line-strong);
  background: #ffffff;
}

.download-action {
  width: auto;
  min-height: 38px;
  padding: 0 14px;
  color: var(--blue-800);
  border-color: var(--line-strong);
  background: #ffffff;
  white-space: nowrap;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.result-area {
  min-width: 0;
  padding: 20px;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.result-toolbar h2 {
  margin: 0;
}

.result-toolbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.result-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
  justify-content: space-between;
}

.message-bar {
  margin-bottom: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--blue-050);
  color: var(--blue-800);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.message-bar.error {
  border-color: #fecaca;
  color: var(--danger);
  background: #fff7f7;
}

.message-bar.success {
  border-color: #b7e4cc;
  color: var(--success);
  background: #f2fbf6;
}

.result-tabs {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface-soft);
}

.result-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 6px 14px;
  color: var(--blue-800);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.result-tab.active {
  color: #ffffff;
  background: var(--blue-600);
}

.result-tab[hidden] {
  display: none;
}

.result-panel {
  min-width: 0;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 13px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin-top: 7px;
  color: var(--blue-900);
  font-size: 22px;
  line-height: 1.1;
}

.preview-frame {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: auto;
}

.placeholder {
  display: grid;
  min-height: 520px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.placeholder strong {
  color: var(--blue-900);
  font-size: 18px;
}

.board-stack {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.board-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.board-card-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--blue-050);
  color: var(--blue-900);
  font-size: 13px;
  font-weight: 800;
}

.board-svg-wrap {
  padding: 12px;
  overflow: auto;
}

.nest-svg {
  display: block;
  width: 100%;
  min-width: 640px;
  height: auto;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.details-stack {
  display: grid;
  gap: 14px;
}

.details-stack[hidden],
.result-panel[hidden],
.details-panel[hidden] {
  display: none !important;
}

.details-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.stats-content {
  margin-top: 10px;
}

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

.stats-table th,
.stats-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  color: var(--blue-800);
  font-size: 12px;
}

.stats-table td:last-child,
.stats-table th:last-child {
  text-align: right;
}

.table-wrap {
  overflow: auto;
}

.combos-table-wrap {
  max-height: 560px;
}

.combos-table {
  min-width: 1320px;
}

.combos-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
  background: #edf5ff;
}

.combos-table td {
  vertical-align: middle;
}

.combos-table th,
.combos-table td {
  white-space: nowrap;
}

.combos-table tbody tr {
  cursor: default;
}

.combos-table tbody tr:hover td,
.selected-row td {
  background: #eaf4ff;
}

.final-combo-row td {
  background: #f0fdf4;
}

.final-combo-row.selected-row td {
  background: #dcfce7;
}

.combo-stack {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 260px;
}

.count-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(17, 52, 95, 0.14);
  border-radius: 999px;
  padding: 4px 8px;
  background: #ffffff;
  font-weight: 800;
  white-space: nowrap;
}

.count-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.strategy {
  min-width: 210px;
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
}

.percent-cell {
  min-width: 130px;
}

.bar {
  width: 118px;
  height: 8px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eefb;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0aa6a6, var(--blue-600));
}

.score {
  color: var(--blue-800);
  font-weight: 900;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.plan-badge.feasible {
  color: #086747;
  background: #dff8eb;
}

.plan-badge.partial {
  color: #165b9d;
  background: #e1f0ff;
}

.plan-badge.pending {
  color: #8a5a05;
  background: #fff3d8;
}

.plan-badge.skipped {
  color: #516071;
  background: #e7edf5;
}

.plan-badge.excluded {
  color: #7f1d1d;
  background: #fee2e2;
}

.plan-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.combo-details-panel {
  padding: 0;
  overflow: hidden;
}

.combo-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
  background: #fbfdff;
}

.combo-panel-head h3 {
  margin: 0;
}

.combo-state-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  border: 1px solid #c7dcf6;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef6ff;
  color: var(--blue-800);
  white-space: nowrap;
}

.combo-state-line span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.combo-state-line strong {
  font-size: 12px;
}

.combo-details-panel .stats-content {
  margin: 0;
  padding: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--blue-800);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.combo-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.combo-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue-800);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.combo-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef6ff;
  color: var(--blue-800);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.combo-status.pending {
  background: #fff3d8;
  color: #8a5a05;
}

.combo-status.success {
  background: #dcfce7;
  color: #166534;
}

.combo-status.testing,
.combo-status.precheck {
  background: #dbeafe;
  color: #1d4ed8;
}

.combo-status.partial {
  background: #fff7ed;
  color: #9a3412;
}

.combo-status.skipped {
  background: #f1f5f9;
  color: #475569;
}

.combo-status.excluded {
  background: #fee2e2;
  color: #991b1b;
}

.combo-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

  .control-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .result-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-toolbar-actions {
    justify-content: flex-start;
  }

  .workspace,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .form-grid.two,
  .kpi-row,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .file-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .file-row input,
  .file-row button {
    grid-column: 2;
  }
}
