/* Flip optimizer: the buy board is the surface. The plan controls are a
   flat strip above it; the board keeps one summary line and the positions. */

html:has(.shell[data-screen="optimizer"]),
body:has(.shell[data-screen="optimizer"]) {
  overflow: auto;
  overscroll-behavior: auto;
}

body:has(.shell[data-screen="optimizer"]) {
  position: static;
  inset: auto;
}

.shell[data-screen="optimizer"] .main {
  min-height: 0;
}

.shell[data-screen="optimizer"] .workspace {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 var(--page-pad) var(--page-pad);
  scrollbar-gutter: stable;
}

.shell[data-screen="optimizer"] .col-main,
.shell[data-screen="optimizer"] .col-side {
  display: none;
}

.opt-mast,
.opt-screen {
  width: 100%;
  max-width: none;
}

.opt-mast {
  display: none;
  padding: 14px 0 0;
  border-bottom: 0;
}

.shell[data-screen="optimizer"] .opt-mast {
  display: block;
}

.opt-mast .page-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 7px;
  margin: 0 0 8px;
  color: var(--ink-4);
  font-size: var(--text-label);
  line-height: 1.3;
}

.opt-mast .page-crumb a {
  color: var(--ink-3);
  text-decoration: none;
}

.opt-mast .page-crumb a:hover {
  color: var(--accent);
}

.opt-mast .page-mast-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-title);
  font-weight: var(--fw-display);
  line-height: var(--leading-display);
  letter-spacing: var(--track-display);
  text-wrap: balance;
}


.opt-screen {
  display: none;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
  color: var(--ink);
}

.shell[data-screen="optimizer"] .opt-screen {
  display: flex;
}

.opt-screen [hidden] {
  display: none !important;
}

.opt-screen *,
.opt-screen *::before,
.opt-screen *::after {
  box-sizing: border-box;
}

/* ------------------------------------------------------------------ setup */

.opt-setup {
  min-width: 0;
  padding: 2px 20px 0;
}

.opt-form {
  min-width: 0;
}

.opt-controls {
  display: grid;
  grid-template-columns:
    minmax(190px, 220px)
    minmax(210px, 1fr)
    120px
    120px
    130px;
  gap: 10px;
  align-items: end;
}

.opt-control {
  min-width: 0;
}

.opt-control-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-height: 15px;
  margin-bottom: 6px;
  color: var(--ink-4);
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
}

.opt-input-wrap {
  position: relative;
}

.opt-input {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  color: var(--ink);
  caret-color: var(--accent);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1;
  transition:
    border-color var(--t-quick) var(--ease),
    box-shadow var(--t-quick) var(--ease),
    background-color var(--t-quick) var(--ease);
}

.opt-input:hover {
  border-color: var(--line-strong);
}

.opt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.opt-input::placeholder {
  color: var(--ink-4);
}

.opt-input-cash {
  height: 48px;
  padding: 0 40px 0 12px;
  font-variant-numeric: tabular-nums;
}

.opt-suffix {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: var(--text-label);
  pointer-events: none;
  transform: translateY(-50%);
}

.opt-budget-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.opt-quick-budgets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.opt-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 37px;
  height: 24px;
  padding: 0 9px;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--t-quick) var(--ease),
    background-color var(--t-quick) var(--ease),
    border-color var(--t-quick) var(--ease);
}

.opt-chip:hover {
  color: var(--ink);
  background: var(--hover);
  border-color: var(--line-strong);
}

.opt-chip[aria-pressed="true"] {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.opt-slot-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.opt-slot {
  display: grid;
  place-items: center;
  height: 40px;
  min-width: 0;
  padding: 0;
  color: var(--ink-3);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1;
  cursor: pointer;
  transition:
    color var(--t-quick) var(--ease),
    background-color var(--t-quick) var(--ease),
    border-color var(--t-quick) var(--ease);
}

.opt-slot:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.opt-slot[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.opt-select-wrap {
  position: relative;
}

.opt-select-wrap::after {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--ink-4);
  border-bottom: 1.5px solid var(--ink-4);
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

.opt-select-wrap:focus-within::after {
  border-color: var(--accent);
}

.opt-select-wrap select {
  padding-right: 30px;
  appearance: none;
  cursor: pointer;
}

.opt-select-wrap select option {
  color: var(--ink);
  background: var(--card);
}

.opt-submit-cell {
  display: flex;
  align-items: end;
}

.opt-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--t-quick) var(--ease),
    opacity var(--t-quick) var(--ease);
}

.opt-run:hover {
  background: var(--accent-2);
}

.opt-run:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.opt-run:disabled {
  cursor: progress;
  opacity: .55;
}

