@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f2f5f3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-soft: #f8faf9;
  --surface-strong: #eef4f1;
  --ink: #18201c;
  --muted: #6b7571;
  --line: rgba(196, 205, 200, 0.9);
  --line-strong: rgba(171, 183, 177, 0.96);
  --accent: #16836f;
  --accent-soft: rgba(22, 131, 111, 0.1);
  --impact: #d97919;
  --impact-soft: rgba(217, 121, 25, 0.12);
  --good: #11764b;
  --good-soft: #dbf4e7;
  --bad: #b63b3b;
  --bad-soft: #f8e3e3;
  --shadow: 0 24px 80px rgba(17, 23, 20, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  letter-spacing: 0;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(22, 131, 111, 0.08), transparent 20%),
    radial-gradient(circle at right center, rgba(217, 121, 25, 0.06), transparent 22%),
    linear-gradient(180deg, #fbfcfb 0%, var(--bg) 26%, #eef2ef 100%);
  color: var(--ink);
  font-family:
    "Manrope",
    "Inter",
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  min-height: 100svh;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(214, 221, 217, 0.86);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: inline-flex;
  flex: 0 0 auto;
  height: 44px;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  transition:
    border-color 160ms ease,
    transform 160ms ease;
  width: 44px;
}

.brand-logo:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.brand-logo img {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.topbar-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.topbar h1,
.hero-copy h2,
.summary-card strong,
.section-head h3 {
  font-family:
    "Space Grotesk",
    "Manrope",
    ui-sans-serif,
    system-ui,
    sans-serif;
}

.topbar h1 {
  font-size: clamp(24px, 2.2vw, 34px);
  letter-spacing: 0;
  line-height: 0.94;
}

.creator-line {
  color: var(--muted);
  font-size: 12px;
}

.creator-line a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.creator-line a:hover {
  text-decoration: underline;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-actions {
  align-items: end;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.header-connections {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 560px;
}

.header-connections:empty {
  display: none;
}

.header-connections span {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  min-height: 26px;
  padding: 7px 10px;
  white-space: nowrap;
}

.page-shell {
  height: calc(100svh - 72px);
  padding: 10px;
}

.workspace-shell {
  display: grid;
  gap: 12px;
  grid-template-columns: clamp(320px, 21vw, 430px) minmax(0, 1fr);
  height: 100%;
  margin: 0;
  max-width: none;
  width: 100%;
}

.side-panel,
.chart-panel {
  background: var(--surface);
  border: 1px solid rgba(214, 221, 217, 0.92);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  padding: 10px;
}

.panel-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.control-section,
.identity-section,
.summary-section {
  border-bottom: 1px solid rgba(214, 221, 217, 0.8);
  padding-bottom: 10px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.mode-head {
  align-items: start;
}

.field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

input,
select {
  appearance: none;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  min-height: 48px;
  outline: none;
  padding: 10px 13px;
  width: 100%;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease,
    opacity 160ms ease;
}

select {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-switch {
  background: rgba(239, 245, 242, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px;
}

.mode-switch button {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  min-height: 34px;
  padding: 0 8px;
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.mode-switch button.active {
  background: #ffffff;
  box-shadow: 0 10px 20px rgba(24, 32, 28, 0.08);
  color: var(--ink);
}

.mode-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}

input:focus,
select:focus {
  border-color: rgba(22, 131, 111, 0.36);
  box-shadow: 0 0 0 5px rgba(22, 131, 111, 0.08);
  transform: translateY(-1px);
}

input[type="number"] {
  padding-right: 10px;
}

input:disabled,
select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

#poolUrlA,
#poolUrlB,
#poolUrlSingle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.load-state {
  align-items: center;
  background: rgba(248, 250, 249, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 8px;
  min-height: 28px;
  padding: 0 9px;
}

.load-state-icon {
  align-items: center;
  display: inline-flex;
  font-size: 11px;
  height: 14px;
  justify-content: center;
  width: 14px;
}

.load-state.loading {
  background: rgba(22, 131, 111, 0.08);
  border-color: rgba(22, 131, 111, 0.2);
  color: #0d6959;
}

.load-state.loading .load-state-icon {
  border: 2px solid rgba(22, 131, 111, 0.16);
  border-radius: 999px;
  border-top-color: var(--accent);
  color: transparent;
  animation: spin 0.9s linear infinite;
}

.load-state.success {
  background: var(--good-soft);
  border-color: rgba(17, 118, 75, 0.18);
  color: var(--good);
}

.load-state.error {
  background: var(--bad-soft);
  border-color: rgba(182, 59, 59, 0.16);
  color: var(--bad);
}

.compact-controls {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

.compact-field {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.compact-field > span {
  align-items: end;
  display: flex;
  min-height: 24px;
}

.compact-field input,
.compact-field select {
  height: 54px;
  min-height: 54px;
}

.button {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 14px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.button:hover {
  box-shadow: 0 16px 28px rgba(24, 32, 28, 0.12);
  transform: translateY(-1px);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.84);
  border-color: var(--line);
  color: var(--ink);
}

.hero-copy {
  display: grid;
  gap: 4px;
}

.hero-copy h2 {
  font-size: clamp(22px, 2.4vw, 31px);
  letter-spacing: 0;
  line-height: 0.92;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hero-copy p {
  color: var(--muted);
  font-size: 12px;
}

.pool-facts {
  display: none !important;
}

.summary-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 0;
}

.summary-card {
  align-items: start;
  background: rgba(248, 250, 249, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  gap: 7px;
  min-width: 0;
  min-height: 78px;
  padding: 10px 12px;
}

.summary-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.summary-card strong {
  font-size: clamp(18px, 1.8vw, 24px);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.98;
  max-width: none;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.summary-card.wide {
  grid-column: 1 / -1;
}

.summary-card.optimal {
  background: rgba(22, 131, 111, 0.08);
  border-color: rgba(22, 131, 111, 0.2);
}

.summary-card.optimal strong {
  color: var(--accent);
}

.notice-band {
  align-items: center;
  background: rgba(239, 245, 242, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  display: flex;
  font-size: 12px;
  line-height: 1.45;
  min-height: 40px;
  padding: 10px 12px;
}

.chart-panel {
  min-height: 0;
  padding: 12px;
}

.chart-shell {
  display: grid;
  gap: 10px;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.section-head {
  align-items: end;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.section-head h3 {
  font-size: clamp(24px, 2.3vw, 32px);
  letter-spacing: -0.07em;
  line-height: 0.94;
}

.section-head p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
}

.chart-head-meta {
  align-items: flex-end;
  display: grid;
  gap: 8px;
  justify-items: end;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-item {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  gap: 8px;
}

.legend-item::before {
  border-radius: 999px;
  content: "";
  display: inline-block;
  height: 10px;
  width: 10px;
}

.legend-item.pnl::before {
  background: var(--accent);
}

.legend-item.impact::before {
  background: var(--impact);
}

.chart-readout {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  min-height: 36px;
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
}

.ladder-chart {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 20px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.ladder-chart.empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: center;
  text-align: center;
}

.ladder-chart.preview {
  border-color: rgba(217, 121, 25, 0.3);
}

.ladder-chart.preview .chart-path,
.ladder-chart.preview .chart-area {
  opacity: 0.72;
}

.ladder-chart.preview .chart-path {
  stroke-dasharray: 8 8;
}

.chart-svg {
  display: block;
  height: 100%;
  width: 100%;
}

.chart-grid-line {
  stroke: #e8eeeb;
  vector-effect: non-scaling-stroke;
}

.chart-axis-line {
  stroke: #d4dcda;
  vector-effect: non-scaling-stroke;
}

.chart-axis-text {
  fill: #616a66;
  font-size: 12px;
  font-weight: 700;
}

.chart-axis-text.right {
  fill: #8b5b1b;
}

.chart-tooltip {
  background: rgba(24, 32, 28, 0.94);
  border-radius: 14px;
  color: #ffffff;
  left: 0;
  min-width: 208px;
  padding: 12px 14px;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate(-9999px, -9999px);
  z-index: 4;
}

.chart-tooltip strong {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.chart-tooltip span {
  color: #d8e2dc;
  display: block;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

.chart-hover-line {
  stroke: rgba(22, 131, 111, 0.28);
  stroke-dasharray: 6 7;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-best-guide {
  stroke: rgba(22, 131, 111, 0.22);
  stroke-dasharray: 4 6;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.chart-impact-guide {
  stroke: rgba(217, 121, 25, 0.34);
  stroke-dasharray: 5 6;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.chart-best-dot {
  fill: var(--accent);
  stroke: #ffffff;
  stroke-width: 3.5;
  vector-effect: non-scaling-stroke;
}

.chart-best-dot.impact {
  fill: var(--impact);
  stroke-width: 3;
}

.chart-best-label {
  fill: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chart-axis-tag rect {
  stroke-width: 1;
}

.chart-axis-tag text {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.chart-axis-tag.accent rect {
  fill: rgba(22, 131, 111, 0.1);
  stroke: rgba(22, 131, 111, 0.26);
}

.chart-axis-tag.accent text {
  fill: var(--accent);
}

.chart-axis-tag.impact rect {
  fill: rgba(217, 121, 25, 0.12);
  stroke: rgba(217, 121, 25, 0.24);
}

.chart-axis-tag.impact text {
  fill: #b06917;
}

.chart-hover-dot {
  fill: var(--accent);
  stroke: #ffffff;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.chart-hover-dot.impact {
  fill: var(--impact);
}

.chart-boundary {
  stroke: rgba(22, 131, 111, 0.42);
  stroke-dasharray: 7 7;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-path {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.chart-path.impact {
  stroke: var(--impact);
  stroke-width: 2.5;
}

.chart-area {
  fill: rgba(22, 131, 111, 0.12);
}

.chart-hitbox {
  cursor: crosshair;
  fill: transparent;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .page-shell {
    height: auto;
    min-height: calc(100svh - 72px);
  }

  .workspace-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .side-panel,
  .chart-panel {
    overflow: visible;
  }

  .chart-panel {
    min-height: 560px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    gap: 12px;
  }

  .topbar-left {
    align-items: start;
    width: 100%;
  }

  .topbar-actions {
    justify-items: start;
    width: 100%;
  }

  .topbar-status,
  .header-connections {
    justify-content: flex-start;
  }

  .page-shell {
    padding: 12px;
  }

  .side-panel,
  .chart-panel {
    border-radius: 20px;
    padding: 14px;
  }

  .compact-controls,
  .summary-grid,
  .pool-facts {
    grid-template-columns: 1fr;
  }

  .summary-card {
    gap: 4px;
  }

  .summary-card strong {
    max-width: none;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .chart-head-meta {
    justify-items: start;
    width: 100%;
  }

  .chart-readout {
    text-align: left;
    white-space: normal;
    width: 100%;
  }

  .hero-copy h2 {
    font-size: 34px;
  }

  .ladder-chart {
    min-height: 420px;
  }
}
