:root {
  --ink: #151515;
  --muted: #6f7277;
  --line: #dedede;
  --soft: #f5f5f5;
  --brand: #c91f2f;
  --brand-2: #1f1f1f;
  --accent: #8f1822;
  --red-soft: #f7e7e9;
  --red-line: #efc7cc;
  --panel: #ffffff;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f2f2f2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 44px);
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-lockup img {
  display: block;
  width: clamp(210px, 26vw, 340px);
  max-height: 58px;
  object-fit: contain;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.5vw, 2.25rem);
  font-weight: 750;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.period-picker {
  display: grid;
  gap: 6px;
  min-width: min(260px, 42vw);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.custom-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
}

.custom-range[hidden] {
  display: none;
}

.custom-range label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.connect-btn,
.reload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--red-line);
  border-radius: 8px;
  color: var(--brand);
  background: var(--red-soft);
  font-size: .9rem;
  font-weight: 780;
  text-decoration: none;
  white-space: nowrap;
}

.connect-btn:hover {
  color: var(--accent);
  background: #f3d9dd;
}

.reload-btn {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.reload-btn:hover {
  background: var(--accent);
}

.reload-btn:disabled {
  cursor: wait;
  opacity: .7;
}

.period-picker select,
.custom-range input {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.custom-range input {
  min-width: 0;
  font: inherit;
}

.layout {
  display: grid;
  gap: 18px;
  padding: 22px clamp(14px, 4vw, 44px) 44px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 22px;
  padding: 0 clamp(14px, 4vw, 44px) 34px;
  color: var(--muted);
  font-size: .9rem;
}

.site-footer a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--brand);
}

.legal-page {
  padding: 28px clamp(14px, 4vw, 44px) 54px;
}

.legal-panel {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 42px);
  line-height: 1.6;
}

.legal-panel h2 {
  margin: 28px 0 10px;
  font-size: 1.15rem;
  font-weight: 780;
}

.legal-panel h2:first-of-type {
  margin-top: 0;
}

.legal-panel p {
  margin: 0 0 14px;
  color: var(--ink);
}

.legal-panel a {
  color: var(--brand);
  font-weight: 700;
}

.legal-date {
  color: var(--muted) !important;
  font-size: .9rem;
  font-weight: 700;
}

.status {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: .92rem;
}

.status.error {
  border-color: var(--red-line);
  color: var(--accent);
  background: #fff7f8;
}

.kpis,
.mini-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
}

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 42px rgba(15, 23, 42, .06);
}

.kpi {
  padding: 16px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  line-height: 1;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 760;
}

.panel-head span {
  color: var(--muted);
  font-size: .86rem;
  text-align: right;
}

.panel-head button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-2);
  font-weight: 750;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-actions span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chart-wrap {
  height: 310px;
  padding: 18px;
}

.chart-wrap.wide {
  height: 360px;
}

.chart-wrap.compact {
  height: 270px;
}

.table-wrap {
  overflow: auto;
  max-height: 360px;
  border-top: 1px solid var(--line);
}

.table-wrap.tall {
  max-height: 500px;
  border-top: 0;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8fafc;
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.goal {
  margin: 18px;
  padding: 16px;
  border: 1px solid var(--red-line);
  border-radius: 8px;
  background: var(--red-soft);
}

.growth-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.growth-copy {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
}

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

.growth-metrics .kpi {
  box-shadow: none;
}

.growth-metrics .kpi.highlight {
  grid-column: 1 / -1;
  border-color: var(--brand);
  background: var(--red-soft);
}

.growth-metrics .kpi.highlight strong {
  color: var(--brand);
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.ideas-grid {
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
  padding: 18px;
}

.idea-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #fff;
}

.idea-card h3 {
  margin: 7px 0 8px;
  font-size: .98rem;
  font-weight: 780;
}

.idea-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--red-soft);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.idea-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.goal strong {
  display: block;
  margin-bottom: 6px;
}

.goal p {
  margin: 0;
  color: var(--muted);
}

.mini-kpis {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  padding: 18px;
}

.mini-kpis .kpi {
  box-shadow: none;
}

.flow-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 18px 0;
}

.flow-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

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

.flow-card span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-card strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 6px;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.25;
}

.journey-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.journey-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #fff;
}

.journey-rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 99px;
  color: #fff;
  background: var(--brand);
  font-weight: 850;
}

.journey-stage {
  min-width: 0;
}

.journey-stage span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.journey-stage strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 3px;
  font-size: .9rem;
}

.journey-stage small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.3;
}

.journey-arrow {
  color: var(--brand);
  font-size: 1.35rem;
  font-weight: 900;
}

.journey-strength {
  grid-column: 2 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eeeeee;
}

.journey-strength span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.journey-note {
  grid-column: 2 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.35;
}

.conclusions ol {
  margin: 0;
  padding: 18px 18px 18px 42px;
}

.conclusions li {
  margin-bottom: 14px;
  line-height: 1.45;
}

.conclusions li strong {
  display: block;
  margin-bottom: 4px;
  color: var(--brand);
  font-size: 1rem;
}

.conclusions li p {
  margin: 0;
  color: var(--ink);
}

.empty {
  padding: 18px;
  color: var(--muted);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(8px);
}

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

.loading-modal {
  width: min(560px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
}

.loading-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.loading-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 780;
}

.loading-head strong {
  color: var(--brand);
  font-size: 1.8rem;
  line-height: 1;
}

.loading-progress {
  height: 12px;
  border-radius: 999px;
  background: #e2e8f0;
}

.loading-progress .progress-bar {
  background: var(--brand);
  transition: width .35s ease;
}

#loadingStep {
  margin: 16px 0 12px;
  color: var(--ink);
  font-weight: 720;
}

.loading-steps {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: .9rem;
}

.loading-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading-steps li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #cbd5e1;
}

.loading-steps li.done::before {
  background: var(--brand);
}

@media (max-width: 1080px) {
  .kpis,
  .mini-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup img {
    width: min(100%, 330px);
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .period-picker,
  .custom-range {
    min-width: 100%;
  }

  .custom-range {
    grid-template-columns: 1fr;
  }

  .kpis,
  .mini-kpis {
    grid-template-columns: 1fr;
  }

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

  .panel-head span {
    text-align: left;
  }

  .chart-wrap {
    height: 260px;
  }

  .journey-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .journey-arrow {
    display: none;
  }

  .journey-strength,
  .journey-note {
    grid-column: 1 / -1;
  }
}
