:root {
  --bg: #f7f5f1;
  --bg-2: #ffffff;
  --ink: #2d373e;
  --muted: #6f7c86;
  --line: rgba(45, 55, 62, 0.1);
  --line-strong: rgba(45, 55, 62, 0.16);
  --card: rgba(255, 255, 255, 0.94);
  --card-2: rgba(232, 240, 247, 0.92);
  --hero: #2d373e;
  --hero-2: #33424d;
  --shadow: 0 14px 34px rgba(45, 55, 62, 0.1);
  --accent: #db625c;
  --accent-2: #98b7cf;
  --accent-3: #2d373e;
  --accent-soft: rgba(219, 98, 92, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
}

.dashboard-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.hero-panel,
.panel,
.filters-card,
.stat-card,
.error-card {
  background: var(--card);
  border: 1px solid rgba(45, 55, 62, 0.08);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
  padding: 22px;
  border-radius: 18px;
  margin-bottom: 16px;
  background: #2d373e;
  color: #f5f7f8;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--accent-2);
  font-weight: 700;
}

.hero-copy h1,
.panel-header h2,
.error-card h2 {
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  line-height: 1.1;
}

.hero-copy h1 {
  font-size: clamp(28px, 3.8vw, 42px);
  max-width: 14ch;
}

.hero-text {
  margin: 12px 0 0;
  max-width: 58ch;
  color: rgba(245, 247, 248, 0.78);
  font-size: 14px;
  line-height: 1.55;
}

.filters-card {
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(152, 183, 207, 0.2);
  box-shadow: none;
}

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

.active-filter-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(232, 240, 247, 0.82);
  border: 1px solid rgba(45, 55, 62, 0.08);
  font-size: 13px;
}

.active-filter-banner span {
  color: var(--muted);
}

.active-filter-banner strong {
  color: var(--ink);
}

.active-filter-banner a {
  margin-left: auto;
  color: #c24f49;
  font-weight: 700;
  text-decoration: none;
}

.filters-card label span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: rgba(245, 247, 248, 0.72);
  font-weight: 700;
}

.filters-card input,
.filters-card select,
.filters-card button {
  width: 100%;
  border: 1px solid rgba(152, 183, 207, 0.24);
  border-radius: 10px;
  font: inherit;
}

.filters-card input,
.filters-card select {
  min-height: 44px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f7f8;
}

.filter-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(245, 247, 248, 0.78);
}

.toggle input {
  width: 18px;
  height: 18px;
  min-height: auto;
}

.filter-actions {
  margin-top: 12px;
}

.filters-card button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(45, 55, 62, 0.18);
  background: #2d373e;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(45, 55, 62, 0.12);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  border-radius: 12px;
  padding: 16px;
  background: var(--card);
}

.stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card strong {
  font-size: clamp(22px, 2.7vw, 34px);
  line-height: 1;
  color: var(--accent-3);
}

.main-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  border-radius: 16px;
  padding: 18px;
  background: var(--card);
}

.panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-caption {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.sankey-frame {
  min-height: 500px;
  border-radius: 14px;
  background: #2d373e;
  border: 1px solid rgba(45, 55, 62, 0.12);
  overflow: hidden;
  position: relative;
}

.sankey-frame::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 374px;
  width: 2px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 426px 0 0 rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

#attribution-sankey {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 500px;
}

.mini-grid {
  display: grid;
  gap: 10px;
}

.mini-card {
  padding: 14px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid rgba(45, 55, 62, 0.06);
}

.mini-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.metric-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.metric-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.metric-list span {
  color: var(--muted);
}

.bars-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid rgba(45, 55, 62, 0.06);
}

.bar-row__header,
.bar-row__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bar-row__header strong,
.bar-row__footer span {
  font-size: 13px;
}

.bar-row__header span,
.bar-row__footer span {
  color: var(--muted);
}

