@charset "UTF-8";
:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #233344;
  background: #f6f7f9;
  font-synthesis: none;
  font-size: 14px;
  --ink: #233344;
  --muted: #566575;
  --line: #e5e9ed;
  --teal: #087f7a;
  --blue: #487dc0;
  --orange: #bb782e;
  --positive: #076f59;
  --negative: #a33836;
  --panel: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

input,
select {
  height: 36px;
  border: 1px solid #dce2e7;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  min-width: 0;
  line-height: 1.2;
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

input:hover,
select:hover {
  border-color: #b7c4ce;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
summary:focus-visible,
a:focus-visible,
.plot-container:focus-visible {
  outline: 2px solid #44a69c;
  outline-offset: 2px;
}

#analyzer[aria-busy="false"]
  :is(
    input:invalid,
    input.invalid,
    input[aria-invalid="true"],
    select[aria-invalid="true"]
  ) {
  border-color: #ce6964;
}

input[type="checkbox"] {
  accent-color: var(--teal);
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
}

input[type="range"] {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  accent-color: var(--teal);
  width: 100%;
  height: 24px;
  cursor: pointer;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: #586a7b;
}

label > input:not([type="range"]):not([type="checkbox"]),
label > select {
  display: block;
  width: 100%;
  margin-top: 7px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  letter-spacing: -0.65px;
  font-weight: 680;
  line-height: 1.3;
}

h2 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.15px;
}

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 36px;
}

.startup-status {
  margin: 32px 0;
  color: var(--muted);
}

.app-header {
  min-height: 88px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  background: #e3efed;
  border: 1px solid #d5e7e3;
  color: var(--teal);
  height: 44px;
  width: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 37px;
  font-family: Georgia, serif;
  padding: 0 0 5px;
  flex-shrink: 0;
}

.brand p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.position-bar {
  padding: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.position-name-label {
  font-size: 12px;
  letter-spacing: 1.3px;
  font-weight: 650;
  min-width: 180px;
  flex: 1;
  max-width: 360px;
}

.position-name-label > input {
  font-size: 20px;
  font-weight: 550;
  letter-spacing: -0.5px;
  border-color: transparent;
  background: transparent;
  padding: 2px 0;
  height: 32px;
  margin-top: 4px;
  border-radius: 0;
}

.position-name-label > input:hover {
  border-bottom-color: #c7d1d9;
}

.file-controls {
  position: relative;
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-controls select {
  max-width: 190px;
  font-size: 12px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  gap: 6px;
  border: 1px solid #dce2e7;
  border-radius: 6px;
  background: #fff;
  color: #3f5265;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 550;
  line-height: 18px;
  min-height: 36px;
  text-decoration: none;
  transition:
    background 0.12s,
    border-color 0.12s;
}

.button:hover {
  background: #f2f6f7;
  border-color: #bccbd2;
}

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

.button.primary:hover {
  background: #056e6a;
}

.button.quiet {
  border-color: transparent;
  background: transparent;
  color: #617181;
}

.button.quiet:hover {
  background: #eef2f4;
  color: #354e63;
}

.button.small {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.button.icon {
  padding: 4px 6px;
  width: 27px;
  min-height: 28px;
  font-size: 16px;
  line-height: 18px;
}

.button.danger:hover {
  color: var(--negative);
  background: #fcf1f0;
}

.button-group {
  display: flex;
  gap: 6px;
}

.share-dialog,
.touch-editor-dialog {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
}

.share-dialog {
  width: min(620px, calc(100% - 32px));
  box-shadow: 0 16px 60px #23334430;
}

.share-dialog::backdrop,
.share-dialog-heading,
.share-link-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share-dialog-heading {
  justify-content: space-between;
}

.share-dialog p {
  margin: 12px 0;
  line-height: 1.5;
}

.share-link-controls {
  margin-top: 7px;
}

.share-link-controls input {
  flex: 1;
  width: 0;
}

#share-status {
  margin-bottom: 0;
  font-size: 12px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px #21354703;
}

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

.heading-group {
  display: flex;
  gap: 9px;
  align-items: center;
}

.muted {
  font-size: 12px;
  font-weight: 450;
  color: var(--muted);
}

.unit {
  font-size: 12px;
  font-weight: 400;
  color: #636d78;
  float: right;
}

.market-panel {
  margin-bottom: 16px;
}

.market-fields {
  padding: 0 20px 16px;
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1fr 1fr 1fr;
  gap: 22px;
}

.market-fields input {
  font-size: 13px;
}

.legs-panel {
  margin-bottom: 16px;
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 21px;
  height: 19px;
  padding: 0 5px;
  background: #f0f4f5;
  border-radius: 4px;
  font-size: 12px;
  color: #637079;
}

.table-scroll {
  position: relative;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.legs-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 12px;
}

.legs-table thead {
  background: #f8fafb;
}

.legs-table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.3px;
  color: #646e78;
  font-weight: 550;
  padding: 10px 4px;
  border-top: 1px solid #edf0f3;
  border-bottom: 1px solid #edf0f3;
}

.legs-table th:first-child {
  padding-left: 20px;
}

.legs-table td {
  height: 88px;
  padding: 6px 4px;
  border-bottom: 1px solid #eef1f4;
}

#legs-body td {
  padding-top: 3px;
  padding-bottom: 3px;
}

