:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181a1f;
  --panel-2: #22252c;
  --line: #343946;
  --text: #f6f0df;
  --muted: #aaa294;
  --gold: #f4c84a;
  --green: #42e593;
  --red: #ff5e73;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.topbar p:last-child {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

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

.setup-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.setup-panel {
  padding: 18px;
  align-self: start;
}

.result-panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-title span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #15120a;
  border-radius: 6px;
  background: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.field span,
.summary-grid span,
.main-result p,
.route-box span {
  color: var(--muted);
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(244, 200, 74, 0.14);
}

.suffix-input {
  display: grid;
  grid-template-columns: 1fr 56px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel-2);
}

.suffix-input input {
  border: 0;
  border-radius: 0;
}

.suffix-input span {
  color: var(--muted);
  text-align: center;
}

.route-box {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141519;
}

.route-box strong {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 12px;
}

.summary-grid > div {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.summary-grid strong {
  display: block;
  margin-top: 10px;
  color: var(--gold);
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1;
}

.main-result strong {
  font-size: clamp(2.7rem, 6vw, 5.2rem);
}

.main-result .loss-text {
  color: var(--red);
}

.main-result p {
  margin: 12px 0 0;
  line-height: 1.5;
}

.plain-verdict {
  margin: 14px 0 0;
  padding: 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141519;
  line-height: 1.6;
}

.plain-verdict span {
  margin-right: 8px;
  color: var(--green);
  font-weight: 800;
}

.plain-verdict.negative span {
  color: var(--red);
}

.profit-text {
  color: var(--green);
}

.loss-cell {
  color: var(--red);
}

.selected-row {
  outline: 1px solid rgba(244, 200, 74, 0.65);
  background: rgba(244, 200, 74, 0.06);
}

tr[data-scenario-id] {
  cursor: pointer;
}

.ranking {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
}

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

@media (max-width: 980px) {
  .topbar,
  .workbench {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: block;
  }

  .topbar p:last-child {
    margin-top: 12px;
  }

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

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .setup-panel,
  .result-panel {
    padding: 14px;
  }

  .split-fields,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
