:root {
  --ink: #18170f;
  --muted: #706c57;
  --line: #e7e2ca;
  --paper: #fffef8;
  --soft: #f7f4e8;
  --yellow: #ffd52e;
  --yellow-dark: #e7b900;
  --danger: #a83a2d;
  --danger-soft: #fff0ed;
  --success: #286442;
  --shadow: 0 16px 42px rgba(75, 62, 0, .09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(255, 213, 46, .24), transparent 26rem),
    var(--soft);
  font-family: "Sora", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.loading-overlay,
.comparison-loading {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--ink);
  background: rgba(255, 254, 248, .88);
  backdrop-filter: blur(6px);
}

.loading-overlay[hidden],
.comparison-loading[hidden] { display: none; }

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: 14px;
}

.comparison-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: inherit;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #f0e7b3;
  border-top-color: var(--yellow-dark);
  border-radius: 50%;
  animation: loading-spin .75s linear infinite;
}

.loading-overlay strong,
.comparison-loading strong { font-size: 14px; }

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

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.kpi-card.is-loading > span,
.kpi-card.is-loading > strong,
.kpi-card.is-loading > small,
.insight.is-loading > span,
.insight.is-loading > strong,
.insight.is-loading > p {
  color: transparent !important;
  border-radius: 7px;
  background: linear-gradient(100deg, #e8e3cf 25%, #f8f5e9 42%, #e8e3cf 60%);
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.15s ease-in-out infinite;
  user-select: none;
}

.kpi-card.is-loading > span { width: 62%; }
.kpi-card.is-loading > strong { width: 48%; min-height: 42px; }
.kpi-card.is-loading > small { width: 72%; min-height: 15px; }
.insight.is-loading > span { width: 46%; min-height: 15px; display: block; }
.insight.is-loading > strong { width: 78%; min-height: 48px; }
.insight.is-loading > p { width: 100%; min-height: 54px; }

@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation-duration: 1.5s; }
  .kpi-card.is-loading > span,
  .kpi-card.is-loading > strong,
  .kpi-card.is-loading > small,
  .insight.is-loading > span,
  .insight.is-loading > strong,
  .insight.is-loading > p { animation-duration: 2.2s; }
}

.funnel-stage,
.comparison-funnel-stage {
  position: relative;
  min-height: 180px;
}

.comparison-funnel-stage { min-width: 1560px; }

button, input, select, code { font: inherit; }

.topbar {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(40, 35, 5, .1);
  background: rgba(255, 254, 248, .86);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.04em;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #191600;
  background: var(--yellow);
  font-weight: 900;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: white;
  font-size: 12px;
  font-weight: 700;
}

.live-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48a66b;
  box-shadow: 0 0 0 4px rgba(72, 166, 107, .13);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.logout-button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid #e1d8ad;
  border-radius: 999px;
  color: var(--ink);
  background: var(--paper);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.login-screen {
  min-height: calc(100vh - 72px);
  padding: 40px 20px;
  display: grid;
  place-items: center;
}
.login-card {
  width: min(100%, 430px);
  padding: 36px;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 4px; }
.login-card h1 { margin: -8px 0 0; font-size: 30px; letter-spacing: -.04em; }
.login-card > p:not(.eyebrow):not(.login-error) { margin: -8px 0 4px; color: var(--muted); line-height: 1.55; }
.login-card label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
.login-card input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: #fffdf5;
  font: inherit;
}
.login-card input:focus { outline: 2px solid var(--yellow-dark); outline-offset: 1px; }
.login-card button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  color: #332b00;
  background: var(--yellow);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.login-card button:disabled { opacity: .6; cursor: wait; }