.legs-table td:first-child {
  padding-left: 20px;
  padding-right: 10px;
}

.legs-table td:last-child {
  padding-right: 16px;
}

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

.legs-table input,
.legs-table select {
  height: 31px;
  font-size: 12px;
  padding: 5px 4px;
  width: 100%;
  margin: 0;
}

.legs-table input[type="checkbox"] {
  height: 15px;
  width: 15px;
}

.legs-table :is(.leg-entry, .leg-quote, .leg-volatility) {
  appearance: textfield;
  -moz-appearance: textfield;
}

.legs-table
  :is(.leg-entry, .leg-quote, .leg-volatility)::-webkit-inner-spin-button {
  appearance: none;
}

.legs-table
  :is(.leg-quantity, .strategy-ratio, .leg-strike)::-webkit-inner-spin-button {
  opacity: 1;
}

.legs-table .leg-side {
  width: 50px;
}

.legs-table .leg-strategy {
  width: 100px;
}

.strategy-stack {
  display: grid;
  grid-template-rows: repeat(var(--strategy-leg-count), 18px);
  gap: 2px;
}

.legs-table .strategy-stack input,
.legs-table .strategy-stack select {
  height: 100%;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: 3px;
}

.legs-table .strategy-ratio {
  width: 44px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.legs-table .leg-quantity {
  width: 52px;
}

.legs-table .leg-kind {
  width: 52px;
}

.legs-table .leg-strike {
  width: 76px;
}

.legs-table .leg-expiry {
  width: 116px;
}

.legs-table .leg-style {
  width: 86px;
}

.legs-table .leg-entry {
  width: 64px;
}

.leg-volatility-control {
  position: relative;
  width: 64px;
  height: 31px;
}

.strategy-stack .leg-volatility-control {
  height: 100%;
}

.legs-table .leg-volatility {
  width: 100%;
  padding-right: 19px;
}

.leg-volatility::placeholder {
  color: #7d8790;
  opacity: 1;
}

.iv-steppers {
  position: absolute;
  top: 1px;
  right: 2px;
  bottom: 1px;
  width: 15px;
  display: grid;
  grid-template-rows: 1fr 1fr;
}

.iv-step {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #737d87;
  font-size: 10px;
  line-height: 7px;
}

.iv-step:hover {
  background: #edf1f4;
  color: #233344;
}

.leg-pricing {
  width: 62px;
}

.legs-table .leg-quote {
  width: 100%;
}

.leg-actions {
  display: flex;
  gap: 2px;
}

.leg-disabled {
  background: #f4f6f7;
}

.leg-disabled:focus-within {
  background: #eaf1f3;
}

.empty-legs {
  text-align: center !important;
  padding: 26px !important;
  color: #636d78;
}

.cell-na {
  color: #696f74;
  padding-left: 7px;
}

.panel-footnote {
  font-size: 12px;
  line-height: 1.6;
  color: #636d78;
  padding: 10px 20px 14px;
  margin: 0;
}

.metrics-grid,
.analysis-layout,
.details-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.metrics-grid {
  margin-bottom: 16px;
}

.metric {
  min-height: 100px;
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
  row-gap: 4px;
  padding: 14px 20px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.metric.primary-metric {
  background: #edf5f3;
  border-color: #d6e7e2;
}

.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.9px;
  font-size: 12px;
  color: #607079;
  font-weight: 600;
  line-height: 1.35;
}

.metric strong {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.9px;
  line-height: 1.3;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.metric-note {
  font-size: 12px;
  line-height: 1.4;
  color: #656e75;
}

.metric .status-value {
  font-size: 16px;
  letter-spacing: -0.2px;
  line-height: 32.5px;
  color: #55736b;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.analysis-layout {
  margin-bottom: 18px;
}

.analysis-layout > .chart-panel {
  grid-column: span 3;
}

.details-layout > .panel {
  grid-column: span 2;
}

.section-description {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.5;
}

.chart-panel .section-heading {
  padding-bottom: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.chart-tools {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chart-metric-control {
  display: grid;
  gap: 5px;
  color: #62707b;
  font-size: 12px;
}

.chart-metric-control select {
  width: 116px;
  height: 30px;
  font-size: 12px;
}

.chart-unit {
  margin: 0;
  padding: 0 20px 4px;
  font-size: 12px;
  color: #646e78;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 17px;
  padding: 0 20px 12px;
}

.chart-legend label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
  color: #62707b;
  cursor: pointer;
}

.chart-legend input[type="checkbox"] {
  width: 12px;
  height: 12px;
  accent-color: #758da1;
}

.legend-swatch {
  width: 17px;
  height: 2px;
  display: inline-block;
}

.legend-valuation .legend-swatch {
  background: var(--blue);
}

.legend-selected .legend-swatch {
  background: var(--teal);
  height: 3px;
}

.legend-expiry .legend-swatch {
  background: var(--orange);
}

.plot-container {
  height: 310px;
  width: 100%;
  position: relative;
  padding: 0 12px;
}

.chart-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: #646e77;
  font-size: 12px;
}

.uplot {
  font-family: inherit;
  font-size: 12px !important;
}

.chart-readout {
  height: 30px;
  padding: 7px 24px 0;
  font-size: 12px;
  color: #62707b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-axis-label {
  text-align: center;
  font-size: 12px;
  color: #646e78;
  padding-bottom: 13px;
}

.chart-range {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid #eef1f4;
  padding: 12px 15px;
  font-size: 12px;
  color: #657079;
  background: #fcfdfd;
}

.chart-range input {
  width: 77px;
  height: 28px;
  font-size: 12px;
  margin: 0 !important;
}

.chart-range .button {
  margin-left: 3px;
}

.scenario-panel .section-heading {
  padding: 14px 17px;
}

.scenario-panel h2 {
  font-size: 12px;
}

.scenario-panel .button {
  padding: 4px;
  font-size: 12px;
}

.scenario-control {
  padding: 0 19px;
  margin-bottom: 16px;
}

.scenario-control > input:not([type="range"]) {
  width: 100%;
  margin-top: 8px;
  font-size: 13px;
}

.scenario-control > input[type="range"] {
  margin-top: 7px;
}

.range-captions {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #656e74;
  gap: 5px;
}

.field-hint {
  font-size: 12px;
  line-height: 1.5;
  color: #656f78;
  margin-top: 2px;
}

.scenario-caption {
  border-top: 1px solid #edf0f2;
  margin: 0 19px;
  padding: 13px 0;
  font-size: 12px;
  color: #656f78;
  line-height: 1.6;
}

.greeks-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 3px 0 5px;
  padding: 0 20px;
  gap: 12px;
}

.greeks-grid dt {
  font-size: 12px;
  color: #616e79;
  margin-bottom: 6px;
}

.greeks-grid dd {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  margin: 0 0 4px;
  font-weight: 500;
  letter-spacing: -0.6px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.greeks-grid span {
  display: block;
  font-size: 12px;
  color: #666f75;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.payoff-panel .section-heading {
  padding-bottom: 0;
}

.payoff-panel > .section-description {
  padding: 0 20px;
}

.payoff-list {
  padding: 2px 20px 6px;
  margin: 10px 0;
}

.payoff-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0;
}

.payoff-list dt {
  font-size: 12px;
  color: #626d78;
}

.payoff-list dd {
  font-size: 12px;
  line-height: 1.4;
  font-weight: 550;
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.notice,
.validation-errors,
.analysis-warnings,
.pricing-notices {
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px solid #cbdfe6;
  background: #eef5f8;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.6;
  color: #486b80;
}

.notice.error,
.validation-errors {
  background: #fff4f2;
  border-color: #efd6cf;
  color: #a35749;
}

.notice.success {
  background: #edf6f1;
  border-color: #cfe7da;
  color: #3c785c;
}

.analysis-warnings {
  margin-top: 18px;
  background: #fff9ed;
  border-color: #eee2c8;
  color: #876730;
  font-size: 12px;
}

.position-footer {
  --help-width: 132px;
  display: grid;
  grid-template-columns: var(--help-width) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 0 20px 10px;
}

.pricing-notices {
  grid-area: 1 / 2;
  height: 40px;
  margin: 0;
  padding: 0;
  line-height: 16px;
  overflow: hidden;
  white-space: normal;
}

.validation-errors ul,
.analysis-warnings ul {
  padding-left: 20px;
  margin: 4px 0;
}

.model-notes {
  margin: 23px 0;
  color: #657079;
  font-size: 12px;
}

.model-notes summary {
  cursor: pointer;
  width: fit-content;
  font-weight: 500;
  padding: 4px 0;
}

.model-notes > div {
  max-width: 1100px;
  padding-top: 10px;
}

.model-notes p {
  font-size: 12px;
  line-height: 1.8;
  color: #616d78;
  margin: 0 0 8px;
}

.model-notes.position-help {
  grid-area: 1 / 1 / 2 / -1;
  min-width: 0;
  margin: 0;
}

.position-help summary {
  /* Messages share this header so fitting never shifts controls during a click. */
  width: var(--help-width);
  height: 40px;
  padding: 12px 0;
  line-height: 16px;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 19px 0 28px;
  color: #687076;
  font-size: 12px;
  letter-spacing: 0.2px;
}

.app-footer span:first-child {
  font-size: 12px;
  letter-spacing: 1px;
  font-weight: 600;
}

.footer-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.feedback-link {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: inherit;
}

.feedback-link:hover {
  color: var(--ink);
}

.import-shell {
  max-width: 1240px;
}

.import-shell .brand-mark {
  text-decoration: none;
}

.import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  margin: 24px 0;
}

.import-panel {
  min-width: 0;
  padding: 24px;
  line-height: 1.6;
}

.import-panel p {
  margin: 12px 0;
  font-size: 13px;
}

.import-panel label {
  margin: 20px 0 8px;
  font-size: 12px;
}

#import-json {
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #dce2e7;
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  font:
    13px/1.6 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.import-error {
  color: var(--negative);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#import-status {
  color: var(--muted);
}

#import-preview {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 20px;
}

