:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f5f7f7;
  color: #1f2528;
  --ink: #1f2528;
  --muted: #697277;
  --line: #d3dcdf;
  --panel: #fcfefd;
  --panel-strong: #ffffff;
  --accent: #236c5c;
  --accent-dark: #154b41;
  --gold: #b1842d;
  --red: #b34238;
  --blue: #315d88;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 22px;
}

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

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

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.05rem;
}

.status-pill,
.action-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #e9eef0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill {
  max-width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.15fr);
  gap: 18px;
  align-items: start;
}

.input-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 34px rgb(26 43 48 / 10%);
}

.input-panel {
  padding: 18px;
}

.result-panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.panel-heading.compact span {
  color: var(--muted);
  font-size: 0.9rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.api-settings {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr);
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.api-settings label {
  display: grid;
  gap: 6px;
}

.api-settings span,
.field span,
.compare-row label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field input,
.api-settings input,
.compare-row input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c8d3d7;
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 8px 10px;
}

.field input:focus,
.api-settings input:focus,
.compare-row input:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(35 108 92 / 18%);
}

.compare-row {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 6px;
  padding: 0 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.ghost-button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #e7f0ed;
  border-color: #b9d3cb;
  color: var(--accent-dark);
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--red);
  font-weight: 700;
}

.recommendation-copy {
  margin: -4px 0 18px;
  color: #475157;
  font-size: 1rem;
  line-height: 1.45;
}

.action-badge[data-action="run"] {
  background: #dceddf;
  border-color: #9ac8a2;
  color: #24552a;
}

.action-badge[data-action="test"] {
  background: #f3e7c7;
  border-color: #d2af5d;
  color: #765814;
}

.action-badge[data-action="hold"] {
  background: #e9edf1;
  border-color: #c9d3dd;
  color: #34495d;
}

.action-badge[data-action="protect_inventory"] {
  background: #f4dedb;
  border-color: #d6978f;
  color: #7a3028;
}

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

.metric {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  padding: 12px;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.35rem;
  line-height: 1;
}

.case-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid #e7edef;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

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

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

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
}

.history-item:hover {
  border-color: #9db4bc;
  background: #f8fbfb;
}

.history-item span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.history-item span:last-child {
  text-align: right;
}

.history-item strong,
.history-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small,
.empty-history {
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-history {
  margin: 0;
}

.comparison-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 58px minmax(120px, 1fr) 86px;
  gap: 10px;
  align-items: center;
}

.bar-label,
.bar-value {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.bar-value {
  text-align: right;
}

.bar-track {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde5e8;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.bar-row.winner .bar-track span {
  background: var(--accent);
}

.bar-row.winner .bar-label,
.bar-row.winner .bar-value {
  color: var(--ink);
}

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

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1500px);
    padding-top: 12px;
  }

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

  .field-grid,
  .api-settings,
  .metric-grid {
    grid-template-columns: 1fr;
  }

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

  .bar-row {
    grid-template-columns: 54px minmax(80px, 1fr) 74px;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-item span:last-child {
    text-align: left;
  }
}