.bar-track {
  height: 12px;
  margin: 10px 0 10px;
  border-radius: 999px;
  background: rgba(45, 55, 62, 0.09);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: #db625c;
}

.bar-fill--cool {
  background: #8fadc3;
}

.panel-table {
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(45, 55, 62, 0.06);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.92);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(45, 55, 62, 0.06);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: rgba(232, 240, 247, 0.96);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

code {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(219, 98, 92, 0.12);
  color: #c24f49;
  font-size: 11px;
}

a {
  color: #7f9fb8;
}

.tracking-code-link {
  text-decoration: none;
}

.tracking-code-link code {
  cursor: pointer;
}

.tracking-help-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  border: 1px solid rgba(45, 55, 62, 0.16);
  border-radius: 999px;
  background: #2d373e;
  color: #fff;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(45, 55, 62, 0.14);
}

.tracking-help-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 21;
  width: min(360px, calc(100vw - 24px));
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(45, 55, 62, 0.08);
  box-shadow: 0 16px 34px rgba(45, 55, 62, 0.14);
}

.tracking-help-panel__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.tracking-help-panel__eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tracking-help-panel h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.tracking-help-panel__close {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tracking-help-panel__text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.tracking-help-panel__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.tracking-help-panel__group {
  padding: 10px 10px 8px;
  border-radius: 10px;
  background: var(--card-2);
  border: 1px solid rgba(45, 55, 62, 0.06);
}

.tracking-help-panel__group strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.tracking-help-panel__group ul {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.tracking-help-panel.is-hidden,
.tracking-help-launcher.is-hidden {
  display: none;
}

.conversion-tags {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.error-card {
  padding: 18px;
  border-radius: 16px;
}

.error-card p {
  margin: 12px 0 0;
  color: var(--muted);
}

.sankey-node rect {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1;
}

.sankey-node text.label {
  fill: #f5f7f8;
  font-size: 16px;
  font-weight: 700;
}

.sankey-node text.value {
  fill: rgba(245, 247, 248, 0.74);
  font-size: 17px;
  font-weight: 700;
}

.sankey-node--light rect {
  stroke: rgba(45, 55, 62, 0.08);
}

.sankey-node--light text.label {
  fill: #2d373e;
  font-size: 15px;
}

.sankey-node--light text.value {
  fill: rgba(45, 55, 62, 0.62);
  font-size: 17px;
  font-weight: 700;
}

.sankey-link {
  fill: none;
  opacity: 0.82;
  mix-blend-mode: multiply;
  transition: opacity 0.16s ease;
}

.sankey-link:hover,
.sankey-node:hover {
  opacity: 1;
}

.sankey-caption {
  fill: rgba(245, 247, 248, 0.62);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sankey-tooltip {
  position: absolute;
  left: 12px;
  top: 12px;
  min-width: 220px;
  max-width: 280px;
  padding: 12px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(45, 55, 62, 0.08);
  box-shadow: 0 10px 24px rgba(45, 55, 62, 0.14);
  color: var(--ink);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 3;
}

.sankey-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.sankey-tooltip__title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.sankey-tooltip__subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.sankey-tooltip__rows {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.sankey-tooltip__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
}

.sankey-tooltip__row span {
  color: var(--muted);
}

.sankey-tooltip__row strong {
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .main-grid,
  .detail-grid,
  .hero-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .dashboard-shell {
    width: min(100% - 20px, 1400px);
    padding: 18px 0 28px;
  }

  .stats-grid,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .panel,
  .hero-panel,
  .filters-card,
  .stat-card {
    border-radius: 14px;
  }

  .tracking-help-panel {
    right: 12px;
    bottom: 12px;
    width: min(360px, calc(100vw - 24px));
  }

  .tracking-help-launcher {
    right: 12px;
    bottom: 12px;
  }

  .tracking-help-panel__grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .bar-row__header,
  .bar-row__footer {
    align-items: start;
    flex-direction: column;
  }
}
