:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #f0f4f8;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e1ea;
  --green: #1c7c54;
  --green-soft: #e4f4ea;
  --gold: #b7791f;
  --gold-soft: #fff1cf;
  --blue: #2f6f9f;
  --blue-soft: #e3f1fb;
  --plum: #68478d;
  --plum-soft: #eee7f7;
  --danger: #bd3b3b;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
  background: #fff;
}

.login-form {
  display: grid;
  width: min(540px, 100%);
  gap: 18px;
  background: var(--surface);
}

.auth-step {
  display: grid;
  gap: 12px;
}

.auth-status {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.mfa-qr-wrap {
  display: grid;
  width: min(220px, 100%);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.mfa-qr-wrap img {
  display: block;
  width: 100%;
  height: auto;
}

.login-brand {
  display: grid;
  gap: 8px;
  margin-bottom: 6px;
}

.logo-wordmark {
  position: relative;
  isolation: isolate;
  width: max-content;
  max-width: 100%;
  margin: 0;
  color: transparent;
  font-family:
    Impact, Haettenschweiler, "Arial Black", Inter, system-ui, sans-serif;
  font-size: clamp(3.2rem, 13vw, 7.4rem);
  font-weight: 900;
  line-height: 0.86;
  text-transform: uppercase;
  filter: drop-shadow(4px 6px 0 rgba(28, 124, 84, 0.18));
}

.logo-wordmark::before,
.logo-wordmark::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: attr(data-text);
  letter-spacing: inherit;
}

.logo-wordmark::before {
  color: #f7c948;
  transform: translate(7px, 7px) rotate(-1.5deg);
}

.logo-wordmark::after {
  color: transparent;
  -webkit-text-stroke: 2px #17202a;
  text-stroke: 2px #17202a;
  transform: translate(-3px, -3px) rotate(1deg);
}

.logo-wordmark span {
  display: inline-block;
  color: var(--letter-color);
  text-shadow:
    2px 2px 0 #fff,
    5px 5px 0 rgba(47, 111, 159, 0.18);
  -webkit-text-stroke: 1px #17202a;
  text-stroke: 1px #17202a;
}

.logo-wordmark span:nth-child(1),
.logo-wordmark span:nth-child(5),
.logo-wordmark span:nth-child(9) {
  --letter-color: #1c7c54;
  transform: rotate(-4deg);
}

.logo-wordmark span:nth-child(2),
.logo-wordmark span:nth-child(6) {
  --letter-color: #2f6f9f;
  transform: translateY(3px) rotate(3deg);
}

.logo-wordmark span:nth-child(3),
.logo-wordmark span:nth-child(7) {
  --letter-color: #b7791f;
  transform: translateY(-2px) rotate(-2deg);
}

.logo-wordmark span:nth-child(4),
.logo-wordmark span:nth-child(8) {
  --letter-color: #68478d;
  transform: rotate(2deg);
}

.market-graffiti {
  position: relative;
  width: min(360px, 75vw);
  height: 54px;
  margin-left: 4px;
}

.chart-bar,
.chart-stroke {
  position: absolute;
  display: block;
  border-radius: 999px;
}

.chart-bar {
  bottom: 8px;
  width: 16px;
  background: var(--green);
  box-shadow: 3px 3px 0 rgba(247, 201, 72, 0.8);
}

.bar-one {
  left: 6px;
  height: 18px;
}

.bar-two {
  left: 34px;
  height: 28px;
  background: var(--blue);
}

.bar-three {
  left: 62px;
  height: 38px;
  background: var(--gold);
}

.bar-four {
  left: 90px;
  height: 46px;
  background: var(--plum);
}

.chart-stroke {
  height: 7px;
  background: #17202a;
  transform-origin: left center;
}

.stroke-one {
  left: 122px;
  top: 36px;
  width: 78px;
  transform: rotate(-20deg);
}

.stroke-two {
  left: 190px;
  top: 12px;
  width: 70px;
  background: var(--green);
  transform: rotate(18deg);
}

.stroke-three {
  left: 250px;
  top: 29px;
  width: 86px;
  background: var(--blue);
  transform: rotate(-28deg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 22px;
}

.brand-lockup,
.topbar-actions,
.section-heading,
.chart-wrap,
.range-row,
.goal-form,
.goal-meta,
.goal-actions {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #1c7c54, #2f6f9f 48%, #f7c948);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 4px 4px 0 rgba(183, 121, 31, 0.22);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.account-pill {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.select-label,
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 159, 0.16);
  outline: none;
}

input[type="range"] {
  min-height: 0;
  padding: 0;
  accent-color: var(--green);
}

.button,
.segment {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.button:disabled {
  cursor: progress;
  opacity: 0.68;
}

.button.ghost:hover,
.segment:hover {
  border-color: #a9b7c5;
  background: var(--surface-strong);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(520px, 1.45fr);
  gap: 18px;
}

.planner-panel,
.metric-card,
.chart-panel,
.scenario-panel,
.goal-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.planner-panel {
  grid-row: span 3;
  padding: 20px;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 278px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  padding: 8px 10px;
  color: var(--muted);
}

.segment.active {
  background: var(--ink);
  color: #fff;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.input-grid.single {
  grid-template-columns: 1fr;
}

.range-row {
  gap: 10px;
}

.range-row span {
  min-width: 74px;
  color: var(--ink);
  font-weight: 850;
  text-align: right;
}

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

.metric-card {
  min-height: 136px;
  padding: 18px;
}

.metric-card p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  line-height: 1.05;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.metric-card.positive strong {
  color: var(--green);
}

.metric-card.warning strong {
  color: var(--gold);
}

.metric-card.negative strong {
  color: var(--danger);
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
}

.chart-panel,
.scenario-panel,
.goal-section {
  padding: 20px;
}

.chart-wrap {
  justify-content: center;
  gap: 22px;
}

canvas {
  width: min(280px, 45vw);
  max-width: 100%;
  height: auto;
}

.legend {
  display: grid;
  gap: 10px;
  min-width: 180px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.callout {
  min-height: 106px;
  margin-top: 14px;
  border: 1px solid #c8e6d4;
  border-radius: 8px;
  background: var(--green-soft);
  padding: 14px;
  color: #25543d;
  line-height: 1.45;
}

.goal-section {
  grid-column: 2;
}

.goal-form {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.goal-form input {
  width: 128px;
}

.goal-form input:first-child {
  width: 170px;
}

.goals-list {
  display: grid;
  gap: 12px;
}

.goal-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.goal-row h3 {
  margin: 0 0 5px;
  font-size: 0.98rem;
}

.goal-row p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.progress-track {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.goal-meta {
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 750;
}

.goal-actions {
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  transform: translateY(18px);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .planner-panel,
  .goal-section {
    grid-column: auto;
    grid-row: auto;
  }

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

@media (max-width: 760px) {
  .app-shell,
  .login-screen {
    padding: 14px;
  }

  .topbar,
  .section-heading,
  .chart-wrap {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .goal-form {
    justify-content: stretch;
  }

  .topbar-actions > *,
  .button,
  .goal-form input,
  .goal-form input:first-child {
    width: 100%;
  }

  .segmented,
  .input-grid,
  .analysis-grid,
  .snapshot-grid,
  .goal-row {
    grid-template-columns: 1fr;
  }

  canvas {
    width: min(280px, 80vw);
    justify-self: center;
  }
}

@media (max-width: 520px) {
  .logo-wordmark {
    font-size: clamp(2.7rem, 15vw, 4.8rem);
  }

  .market-graffiti {
    width: 100%;
    transform: scale(0.86);
    transform-origin: left center;
  }
}
