:root {
  color-scheme: light;
  --canvas: #f3f1ea;
  --surface: #faf9f5;
  --surface-strong: #ffffff;
  --ink: #121713;
  --ink-soft: #555d57;
  --muted: #7d857f;
  --line: #d8d7cf;
  --line-strong: #b9bcb5;
  --accent: #194f3d;
  --accent-hover: #103c2e;
  --accent-soft: #dcebe3;
  --positive: #08794d;
  --positive-soft: #e0f2e8;
  --negative: #b83a2f;
  --negative-soft: #f7e5e1;
  --warning: #9b6810;
  --warning-soft: #f5ebd4;
  --focus: #f1a622;
  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow: 0 12px 30px rgba(24, 30, 25, 0.06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #111512;
  --surface: #171c18;
  --surface-strong: #1d231e;
  --ink: #edf1ec;
  --ink-soft: #b4bcb5;
  --muted: #858e87;
  --line: #303731;
  --line-strong: #505a52;
  --accent: #8ed6af;
  --accent-hover: #a8e5c2;
  --accent-soft: #203a2c;
  --positive: #73d5a3;
  --positive-soft: #173426;
  --negative: #f08b80;
  --negative-soft: #40231f;
  --warning: #efc56c;
  --warning-soft: #3b301a;
  --focus: #ffc45c;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #111512;
    --surface: #171c18;
    --surface-strong: #1d231e;
    --ink: #edf1ec;
    --ink-soft: #b4bcb5;
    --muted: #858e87;
    --line: #303731;
    --line-strong: #505a52;
    --accent: #8ed6af;
    --accent-hover: #a8e5c2;
    --accent-soft: #203a2c;
    --positive: #73d5a3;
    --positive-soft: #173426;
    --negative: #f08b80;
    --negative-soft: #40231f;
    --warning: #efc56c;
    --warning-soft: #3b301a;
    --focus: #ffc45c;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), color-mix(in srgb, var(--line) 36%, transparent) 50%, transparent calc(50% + 0.5px)),
    var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 58%, transparent);
  outline-offset: 3px;
}

.shell {
  width: min(100% - 40px, 1440px);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
  font-weight: 690;
  letter-spacing: -0.025em;
}

.brand-mark {
  position: relative;
  width: 24px;
  height: 24px;
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  height: 1px;
  background: var(--ink);
  transform-origin: left center;
}

.brand-mark::before {
  top: 14px;
  transform: rotate(-28deg);
}

.brand-mark::after {
  top: 8px;
  transform: rotate(18deg);
}

.product-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.product-mode::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 4px var(--positive-soft);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

main {
  padding: 72px 0 96px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  gap: clamp(48px, 8vw, 120px);
  align-items: end;
  padding-bottom: 72px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 18px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  max-width: 740px;
  margin: 0;
  font-size: clamp(3.1rem, 6.2vw, 6.9rem);
  font-weight: 560;
  letter-spacing: -0.067em;
  line-height: 0.91;
}

.intro-copy {
  max-width: 530px;
  margin: 28px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.65;
}

.sync-panel {
  position: relative;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line-strong);
  padding: 22px 0 20px;
}

.sync-panel::before {
  content: "01";
  position: absolute;
  top: -28px;
  right: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.sync-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: baseline;
  margin-bottom: 18px;
}

.sync-heading h2 {
  margin: 0;
  font-size: 1.04rem;
  letter-spacing: -0.02em;
}

.trust-note {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
}

#address-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.field {
  min-width: 0;
}

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

input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.87rem;
  padding: 0 15px;
}

input::placeholder {
  color: var(--muted);
}

input:hover {
  border-color: var(--ink-soft);
}

input:focus {
  border-color: var(--accent);
}

.primary-button {
  min-height: 50px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--surface-strong);
  padding: 0 22px;
  font-size: 0.84rem;
  font-weight: 720;
  cursor: pointer;
}

:root[data-theme="dark"] .primary-button {
  color: #102018;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

#status {
  min-height: 21px;
  margin: 13px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

#status[data-state="loading"]::before,
#status[data-state="success"]::before,
#status[data-state="error"]::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
  background: currentColor;
}

#status[data-state="loading"] {
  color: var(--warning);
}

#status[data-state="success"] {
  color: var(--positive);
}

#status[data-state="error"] {
  color: var(--negative);
}

#dashboard[hidden] {
  display: none;
}

#dashboard {
  border-top: 1px solid var(--line-strong);
  padding-top: 40px;
}

.dashboard-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 32px;
}

#dashboard-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.75rem);
  font-weight: 560;
  letter-spacing: -0.055em;
  line-height: 1;
}

.coverage {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.scope-note {
  max-width: 340px;
  margin: 0;
  border-left: 2px solid var(--accent);
  padding-left: 13px;
  color: var(--muted);
  font-size: 0.78rem;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(0, 1.72fr);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats-panel {
  border-right: 1px solid var(--line);
  padding: clamp(22px, 3vw, 36px);
}

.panel-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-label::after {
  content: "";
  width: 34px;
  height: 1px;
  background: var(--line-strong);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
}

.stat {
  min-width: 0;
  min-height: 116px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 16px 12px 16px 0;
}

.stat:nth-child(even) {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.stat:last-child {
  grid-column: 1 / -1;
  min-height: 132px;
  padding-top: 22px;
}

.stat-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.stat-value {
  overflow: hidden;
  font-size: clamp(1.8rem, 3vw, 3.1rem);
  font-weight: 590;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
  line-height: 1;
  text-overflow: ellipsis;
}

.stat:last-child .stat-value {
  font-size: clamp(2.5rem, 5vw, 5.2rem);
}

.pos {
  color: var(--positive) !important;
}

.neg {
  color: var(--negative) !important;
}

.partial-note {
  margin: 20px 0 0;
  border-top: 1px solid var(--warning);
  padding-top: 12px;
  color: var(--warning);
  font-size: 0.76rem;
}

.chart-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 3vw, 36px);
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 24px;
}

.chart-head h3 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 630;
  letter-spacing: -0.025em;
}