#import-list {
  padding-left: 24px;
  max-height: 360px;
  overflow-y: auto;
}

#import-list li {
  margin: 12px 0;
  overflow-wrap: anywhere;
}

#import-list strong,
#import-list span {
  display: block;
}

#import-list span {
  color: var(--muted);
  font-size: 12px;
}

.import-guide details {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.import-guide summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.import-guide code {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.import-guide pre {
  padding: 12px;
  background: #f6f7f9;
  border-radius: 6px;
  overflow-x: auto;
}

.import-fields {
  font-size: 13px;
}

.import-fields dt {
  margin-top: 12px;
  font-weight: 600;
}

.import-fields dd {
  margin: 4px 0;
  color: var(--muted);
}

@media (max-width: 800px) {
  .import-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin: 16px 0;
  }

  .import-panel {
    padding: 18px;
  }

  #import-json {
    font-size: 16px;
  }

  .import-shell .app-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 0;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.results-stale .metric strong:not(.status-value),
.results-stale .greeks-grid dd,
.results-stale .payoff-list dd {
  color: #566575;
}

.results-stale .plot-container {
  filter: grayscale(1);
}

.results-stale .status-value {
  color: #8d6834;
}

.quote-pending {
  opacity: 0.65;
}

.legs-table .pricing-warning {
  border-color: #c8b89d;
}

.legs-table .pricing-error {
  border-color: var(--negative);
}

#legs-body .field-error {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (min-width: 1450px) {
  .plot-container {
    height: 340px;
  }

  .scenario-control {
    margin-bottom: 25px;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    padding: 0 24px;
  }

  .position-bar {
    align-items: flex-start;
  }

  .file-controls {
    max-width: 540px;
  }

  .analysis-layout {
    grid-template-columns: minmax(0, 1fr) 250px;
    gap: 14px;
  }

  .metrics-grid {
    grid-template-columns: 1.1fr 1fr 1fr 1fr;
    gap: 10px;
  }

  .analysis-layout > .chart-panel,
  .details-layout > .panel {
    grid-column: auto;
  }

  .metric {
    padding: 15px;
  }

  .metric strong {
    font-size: 22px;
  }

  .market-fields {
    gap: 14px;
  }

  .details-layout {
    grid-template-columns: 1.3fr 1fr;
    gap: 14px;
  }

  .greeks-grid {
    padding: 0 15px;
    gap: 8px;
  }

  .greeks-grid dd {
    font-size: 17px;
  }
}

