/* Vertical Funnel · mobile-first */
:root {
  --bg: #05080f;
  --bg-elev: #0e1522;
  --bg-card: #141c2c;
  --line: rgba(212, 160, 84, 0.2);
  --text: #f5f0e8;
  --muted: #94a0b8;
  --gold: #d4a054;
  --gold-soft: rgba(212, 160, 84, 0.16);
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.18);
  --ok: #4ade80;
  --warn: #fbbf24;
  --alert: #fb7185;
  --na: #6b7588;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  --pad: clamp(12px, 4vw, 24px);
  --radius: 18px;
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(212, 160, 84, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.4;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

.top, main, footer {
  width: min(720px, calc(100% - (var(--pad) * 2)));
  margin: 0 auto;
}
.top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(16px + env(safe-area-inset-top)) 0 12px;
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.mark {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #e8c27a, #b07a2c);
  color: #1a1206; font-weight: 800; letter-spacing: 0.04em;
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0; color: var(--gold); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; }
h1 {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 4.2vw, 1.55rem);
  font-weight: 700;
  line-height: 1.2;
}
.meta { color: var(--muted); font-size: 0.82rem; }

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.filters label {
  display: grid; gap: 6px; color: var(--muted); font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase;
}
select, .ghost {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
select {
  background-color: var(--bg-elev);
  padding: 12px 40px 12px 14px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.ghost {
  background: transparent;
  color: var(--gold);
  padding: 12px 14px;
  font-weight: 600;
}
.ghost:active, select:active, .stage:active, .cr:active, tbody tr:active, .kpi:active {
  transform: scale(0.985);
}

.slice-note {
  background: var(--gold-soft);
  border: 1px solid var(--line);
  color: #f3e2c0;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 0.9rem;
}

.funnel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}
.stage-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.stage-cell .stage { flex: 1 1 auto; }
.stage-cell .cr { margin: 0; }

.stage {
  display: block;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.stage:hover, .stage:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.stage.active { border-color: var(--gold); background: #1a2438; }
.stage-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.stage-name {
  margin: 0; font-size: 0.78rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600;
}
.cost { margin: 0; font-size: 0.78rem; color: var(--na); }
.stage-value {
  font-size: clamp(1.35rem, 5.5vw, 2.1rem);
  font-weight: 750;
  margin: 8px 0 4px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.stage-sub { margin: 0 0 12px; color: var(--muted); font-size: 0.84rem; overflow-wrap: anywhere; }
.bar {
  height: 10px; border-radius: 999px; background: #0a101c; overflow: hidden;
}
.bar > span {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, #8a5a1f, var(--gold) 55%, #f0c48a);
}
.stage.sales .bar > span {
  background: linear-gradient(90deg, #0f766e, var(--teal));
}
.stage.placeholder .bar > span {
  width: 22% !important;
  background: repeating-linear-gradient(90deg, #2a3348, #2a3348 8px, #1a2234 8px, #1a2234 16px);
}
.stage.placeholder .stage-value { color: var(--na); font-size: 1.35rem; }

.cr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: var(--bg-elev);
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.cr:hover, .cr:focus-visible { outline: 2px solid var(--gold); }
.cr.active { border-style: solid; border-color: var(--gold); background: var(--gold-soft); }
.cr .cr-id { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.cr .cr-pct { font-size: 0.95rem; font-weight: 750; }
.cr .cr-label { color: var(--muted); font-size: 0.65rem; letter-spacing: 0.04em; text-transform: uppercase; flex: 1 1 100%; }
.cr.warn .cr-pct { color: var(--warn); }
.cr.alert .cr-pct { color: var(--alert); }
.cr.ok .cr-pct { color: var(--ok); }
.cr.na .cr-pct { color: var(--na); font-weight: 600; }

.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.kpi {
  display: block;
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  min-height: 72px;
}
.kpi:hover, .kpi:focus-visible { outline: 2px solid var(--gold); }
.kpi.active { border-color: var(--gold); background: var(--gold-soft); }
.kpi p { margin: 0; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi strong { display: block; margin-top: 6px; font-size: 1.1rem; overflow-wrap: anywhere; }

.caveats {
  color: #c9d1e0;
  background: #111827;
  border-left: 3px solid var(--gold);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
}

.tables { display: grid; gap: 14px; margin: 18px 0 36px; }
.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel header { padding: 14px 14px 0; }
.panel h2 { margin: 0; font-size: 1rem; }
.panel header p { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }
.table-wrap { overflow: visible; padding: 8px 10px 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.05); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; }
tbody tr { cursor: pointer; -webkit-tap-highlight-color: transparent; }
tbody tr:hover { background: rgba(212, 160, 84, 0.08); }
tbody tr.active { background: var(--gold-soft); }
.na { color: var(--na); }

footer { color: var(--muted); padding: 4px 0 28px; font-size: 0.8rem; }

/* Card rows on narrow screens (default for this mobile-first layout) */
@media (max-width: 900px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    min-height: 44px;
  }
  tbody tr.active { outline: 1px solid var(--gold); }
  tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    text-align: right;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    white-space: normal;
  }
  tbody td:last-child { border-bottom: 0; }
  tbody td:first-child {
    display: block;
    text-align: left;
    font-weight: 700;
    color: var(--gold);
    padding-bottom: 8px;
    margin-bottom: 2px;
    border-bottom: 1px solid rgba(212, 160, 84, 0.22);
  }
  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: left;
    flex: 1 1 auto;
  }
  tbody td:first-child::before { content: none; }
  .panel header p { display: none; }
}

@media (min-width: 720px) {
  .top, main, footer { width: min(860px, calc(100% - 48px)); }
  .filters { grid-template-columns: repeat(3, 1fr) auto; align-items: end; }
  .ghost { width: auto; min-width: 120px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .funnel { gap: 12px; }
  .stage { padding: 16px; }
  .stage-value { font-size: clamp(1.7rem, 3.5vw, 2.35rem); }
}

@media (max-width: 400px) {
  .kpis { grid-template-columns: 1fr; }
  .stage-sub { font-size: 0.75rem; }
  .cost { display: none; }
}
