:root {
  color-scheme: light;
  --ink: #18202f;
  --muted: #687184;
  --line: #dde3ea;
  --panel: #ffffff;
  --canvas: #f6f8fb;
  --brand: #0f766e;
  --brand-dark: #0b4f4a;
  --accent: #c2410c;
  --gold: #a16207;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --shadow: 0 18px 50px rgba(24, 32, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 360px),
    #eef2f5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  min-height: 250px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: end;
  padding: 34px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.7)),
    url("data:image/svg+xml,%3Csvg width='1200' height='500' viewBox='0 0 1200 500' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1200' height='500' fill='%23dfe9ee'/%3E%3Cg opacity='.55'%3E%3Cpath d='M0 360 C95 330 150 383 230 332 S390 243 500 291 663 414 780 331 947 143 1070 205 1180 274 1200 236' fill='none' stroke='%230f766e' stroke-width='7'/%3E%3Cpath d='M0 230 C130 196 202 244 290 206 S466 101 595 158 753 279 882 197 1010 89 1200 122' fill='none' stroke='%23c2410c' stroke-width='4'/%3E%3Cpath d='M60 430 H1140 M80 390 H1140 M100 350 H1140 M120 310 H1140 M140 270 H1140 M160 230 H1140' stroke='%2395a3b3' stroke-width='1'/%3E%3C/g%3E%3Cg fill='%2318202f' opacity='.55'%3E%3Ccircle cx='235' cy='331' r='8'/%3E%3Ccircle cx='502' cy='292' r='8'/%3E%3Ccircle cx='780' cy='331' r='8'/%3E%3Ccircle cx='1072' cy='206' r='8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 14px;
  font-size: clamp(38px, 7vw, 78px);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.2;
}

.hero-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: #344054;
  font-size: 18px;
  line-height: 1.7;
}

.market-pulse {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(24, 32, 47, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
}

.market-pulse strong,
.market-pulse small {
  display: block;
}

.market-pulse small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.pulse-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(194, 65, 12, 0.15);
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 150px 170px 220px auto minmax(150px, 0.95fr) auto;
  gap: 12px;
  align-items: end;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  padding: 0 12px;
}

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

.auto-refresh-control {
  align-self: stretch;
}

.auto-refresh-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
}

.auto-refresh-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
}

.auto-refresh-row small {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.primary-action {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 18px;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.22);
}

.primary-action:hover {
  background: var(--brand-dark);
}

.secondary-action {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.secondary-action:hover {
  border-color: rgba(15, 118, 110, 0.55);
  color: var(--brand-dark);
}

.secondary-action:disabled {
  cursor: wait;
  opacity: 0.64;
}

.quote-status {
  margin: -6px 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
}

.quote-status[data-tone="loading"] {
  color: var(--brand-dark);
  border-color: rgba(15, 118, 110, 0.3);
  background: #ecfdf5;
}

.quote-status[data-tone="success"] {
  color: var(--good);
  border-color: rgba(21, 128, 61, 0.24);
  background: #f0fdf4;
}

.quote-status[data-tone="error"] {
  color: var(--bad);
  border-color: rgba(185, 28, 28, 0.24);
  background: #fef2f2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(340px, 0.98fr) minmax(440px, 1.24fr);
  gap: 18px;
  align-items: stretch;
  min-height: clamp(620px, 70vh, 920px);
}

.panel,
.strategy-column {
  min-width: 0;
  min-height: 0;
}

.panel,
.strategy-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(24, 32, 47, 0.08);
}

.universe-panel,
.strategy-column,
.calculator-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px;
}

.strategy-filter-panel {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.strategy-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
}

.strategy-filter-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.compact-action {
  min-height: 40px;
  white-space: nowrap;
  grid-column: 2 / 4;
  width: 100%;
}

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

.badge,
.score-badge {
  display: inline-grid;
  min-width: 42px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #ecfdf5;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.score-badge {
  min-width: 58px;
  background: #fff7ed;
  color: var(--accent);
}

.universe-list,
.strategy-list {
  display: grid;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.universe-list::-webkit-scrollbar,
.strategy-list::-webkit-scrollbar,
.calculator-panel::-webkit-scrollbar {
  width: 8px;
}

.universe-list::-webkit-scrollbar-thumb,
.strategy-list::-webkit-scrollbar-thumb,
.calculator-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}

.calculator-panel {
  overflow: auto;
}

.asset-card,
.strategy-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.asset-card {
  padding: 12px;
}