.opt-btn-arrow {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.opt-run-short {
  display: none;
}

.opt-strategy-help {
  min-height: 18px;
  max-width: 82ch;
  margin: 9px 0 0;
  color: var(--ink-4);
  font-size: var(--text-label);
  line-height: 1.5;
}

.opt-error {
  margin: 9px 0 0;
  padding: 9px 10px;
  color: var(--down);
  background: var(--down-soft);
  border: 1px solid rgba(255, 133, 140, .28);
  border-radius: 5px;
  font-size: var(--text-label);
  line-height: 1.45;
}

.opt-noscript {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--down);
  font-size: var(--text-label);
}

/* ------------------------------------------------------------------ board */

.opt-board {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.opt-board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding-bottom: 9px;
}

.opt-board-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-width: 0;
}

.opt-board-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  letter-spacing: 0;
  white-space: nowrap;
}

.opt-board-title h2:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.opt-board-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-width: 0;
}

.opt-status {
  margin: 0;
  color: var(--ink-4);
  font-family: var(--sans);
  font-size: var(--text-micro);
  font-weight: var(--fw-regular);
  line-height: 1.4;
}

.opt-board-slots {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: var(--text-micro);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.opt-board-slots b {
  color: var(--ink-2);
  font-weight: var(--fw-medium);
}

.opt-method {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: var(--text-micro);
  line-height: 1.4;
}

.opt-board-head:has(.opt-update:not([hidden])) .opt-board-meta {
  display: none;
}

.opt-skipped {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  color: var(--ink-3);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.opt-skipped span {
  color: var(--accent-2);
  font-family: var(--mono);
}

.opt-skipped:hover,
.opt-skipped[aria-expanded="true"] {
  color: var(--ink);
  border-color: var(--accent-line);
}

.opt-skipped-menu {
  position: absolute;
  top: 54px;
  right: 20px;
  z-index: 10;
  width: min(310px, calc(100% - 40px));
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px;
  color: var(--ink);
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
}

.opt-skipped-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.opt-skipped-head p {
  margin: 0;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.opt-skipped-clear {
  padding: 0;
  color: var(--accent-2);
  background: transparent;
  border: 0;
  font-family: var(--sans);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.opt-skipped-clear:hover {
  color: var(--accent);
}

.opt-skipped-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.opt-skipped-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
}

.opt-skipped-row:last-child {
  border-bottom: 0;
}

.opt-skipped-name {
  overflow: hidden;
  color: var(--ink-3);
  font-size: var(--text-label);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-skipped-restore {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 7px;
  color: var(--ink-4);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.opt-skipped-restore:hover {
  color: var(--accent-2);
  border-color: var(--accent-line);
}

.opt-update {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 4px 4px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 6px;
}

.opt-update-copy {
  min-width: 0;
}

.opt-update-title {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1.2;
}

.opt-update-note {
  margin: 2px 0 0;
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1.2;
}

.opt-update-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 9px;
  color: var(--on-accent);
  background: var(--accent);
  border: 0;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
}

.opt-update-btn:hover {
  background: var(--accent-2);
}

.opt-update-btn .opt-btn-arrow {
  width: 12px;
  height: 12px;
  flex-basis: 12px;
}

/* Summary */

.opt-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 22px;
  margin: 0;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--line);
}

.opt-summary-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.opt-summary dt {
  color: var(--ink-4);
  font-family: var(--sans);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.opt-summary dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.opt-summary-profit dd,
.opt-summary-profit #opt-profit {
  color: var(--ink);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
}

.opt-board #opt-profit.opt-up {
  color: var(--up);
}

.opt-board #opt-profit.opt-down {
  color: var(--down);
}

.opt-announce {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Empty states */

.opt-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 218px;
  margin: 0;
  padding: 30px 0 34px;
  text-align: center;
}

.opt-onboarding,
.opt-preview-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.opt-onboarding {
  gap: 10px;
  max-width: 62ch;
}

.opt-preview-title {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.4;
}

.opt-start-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  color: var(--ink-2);
  font-size: var(--text-label);
  line-height: 1.4;
  list-style: none;
}

