:root {
  --blue: #0a7dc2; --blue2: #38a8de; --navy: #0b1b2b; --ink: #0b131c; --ink2: #44505c; --muted: #6b7783;
  --line: #e3e8ee; --bg: #f4f7fa; --card: #fff; --good: #1a7f4b; --warn: #a15c00; --bad: #b42318;
  --good-bg: #e7f6ee; --warn-bg: #fff4e0; --bad-bg: #fdecea;
  --r: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.err { color: var(--bad); min-height: 1.2em; font-size: 14px; margin: 8px 0 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--navy) 0%, #0f2c46 55%, #11466d 100%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { border-radius: 14px; display: block; }
.login-card .by { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--blue); letter-spacing: .02em; }
.login-card h1 { margin: 16px 0 4px; font-size: 24px; letter-spacing: -.01em; }
.login-card p.muted { margin: 0 0 18px; font-size: 15px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin-bottom: 12px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfd; }
.login-card input:focus { outline: 2px solid var(--blue2); border-color: transparent; }
.login-card button { width: 100%; padding: 13px; border: 0; border-radius: 10px; color: #fff; font-weight: 600; font-size: 16px;
  background: linear-gradient(90deg, var(--blue), var(--blue2)); margin-top: 6px; }
.login-card button:disabled { opacity: .6; }

/* Header + nav */
.top { background: var(--navy); color: #fff; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.brand > div { min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand-line { font-size: 12px; color: #9fc4de; letter-spacing: .02em; }
.client-name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; gap: 8px; align-items: center; }
.top select { max-width: 220px; padding: 6px 8px; border-radius: 8px; border: 1px solid #2c4660; background: #12304b; color: #fff; font-size: 14px; }
.ghost { background: transparent; border: 1px solid #2c4660; color: #cfe3f2; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--navy); padding: 0 10px; scrollbar-width: none; position: sticky; top: 0; z-index: 5; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; background: none; border: 0; color: #9fb3c4; padding: 10px 12px 12px; font-size: 15px; font-weight: 600;
  border-bottom: 3px solid transparent; }
.tabs button.on { color: #fff; border-bottom-color: var(--blue2); }
.subbar { padding: 12px 16px 4px; max-width: 1100px; margin: 0 auto; }
.ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.ranges button { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 14px; color: var(--ink2); }
.ranges button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.custom { margin-top: 8px; display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.custom input { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; }
.synced { font-size: 12px; color: var(--muted); margin-top: 8px; }
.synced b { color: var(--ink2); font-weight: 600; }
main { padding: 8px 16px 24px; max-width: 1100px; margin: 0 auto; }
.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--ink); }
.card h3 { font-size: 14px; margin: 14px 0 6px; color: var(--ink2); }
.note { border-left: 4px solid var(--blue); }
.note .who { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.note .who img { border-radius: 50%; flex: none; }
.note p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink2); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12.5px; color: var(--ink2); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: #eef2f6; color: var(--ink2); }
.pill.live { background: var(--good-bg); color: var(--good); }
.pill.src { background: #e8f3fb; color: #075d91; }
table.split { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.split th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.split th:first-child, table.split td:first-child { text-align: left; }
table.split td { text-align: right; padding: 9px 4px; border-bottom: 1px solid var(--line); }
table.split tr:last-child td { border-bottom: 0; font-weight: 700; }
.small { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 8px 0 0; }

/* Charts */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--blue); }
.chart .bar.partial { fill: #9ccbe8; }
.chart .bar:hover, .chart .hit:hover + .bar { fill: #075d91; }
.chart .hit { fill: transparent; }
.chart .grid { stroke: #edf1f5; stroke-width: 1; }
.chart text { font-size: 10px; fill: var(--muted); font-family: inherit; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; }
.chart-title span { font-size: 12px; color: var(--muted); }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 8px;
  z-index: 50; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
details.table summary { font-size: 13px; color: var(--blue); cursor: pointer; margin-top: 6px; }

/* Ads */
.ads { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 760px) { .ads { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .ads { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ad { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.ad .thumb { position: relative; background: #0b131c; aspect-ratio: 4 / 5; overflow: hidden; }
.ad .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad .thumb .play { position: absolute; left: 10px; bottom: 10px; background: rgba(11,19,28,.75); color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px; }
.ad .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.ad .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ad .name { font-weight: 700; font-size: 15px; }
.ad .camp { font-size: 12px; color: var(--muted); }
.ad .headline { font-weight: 600; font-size: 14px; }
.ad .copy { font-size: 13.5px; color: var(--ink2); line-height: 1.45; white-space: pre-line; max-height: 4.4em; overflow: hidden; }
.ad .copy.open { max-height: none; }
.ad .more { background: none; border: 0; color: var(--blue); padding: 0; font-size: 13px; text-align: left; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.metrics div { text-align: center; }
.metrics .mv { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.metrics .mk { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 2px; }
.section-h h2 { font-size: 17px; margin: 0; }
.section-h span { font-size: 12.5px; color: var(--muted); }

/* Timeline */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 18px 26px; }
.tl li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.tl li:last-child::before { display: none; }
.tl li::after { content: ""; position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--blue); }
.tl li.result::after { border-color: var(--good); }
.tl .d { font-size: 12px; color: var(--muted); font-weight: 600; }
.tl .t { font-weight: 700; font-size: 15px; margin: 2px 0 4px; }
.tl .x { font-size: 14px; color: var(--ink2); line-height: 1.5; }
.tl .why { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tl .why b { color: var(--ink2); }

/* Leads */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.filters button { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--ink2); }
.filters button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.lead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.lead:last-child { border-bottom: 0; }
.lead .ln { font-weight: 600; font-size: 15px; }
.lead .ld { font-size: 12.5px; color: var(--muted); }
.lead .rs { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lead .stage { font-size: 12.5px; color: var(--ink2); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.report { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.report:last-child { border-bottom: 0; }
.banner { background: #e8f3fb; color: #075d91; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.admin-tag { display: inline-block; font-size: 11px; background: #12304b; color: #9fc4de; padding: 2px 6px; border-radius: 6px; margin-top: 3px; font-weight: 600; }
@media (max-width: 560px) {
  .top-right { flex: 1 1 100%; }
  .top select { flex: 1; max-width: none; }
}

/* Services */
.svcs { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 12px 0; }
@media (min-width: 760px) { .svcs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.svc { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; }
.svc-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.svc-h h3 { font-size: 16px; margin: 0; color: var(--ink); line-height: 1.3; }
.svc-blurb { font-size: 14px; line-height: 1.5; color: var(--ink2); margin: 8px 0 0; }
.svc-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; }
.svc-stats > div { background: #f7fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.svc-stats .sv { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.svc-stats .sk { font-size: 11.5px; color: var(--ink2); margin-top: 2px; line-height: 1.35; }
.svc-note { font-size: 12.5px; font-weight: 600; color: var(--good); margin-top: 12px; }
.svc-note.muted { color: var(--muted); font-weight: 500; }
.svc-link { margin-top: 14px; align-self: flex-start; background: #eef6fc; border: 1px solid #cfe6f6; color: #075d91; font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 10px; }
.svc-link:hover { background: #e2f0fa; }