.chart-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.67rem;
  text-transform: uppercase;
}

.chart-legend::before {
  content: "";
  width: 20px;
  height: 2px;
  background: var(--positive);
}

.chart-wrap {
  min-height: 360px;
  flex: 1;
  display: grid;
  align-items: end;
  margin-top: 26px;
  border-bottom: 1px solid var(--line-strong);
  background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), var(--line) 25%);
}

#equity-curve {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 330px;
  overflow: visible;
}

.empty {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  font-size: 0.86rem;
  text-align: center;
}

.dashboard-section {
  display: grid;
  grid-template-columns: minmax(180px, 0.26fr) minmax(0, 1fr);
  gap: clamp(28px, 6vw, 90px);
  border-top: 1px solid var(--line-strong);
  padding-top: 28px;
  margin-top: 72px;
}

.section-rail {
  align-self: start;
  position: sticky;
  top: 24px;
}

.section-index {
  display: block;
  margin-bottom: 15px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
}

.section-title {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  font-weight: 610;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.section-description,
#behavioral-flags-note,
.breakdown-timezone {
  max-width: 280px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.flag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.flag {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 20px 8px 20px 0;
}

.flag::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.flag.elevated::before {
  border-color: var(--warning);
  background: var(--warning);
  box-shadow: 0 0 0 4px var(--warning-soft);
}

.flag-kind {
  font-weight: 640;
  letter-spacing: -0.015em;
}

.flag-meta {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.flag-sev {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.flag.elevated .flag-sev {
  color: var(--warning);
}

.breakdowns-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.breakdown-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}

.breakdown-card h4 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  font-size: 0.77rem;
  font-weight: 690;
  letter-spacing: -0.01em;
}

.table-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}

.table-scroll {
  overflow-x: auto;
  scrollbar-color: var(--line-strong) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

th,
td {
  padding: 13px 15px;
  text-align: left;
  white-space: nowrap;
}

thead th {
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

tbody tr + tr td {
  border-top: 1px solid var(--line);
}

tbody tr:hover td {
  background: var(--accent-soft);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.mono {
  font-family: var(--mono);
  font-size: 0.76rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.long,
.badge.complete {
  color: var(--positive);
}

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

.badge.partial {
  color: var(--warning);
}

.site-footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
}

@media (max-width: 1040px) {
  main {
    padding-top: 52px;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 66px;
  }

  .sync-panel {
    width: min(100%, 680px);
  }

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

  .stats-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .stat,
  .stat:last-child {
    grid-column: auto;
    min-height: 105px;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    padding: 14px;
  }

  .stat:first-child {
    border-left: 0;
  }

  .stat-value,
  .stat:last-child .stat-value {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
  }

  .chart-wrap {
    min-height: 320px;
  }

  #equity-curve {
    min-height: 290px;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--canvas);
  }

  .shell {
    width: min(100% - 28px, 1440px);
  }

  .header-inner {
    min-height: 64px;
    grid-template-columns: 1fr auto;
  }

  .product-mode {
    display: none;
  }

  main {
    padding: 44px 0 72px;
  }

  .intro {
    gap: 62px;
    padding-bottom: 56px;
  }

  h1 {
    max-width: 520px;
    font-size: clamp(3.2rem, 16vw, 5.6rem);
  }

  .intro-copy {
    margin-top: 22px;
  }

  .sync-heading {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  #address-form {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

  .dashboard-head {
    grid-template-columns: 1fr;
  }

  .scope-note {
    max-width: 100%;
  }

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

  .stat,
  .stat:last-child {
    min-height: 104px;
  }

  .stat:nth-child(odd) {
    border-left: 0;
  }

  .stat:last-child {
    grid-column: 1 / -1;
    min-height: 122px;
  }

  .stat:last-child .stat-value {
    font-size: 3rem;
  }

  .chart-wrap {
    min-height: 250px;
  }

  #equity-curve {
    min-height: 230px;
  }

  .dashboard-section {
    grid-template-columns: 1fr;
    gap: 24px;
    margin-top: 56px;
  }

  .section-rail {
    position: static;
  }

  .section-description,
  #behavioral-flags-note,
  .breakdown-timezone {
    max-width: 520px;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }
}

@media (max-width: 430px) {
  .shell {
    width: min(100% - 22px, 1440px);
  }

  .brand {
    font-size: 0.92rem;
  }

  h1 {
    font-size: clamp(3rem, 16vw, 4.4rem);
  }

  .stats-panel,
  .chart-panel {
    padding: 20px 16px;
  }

  .stat-value {
    font-size: 1.65rem;
  }

  .chart-head {
    flex-direction: column;
    gap: 8px;
  }

  .flag {
    grid-template-columns: 8px minmax(0, 1fr);
  }

  .flag-sev {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
