:root {
  --pink: #e0336e;
  --green: #8e8a2e;
  --orange: #e45b3a;
  --brown: #5a3e2b;
  --ink: #2b2522;
  --muted: #6e6560;
  --cream: #fbf6f1;
  --line: #eadfd6;
  --bg: #ffffff;
  --card: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Montserrat, Helvetica, Arial, sans-serif; }
a { color: var(--pink); }

/* Installed app on iPhone: keep content clear of the notch and home bar. */
body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.bar { height: 8px; display: flex; }
.bar i { flex: 1; }
.o { background: var(--orange); } .g { background: var(--green); } .p { background: var(--pink); }

.wrap { max-width: 1600px; margin: 0 auto; padding: 22px 20px 48px; }
/* Sections pack into columns like bricks, so there are no empty gaps. */
.grid { column-count: 1; column-gap: 16px; }
.grid section.src { break-inside: avoid; display: inline-block; width: 100%; margin: 0 0 16px; }
@media (min-width: 1100px) { .grid { column-count: 2; } }
@media (min-width: 1100px) { .grid .row2 { grid-template-columns: 1fr; } }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
header.top img { height: 40px; }
header.top h1 { margin: 0; font-size: 22px; font-weight: 800; }
header.top h1 span { color: var(--pink); }
header.top .meta { font-size: 12px; color: var(--muted); font-weight: 600; }
.btn { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font: 600 12px Montserrat, sans-serif; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--pink); color: var(--pink); }