.opt-start-steps li {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.opt-step-num {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

.opt-preview-note {
  max-width: 56ch;
  margin: 0;
  color: var(--ink-4);
  font-size: var(--text-label);
  line-height: 1.55;
}

.opt-onboarding .opt-preview-note {
  color: var(--ink-3);
}

.opt-sample {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  margin-top: 2px;
  padding: 0 12px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--t-quick) var(--ease),
    background-color var(--t-quick) var(--ease),
    border-color var(--t-quick) var(--ease);
}

.opt-sample:hover {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.opt-empty {
  margin: 0;
  padding: 22px 0 6px;
  color: var(--ink-4);
  font-size: var(--text-label);
  line-height: 1.55;
}

/* Positions */

.opt-results {
  padding-top: 0;
}

.opt-columns,
.opt-trade {
  display: grid;
  grid-template-columns:
    40px
    minmax(220px, 1.7fr)
    repeat(4, minmax(70px, .55fr))
    minmax(110px, .8fr)
    72px;
  gap: 12px;
  align-items: center;
}

.opt-columns {
  padding: 7px 4px;
  color: var(--ink-4);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  letter-spacing: .1em;
  text-transform: none;
}

.opt-columns span:nth-child(n + 3) {
  text-align: right;
}

.opt-trades {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.opt-trade {
  min-height: 52px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color var(--t-quick) var(--ease);
}

.opt-trade:last-child {
  border-bottom: 0;
}

.opt-trade:hover {
  background: var(--hover);
}

.opt-trade-slot {
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.opt-trade:first-child .opt-trade-slot {
  color: var(--accent);
}

.opt-trade-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.opt-icon-box {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  overflow: hidden;
  background: var(--field);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

.opt-icon,
.opt-icon-fallback {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.opt-icon-fallback {
  display: grid;
  place-items: center;
  color: var(--ink-4);
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
}

.opt-trade-id {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.opt-trade-name {
  overflow: hidden;
  color: var(--ink);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opt-trade-window {
  flex: 0 0 auto;
  padding: 1px 5px;
  color: var(--ink-4);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: var(--text-micro);
  font-weight: var(--fw-medium);
  line-height: 1.5;
  white-space: nowrap;
}

.opt-trade-facts {
  display: contents;
}

.opt-fact {
  min-width: 0;
}

.opt-fact dt {
  display: none;
}

.opt-fact dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.3;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.opt-fact-cost dd {
  color: var(--ink);
  font-weight: var(--fw-medium);
}

.opt-trade-profit {
  min-width: 0;
  text-align: right;
}

.opt-trade-profit b {
  display: block;
  overflow: hidden;
  font-family: var(--mono);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.opt-board .opt-trade-profit .opt-up {
  color: var(--up);
}

.opt-board .opt-trade-profit .opt-down {
  color: var(--down);
}

.opt-trade-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 5px;
  color: var(--ink-4);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color var(--t-quick) var(--ease),
    background-color var(--t-quick) var(--ease),
    border-color var(--t-quick) var(--ease);
}

.opt-trade-buy:hover {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.opt-trade-buy-mark {
  display: block;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
}

.opt-trade-buy-lbl {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shared chrome */

.opt-setup :focus-visible,
.opt-board :focus-visible,
.opt-mast a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.opt-screen ::selection,
.opt-mast ::selection {
  color: var(--on-accent);
  background: var(--accent);
}

.shell[data-screen="optimizer"] .workspace {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}

.shell[data-screen="optimizer"] .workspace::-webkit-scrollbar {
  width: 10px;
}

.shell[data-screen="optimizer"] .workspace::-webkit-scrollbar-track {
  background: transparent;
}

.shell[data-screen="optimizer"] .workspace::-webkit-scrollbar-thumb {
  background: var(--scroll);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
}

.shell[data-screen="optimizer"] .workspace::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
  background-clip: padding-box;
}

.opt-skipped-menu {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}

.opt-skipped-menu::-webkit-scrollbar {
  width: 8px;
}

.opt-skipped-menu::-webkit-scrollbar-thumb {
  background: var(--scroll);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 999px;
}

/* Responsive */

@media (max-width: 980px) {
  .opt-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 8px;
  }

  .opt-bank,
  .opt-slot-pick,
  .opt-submit-cell {
    grid-column: 1 / -1;
  }

  .opt-submit-cell {
    justify-content: flex-end;
  }

  .opt-run {
    width: auto;
    min-width: 200px;
  }
}

@media (max-width: 760px) {
  .opt-mast {
    padding-top: 12px;
  }

  .opt-screen {
    gap: 14px;
    margin-top: 12px;
  }

  .opt-setup {
    padding: 0 16px 2px;
  }

  .opt-board {
    padding: 16px;
  }

  .opt-board-head {
    gap: 10px;
  }

  .opt-summary {
    gap: 5px 18px;
    padding: 4px 0 12px;
  }

  .opt-columns {
    display: none;
  }

  .opt-trade {
    grid-template-columns: 24px 28px minmax(0, 1fr) auto 38px;
    grid-template-areas:
      "slot icon id profit action"
      "facts facts facts facts facts";
    gap: 4px 7px;
    padding: 10px 2px;
  }

  .opt-trade-slot {
    grid-area: slot;
  }

  .opt-trade-head {
    display: contents;
  }

  .opt-icon-box {
    grid-area: icon;
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .opt-icon,
  .opt-icon-fallback {
    width: 24px;
    height: 24px;
  }

  .opt-trade-id {
    grid-area: id;
    min-width: 0;
  }

  .opt-trade-name {
    font-size: var(--text-label);
  }

  .opt-trade-window {
    padding: 0 4px;
    font-size: var(--text-micro);
  }

  .opt-trade-facts {
    display: flex;
    grid-area: facts;
    flex-wrap: wrap;
    gap: 3px 10px;
    padding-left: 31px;
  }

  .opt-fact {
    display: flex;
    align-items: baseline;
    gap: 3px;
  }

  .opt-fact dt {
    display: block;
    color: var(--ink-4);
    font-family: var(--sans);
    font-size: var(--text-micro);
    font-weight: var(--fw-medium);
    line-height: 1.3;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .opt-fact dd {
    font-size: var(--text-label);
    text-align: left;
  }

  .opt-trade-profit {
    grid-area: profit;
  }

  .opt-trade-profit b {
    font-size: var(--text-label);
  }

  .opt-trade-buy {
    grid-area: action;
    width: 38px;
    height: 36px;
    padding: 0;
    font-size: 0;
  }

  .opt-trade-buy-mark {
    width: 14px;
    height: 14px;
    flex-basis: 14px;
  }

  .opt-preview {
    min-height: 202px;
    padding: 26px 0 28px;
  }

  .opt-onboarding {
    gap: 9px;
  }

  .opt-start-steps {
    gap: 4px 14px;
  }

  .opt-skipped-menu {
    top: 50px;
    right: 16px;
    width: min(310px, calc(100% - 32px));
  }
}

@media (max-width: 620px) {
  .shell[data-screen="optimizer"] .workspace {
    padding-bottom: 14px;
  }

  .opt-mast {
    padding: 12px 0 0;
  }

  .opt-mast .page-crumb {
    margin-bottom: 6px;
  }

  .opt-screen {
    gap: 14px;
    margin-top: 12px;
  }

  .opt-setup {
    padding: 0 16px 2px;
  }

  .opt-controls {
    gap: 10px 8px;
  }

  .opt-input {
    height: 40px;
    font-size: var(--text-label);
  }

  .opt-input-cash {
    height: 44px;
    padding-right: 38px;
  }

  .opt-chip {
    min-width: 0;
    height: 28px;
    flex: 1 1 0;
    padding: 0 7px;
    font-size: var(--text-micro);
  }

  .opt-slot {
    height: 40px;
  }

  .opt-select-wrap select {
    height: 40px;
  }

  .opt-run {
    width: 100%;
    min-width: 0;
    height: 52px;
    justify-content: center;
    gap: 8px;
  }

  .opt-strategy-help {
    margin-top: 8px;
    font-size: var(--text-micro);
  }

  .opt-board {
    padding: 16px;
  }

  .opt-board-head {
    flex-wrap: wrap;
    align-items: flex-start;
    padding-bottom: 8px;
  }

  .opt-board-title {
    gap: 3px 8px;
  }

  .opt-status {
    font-size: var(--text-micro);
  }

  .opt-update {
    gap: 6px;
    padding-left: 7px;
  }

  .opt-update-copy {
    display: none;
  }

  .opt-summary {
    gap: 4px 14px;
    padding: 2px 0 12px;
  }

  .opt-trade {
    grid-template-columns: 20px 26px minmax(0, 1fr) auto 36px;
    gap: 3px 6px;
    padding: 9px 0;
  }

  .opt-icon-box {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .opt-trade-facts {
    padding-left: 0;
    gap: 3px 8px;
  }

  .opt-fact-cost {
    display: none;
  }

  .opt-trade-buy {
    width: 36px;
    height: 34px;
  }

  .opt-skipped-menu {
    right: 16px;
    left: 16px;
    width: auto;
  }
}

@media (max-width: 380px) {
  .opt-trade {
    grid-template-columns: 18px 24px minmax(0, 1fr) 36px;
    grid-template-areas:
      "slot icon id action"
      "profit profit profit profit"
      "facts facts facts facts";
  }

  .opt-icon-box {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .opt-icon,
  .opt-icon-fallback {
    width: 22px;
    height: 22px;
  }

  .opt-trade-profit {
    grid-area: profit;
    padding-top: 2px;
  }

  .opt-trade-profit b {
    text-align: right;
  }
}

@media (pointer: coarse) {
  .opt-chip {
    min-height: 30px;
  }

  .opt-skipped,
  .opt-skipped-restore {
    min-height: 32px;
  }

  .opt-sample {
    min-height: 40px;
  }

  .opt-trade-buy {
    min-height: 36px;
  }

  .opt-update-btn {
    min-height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .opt-screen *,
  .opt-screen *::before,
  .opt-screen *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
