:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #182126;
  background: #f2f5f4;
  font-synthesis: none;
  --ink: #182126;
  --muted: #68757b;
  --line: #d7dedc;
  --line-strong: #b8c3c0;
  --paper: #ffffff;
  --wash: #f7f9f8;
  --green: #087b5d;
  --green-dark: #075b47;
  --green-soft: #e4f2ed;
  --copper: #b76525;
  --copper-soft: #faeadf;
  --red: #a43a36;
  --red-soft: #f9e9e7;
  --focus: #126e9c;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  min-width: 320px;
  margin: 0;
  background: #f2f5f4;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button,
summary,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(18, 110, 156, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 1560px);
  margin: 0 auto;
  background: var(--paper);
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.app-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.eyebrow,
.section-index {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.25;
}

.model-control {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--wash);
}

.model-button {
  min-height: 32px;
  padding: 5px 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.model-button.is-active {
  background: var(--ink);
  color: #fff;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  align-items: start;
}

.parameter-rail {
  position: sticky;
  top: 0;
  min-height: calc(100vh - 92px);
  padding: 24px 22px 28px;
  border-right: 1px solid var(--line);
  background: var(--wash);
}

.rail-heading,
.analysis-heading,
.chart-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.rail-heading {
  margin-bottom: 20px;
}

.parameter-count {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--paper);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.parameter-list {
  display: grid;
  gap: 17px;
}

.parameter-control {
  display: grid;
  gap: 9px;
}

.parameter-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.parameter-heading > span:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.parameter-heading b {
  font-size: 13px;
  font-weight: 650;
}

.parameter-heading small,
.feller-panel small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.parameter-heading output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.4;
  text-align: right;
  white-space: nowrap;
}

.parameter-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--green);
}

input[type="number"] {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

input[type="number"]:focus {
  border-color: var(--focus);
}

.feller-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 22px;
  padding: 12px;
  border-left: 3px solid var(--green);
  background: var(--green-soft);
}

.feller-panel > span:first-child {
  display: grid;
  gap: 2px;
}

.feller-panel b,
.feller-panel strong {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.feller-panel[data-state="warn"] {
  border-left-color: var(--copper);
  background: var(--copper-soft);
}

.status-chip {
  padding: 4px 6px;
  border: 1px solid rgba(8, 123, 93, 0.35);
  border-radius: 4px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.55);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.feller-panel[data-state="warn"] .status-chip {
  border-color: rgba(183, 101, 37, 0.4);
  color: #834719;
}

.contract-details {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.contract-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 45px;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
}

.contract-details summary::-webkit-details-marker {
  display: none;
}

.contract-details summary > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contract-details summary .section-index {
  margin: 0;
}

#contract-summary {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.contract-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px 12px;
  padding: 4px 0 16px;
}

.contract-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.preset-actions {
  display: grid;
  grid-template-columns: 0.85fr 1.4fr;
  gap: 8px;
  margin-top: 14px;
}

.preset-actions button {
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
}

.preset-actions button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.analysis {
  min-width: 0;
  padding: 25px 28px 42px;
}

.analysis-heading {
  align-items: center;
  margin-bottom: 17px;
}

