/* Optimal Clearing Frontier — professional decision-support UI */

:root {
  --bg: #f0f3f8;
  --bg-accent: #e4eaf3;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f6f8fb;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #1a3a5c;
  --accent-mid: #2563eb;
  --accent-soft: #eff6ff;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --gold: #b8954a;
  --gold-soft: #faf6ed;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --warn-text: #92400e;
  --good: #047857;
  --good-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1), 0 24px 48px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(26, 58, 92, 0.06), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, #e8edf4 100%);
  pointer-events: none;
}

a {
  color: var(--accent-mid);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 1.5rem 3.5rem;
}

/* —— Top bar —— */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent) 0%, #2d4a6f 100%);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 12px rgba(26, 58, 92, 0.25);
}

.brand-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* —— Hero —— */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0f2847 0%, #1a3a5c 42%, #1e4976 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2.25rem 2.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.hero::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -15%;
  width: 55%;
  height: 140%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.07) 0%, transparent 65%);
  pointer-events: none;
}

.hero h1 {
  position: relative;
  margin: 0 0 0.65rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  max-width: 20ch;
}

.hero p {
  position: relative;
  margin: 0;
  max-width: 58ch;
  font-size: 0.95rem;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.88);
}

.hero p strong {
  color: #fff;
  font-weight: 600;
}

.hero-meta {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}

/* —— Guide steps —— */
.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .guide-steps {
    grid-template-columns: 1fr;
  }
}

.guide-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.guide-step:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.guide-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-mid), #1d4ed8);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.guide-step strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.guide-step span:not(.guide-num) {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* —— Toolbar (alert + presets) —— */
.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.alert {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
}

.alert-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #fef3c7;
  color: var(--warn-text);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert strong {
  color: #78350f;
}

.scenario-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.scenario-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.chip:hover {
  border-color: var(--accent-mid);
  color: var(--accent-mid);
  background: var(--accent-soft);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(26, 58, 92, 0.25);
}

/* —— Layout —— */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sticky {
    position: static;
  }
}

.inputs-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sticky {
  position: sticky;
  top: 1.25rem;
}

/* —— Panels —— */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.25s var(--ease);
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface) 100%);
}

.step-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-transform: none;
}

.panel-body {
  padding: 1.35rem 1.35rem 1.5rem;
}

.panel-intro {
  margin: 0 0 1.15rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.panel-intro--spaced {
  margin-top: 1.15rem;
}

.field-help--flush {
  margin-top: 0.75rem;
}

.panel-results {
  border-color: #c7d8ec;
  box-shadow: var(--shadow-md);
}

.panel-results .panel-header {
  background: linear-gradient(135deg, var(--accent) 0%, #1e4976 100%);
  border-bottom: none;
}

.panel-results .panel-header h2 {
  color: #fff;
}

.panel-results .step-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.panel-results .panel-body {
  padding: 1.5rem;
}

.panel-results .panel-intro {
  color: var(--text-secondary);
}

/* —— Form fields —— */
.field-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field-card {
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.field-card:hover {
  border-color: var(--border-strong);
  background: #fff;
}

.field-card.highlight-card {
  border-color: #bfdbfe;
  background: linear-gradient(135deg, #f8fafc 0%, var(--accent-soft) 100%);
}

.field-card > label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.5rem;
}

.field-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.field-symbol {
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.field-card input,
.field-card select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: #fff;
  color: var(--text);
  font-size: 0.9375rem;
  font-family: var(--mono);
  font-weight: 500;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field-card input:focus {
  outline: none;
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-help {
  margin: 0.65rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.field-help strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* —— Toggle & regime —— */
.toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s var(--ease);
}

.toggle:has(input:checked) {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}

.toggle input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent-mid);
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.toggle strong {
  font-size: 0.9rem;
}

.toggle small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.regime {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 560px) {
  .regime {
    grid-template-columns: 1fr;
  }
}

.regime label {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
  font-size: 0.85rem;
  transition: all 0.2s var(--ease);
}

.regime label:hover {
  border-color: var(--border-strong);
}

.regime label small {
  display: block;
  margin-top: 0.35rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.45;
  font-size: 0.78rem;
}

.regime input {
  display: none;
}

.regime label:has(input:checked) {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-mid);
}

.regime input:checked + span strong {
  color: var(--accent-mid);
}

/* —— Gamma slider —— */
.gamma-block {
  margin-top: 0;
}

.gamma-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.gamma-top > span:first-child {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.gamma-top strong {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-mid);
  background: var(--accent-soft);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-xs);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good) 0%, var(--border) 50%, var(--danger) 100%);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-mid);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  cursor: grab;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-mid);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  cursor: grab;
}

.results-updated .price-hero {
  animation: resultPulse 0.45s var(--ease);
}

@keyframes resultPulse {
  0% {
    transform: scale(0.98);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.gamma-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
}

/* —— Results —— */
.inactive-card {
  text-align: center;
  padding: 2.75rem 1.75rem;
  background: var(--good-soft);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
}

.inactive-card strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--good);
  margin-bottom: 0.5rem;
}

.inactive-card span {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.price-hero {
  text-align: center;
  padding: 1.75rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(160deg, var(--accent-soft) 0%, #fff 50%, var(--gold-soft) 100%);
  border: 1px solid #bfdbfe;
}

.price-hero .label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.price-hero .value {
  display: block;
  font-family: var(--mono);
  font-size: clamp(2.5rem, 6vw, 3.25rem);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.discount-pill {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.discount-pill.is-discount {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.metric {
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  transition: background 0.2s var(--ease);
}

.metric:hover {
  background: #fff;
}

.metric .label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.metric .value {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent);
}

.metric .sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.45;
}

.metric--best {
  border-left: 3px solid var(--good);
}

.metric--worst {
  border-left: 3px solid var(--danger);
}

.metric--cap {
  border-left: 3px solid var(--gold);
}

/* —— Frontier bar —— */
.frontier {
  margin: 0 0 1.25rem;
  padding: 1.15rem;
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.frontier-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bar-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fecaca 0%, #e2e8f0 42%, #bbf7d0 100%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.bar-range {
  position: absolute;
  top: 1px;
  bottom: 1px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.2);
  border: 1px solid rgba(37, 99, 235, 0.35);
}

.marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: left 0.35s var(--ease);
}

.marker.base {
  background: var(--danger);
}

.marker.final {
  background: var(--accent-mid);
  width: 18px;
  height: 18px;
  z-index: 2;
  box-shadow: 0 0 0 4px var(--accent-glow), 0 2px 10px rgba(37, 99, 235, 0.4);
}

.marker.target {
  background: var(--good);
}

.bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 0.85rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot--worst {
  background: var(--danger);
}

.dot--estimate {
  background: var(--accent-mid);
}

.dot--best {
  background: var(--good);
}

.site-header .badge {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: var(--accent);
}

.diag {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.65;
  padding: 1rem 1.15rem;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.diag strong {
  color: var(--text);
  font-weight: 600;
}

/* —— Details —— */
details {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  overflow: hidden;
}

summary {
  cursor: pointer;
  padding: 0.85rem 1.15rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-mid);
  list-style: none;
  transition: background 0.15s var(--ease);
}

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

summary::after {
  content: "+";
  float: right;
  font-weight: 400;
  color: var(--text-muted);
}

details[open] summary::after {
  content: "−";
}

details[open] summary {
  background: #fff;
  border-bottom: 1px solid var(--border);
}

details ul {
  margin: 0;
  padding: 1rem 1.15rem 1.15rem 1.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: #fff;
}

details li {
  margin: 0.4rem 0;
}

details code {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
  background: var(--surface-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
