/* MAD Colour brand – colours and fonts taken from madcolour.com */
:root {
  color-scheme: light;
  --mad-navy: #1c70b8;
  --mad-blue: #009ee2;
  --mad-teal: #1aa69f;
  --mad-yellow: #ffec00;
  --mad-orange: #fbb900;
  --mad-pink: #e84f96;
  --mad-magenta: #e5007e;
  --mad-purple: #ba3b8c;
  --mad-deep: #3f2669;
  --stripe: linear-gradient(90deg, #1c70b8 0%, #009ee2 14%, #1aa69f 28%, #ffec00 44%, #fbb900 58%, #e84f96 72%, #e5007e 86%, #ba3b8c 100%);

  --bg: #f4f4f4;
  --surface: #ffffff;
  --border: #e6e6e6;
  --text: #111111;
  --text-2: #4a4a4a;
  --muted: #7a7a7a;
  --accent: var(--mad-magenta);
  --line: #1c70b8;
  --series-prev: #b5b5b5;
  --bar-track: #f0f0f0;
  --good: #1a8a4a;
  --bad: #c62828;
  --grid: #efefef;
  --radius: 14px;

  --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "neusa-next-std-condensed", "Poppins", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0b;
    --surface: #161616;
    --border: #262626;
    --text: #f5f5f5;
    --text-2: #cfcfcf;
    --muted: #8c8c8c;
    --line: #009ee2;
    --series-prev: #5c5c5c;
    --bar-track: #232323;
    --good: #4cc77f;
    --bad: #ff6b6b;
    --grid: #222222;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #161616;
  --border: #262626;
  --text: #f5f5f5;
  --text-2: #cfcfcf;
  --muted: #8c8c8c;
  --line: #009ee2;
  --series-prev: #5c5c5c;
  --bar-track: #232323;
  --good: #4cc77f;
  --bad: #ff6b6b;
  --grid: #222222;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-body);
}
h1, h2 { margin: 0; font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
h2 { font-size: 20px; margin-bottom: 14px; line-height: 1.1; }
h2 .muted { font-family: var(--font-body); font-size: 13px; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.muted { color: var(--muted); font-weight: 400; }
button { font: inherit; cursor: pointer; }

/* Header – black like madcolour.com, with the logo's colour stripes underneath */
.topbar {
  position: relative;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px max(16px, calc((100% - 1200px) / 2));
  background: #000; color: #fff;
}
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px; background: var(--stripe); }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: #fff; }
.brand img { height: 44px; width: auto; display: block; }
.brand h1 { font-size: 26px; line-height: 1; padding-left: 14px; border-left: 1px solid #333; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar form { margin: 0; }
.live { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #ddd; }
.live strong { color: #fff; font-weight: 600; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #4cc77f; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(76,199,127,.55); } 70% { box-shadow: 0 0 0 9px rgba(76,199,127,0); } 100% { box-shadow: 0 0 0 0 rgba(76,199,127,0); } }
@media (prefers-reduced-motion: reduce) { .live .dot { animation: none; } }

.btn-ghost { white-space: nowrap; background: none; border: 1px solid #444; color: #fff; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.btn-ghost:hover { border-color: var(--mad-magenta); color: #fff; background: var(--mad-magenta); }
.btn-primary { background: var(--mad-magenta); color: #fff; border: 0; padding: 12px 18px; border-radius: 999px; font-weight: 600; letter-spacing: .02em; }
.btn-primary:hover { background: #c4006c; }

/* Layout */
.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 16px 48px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.toolbar p { margin: 0; font-size: 13px; }

.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.segmented button { background: none; border: 0; color: var(--text-2); padding: 7px 14px; border-radius: 999px; white-space: nowrap; font-weight: 500; font-size: 14px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--mad-magenta); color: #fff; }
.segmented.small button { padding: 5px 12px; font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; position: relative; overflow: hidden; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--mad-navy)); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }

/* KPIs – each tile takes a colour from the logo */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 14px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--c); }
.kpi:nth-child(1) { --c: var(--mad-navy); }
.kpi:nth-child(2) { --c: var(--mad-blue); }
.kpi:nth-child(3) { --c: var(--mad-teal); }
.kpi:nth-child(4) { --c: var(--mad-orange); }
.kpi:nth-child(5) { --c: var(--mad-pink); }
.kpi:nth-child(6) { --c: var(--mad-magenta); }
.kpi .label { font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 15px; color: var(--text-2); margin-top: 2px; }
.kpi .value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin: 2px 0 2px; line-height: 1.2; }
.kpi .delta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.delta .up { color: var(--good); font-weight: 600; }
.delta .down { color: var(--bad); font-weight: 600; }

/* Trend chart */
.trend { --c: var(--line); }
.legend { display: flex; gap: 18px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch.line { width: 20px; height: 0; border-top: 3px solid var(--line); display: inline-block; border-radius: 2px; }
.swatch.line.dashed { border-top: 2px dashed var(--series-prev); }
.chart-box { position: relative; height: 290px; }

/* Bar lists */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.span-2 { grid-column: span 2; }
.card.pages { --c: var(--mad-navy); }
.card.channels { --c: var(--mad-teal); }
.card.sources { --c: var(--mad-magenta); }
.card.countries { --c: var(--mad-orange); }
.card.devices { --c: var(--mad-purple); }
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 14px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bar-row .name a { color: inherit; text-decoration: none; }
.bar-row .name a:hover { color: var(--mad-magenta); text-decoration: underline; }
.bar-row .val { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; text-align: right; }
.bar-row .val small { color: var(--muted); margin-left: 6px; font-weight: 400; }
.bar-row .track { grid-column: 1 / -1; height: 7px; background: var(--bar-track); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--c); border-radius: 4px; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

.alert { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.foot { font-size: 12px; margin-top: 24px; text-align: center; }
.foot a { color: inherit; }

.loading .kpis, .loading .card { opacity: .55; transition: opacity .2s; }

@media (max-width: 720px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 24px; }
  .chart-box { height: 220px; }
  .brand img { height: 30px; }
  .brand h1 { font-size: 21px; padding-left: 10px; }
  .brand { gap: 10px; }
  .topbar-right { gap: 10px; }
  .btn-ghost { padding: 6px 11px; }
}

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #000; position: relative; }
.login-page::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 6px; background: var(--stripe); }
.login-card { width: 100%; max-width: 380px; background: #111; border: 1px solid #262626; border-radius: 18px; padding: 32px 28px; color: #f5f5f5; }
.login-card .logo { display: block; height: 72px; width: auto; margin: 0 auto 14px; }
.login-card h1 { text-align: center; font-size: 30px; margin-bottom: 22px; color: #fff; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #bdbdbd; }
.login-card input { font: inherit; padding: 11px 14px; border: 1px solid #333; border-radius: 10px; background: #0b0b0b; color: #fff; }
.login-card input:focus { outline: 2px solid var(--mad-magenta); outline-offset: 1px; border-color: transparent; }
.login-card .btn-primary { margin-top: 6px; }
.login-card .alert { background: rgba(229, 0, 126, .12); color: #ff8ac4; border-color: rgba(229, 0, 126, .4); }

/* Icons (Font Awesome 5 – same set as madcolour.com) */
h2 > i { color: var(--c); margin-right: 6px; font-size: .85em; width: 1.15em; text-align: center; }
.kpi-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 14px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); flex: none; }
.row-icon { display: inline-block; width: 1.4em; margin-right: 6px; text-align: center; color: var(--c); font-size: 13px; }
.row-icon.flag { font-size: 15px; }
.bar-row .name .page-title { color: var(--text); font-weight: 500; text-decoration: none; }
.bar-row .name a.page-title:hover { color: var(--mad-magenta); text-decoration: underline; }
.bar-row .name .page-path { color: var(--muted); font-size: 12.5px; margin-left: 8px; }
.site-link { display: inline-flex; align-items: center; gap: 7px; color: #ddd; text-decoration: none; font-size: 13px; white-space: nowrap; }
.site-link:hover { color: #fff; }
.site-link i { font-size: 11px; }
.btn-ghost i { font-size: 12px; margin-right: 4px; }
@media (max-width: 720px) {
  .site-link span { display: none; }
  .bar-row .name .page-path { display: none; }
}

/* Enquiries */
.card.enquiries { --c: var(--mad-magenta); }
.card h3 { font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 15px; color: var(--text-2); margin: 0 0 12px; }
.card h3 i { color: var(--c); margin-right: 6px; font-size: .85em; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 4px 0 22px; }
.mini-kpi { display: flex; gap: 12px; align-items: flex-start; background: color-mix(in srgb, var(--c) 6%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 18%, var(--border)); border-radius: 12px; padding: 14px; }
.mini-kpi > i { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; background: var(--c); font-size: 14px; }
.mini-kpi .value { font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mini-kpi .delta { font-size: 12px; color: var(--muted); }
.mini-kpi .label { font-size: 12.5px; color: var(--text-2); margin: 2px 0 3px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.note { margin: 18px 0 0; font-size: 12px; color: var(--muted); }
.note i { margin-right: 4px; }
@media (max-width: 900px) { .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .split { grid-template-columns: minmax(0, 1fr); gap: 22px; } .mini-kpi .value { font-size: 20px; } }
.card.enquiries { margin-top: 16px; }

/* Google Search */
.card.google { --c: var(--mad-blue); margin-top: 16px; }
.card.google.is-loading .mini-kpis, .card.google.is-loading .split { opacity: .5; transition: opacity .2s; }
.h3-sub { display: block; font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.card .alert { margin: 0 0 14px; }

/* Phase 1: commercial view */
.row-title{font-size:15px;margin:22px 0 10px;color:var(--text-2)}
.row-title i{color:var(--mad-magenta);margin-right:6px}
.ckpis .kpi:nth-child(1){--c:var(--mad-navy)}.ckpis .kpi:nth-child(2){--c:var(--mad-teal)}.ckpis .kpi:nth-child(3){--c:var(--mad-magenta)}
.ckpis .kpi:nth-child(4),.ckpis .kpi:nth-child(5){--c:#a4a7b0}
.kpi-soon .value{color:var(--muted)}.kpi-soon{border-style:dashed}
.card.insights{--c:var(--mad-orange);margin-bottom:6px}
.ins-list{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
.ins{display:flex;gap:12px;align-items:flex-start;padding:14px;border-radius:10px;border:1px solid var(--border);background:color-mix(in srgb,var(--t) 7%,var(--surface))}
.ins>i{flex:none;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;font-size:13px;color:#fff;background:var(--t)}
.ins b{display:block;font-size:14px;margin-bottom:2px}.ins span{font-size:13px;color:var(--text-2);line-height:1.45}
.ins.good{--t:var(--good)}.ins.bad{--t:var(--bad)}.ins.opp{--t:var(--mad-orange)}.ins.info{--t:var(--mad-blue)}
.grid.two{grid-template-columns:repeat(2,minmax(0,1fr));margin:16px 0 0}
.funnel-card{--c:var(--mad-magenta)}.traffic-card{--c:var(--mad-navy)}
.funnel{display:flex;flex-direction:column;gap:8px}
.fstep{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;font-size:14px}
.fstep .fbar{grid-column:1/-1;order:3;height:10px;background:var(--bar-track);border-radius:5px;overflow:hidden}
.fstep .fbar span{display:block;height:100%;border-radius:5px}
.fstep .fval{font-variant-numeric:tabular-nums;color:var(--text-2);font-weight:500}
.fstep.soon{opacity:.45}.fstep.soon .fbar span{background:repeating-linear-gradient(45deg,var(--bar-track) 0 6px,transparent 6px 12px)!important}
.bar-row.dim{opacity:.55}
.row-icon.dot{width:10px;height:10px;border-radius:50%;display:inline-block;margin-right:10px;vertical-align:middle}
@media(max-width:720px){.grid.two{grid-template-columns:minmax(0,1fr)}}