.calculation-status {
  margin: 0;
  padding-left: 12px;
  border-left: 3px solid var(--green);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.calculation-status[data-state="loading"] {
  border-left-color: var(--copper);
}

.calculation-status[data-state="error"] {
  border-left-color: var(--red);
  color: var(--red);
}

.valuation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.valuation-card {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.valuation-card:last-child {
  border-right: 0;
}

.valuation-card.primary-metric {
  background: var(--ink);
  color: #fff;
}

.valuation-card span,
.valuation-card small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.valuation-card.primary-metric span,
.valuation-card.primary-metric small {
  color: #bfc9cc;
}

.valuation-card strong {
  display: block;
  overflow-wrap: anywhere;
  margin: 9px 0 6px;
  font-size: 23px;
  font-weight: 680;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.model-details {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 28px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.model-details div {
  min-width: 0;
  padding: 2px 12px;
  border-right: 1px solid var(--line);
}

.model-details div:first-child {
  padding-left: 0;
}

.model-details div:last-child {
  border-right: 0;
}

.model-details dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.model-details dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chart-section {
  min-width: 0;
  padding: 2px 0 28px;
}

.chart-section + .chart-section {
  padding-top: 25px;
  border-top: 1px solid var(--line);
}

.chart-heading {
  align-items: flex-end;
  margin-bottom: 13px;
}

.chart-heading p:not(.section-index) {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 13px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 19px;
  height: 3px;
  display: inline-block;
  background: var(--green);
}

.swatch.benchmark {
  height: 0;
  border-top: 2px dashed var(--copper);
  background: transparent;
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  background: var(--paper);
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: 350px;
  overflow: visible;
}

.compact-chart .chart-wrap svg {
  height: 285px;
}

.chart-description {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 132px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(24, 33, 38, 0.12);
  background: var(--paper);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.5;
  pointer-events: none;
}

.chart-tooltip b,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  color: var(--muted);
}

.chart-grid line {
  stroke: #e4e9e7;
  stroke-width: 1;
}

.chart-axis text,
.current-marker text,
.series-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 10px;
}

.chart-axis .axis-title {
  fill: var(--ink);
  font-size: 10px;
  font-weight: 650;
}

.series-line {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.benchmark-line {
  fill: none;
  stroke: var(--copper);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.current-marker line {
  stroke: #87938f;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.current-marker circle {
  fill: var(--paper);
  stroke: var(--green);
  stroke-width: 2.5;
}

.chart-hit {
  fill: transparent;
  pointer-events: all;
}

.hover-marker {
  fill: var(--paper);
  stroke: var(--green);
  stroke-width: 2;
  pointer-events: none;
}

.error-message {
  color: var(--red);
}

@media (max-width: 1180px) {
  .workbench {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .valuation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .valuation-card:nth-child(2) {
    border-right: 0;
  }

  .valuation-card:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .model-details {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 10px;
  }

  .model-details div:nth-child(3) {
    border-right: 0;
  }

  .model-details div:nth-child(4) {
    padding-left: 0;
  }
}

@media (max-width: 900px) {
  .app-shell {
    border: 0;
  }

  .workbench {
    display: block;
  }

  .parameter-rail {
    position: static;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .parameter-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }

  .parameter-control:last-child {
    grid-column: 1 / -1;
    width: calc(50% - 14px);
  }
}

@media (max-width: 620px) {
  .app-header {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
    padding: 17px 16px;
  }

  h1 {
    font-size: 21px;
  }

  .model-control {
    width: 100%;
    justify-content: space-between;
  }

  .parameter-rail,
  .analysis {
    padding-right: 16px;
    padding-left: 16px;
  }

  .parameter-list {
    grid-template-columns: 1fr;
  }

  .parameter-control:last-child {
    grid-column: auto;
    width: auto;
  }

  .feller-panel {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .feller-panel .status-chip {
    grid-column: 1 / -1;
    justify-self: start;
  }

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

  .valuation-card {
    padding: 13px 11px;
  }

  .valuation-card strong {
    font-size: 19px;
  }

  .model-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-details div,
  .model-details div:nth-child(4) {
    padding: 3px 9px;
    border-right: 1px solid var(--line);
  }

  .model-details div:nth-child(odd) {
    padding-left: 0;
  }

  .model-details div:nth-child(even) {
    border-right: 0;
  }

  .chart-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .chart-wrap svg {
    height: 310px;
  }

  .compact-chart .chart-wrap svg {
    height: 270px;
  }
}

@media (max-width: 420px) {
  .contract-grid,
  .preset-actions {
    grid-template-columns: 1fr;
  }

  .parameter-heading {
    gap: 6px;
  }

  .parameter-heading output {
    font-size: 10px;
  }

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

  .valuation-card,
  .valuation-card:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .valuation-card:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