.strategy-card {
  padding: 15px;
}

.strategy-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.asset-card:hover,
.strategy-card:hover,
.asset-card.active,
.strategy-card.active {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 12px 24px rgba(24, 32, 47, 0.1);
}

.strategy-card {
  position: relative;
  border-color: #d7e0eb;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow:
    0 8px 20px rgba(24, 32, 47, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.75) inset;
}

.strategy-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.75), rgba(194, 65, 12, 0.55));
  opacity: 0.65;
}

.strategy-card:hover,
.strategy-card.active {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.5);
  box-shadow: 0 14px 28px rgba(24, 32, 47, 0.14);
}

.card-top,
.strategy-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.ticker {
  display: block;
  font-size: 19px;
  font-weight: 900;
}

.asset-name,
.strategy-kind,
.card-note {
  color: var(--muted);
  font-size: 12px;
}

.asset-stats,
.strategy-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.asset-stats span,
.strategy-stats span {
  display: grid;
  gap: 2px;
  padding: 7px;
  border-radius: 7px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 11px;
}

.asset-stats strong,
.strategy-stats strong {
  color: var(--ink);
  font-size: 13px;
}

.strategy-card h3 {
  margin: 0 0 5px;
  font-size: 18px;
}

.strategy-card p {
  margin: 10px 0 0;
  color: #4b5563;
  line-height: 1.5;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.metrics-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
}

.metrics-grid small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-weight: 800;
}

.metrics-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

#payoffChart {
  display: block;
  width: 100%;
  height: auto;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.score-grid div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

meter {
  width: 100%;
  height: 12px;
}

.legs-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.legs-header,
.leg-row {
  display: grid;
  grid-template-columns: 0.9fr 0.8fr 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.legs-header {
  padding: 10px 12px;
  color: var(--muted);
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 900;
}

.leg-row {
  padding: 11px 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.leg-row strong {
  color: var(--brand-dark);
}

.strike-input {
  width: 100%;
  min-height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: #1f2937;
  font-size: 13px;
}

.calibration-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.calibration-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.calibration-head h3 {
  margin: 0;
  font-size: 14px;
  color: #334155;
}

.calibration-type-tag {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.calibration-grid {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.calibration-grid input,
.calibration-grid select {
  min-height: 36px;
}

.rationale {
  margin: 14px 0 0;
  color: #475569;
  line-height: 1.6;
}

.summary-box {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 300px;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.summary-head h3 {
  margin: 0;
  font-size: 14px;
  color: #334155;
}

.summary-copy-btn {
  min-height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.summary-copy-btn:hover {
  border-color: rgba(15, 118, 110, 0.45);
  color: var(--brand-dark);
}

.summary-textarea {
  width: 100%;
  min-height: 300px;
  border: 1px solid #d1d9e6;
  border-radius: 7px;
  resize: none;
  overflow: hidden;
  padding: 10px 11px;
  line-height: 1.5;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
  flex: 1;
}

.grade-good {
  background: #dcfce7;
  color: var(--good);
}

.grade-warn {
  background: #fef3c7;
  color: var(--warn);
}

.grade-bad {
  background: #fee2e2;
  color: var(--bad);
}

@media (max-width: 1180px) {
  .hero,
  .workspace,
  .control-bar {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: 0;
  }

  .universe-list,
  .strategy-list,
  .calculator-panel {
    overflow: visible;
    padding-right: 0;
  }

  .market-pulse {
    max-width: 520px;
  }

  .strategy-filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .strategy-filter-actions {
    grid-template-columns: 1fr 1fr;
  }

  .compact-action {
    grid-column: 1 / -1;
    width: 100%;
  }

  .strategy-list {
    max-height: none;
    min-height: 0;
  }

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

  .calibration-grid .secondary-action {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 10px;
  }

  .hero {
    padding: 22px;
  }

  h1 {
    font-size: 42px;
  }

  .hero-copy {
    font-size: 15px;
  }

  .metrics-grid,
  .score-grid,
  .asset-stats,
  .strategy-stats {
    grid-template-columns: 1fr;
  }

  .score-grid div {
    grid-template-columns: 1fr;
  }

  .summary-box,
  .summary-textarea {
    min-height: 220px;
  }

  .strategy-filter-grid {
    grid-template-columns: 1fr;
  }

  .strategy-filter-actions {
    margin-top: 8px;
    grid-template-columns: 1fr;
  }

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