:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --border: #1b1b1b;
  --soft-border: #cfcfcf;
  --muted: #666666;
  --text: #111111;
  --positive: #1d6a3a;
  --negative: #a22424;
  --header-bg: #f2f2f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

button,
input {
  font: inherit;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px;
}

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

h1,
h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.subtitle,
.status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
}

button {
  border: 1px solid var(--border);
  background: #f0f0f0;
  color: var(--text);
  cursor: pointer;
  padding: 6px 10px;
}

button:hover {
  background: #e7e7e7;
}

.summary {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--border);
  padding: 10px;
  background: #fcfcfc;
}

.metric-primary {
  background: #f7f7f7;
}

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

.metric-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.metric-value-small {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.bid-table,
.scenario-table {
  width: 100%;
  border-collapse: collapse;
}

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

.bid-table th,
.scenario-table th {
  background: var(--header-bg);
}

.bid-input,
.form-input {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 6px;
}

.bid-input.is-invalid,
.form-input.is-invalid {
  background: #f3f3f3;
  border-style: dashed;
}

.panel-header {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.auction-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: start;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--soft-border);
  padding: 4px 6px;
  font-size: 11px;
  background: #fcfcfc;
  white-space: nowrap;
}

.legend-key {
  font-weight: 700;
}

.scenario-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

.scenario-columns {
  display: grid;
  grid-template-columns: repeat(8, max-content);
  gap: 8px;
  align-items: start;
  width: max-content;
}

.scenario-group {
  display: grid;
  gap: 8px;
  width: max-content;
}

.group-title {
  font-size: 12px;
}

.scenario-table {
  width: auto;
  font-size: 10px;
}

.scenario-table th,
.scenario-table td {
  padding: 4px;
  white-space: nowrap;
}

.scenario-table td:nth-child(1) {
  width: 34px;
}

.delta-positive {
  color: var(--positive);
  font-weight: 700;
}

.delta-negative {
  color: var(--negative);
  font-weight: 700;
}

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

@media (max-width: 560px) {
  .panel {
    padding: 12px;
  }

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