:root {
  color-scheme: light;
  --ink: #121723;
  --muted: #667085;
  --subtle: #8b95a5;
  --line: #e8e3dc;
  --line-strong: #d8d0c7;
  --panel: #ffffff;
  --page: #fbfaf8;
  --field: #ffffff;
  --accent: #10a37f;
  --accent-soft: #e7f7f2;
  --brand: #c33222;
  --brand-soft: #fff1ed;
  --danger: #d92d20;
  --blue: #0f6cbd;
  --amber: #a86616;
  --shadow: 0 18px 48px rgba(18, 23, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.app-header,
.control-strip,
.workspace {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 0 20px;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(300px, 0.75fr);
  gap: 14px;
  margin-bottom: 18px;
}

.brand,
.header-status,
.panel-title,
.chart-head,
.topbar,
.actions,
.tabs,
.field,
.slider-field,
.toggle,
.rank-cell,
.winner,
.score-panel,
.pair-row {
  display: flex;
}

.brand {
  align-items: center;
  gap: 12px;
  min-height: 64px;
  margin-bottom: 0;
}

.brand-logo {
  width: 58px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

.header-status {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.header-status span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #414956;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}

.brand p,
.eyebrow,
.label,
.panel-title span:last-child,
.winner p,
.math-list,
.memo,
td small {
  color: var(--muted);
}

.panel,
.decision-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel.compact {
  margin-top: 0;
}

.panel.no-pad {
  padding: 0;
  overflow: hidden;
}

.panel-title,
.chart-head,
.topbar,
.pair-row {
  justify-content: space-between;
  gap: 14px;
}

.panel-title {
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.field-grid,
.slider-grid {
  display: grid;
  gap: 12px;
}

.field-grid {
  grid-template-columns: minmax(210px, 1fr) minmax(140px, 0.62fr) minmax(180px, 0.8fr);
}

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

.bad-weight {
  color: var(--danger);
}

.field,
.slider-field {
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
  color: #2f3135;
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus {
  border-color: var(--ink);
  outline: 2px solid rgba(15, 15, 15, 0.08);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--ink);
}

.slider-field output {
  align-self: flex-end;
  margin-top: -25px;
  color: var(--ink);
  font-weight: 700;
}

.scenario-note {
  margin-top: 14px;
  border: 1px solid #f2d2c9;
  border-radius: 8px;
  background: var(--brand-soft);
  color: #713024;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 650;
}

.toggle {
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  color: #2f3135;
  font-size: 13px;
  font-weight: 600;
}

.toggle input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--ink);
}

.workspace {
  min-width: 0;
  padding: 12px 0 48px;
  overflow: hidden;
}

.topbar {
  align-items: center;
  margin-bottom: 20px;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
}

h2 {
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.08;
  letter-spacing: 0;
}

.actions {
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button,
.icon-button,
.tab,
.delete-button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  align-items: center;
  gap: 8px;
}

.primary-button,
.secondary-button {
  display: flex;
  min-height: 42px;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 650;
}

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

.secondary-button,
.tab,
.icon-button,
.delete-button {
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
}

.primary-button:hover {
  background: #2a2a2a;
}

.secondary-button:hover,
.icon-button:hover,
.tab:not(.active):hover {
  background: #f2f2f3;
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button,
.delete-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
}

.delete-button {
  color: var(--danger);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 14px;
}

.decision-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 220px);
  gap: 18px;
  min-height: 212px;
  padding: 26px;
  overflow: hidden;
  background: #fffdfb;
}

.winner {
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.winner strong {
  max-width: 100%;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1.08;
  overflow-wrap: break-word;
}

.winner p {
  max-width: 620px;
  font-size: 15px;
}

.label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.score-panel {
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.score-label,
.score-details span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.score-panel > strong {
  font-size: 56px;
  line-height: 0.95;
  letter-spacing: 0;
}

.score-details {
  display: grid;
  gap: 10px;
}

.score-details div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.score-details b {
  min-width: 0;
  overflow: hidden;
  color: #2f3135;
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-head {
  align-items: center;
  flex-wrap: wrap;
  padding: 18px 18px 0;
}

#rankingChart {
  display: block;
  width: 100%;
}

#modelBadge {
  border: 1px solid #ffd7c8;
  border-radius: 999px;
  background: var(--brand-soft);
  color: #963424;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.tabs {
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 14px;
}

.tab {
  min-height: 40px;
  padding: 0 14px;
  border-color: var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  transform: none;
}

.tab:not(.active):hover {
  color: var(--ink);
}

.tab-page {
  display: none;
}

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fffaf7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

td input {
  min-width: 88px;
  border-color: transparent;
  background: #f7f5f2;
}

td:nth-child(2) input {
  min-width: 230px;
  font-weight: 650;
}

td:nth-child(6) input,
td:nth-child(7) input {
  min-width: 160px;
}

td small {
  display: block;
  margin-top: 4px;
  max-width: 240px;
  line-height: 1.35;
}

.rank-cell {
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.rank-num {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #f1f1f1;
  color: var(--ink);
  font-weight: 750;
}

.confidence {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

tr.disqualified {
  background: #fbfaf8;
}

tr.disqualified .rank-num {
  color: var(--danger);
  background: #fff0ee;
}

.gate-cell {
  min-width: 180px;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 8px 6px 0;
  color: #2f3135;
  font-size: 12px;
  font-weight: 650;
}

.mini-check input {
  width: 14px;
  min-width: 14px;
  min-height: 14px;
  accent-color: var(--ink);
}

.criteria-layout,
.logic-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 1fr);
  gap: 14px;
}

.criteria-list,
.pairwise-list {
  display: grid;
  gap: 10px;
}

.guide-layout {
  align-items: start;
}

.guide-list {
  gap: 12px;
}

.guide-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf7;
  padding: 13px;
}

.guide-item strong {
  color: var(--ink);
  font-size: 14px;
}

.guide-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.criteria-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 84px 132px 34px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fafafa;
}