section.src { border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 14px; margin-bottom: 18px; background: var(--card); }
section.src h2 { margin: 0 0 14px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; display: flex; align-items: center; gap: 8px; }
section.src h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--pink)); }
section.src h2 .t { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
section.src h2 .open { margin-left: auto; flex-shrink: 0; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: none; color: var(--ink); text-decoration: none; white-space: nowrap; }
section.src h2 .open:hover { border-color: var(--c, var(--pink)); color: var(--c, var(--pink)); }
.wall section.src h2 .open { padding: 3px 9px; font-size: 10px; }
section.src h2 small { font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.metric { background: var(--cream); border-radius: 10px; padding: 12px 14px; border-left: 4px solid var(--c, var(--pink)); }
.metric .v { font-size: 26px; font-weight: 800; line-height: 1.1; }
.metric .l { font-size: 12px; font-weight: 700; margin-top: 4px; }
.metric .s { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: 2px; }

.metric .d { font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.metric .d b { font-weight: 800; margin-right: 2px; }
.metric .d.good b { color: #2e7d32; }
.metric .d.bad b { color: #c62828; }
.metric.link { display: block; color: inherit; text-decoration: none; }
.metric.link:hover { box-shadow: 0 0 0 2px var(--c, var(--pink)) inset; }
a.cell { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
a.cell:hover { color: var(--pink); text-decoration-color: var(--pink); }
.cell.bad { color: #c62828; font-weight: 700; }
.extra { margin-top: 14px; background: #fff6f6; border-radius: 10px; padding: 10px 12px; }

.health { border-radius: 10px; padding: 9px 14px; font-size: 12.5px; font-weight: 600; margin-bottom: 12px; }
.health.good { background: #eef5e4; color: #3b5a12; }
.health.bad { background: #fbebeb; color: #8a1c1c; border: 1px solid #f3c4c4; }
.health a { color: #8a1c1c; text-decoration: underline; }

/* Lead funnel strip */
section.funnel { border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; background: var(--cream); }
section.funnel h2 { margin: 0 0 14px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; }
section.funnel h2 small { font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 12px; margin-left: 8px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.step { display: flex; align-items: stretch; }
.step .box { flex: 1; background: #fff; border-radius: 10px; padding: 12px 14px; border-top: 4px solid var(--pink); }
.step:nth-child(2) .box { border-top-color: var(--orange); }
.step:nth-child(3) .box { border-top-color: var(--green); }
.step:nth-child(4) .box { border-top-color: var(--brown); }
.step .v { font-size: 28px; font-weight: 800; line-height: 1.1; }
.step .l { font-size: 12px; font-weight: 700; margin-top: 4px; }
.step .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.conv { display: flex; flex-direction: column; justify-content: center; align-items: center; min-width: 52px; font-size: 12px; font-weight: 800; color: var(--pink); }
.conv span { font-size: 18px; color: var(--muted); line-height: 1; }
.cost { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 14px; font-size: 13px; align-items: baseline; }
.cost b { font-size: 18px; font-weight: 800; color: var(--pink); }
.cost .muted { color: var(--muted); font-size: 12px; font-weight: 600; }
@media (max-width: 820px) {
  .steps { grid-template-columns: 1fr 1fr; gap: 10px; }
  .conv { min-width: 40px; }
}
.wall section.funnel { padding: 10px 12px; margin-bottom: 10px; }
.wall .step .v { font-size: 20px; }
.wall .cost { margin-top: 8px; font-size: 12px; }

@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 10px 11px; }
  .metric .v { font-size: 22px; }
  .wrap { padding: 14px 12px 32px; }
  header.top img { height: 30px; }
}
.row2 { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; margin-top: 14px; }
@media (max-width: 820px) { .row2 { grid-template-columns: 1fr; } }
.spark { background: var(--cream); border-radius: 10px; padding: 12px 14px; }
.spark .l { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.spark svg { width: 100%; height: 70px; display: block; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 2px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tablewrap { overflow-x: auto; }
.tablewrap h3 { margin: 0 0 6px; font-size: 12px; font-weight: 700; }

.empty { background: var(--cream); border-radius: 10px; padding: 14px; font-size: 13px; color: var(--muted); }
.empty b { color: var(--ink); }
.empty.connect { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn.pink { background: var(--pink); border-color: var(--pink); color: #fff; text-decoration: none; }
.btn.pink:hover { background: #c92a60; color: #fff; }
.err { background: #fbebeb; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: #8a1c1c; }

/* Wall view: everything on one big screen, compact. */
.wall { max-width: none; padding: 12px 16px 16px; }
.wall header.top { margin-bottom: 10px; }
.wall header.top img { height: 30px; }
.wall header.top h1 { font-size: 18px; }
/* Sections not connected yet: small and quiet, at the bottom. */
section.src.pending { padding: 10px 14px; opacity: .75; }
section.src.pending h2 { margin-bottom: 6px; font-size: 12px; }
section.src.pending .empty { padding: 8px 10px; font-size: 12px; }

/* Wall view packs sections into columns like bricks, so there are no empty gaps. */
.wall .grid { display: block; column-gap: 10px; column-count: 1; }
@media (min-width: 900px) { .wall .grid { column-count: 2; } }
@media (min-width: 1300px) { .wall .grid { column-count: 3; } }
.wall .grid section.src { break-inside: avoid; display: inline-block; width: 100%; margin: 0 0 10px; }
/* Sections still waiting on setup stay off the wall. */
.wall .grid section.src.pending { display: none; }
.wall section.src { padding: 12px 12px 10px; border-radius: 10px; }
.wall section.src h2 { font-size: 12px; margin-bottom: 8px; }
.wall .metrics { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; }
.wall .metric { padding: 7px 9px; border-left-width: 3px; }
.wall .metric .v { font-size: 19px; }
.wall .metric .l { font-size: 10.5px; }
.wall .metric .s { display: none; }
.wall .row2 { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.wall .spark { padding: 6px 9px; }
.wall .spark .l { font-size: 10.5px; margin-bottom: 4px; }
.wall .spark svg { height: 44px; }
.wall table { font-size: 11px; }
.wall th, .wall td { padding: 3px 6px; }
.wall tbody tr:nth-child(n+5) { display: none; }
.wall footer.f { margin-top: 10px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 360px; border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; text-align: center; }
.login img { height: 46px; margin-bottom: 14px; }
.login h1 { font-size: 18px; margin: 0 0 16px; }
.login input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font: 500 14px Montserrat, sans-serif; margin-bottom: 12px; }
.login button { width: 100%; padding: 11px; border: 0; border-radius: 8px; background: var(--pink); color: #fff; font: 700 14px Montserrat, sans-serif; cursor: pointer; }
.login .bad { color: #8a1c1c; font-size: 12px; margin-bottom: 10px; }
footer.f { margin-top: 26px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
