:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #667085;
  --line: #d8dee6;
  --surface: #ffffff;
  --wash: #f4f6f8;
  --teal: #087f73;
  --teal-dark: #06685f;
  --amber: #b96b08;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--wash); color: var(--ink); font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.ds-header {
  min-height: 72px; padding: 14px clamp(16px, 3vw, 42px); background: #14212a; color: white;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.ds-header h1 { margin: 2px 0 0; font-size: 23px; letter-spacing: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.ds-header .secondary { background: transparent; border-color: #71808b; color: white; }
.back-link { color: #9de2d9; text-decoration: none; font-size: 12px; font-weight: 700; }
main { width: min(1480px, 100%); margin: 0 auto; padding: 20px clamp(12px, 2.5vw, 34px) 48px; }
.status-band {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid #b8dcd7;
  background: #edf9f7; color: #245c56; margin-bottom: 16px;
}
.status-band span:last-child { color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.workspace { background: var(--surface); border: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; }
.section-head.compact { padding: 0 0 12px; }
.section-head h2, .section-head h3 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.primary, .secondary, .icon-button {
  min-height: 36px; border: 1px solid transparent; border-radius: 5px; padding: 7px 13px; font-weight: 700;
}
.download-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.primary { background: var(--teal); color: white; }
.primary:hover { background: var(--teal-dark); }
.secondary { background: white; border-color: #aeb7c2; color: var(--ink); }
.icon-button { width: 36px; padding: 0; background: transparent; color: var(--muted); font-size: 18px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #e7eaee; vertical-align: top; }
th { background: #f8f9fa; color: #475467; font-size: 12px; text-transform: uppercase; }
td strong { display: block; }
.muted { color: var(--muted); font-size: 12px; margin-top: 3px; }
.badge { display: inline-flex; padding: 3px 7px; border-radius: 4px; background: #edf9f7; color: #12675f; font-weight: 700; font-size: 11px; }
.pnl-positive { color: #087f5b; }
.pnl-negative { color: var(--danger); }
.actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.actions button { border: 1px solid var(--line); background: white; border-radius: 4px; padding: 5px 8px; }
.actions .delete { color: var(--danger); }
.empty-state { padding: 42px 18px; text-align: center; color: var(--muted); }

dialog { width: min(1180px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; box-shadow: 0 18px 60px #0004; }
dialog::backdrop { background: #10182099; }
#strategyForm { padding: 20px; overflow-y: auto; max-height: calc(100vh - 24px); }
.dialog-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 18px; }
.dialog-head h2 { margin: 2px 0 0; font-size: 21px; }
.eyebrow { margin: 0; color: var(--teal); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.form-grid { display: grid; gap: 12px; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.wide-field { grid-column: span 3; }
label { display: flex; flex-direction: column; gap: 5px; color: #475467; font-size: 12px; font-weight: 700; }
input, select { width: 100%; min-height: 38px; border: 1px solid #b9c1cb; border-radius: 5px; padding: 7px 9px; color: var(--ink); background: white; }
input:focus, select:focus { outline: 2px solid #9adbd3; border-color: var(--teal); }
.form-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-section > h3 { margin: 0 0 12px; font-size: 15px; }
.symbol-field { position: relative; }
.suggestions { position: absolute; z-index: 5; top: 61px; width: 100%; max-height: 230px; overflow-y: auto; background: white; border: 1px solid #aeb7c2; box-shadow: 0 8px 22px #0002; }
.suggestions button { display: block; width: 100%; border: 0; border-bottom: 1px solid #edf0f2; background: white; padding: 9px; text-align: left; }
.suggestions button:hover { background: #edf9f7; }
.leg-list { display: grid; gap: 8px; }
.leg-row { display: grid; grid-template-columns: repeat(8, minmax(90px, 1fr)) 36px; gap: 8px; align-items: end; background: #f8f9fa; border: 1px solid var(--line); padding: 10px; }
.remove-leg { width: 36px; height: 38px; border: 1px solid #e4b9b5; background: white; color: var(--danger); border-radius: 4px; }
.preview-actions { margin-top: 12px; }
.ladder-preview { margin-top: 12px; border-left: 3px solid var(--amber); background: #fff8ed; padding: 12px; }
.preview-metrics { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 10px; }
.preview-metrics strong { display: block; font-size: 16px; }
.preview-entries { display: flex; flex-wrap: wrap; gap: 7px; }
.preview-entry { background: white; border: 1px solid #e7c896; border-radius: 4px; padding: 6px 8px; }
.form-error { margin-top: 14px; padding: 10px; background: #fff1f0; border: 1px solid #f3b7b2; color: var(--danger); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.analysis-dialog { padding: 20px; }
.analysis-metrics { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 16px; }
.analysis-metric { background: white; padding: 11px; }
.analysis-metric span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.analysis-metric strong { display: block; margin-top: 4px; font-size: 15px; }
.analysis-block { margin-top: 18px; }
.analysis-block h3 { margin: 0 0 8px; font-size: 15px; }
.analysis-block .table-wrap { border: 1px solid var(--line); max-height: 300px; overflow: auto; }
.analysis-block table { min-width: 900px; }
.actions { display: flex; gap: 4px; flex-wrap: nowrap; }
.icon-action {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
}
.icon-action:hover { background: #eef7f5; border-color: var(--teal); }
.icon-action.danger { color: var(--danger); }
.icon-action:disabled { opacity: .35; cursor: not-allowed; }
[hidden] { display: none !important; }

@media (max-width: 900px) {
  .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wide-field { grid-column: span 1; }
  .leg-row { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
  .analysis-metrics { grid-template-columns: repeat(3, minmax(90px, 1fr)); }
}
@media (max-width: 560px) {
  .ds-header { align-items: flex-end; }
  .ds-header h1 { font-size: 19px; }
  .status-band { align-items: flex-start; flex-wrap: wrap; }
  .form-grid.four, .leg-row { grid-template-columns: 1fr; }
  #strategyForm { padding: 14px; }
  .header-actions { align-items: stretch; flex-direction: column; }
  .analysis-metrics { grid-template-columns: repeat(2, minmax(80px, 1fr)); }
}