.criteria-row input[type="text"],
.criteria-row input[type="number"],
.criteria-row select {
  min-width: 0;
}

.pair-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf7;
}

.gate-rule {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf7;
  color: #2f3135;
  font-size: 14px;
  font-weight: 650;
}

.pair-row strong {
  min-width: 170px;
}

.pair-row input {
  max-width: 160px;
}

.math-list {
  display: grid;
  gap: 10px;
  padding-left: 18px;
  line-height: 1.5;
}

.memo {
  display: grid;
  gap: 12px;
  line-height: 1.55;
}

.logic-layout {
  align-items: start;
}

.formula-grid,
.logic-breakdown,
.logic-gates {
  display: grid;
  gap: 10px;
}

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

.formula-step,
.logic-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf7;
}

.formula-step {
  display: grid;
  gap: 7px;
  padding: 12px;
}

.formula-step span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 750;
}

.formula-step strong {
  font-size: 14px;
}

.formula-step p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.logic-card {
  padding: 12px;
}

.logic-card-title,
.logic-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logic-card-title {
  margin-bottom: 10px;
}

.logic-card-title strong {
  min-width: 0;
  overflow-wrap: break-word;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 750;
}

.status-pill.pass {
  background: var(--accent-soft);
  color: #08745f;
}

.status-pill.fail {
  background: #fff0ee;
  color: var(--danger);
}

.logic-card-detail {
  display: grid;
  gap: 7px;
}

.logic-row {
  border-top: 1px solid var(--line);
  padding-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.logic-row strong {
  color: #2f3135;
  text-align: right;
}

.logic-row.strong strong {
  color: var(--ink);
  font-size: 15px;
}

.logic-row.muted strong,
.logic-row.fail strong {
  color: var(--danger);
}

@media (max-width: 1320px) {
  .hero-grid,
  .criteria-layout,
  .logic-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 960px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-status {
    justify-content: flex-start;
  }

  .control-strip,
  .field-grid,
  .slider-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-header,
  .control-strip,
  .workspace {
    width: min(100% - 32px, 1280px);
  }

  .workspace,
  .app-header {
    padding-top: 16px;
  }

  .formula-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    justify-content: center;
    flex: 1;
  }

  .decision-card {
    grid-template-columns: 1fr;
  }

  .score-panel {
    min-height: 0;
  }

  .criteria-row {
    grid-template-columns: 1fr 80px;
  }

  .criteria-row select {
    grid-column: 1 / -1;
  }
}