.login-card small { color: #99927a; text-align: center; }
.login-error { min-height: 20px; margin: -6px 0; color: #b64040; font-size: 13px; font-weight: 700; }

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8d7200;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.funnel-source {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(38px, 6vw, 66px);
  line-height: .98;
  letter-spacing: -.06em;
}

.hero-copy {
  max-width: 600px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.filters {
  width: 100%;
  padding: 14px;
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.filters > label { min-width: 160px; flex: 1; }

.filters input,
.filters select {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: white;
}

.filters select {
  width: 100%;
  cursor: pointer;
}

.landing-filter small {
  margin-left: 4px;
  color: #806800;
  font-size: 8px;
}

.landing-filter.feature-locked {
  opacity: .72;
}

.landing-filter.feature-locked select:disabled {
  color: var(--muted);
  background: var(--soft);
  cursor: not-allowed;
}

.filters button {
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  color: #1b1800;
  background: var(--yellow);
  font-weight: 850;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}

.filters button:hover { background: #ffca08; transform: translateY(-1px); }
.filters button:disabled { cursor: wait; opacity: .65; transform: none; }

.filters .feature-locked-button:disabled {
  color: var(--muted);
  background: var(--soft);
  cursor: not-allowed;
  opacity: .78;
}

.filters .secondary-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: white;
}

.filters .secondary-button:not(:disabled):hover { background: var(--soft); }

.mode-fieldset {
  min-width: 260px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-fieldset legend {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.segmented-switch {
  height: 42px;
  padding: 3px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
}

.segmented-switch label { display: block; cursor: pointer; }
.segmented-switch input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-switch span {
  height: 34px;
  padding: 0 14px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: none;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.segmented-switch input:checked + span {
  color: var(--ink);
  background: white;
  box-shadow: 0 2px 8px rgba(75, 62, 0, .1);
}

.segmented-switch input:focus-visible + span { outline: 2px solid var(--yellow-dark); }

.status {
  display: none;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 28px;
  margin-bottom: 18px;
}

.kpi-card {
  min-height: 148px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(75, 62, 0, .05);
}

.kpi-card > span { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi-card strong { font-size: clamp(30px, 4vw, 44px); letter-spacing: -.05em; }
.kpi-card small { color: #99927a; font-size: 11px; }
.kpi-card .metric-trend { font-weight: 800; }
.metric-trend.positive { color: #16834b; }
.metric-trend.negative { color: #b64040; }
.metric-trend.neutral { color: #7a7154; }
.step-metric .metric-trend { display: block; margin-top: 2px; font-size: 10px; font-weight: 800; letter-spacing: 0; text-transform: none; }
.kpi-card.featured { border-color: #ecc424; background: var(--yellow); }
.kpi-card.featured span, .kpi-card.featured small { color: #5f5000; }

.panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel-heading {
  margin-bottom: 26px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.panel-heading h2 { margin-bottom: 0; font-size: 26px; letter-spacing: -.035em; }
.panel-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.panel-mode-fieldset {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.panel-mode-fieldset legend {
  margin-bottom: 6px;
  text-align: right;
}
.period {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.funnel { display: grid; gap: 9px; }

.funnel-row {
  --depth: 0;
  width: calc(100% - (var(--depth) * 2.1%));
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(4, minmax(92px, .42fr));
  align-items: center;
  overflow: hidden;
  border: 1px solid #eadc9d;
  border-radius: 13px;
  background: hsl(48 100% calc(96% - var(--depth) * 2.2%));
}

.step-main {
  min-width: 0;
  padding: 15px 17px;
  display: flex;
  align-items: center;
  gap: 13px;
}

.step-index {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #6f5900;
  background: rgba(255, 255, 255, .67);
  font-size: 11px;
  font-weight: 900;
}

.step-copy { min-width: 0; }
.step-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.step-copy code { color: #80775a; font-size: 10px; }

.step-metric {
  min-height: 62px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid rgba(119, 95, 0, .12);
}

.step-metric span { color: #7a7154; font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.step-metric strong { margin-top: 3px; font-size: 14px; }

.insight-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.insight { padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.insight > span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.insight strong { margin-top: 10px; display: block; font-size: 17px; line-height: 1.45; }
.insight p { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.empty-state { padding: 40px; color: var(--muted); text-align: center; }

footer { padding: 24px; color: #89836e; font-size: 12px; text-align: center; }

.comparison-dialog {
  width: min(1900px, calc(100% - 12px));
  max-width: none;
  height: 97vh;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: transparent;
  box-shadow: 0 26px 80px rgba(42, 36, 5, .28);
}

.comparison-dialog::backdrop {
  background: rgba(31, 28, 15, .55);
  backdrop-filter: blur(3px);
}

.comparison-modal {
  height: 100%;
  padding: 30px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--paper);
}
.comparison-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.comparison-header h2 { margin: 3px 0 0; font-size: clamp(22px, 3vw, 32px); }
.comparison-header .eyebrow { margin: 0; }

.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: white;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.comparison-description { margin: 16px 0 22px; color: var(--muted); }
.comparison-workspace {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 0 4px 4px 0;
}
.comparison-selectors {
  width: min(720px, 100%);
  margin: 0 auto 20px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 3;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 254, 248, .96);
  box-shadow: 0 8px 24px rgba(75, 62, 0, .08);
  backdrop-filter: blur(12px);
}
.comparison-selector {
  display: grid;
  gap: 7px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
  text-align: center;
  color: var(--ink);
  text-transform: uppercase;
}
.comparison-selector-a select { border: 2px solid #e3b900; background: #fff5b8; }
.comparison-selector-b select { border: 2px solid #8b6fc4; background: #eee6ff; }
.comparison-selector select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}
.comparison-versus { padding-bottom: 13px; color: var(--muted); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.comparison-combined-funnel { padding-right: 4px; }
.comparison-funnel-row {
  grid-template-columns: minmax(260px, 1fr) repeat(4, minmax(220px, .72fr));
}
.comparison-step-metric { min-height: 82px; }
.comparison-value-pair {
  margin-top: 7px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.comparison-value {
  min-width: 0;
  padding: 7px 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: center;
}
.comparison-value-1 { border-color: #e3b900; background: #fff1a1; }
.comparison-value-2 { border-color: #8b6fc4; background: #e8dcff; }
.comparison-landing-name {
  display: block;
  overflow: hidden;
  font-size: 9px;
  font-weight: 900;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comparison-value strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 15px;
}
.comparison-notice {
  flex: 0 0 auto;
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  color: #715d00;
  background: #fff9dc;
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .filters { width: 100%; }
  .filters label { flex: 1; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .insight-grid { grid-template-columns: 1fr 1fr; }
  .growth-insight { grid-column: 1 / -1; }
  .funnel-row { width: 100%; grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(90px, .45fr)); }
  .step-metric.optional { display: none; }
  .comparison-funnel-row {
    width: calc(100% - (var(--depth) * 2.1%));
    grid-template-columns: minmax(260px, 1fr) repeat(4, minmax(220px, .72fr));
  }
  .comparison-funnel-row .step-metric.optional { display: flex; }
}

@media (max-width: 620px) {
  .topbar { height: 62px; padding: 0 16px; }
  .live-pill { font-size: 0; }
  main { width: min(100% - 20px, 1180px); padding-top: 30px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .mode-fieldset, .landing-filter { min-width: 0; }
  .mode-fieldset { grid-column: 1 / -1; }
  .filters button { grid-column: 1 / -1; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kpi-card { min-height: 124px; padding: 16px; }
  .panel { padding: 18px 10px; }
  .panel-heading { padding: 0 8px; flex-direction: column; }
  .panel-header-actions { width: 100%; align-items: flex-start; }
  .panel-mode-fieldset { align-items: flex-start; }
  .panel-mode-fieldset legend { text-align: left; }
  .funnel-row { grid-template-columns: 1fr 92px; }
  .step-metric:not(.users) { display: none; }
  .comparison-funnel-row {
    grid-template-columns: minmax(260px, 1fr) repeat(4, minmax(220px, .72fr));
  }
  .comparison-funnel-row .step-metric { display: flex; }
  .step-main { padding: 13px 10px; }
  .step-copy strong { font-size: 12px; }
  .insight-grid { grid-template-columns: 1fr; }
  .growth-insight { grid-column: auto; }
  .comparison-modal { padding: 20px 14px; }
  .comparison-selectors { position: static; grid-template-columns: 1fr; }
  .comparison-versus { padding: 0; }
}
