:root {
  --bg: #f4efe7;
  --surface: rgba(255, 250, 244, 0.88);
  --surface-strong: #fffaf4;
  --ink: #1d2433;
  --muted: #5b6473;
  --line: rgba(29, 36, 51, 0.12);
  --brand: #0a7a67;
  --brand-strong: #075a4c;
  --warm: #f28b50;
  --danger: #d9485f;
  --shadow: 0 22px 60px rgba(42, 31, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(242, 139, 80, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(10, 122, 103, 0.18), transparent 26%),
    linear-gradient(180deg, #f8f2eb 0%, #efe4d5 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(29, 36, 51, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 36, 51, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
}

.layout {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
  display: grid;
  gap: 24px;
}

.hero,
.calculator-panel,
.results-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero {
  padding: 36px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--brand-strong);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 0.98;
  max-width: 10ch;
}

h2 {
  font-size: 1.7rem;
}

.hero-copy {
  max-width: 60ch;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 18px 0 28px;
}

.hero-grid,
.stats-grid,
.summary-card,
.form-grid {
  display: grid;
  gap: 16px;
}

.hero-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.info-card,
.stat-card,
.summary-card,
.insight-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.info-card {
  padding: 20px;
}

.info-card.accent {
  background: linear-gradient(135deg, rgba(10, 122, 103, 0.12), rgba(255, 250, 244, 0.92));
}

.info-card ul {
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.calculator-panel,
.results-panel {
  padding: 30px;
}

.panel-head,
.results-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-grid {
  margin-top: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field span {
  font-size: 0.95rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.field textarea,
.field select {
  width: 100%;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(10, 122, 103, 0.45);
  box-shadow: 0 0 0 4px rgba(10, 122, 103, 0.12);
  transform: translateY(-1px);
}

.field-wide {
  grid-column: 1 / -1;
}

.actions {
  margin-top: 22px;
  justify-content: flex-start;
}

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.primary-button,
.secondary-button,
.ghost-button {
  padding: 14px 20px;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), #11a289);
  color: #fff;
  box-shadow: 0 12px 24px rgba(10, 122, 103, 0.2);
}

.secondary-button,
.ghost-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border: 1px solid var(--line);
}

.form-message {
  min-height: 24px;
  margin: 14px 0 0;
  font-weight: 500;
  color: var(--danger);
}

.results-head {
  margin-bottom: 20px;
}

.scenarios-panel {
  overflow: hidden;
}

.scenario-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.trade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 700;
}

.trade-badge.neutral {
  background: rgba(91, 100, 115, 0.12);
  color: var(--muted);
}

.trade-badge.long {
  background: rgba(10, 122, 103, 0.14);
  color: var(--brand-strong);
}

.trade-badge.short {
  background: rgba(217, 72, 95, 0.12);
  color: #96293c;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
  padding: 20px;
}

.stat-card p,
.summary-label {
  margin: 0;
  color: var(--muted);
}

.stat-card strong,
.summary-main strong {
  display: block;
  margin: 10px 0 8px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-family: "Space Grotesk", sans-serif;
}

.stat-card span {
  color: var(--muted);
  line-height: 1.5;
}

.summary-card {
  margin-top: 18px;
  padding: 20px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.summary-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insight-card {
  margin-top: 18px;
  padding: 22px;
}

.insight-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-strong);
}

.filter-grid,
.backtest-grid {
  display: grid;
  gap: 16px;
}

.filter-grid {
  margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.backtest-stats {
  margin-top: 24px;
}

.backtest-grid {
  margin-top: 18px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.scenario-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.scenario-table th,
.scenario-table td {
  padding: 16px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.scenario-table th {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  color: var(--brand-strong);
  background: rgba(10, 122, 103, 0.06);
}

.scenario-table td {
  color: var(--muted);
}

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

.scenario-table strong {
  color: var(--ink);
}

.empty-row td {
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
}

.row-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.row-badge.long {
  background: rgba(10, 122, 103, 0.14);
  color: var(--brand-strong);
}

.row-badge.short {
  background: rgba(217, 72, 95, 0.12);
  color: #96293c;
}

.icon-button {
  padding: 10px 14px;
  background: rgba(217, 72, 95, 0.08);
  border: 1px solid rgba(217, 72, 95, 0.18);
  color: #96293c;
}

.chart-shell {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-strong);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 500;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.legend-dot.price-line {
  background: #1d2433;
}

.legend-dot.short-line {
  background: #f28b50;
}

.legend-dot.long-line {
  background: #0a7a67;
}

.legend-dot.equity-line {
  background: #2b5cff;
}

.backtest-chart {
  width: 100%;
  min-height: 260px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(10, 122, 103, 0.03), rgba(255, 255, 255, 0.66));
}

.chart-grid-line {
  stroke: rgba(29, 36, 51, 0.08);
  stroke-width: 1;
}

.chart-series {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-series.price {
  stroke: #1d2433;
}

.chart-series.short {
  stroke: #f28b50;
}

.chart-series.long {
  stroke: #0a7a67;
}

.chart-series.equity {
  stroke: #2b5cff;
}

.chart-empty {
  fill: var(--muted);
  font-size: 20px;
  font-family: "DM Sans", sans-serif;
}

@media (max-width: 760px) {
  .layout {
    width: min(100% - 20px, 1180px);
    padding: 20px 0 32px;
  }

  .hero,
  .calculator-panel,
  .results-panel {
    padding: 22px;
    border-radius: 22px;
  }

  .panel-head,
  .results-head,
  .actions,
  .scenario-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .trade-badge {
    min-width: 100%;
  }

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

  .field-wide {
    grid-column: auto;
  }
}
