/* Simplified reporting prototype. Derived from ../style.css so the pages look like the same product: the same colour
   tokens, system font, card radius and footer. Rules that only the old tabbed dashboard needs are left out; the few
   new ones (top navigation, status badges, funnel, tally box, stacked tables on phones) are at the end. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781; --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11, 11, 11, .10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s1-soft: rgba(42, 120, 214, .12); --track: #cde2fb;
  --good: #006300; --good-soft: rgba(27, 175, 122, .14); --critical: #d03b3b; --critical-soft: rgba(208, 59, 59, .12); --warn: #a35d00; --warn-soft: rgba(235, 104, 52, .14);
  --accent: #2a78d6; --accent-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s1-soft: rgba(57, 135, 229, .18); --track: #184f95;
    --good: #0ca30c; --good-soft: rgba(25, 158, 112, .22); --critical: #e66767; --critical-soft: rgba(230, 103, 103, .18); --warn: #f0a050; --warn-soft: rgba(217, 89, 38, .22); --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .10);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s1-soft: rgba(57, 135, 229, .18); --track: #184f95;
  --good: #0ca30c; --good-soft: rgba(25, 158, 112, .22); --critical: #e66767; --critical-soft: rgba(230, 103, 103, .18); --warn: #f0a050; --warn-soft: rgba(217, 89, 38, .22); --accent: #3987e5;
}

/* ---- base (same as the dashboard) ---- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; padding: 0 16px 48px; min-width: 0; overflow-x: hidden; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--ink-2); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; max-width: 1280px; margin: 0 auto; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; min-width: 0; }
.brand .logo { display: inline-flex; color: var(--ink); line-height: 0; }
.brand .helo { height: 30px; width: auto; display: block; }
.brand .sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.brand > span:not(.sep) { white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 14px; }
.theme { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.theme:hover { background: var(--s1-soft); color: var(--ink); }
.theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun { display: block; }
  :root:not([data-theme="light"]) .theme .moon { display: none; }
}
:root[data-theme="dark"] .theme .sun { display: block; }
:root[data-theme="dark"] .theme .moon { display: none; }
.foot { max-width: 1280px; margin: 40px auto 0; padding-top: 14px; border-top: 1px solid var(--grid); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.foot a { color: var(--ink-2); }
@media (max-width: 600px) { .brand > span:not(.sep) { display: none; } .brand .sep { display: none; } }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 9px 16px; font-weight: 600; text-decoration: none; display: inline-block; }
.primary:disabled { opacity: .65; cursor: progress; }
.ghost { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; color: var(--ink); text-decoration: none; display: inline-block; }
.ghost:hover, .range button:hover { background: var(--s1-soft); }
.ghost.sm { padding: 4px 10px; font-size: 12.5px; }
.error { color: var(--critical); }
main { max-width: 1280px; margin: 0 auto; display: grid; gap: 16px; }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.filters label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.filters input, .filters select, .inline input, .form input, .form select { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; min-width: 0; color: var(--ink); }
.filters .grow { flex: 1 1 260px; }
.range { display: flex; flex-wrap: wrap; align-items: end; gap: 6px; }
.range button { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.range button.on { background: var(--s1); border-color: var(--s1); color: #fff; font-weight: 600; }
.spacer { flex: 1; }
.status { min-height: 18px; color: var(--ink-2); font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; min-width: 0; }
.card > header { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin-bottom: 14px; align-items: start; }
.card > header h2 { grid-column: 1; }
.card > header p { grid-column: 1; font-size: 13px; }
.card > header .tbl { grid-column: 2; grid-row: 1 / span 2; align-self: start; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: grid; gap: 4px; align-content: start; }
.kpi .label { font-size: 12.5px; color: var(--ink-2); }
.kpi .value { font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--ink-2); }
.kpi.bad .value { color: var(--critical); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } .grid .wide { grid-column: auto; } }

/* ---- bars (same as the dashboard) ---- */
.hbars { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; align-items: center; gap: 12px; }
.hbar .lbl { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .trk { position: relative; height: 24px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; min-width: 0; }
.hbar .barw { min-width: 0; }
.hbar .bar { height: 20px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; flex: none; transition: width .35s ease; }
.hbar .bar.dim { background: var(--axis); }
.hbar .val { font-size: 13px; white-space: nowrap; color: var(--ink); font-variant-numeric: tabular-nums; }
.hbar .val .pct { color: var(--ink-2); margin-left: 6px; }
.drop { font-size: 12px; color: var(--muted); margin: -6px 0 -2px 0; padding-left: min(202px, 40%); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-2); }
.smallmultiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.sm { display: grid; gap: 6px; min-width: 0; }
.sm h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
.sm .n { font-size: 12px; color: var(--ink-2); }
.linechart { width: 100%; display: block; overflow: visible; }
.linechart .grid line { stroke: var(--grid); stroke-width: 1; }
.linechart .axis line { stroke: var(--axis); stroke-width: 1; }
.linechart text { fill: var(--muted); font-size: 11px; }
.linechart .series path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; stroke: var(--s1); }
.linechart .area { fill: var(--s1); opacity: .10; }
.linechart .dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
@media (max-width: 600px) { .hbar { grid-template-columns: 1fr; gap: 4px; } .drop { padding-left: 0; } }