@media (max-width: 800px) {
  .app-shell {
    padding: 0 16px;
  }

  .app-header {
    min-height: 76px;
  }

  .position-bar {
    padding: 12px 0;
    display: block;
  }

  .position-name-label {
    max-width: 100%;
    margin-bottom: 10px;
  }

  .file-controls {
    max-width: none;
    justify-content: flex-start;
  }

  .file-controls .button {
    min-height: 32px;
    padding: 6px 9px;
  }

  .file-controls select {
    height: 32px;
    flex: 1;
  }

  .market-fields {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
  }

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

  .metric {
    min-height: 98px;
  }

  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .scenario-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    order: -1;
  }

  .scenario-panel > .section-heading {
    grid-column: 1/-1;
    padding: 12px 15px;
  }

  .scenario-control {
    padding: 0 12px;
    margin-bottom: 8px;
  }

  .scenario-control .unit {
    float: none;
  }

  .scenario-control label {
    min-height: 32px;
    line-height: 16px;
  }

  .scenario-caption {
    grid-column: 1/-1;
    margin: 0 15px;
    padding: 8px 0;
    line-height: 1.4;
  }

  .details-layout {
    grid-template-columns: 1fr;
  }

  .greeks-grid {
    padding: 0 20px;
  }

  .greeks-grid dd {
    font-size: 21px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: 0 12px;
  }

  h1 {
    font-size: 18px;
  }

  .brand-mark {
    height: 38px;
    width: 38px;
    font-size: 32px;
  }

  .brand {
    gap: 10px;
  }

  .market-fields {
    grid-template-columns: 1fr 1fr;
    padding: 0 15px 14px;
  }

  .market-fields label:first-child {
    grid-column: 1/-1;
  }

  .section-heading {
    padding: 12px 15px 10px;
  }

  .file-controls {
    gap: 5px;
  }

  .file-controls select {
    max-width: none;
    width: 100%;
    flex-basis: 100%;
  }

  .file-controls .button {
    flex-grow: 1;
  }

  .metrics-grid {
    gap: 8px;
  }

  .metric {
    padding: 13px 12px;
    min-height: 102px;
  }

  .metric-note {
    line-height: 1.5;
  }

  .metric .status-value {
    font-size: 14px;
  }

  .chart-legend {
    padding-left: 15px;
    gap: 10px;
  }

  .chart-tools {
    width: 100%;
    justify-content: space-between;
  }

  .chart-unit {
    padding-left: 15px;
  }

  .chart-legend label {
    gap: 4px;
  }

  .legend-swatch {
    width: 12px;
  }

  .plot-container {
    padding: 0 5px;
    height: 280px;
  }

  .chart-readout {
    padding-left: 15px;
  }

  .chart-range {
    gap: 5px;
    padding: 10px 8px;
  }

  .chart-range input {
    width: 64px;
  }

  .chart-range .button {
    padding: 4px;
  }

  .scenario-panel {
    grid-template-columns: 1fr;
  }

  .scenario-control {
    padding: 0 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 138px;
    column-gap: 12px;
    align-items: center;
  }

  .scenario-control label {
    min-height: 0;
  }

  .scenario-control > input:not([type="range"]) {
    margin-top: 0;
    height: 32px;
  }

  .scenario-control > input[type="range"],
  .scenario-control > .range-captions,
  .scenario-control > .field-hint {
    grid-column: 1/-1;
  }

  .scenario-control > input[type="range"] {
    margin-top: 5px;
  }

  .scenario-control .unit {
    display: block;
    margin-top: 3px;
  }

  .greeks-grid {
    padding: 0 15px;
    gap: 9px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 18px;
  }

  .greeks-grid dd {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.field-error {
  display: block;
  max-width: 180px;
  margin-top: 5px;
  color: var(--negative);
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
}

.validation-errors a {
  color: inherit;
  text-decoration: underline;
}

.chart-help {
  margin: 4px 20px 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chart-help summary {
  width: fit-content;
  cursor: pointer;
  padding: 4px 0;
}

.chart-keyboard-help {
  margin: 4px 0 0;
}

.pricing-notices-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 3px 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pricing-notices-button:hover {
  background: #e3eef3;
}

.pricing-notices-button:focus-visible {
  outline: 2px solid #557f97;
  outline-offset: -3px;
}

.pricing-notices-preview {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pricing-notices-count {
  flex: none;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pricing-notices-dialog {
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 1px solid #cbd5dc;
  border-radius: 10px;
  color: #364652;
  background: #fff;
  box-shadow: 0 16px 64px #18263033;
}

.pricing-notices-dialog::backdrop {
  background: #18263066;
}

.pricing-notices-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pricing-notices-heading h2 {
  margin: 0;
  font-size: 18px;
}

.pricing-notices-list {
  display: grid;
  gap: 18px;
  padding: 0;
  margin: 20px 0 0;
  list-style: none;
}

.pricing-notice {
  min-width: 0;
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.pricing-notice p {
  margin: 6px 0 10px;
  white-space: pre-wrap;
}

.pricing-notices-dialog .button {
  min-height: 44px;
}

.touch-edit {
  display: none;
}

@media (max-width: 800px), (pointer: coarse) {
  .legs-table .touch-edit {
    display: block;
    margin-top: 6px;
    min-height: 44px;
    width: 100px;
  }
}

.touch-editor-dialog {
  width: min(700px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  /* Fit feedback must not move a control between pointer down and up. */
  margin: 12px auto auto;
  overflow: auto;
}

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

.touch-editor-heading .button {
  min-height: 44px;
}

.touch-editor-dialog .pricing-notices {
  height: 46px;
  margin: 16px 0 0;
}

.touch-editor-dialog .table-scroll {
  overflow: visible;
}

.touch-editor-dialog .legs-table,
.touch-editor-dialog tbody {
  display: block;
  white-space: normal;
}

.touch-editor-dialog thead,
.touch-editor-dialog .legs-table .touch-edit {
  display: none;
}

.touch-editor-dialog #legs-body tr:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
  background: transparent;
}

.touch-editor-dialog #legs-body td {
  display: block;
  min-width: 0;
  height: auto;
  border: 0;
  padding: 0;
}

.touch-editor-dialog #legs-body .cell-na {
  display: none;
}

.touch-editor-dialog td::before {
  content: attr(data-touch-label);
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.touch-editor-dialog .legs-table :is(input, select),
.touch-editor-dialog .leg-volatility-control,
.touch-editor-dialog .leg-pricing {
  width: 100%;
  height: 48px;
  font-size: 16px;
}

.touch-editor-dialog .legs-table input[type="checkbox"] {
  width: 28px;
  height: 28px;
  margin: 8px 0;
}

.touch-editor-dialog .strategy-stack {
  grid-template-rows: repeat(var(--strategy-leg-count), 48px);
  gap: 10px;
}

.touch-editor-dialog .legs-table .leg-volatility {
  padding-right: 44px;
}

.touch-editor-dialog .iv-steppers {
  top: 0;
  bottom: 0;
  width: 40px;
}

.touch-editor-dialog .iv-step {
  font-size: 14px;
  line-height: 18px;
}

.touch-editor-dialog .leg-actions {
  gap: 10px;
}

.touch-editor-dialog .leg-actions .button {
  width: 44px;
  min-height: 44px;
  font-size: 22px;
}

@media (max-width: 360px) {
  .touch-editor-dialog {
    padding: 12px;
    max-width: none;
  }

  .touch-editor-dialog #legs-body td:has(.leg-expiry) {
    grid-column: 1 / -1;
  }
}