/* ---- tables (same as the dashboard, plus a stacked layout on phones) ---- */
.table { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; vertical-align: top; }
th { color: var(--ink-2); font-weight: 500; font-size: 12px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--axis); border-bottom: 0; }
.empty { color: var(--muted); padding: 10px 0; }
tr.pick { cursor: pointer; }
tr.pick:hover td { background: var(--s1-soft); }
td.wrap, th.wrap, .table.fit th, .table.fit td { white-space: normal; }
.table.tight th, .table.tight td { padding: 7px 8px; }
.table.tight td.wrap { min-width: 150px; }
td a.name { color: var(--ink); font-weight: 600; text-decoration: none; }
td a.name:hover { text-decoration: underline; }
td .id { display: block; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .table.stack table, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack thead, .table.stack tfoot { display: none; }
  .table.stack tr { border: 1px solid var(--grid); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }
  .table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; white-space: normal; text-align: right; }
  .table.stack td::before { content: attr(data-l); color: var(--ink-2); font-size: 12px; text-align: left; flex: none; }
  .table.stack td.n { text-align: right; }
  .table.stack td.full { display: block; text-align: left; }
  .table.stack td.full::before { display: block; margin-bottom: 2px; }
  .table.stack td.full:empty::before, .table.stack td.full[data-l=""]::before { display: none; }
  .table.stack td.head { font-weight: 600; text-align: left; display: block; }
  .table.stack td.head::before { display: none; }
  .table.stack tr.pick:hover td { background: none; }
}

/* ---- top navigation (new): four items, Advanced de-emphasised ---- */
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 13.5px; white-space: nowrap; }
.nav a:hover { background: var(--s1-soft); color: var(--ink); }
.nav a.on { color: var(--ink); font-weight: 600; background: var(--s1-soft); }
.nav a.adv { color: var(--muted); font-size: 12px; margin-left: 6px; padding: 8px 8px; }
.nav a.adv:hover { background: none; text-decoration: underline; }
@media (max-width: 860px) { .top { gap: 8px 16px; } .nav { order: 3; width: 100%; margin-left: -8px; } }
.crumb { font-size: 12.5px; color: var(--ink-2); }
.crumb a { color: var(--ink-2); }
.note { font-size: 12.5px; color: var(--muted); }

/* ---- page header (campaign) ---- */
.pagehead { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 12px 16px; }
.pagehead .meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.pagehead .meta b { color: var(--ink); font-weight: 500; }
.pagehead .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- status badges ---- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--border); color: var(--ink-2); vertical-align: 1px; white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--critical-soft); color: var(--critical); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--s1-soft); color: var(--s1); border-color: transparent; }
.chan { display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 600; letter-spacing: .02em; background: var(--s1-soft); color: var(--s1); margin-right: 4px; }

/* ---- tally box ---- */
.tally table td:nth-child(2), .tally table td:nth-child(3), .tally table td:nth-child(4) { font-variant-numeric: tabular-nums; }
.diff.zero { color: var(--good); }
.diff.some { color: var(--warn); }

/* ---- find a customer ---- */
.inline { display: flex; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.inline input { flex: 1 1 220px; }
.msg { border: 1px solid var(--grid); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.msg > header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.msg > header h3 { color: var(--ink); font-size: 14px; }
.msg .facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); }
.msg .facts b { color: var(--ink); font-weight: 500; }
.visit { border-top: 1px solid var(--grid); padding-top: 10px; display: grid; gap: 6px; }
.visit .vhead { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 12.5px; color: var(--ink-2); }
.visit .vhead b { color: var(--ink); font-weight: 600; }
.steps { font-size: 13px; line-height: 1.7; }
.steps .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.steps .d { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.steps .sep { color: var(--axis); margin: 0 6px; }
.steps .act { font-weight: 600; }
.hints { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.hints button { font-size: 12.5px; }

/* ---- reports ---- */
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.form .full { grid-column: 1 / -1; }
.form .row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.progress { display: inline-block; width: 90px; height: 6px; border-radius: 3px; background: var(--grid); vertical-align: middle; margin-left: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--s1); }

/* ---- glossary ---- */
.glossary td { white-space: normal; }
.glossary td:first-child { font-weight: 600; white-space: nowrap; }
.src { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 700px) {
  .glossary thead { display: none; }
  .glossary table, .glossary tbody, .glossary tr, .glossary td { display: block; width: 100%; }
  .glossary tr { padding: 8px 0; border-bottom: 1px solid var(--grid); }
  .glossary tr:last-child { border-bottom: 0; }
  .glossary td { padding: 0; border: 0; }
  .glossary td:first-child { margin-bottom: 2px; }
  .glossary td.src:not(:empty)::before { content: "From "; }
  .glossary td.src { margin-top: 2px; }
}

/* ---- Advanced: sub-navigation, columns, step builder, breakdowns ---- */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--grid); }
.subnav a { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13.5px; white-space: nowrap; }
.subnav a:hover { color: var(--ink); }
.subnav a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.subnav a.away { color: var(--muted); margin-left: auto; }
.pane { display: grid; gap: 16px; }
.cols { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: 6px; align-items: end; height: 170px; padding-top: 22px; border-bottom: 1px solid var(--axis); }
.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; position: relative; min-width: 0; }
.col .bar { width: min(100%, 26px); border-radius: 4px 4px 0 0; background: var(--s1); min-height: 2px; }
.col .cap { font-size: 11.5px; color: var(--ink); position: absolute; top: -20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col:hover .bar { filter: brightness(1.12); }
.colx { display: grid; grid-template-columns: repeat(var(--n, 7), 1fr); gap: 6px; margin-top: 6px; }
.colx span { text-align: center; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark { color: var(--s1); vertical-align: middle; }
.detail { display: grid; gap: 14px; }
.props { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.props .prop { border: 1px solid var(--grid); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.props .prop h4 { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; }
.props .prop div { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 2px 0; }
.props .prop div span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge.auto { font-size: 10.5px; margin-left: 6px; }
.fallback { display: grid; gap: 4px; font-size: 13px; }
.fallback div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--grid); padding: 5px 0 0; }
.fallback div:first-child { border-top: 0; }
.fallback .num { font-variant-numeric: tabular-nums; }
.today { border-color: var(--s1); }
