/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ebef;
  --sidebar: #fbfbfc;
  --border: #e4e6eb;
  --border-strong: #d3d6dd;
  --grid: #eceef1;
  --text: #0f1115;
  --text-2: #4b5060;
  --text-3: #7b8091;
  --accent: #2a63d4;
  --accent-soft: #e8effc;
  --accent-text: #1f4fb0;
  --series-1: #2a78d6; /* Google */
  --series-2: #eb6834; /* Meta */
  --series-3: #1baf7a; /* GA4 */
  --series-4: #eda100; /* breakdowns: share of spend */
  --series-7: #6250d6; /* breakdowns: share of conversions */
  /* Client mix: validated order (aqua, yellow, violet, green) + neutral "Other" */
  --mix-1: #1baf7a;
  --mix-2: #eda100;
  --mix-3: #6250d6;
  --mix-4: #008300;
  --mix-other: #b9bdc6;
  /* channels: one hue each, in stacking order (validated adjacent pairs, light) */
  --ch-1: #2a78d6; --ch-2: #eb6834; --ch-3: #1baf7a; --ch-4: #eda100; --ch-5: #e87ba4; --ch-6: #008300; --ch-7: #6250d6; --ch-8: #e34948;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --info: #2a78d6;
  --good-text: #0b6b1f;
  --bad-text: #b42323;
  --good-soft: #e5f4e8;
  --bad-soft: #fbe9e9;
  --neutral-soft: #eef0f3;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 1px 3px rgb(16 24 40 / 0.04);
  --shadow-pop: 0 12px 32px rgb(16 24 40 / 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0e0f12;
    --surface: #16181d;
    --surface-2: #1d2026;
    --surface-3: #262a31;
    --sidebar: #121418;
    --border: #262a31;
    --border-strong: #333843;
    --grid: #22252c;
    --text: #eef0f3;
    --text-2: #b4b9c4;
    --text-3: #818796;
    --accent: #5b8def;
    --accent-soft: #1b2740;
    --accent-text: #8fb1f5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-7: #9085e9;
    --mix-1: #199e70;
    --mix-2: #c98500;
    --mix-3: #9085e9;
    --mix-4: #008300;
    --mix-other: #4a4f5a;
    --ch-1: #3987e5; --ch-2: #d95926; --ch-3: #199e70; --ch-4: #c98500; --ch-5: #d55181; --ch-6: #008300; --ch-7: #9085e9; --ch-8: #e66767;
    --info: #3987e5;
    --good-text: #6ad57a;
    --bad-text: #ff8f8f;
    --good-soft: #143322;
    --bad-soft: #3a1a1c;
    --neutral-soft: #23262d;
    --shadow: none;
    --shadow-pop: 0 16px 40px rgb(0 0 0 / 0.5);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0e0f12;
  --surface: #16181d;
  --surface-2: #1d2026;
  --surface-3: #262a31;
  --sidebar: #121418;
  --border: #262a31;
  --border-strong: #333843;
  --grid: #22252c;
  --text: #eef0f3;
  --text-2: #b4b9c4;
  --text-3: #818796;
  --accent: #5b8def;
  --accent-soft: #1b2740;
  --accent-text: #8fb1f5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-7: #9085e9;
  --mix-1: #199e70;
  --mix-2: #c98500;
  --mix-3: #9085e9;
  --mix-4: #008300;
  --mix-other: #4a4f5a;
  --ch-1: #3987e5; --ch-2: #d95926; --ch-3: #199e70; --ch-4: #c98500; --ch-5: #d55181; --ch-6: #008300; --ch-7: #9085e9; --ch-8: #e66767;
  --info: #3987e5;
  --good-text: #6ad57a;
  --bad-text: #ff8f8f;
  --good-soft: #143322;
  --bad-soft: #3a1a1c;
  --neutral-soft: #23262d;
  --shadow: none;
  --shadow-pop: 0 16px 40px rgb(0 0 0 / 0.5);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--text-3); }
h1, h2, h3 { margin: 0; letter-spacing: -0.011em; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; --gutter: clamp(16px, 2vw, 32px); }
.sidebar {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 20px;
  padding: 18px 12px; background: var(--sidebar); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; }
.brand strong { display: block; font-size: 14px; font-weight: 650; }
.brand small { color: var(--text-3); font-size: 12px; }
.mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2a63d4, #6250d6); }
[hidden] { display: none !important; }
.nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-height: 0; overflow-y: auto; overflow-x: hidden; align-content: start; }
.nav-group { display: contents; }
.prop-mark {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; flex: none; margin-left: -2px;
  font-style: normal; font-size: 9.5px; font-weight: 650; letter-spacing: 0.02em; color: var(--text-2); background: var(--surface-3);
}
.nav a[aria-current='page'] .prop-mark { color: var(--accent-text); background: var(--surface); }
.nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; text-decoration: none; transition: background 150ms ease, color 150ms ease;
}
.nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current='page'] { background: var(--accent-soft); color: var(--accent-text); }
.nav .swatch { width: 10px; height: 10px; border-radius: 3px; margin: 0 3px 0 4px; flex: none; }
.badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 650; background: var(--bad-soft); color: var(--bad-text); }
.badge[hidden] { display: none; }
.connections { margin-top: auto; display: grid; gap: 4px; }
.connections .nav-label { padding-top: 0; }
.conn { display: flex; align-items: center; gap: 8px; padding: 2px 10px; font-size: 13px; color: var(--text-2); }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); opacity: 0.5; }
.conn.on .dot { background: var(--good); opacity: 1; }
.conn-state { margin-left: auto; font-size: 12px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 14px var(--gutter); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.heading { min-width: 0; flex: 1 1 320px; }
.heading h1, .heading p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.range { flex: none; }
.heading p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dates { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 4px; }
.dates input { border: 0; background: transparent; min-height: 34px; padding: 0 6px; }
.dates span { color: var(--text-3); }
main { padding: 24px var(--gutter) 48px; display: grid; gap: 20px; max-width: 2400px; width: 100%; margin: 0 auto; }
main:focus { outline: none; }
main > *, .grid-2 > *, .card, .summary > * { min-width: 0; }

/* ---------- Controls ---------- */
input, select {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; min-height: 36px;
}
select { cursor: pointer; }
input:hover, select:hover { border-color: var(--border-strong); }
.icon-btn, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; min-width: 36px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-weight: 500;
  transition: background 150ms ease, border-color 150ms ease;
}
.icon-btn { padding: 0; }
.icon-btn:hover, .btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: 0.5; cursor: progress; }

.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.filterbar .btn { margin-left: auto; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--text-3); }
.field select { min-width: 240px; max-width: 100%; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0 12px; min-height: 30px;
  border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 500; transition: background 150ms ease, color 150ms ease;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.segmented .n { font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--surface-3); border-radius: 6px; padding: 0 6px; line-height: 18px; }
.segmented .n:empty { display: none; }
.segmented button[aria-pressed='true'] .n { background: var(--accent-soft); color: var(--accent-text); }
.segmented.small { padding: 2px; }
.segmented.small button { min-height: 26px; padding: 0 10px; font-size: 12px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card > header p { margin: 3px 0 0; color: var(--text-3); font-size: 13px; max-width: 72ch; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-title { display: flex; align-items: baseline; gap: 8px; }
.count { color: var(--text-3); font-weight: 500; font-size: 13px; }

/* ---------- KPI strip + pacing ---------- */
.summary { display: grid; gap: 12px; }
.kpis { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.kpi-main { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { padding: 18px 20px; border-right: 1px solid var(--border); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kpi-value { font-size: clamp(18px, 1.6vw, 30px); font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.wrap { white-space: normal; font-size: clamp(16px, 1.25vw, 20px); line-height: 1.3; }
.kpi-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.kpi-secondary { display: flex; flex-wrap: wrap; gap: 8px 28px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.kpi-detail { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.kpi-detail b { color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-sm { display: inline-flex; align-items: baseline; gap: 8px; font-size: 13px; }
.kpi-sm > span:first-child { color: var(--text-3); }
.kpi-sm b { font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-sm .delta { font-size: 11px; }
#kpis, #sc-tiles { min-width: 0; }

/* Pacing: a slim band under the KPIs */
.pacing { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 32px; padding: 14px 20px; }
.pace-title p { margin: 1px 0 0; font-size: 12px; color: var(--text-3); }
.pace-body { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 14px 32px; min-width: 0; }
.pace-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pace-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pace-meter { flex: 1 1 240px; min-width: 200px; }
.meter { position: relative; height: 8px; margin: 4px 0 8px; border-radius: 4px; background: var(--surface-3); }
.meter-fill, .meter-proj { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.meter-proj { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.meter-fill { background: var(--accent); }
.meter-cap { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.meter-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.meter-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.lg-fill { background: var(--accent); }
.lg-proj { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.lg-cap { background: var(--text); width: 3px !important; }
.pace-list { margin: 0; display: flex; flex-wrap: wrap; gap: 10px 28px; }
.pace-list div { display: grid; gap: 1px; }
.pace-list dt { color: var(--text-3); font-size: 12px; }
.pace-list dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.pace-list dd .muted { font-weight: 500; font-size: 12px; }

/* ---------- Change badges ---------- */
.delta {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 6px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 18px;
}
.delta span[aria-hidden] { font-size: 8px; }
.delta.good { color: var(--good-text); background: var(--good-soft); }
.delta.bad { color: var(--bad-text); background: var(--bad-soft); }
.delta.neutral { color: var(--text-2); background: var(--neutral-soft); }
.delta.muted { color: var(--text-3); font-weight: 400; background: none; padding: 0; }
.eff.hi { color: var(--good-text); font-weight: 600; }
.eff.lo { color: var(--bad-text); font-weight: 600; }

/* ---------- Overview: platform split + client mix ---------- */
.ov-split { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#ov-body { display: grid; gap: 20px; min-width: 0; }
#ov-body > * { min-width: 0; }
.mix-card { display: flex; flex-direction: column; }
.mix-card .mix-body { flex: 1; }
.split-bars { display: grid; gap: 12px; margin-bottom: 16px; }
.split-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 14px; font-size: 13px; }
.split-label { color: var(--text-2); }
.split-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.split-bar i { display: block; height: 100%; }
.split-legend { display: flex; gap: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.split-legend i, .mix-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.split-missing { margin: 12px 0 0; font-size: 13px; }

.mix-body { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
#mix-donut { flex: none; min-height: 0; }
#mix-legend { flex: 1; min-width: 190px; }
.donut .slice { stroke: var(--surface); stroke-width: 2; transition: opacity 150ms ease; cursor: default; }
.donut .slice.dim { opacity: 0.3; }
.donut-value { fill: var(--text); font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-label { fill: var(--text-3); font-size: 12px; }
.mix-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mix-legend li { display: grid; grid-template-columns: auto minmax(0, 1fr) 52px; align-items: center; gap: 4px 10px; padding: 7px 8px; border-radius: 6px; font-size: 13px; }
.mix-legend li:hover { background: var(--surface-2); }
.mix-legend i { margin: 0; }
.mix-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-val { color: var(--text-3); font-variant-numeric: tabular-nums; }
.mix-legend b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.mix-excluded { margin: 10px 8px 0; font-size: 12px; color: var(--text-3); }
.mix-bar { display: flex; gap: 2px; width: 90px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.mix-bar i { display: block; height: 100%; }
.segmented button:disabled { opacity: 0.4; cursor: not-allowed; }

.plat-rows { display: grid; gap: 10px; }
.plat-row {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px; color: inherit; transition: border-color 150ms ease, background 150ms ease;
}
a.plat-row:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.plat-row.off { border-style: dashed; }
.plat-row dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px 12px; margin: 0; }
.plat-row.off { grid-template-columns: auto 1fr; align-items: center; }
.plat-row dt { font-size: 12px; color: var(--text-3); }
.plat-row dd { margin: 2px 0 0; display: grid; gap: 4px; justify-items: start; }
.plat-row dd b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plat-row .delta { font-size: 11px; }

.head-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tools-slot .table-tools { margin: 0; }
.tools-slot:empty { display: none; }
.card > header .tools-slot { margin-left: auto; }

/* ---------- Platform cards ---------- */
.platforms { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.platform-card { display: grid; gap: 12px; color: inherit; transition: border-color 150ms ease; }
a.platform-card:hover { border-color: var(--border-strong); text-decoration: none; }
.platform-card h3 { display: flex; align-items: center; gap: 8px; }
.platform-card h3 i { width: 10px; height: 10px; border-radius: 3px; }
.platform-card dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.platform-card dt { color: var(--text-3); font-size: 12px; }
.platform-card dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- Tables ---------- */
.table-host { position: relative; }
.table-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -6px 0 10px; flex-wrap: wrap; }
.table-tools:not(:has(.col-picker)):has(.chips:empty) { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 6px 0 10px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--accent-soft); color: var(--accent-text); font-size: 12px; cursor: pointer;
}
.chip b { font-weight: 600; }
.chip > span[aria-hidden] { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; font-size: 14px; }
.chip:hover > span[aria-hidden] { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.filter-pop {
  position: absolute; z-index: 40; width: 260px; padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-pop); display: grid; gap: 8px;
}
.filter-pop[hidden] { display: none; }
.pop-title { font-size: 12px; font-weight: 600; color: var(--text-2); }
.filter-pop input { width: 100%; }
.filter-pop input.invalid { border-color: var(--critical); }
.pop-hint { margin: 0; font-size: 12px; color: var(--text-3); line-height: 1.4; }
.pop-actions { display: flex; justify-content: space-between; align-items: center; }
.btn.small { min-height: 30px; padding: 0 12px; font-size: 13px; }
.pop-options { display: grid; gap: 1px; max-height: 280px; overflow: auto; }
.pop-options button { text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.pop-options button:hover { background: var(--surface-2); }
.pop-options button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* Searchable multi-select */
.ms { position: relative; min-width: 280px; }
.ms-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: border-color 150ms ease;
}
.ms-trigger:hover { border-color: var(--border-strong); }
.ms-trigger[aria-expanded='true'] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.ms-trigger.filtered { color: var(--accent-text); font-weight: 600; }
.ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-trigger svg { color: var(--text-3); flex: none; }
.ms-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: max(100%, 320px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); overflow: hidden;
}
.ms-panel[hidden] { display: none; }
.ms-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.ms-search input { flex: 1; border: 0; background: none; min-height: 42px; padding: 0; outline: none; color: var(--text); }
.ms-list { list-style: none; margin: 0; padding: 6px; max-height: 300px; overflow: auto; }
.ms-list li[role='option'] { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 8px; border-radius: 6px; cursor: pointer; }
.ms-list li.active { background: var(--surface-2); }
.ms-list li small { margin-left: auto; color: var(--text-3); font-size: 12px; }
.ms-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-all { font-weight: 600; border-bottom: 1px solid var(--grid); border-radius: 6px 6px 0 0 !important; margin-bottom: 4px; }
.ms-check {
  width: 16px; height: 16px; flex: none; border: 1.5px solid var(--border-strong); border-radius: 4px; display: grid; place-items: center;
  transition: background 120ms ease, border-color 120ms ease;
}
li[aria-selected='true'] .ms-check { background: var(--accent); border-color: var(--accent); }
li[aria-selected='true'] .ms-check::after { content: ''; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.ms-empty { padding: 14px 8px; color: var(--text-3); font-size: 13px; }
.ms-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.table-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data thead th { position: sticky; background: var(--surface); z-index: 2; }
table.data tr.head th { top: 0; padding: 0; border-bottom: 0; }
table.data tr.head th { border-bottom: 1px solid var(--border); }
.th-inner { display: flex; align-items: center; }
th.num .th-inner { flex-direction: row; justify-content: flex-end; }
.th-inner .sort { flex: 1; }
.th-filter {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; flex: none;
  border: 0; border-radius: 6px; background: none; color: var(--text-3); cursor: pointer; opacity: 0.35;
  transition: opacity 150ms ease, background 150ms ease, color 150ms ease;
}
th:hover .th-filter, .th-filter:focus-visible { opacity: 1; }
.th-filter:hover { background: var(--surface-3); color: var(--text); }
.th-filter.on { opacity: 1; color: var(--accent-text); background: var(--accent-soft); }
table.data .sort {
  all: unset; box-sizing: border-box; display: flex; gap: 4px; align-items: center; width: 100%; height: 36px;
  padding: 0 12px; cursor: pointer; font-weight: 600; color: var(--text-3); font-size: 12px;
}
table.data th.num .sort { justify-content: flex-end; }
table.data .sort:hover { color: var(--text); }
table.data .sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.data th[aria-sort='ascending'] .sort, table.data th[aria-sort='descending'] .sort { color: var(--text); }
table.data .arrow { font-size: 9px; color: var(--accent); min-width: 8px; }
table.data th.sticky, table.data td.sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
table.data thead th.sticky { z-index: 3; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr { transition: background 120ms ease; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
table.data td.empty { text-align: center; color: var(--text-3); padding: 32px; }
table.data td.wrap { white-space: normal; min-width: 260px; max-width: 420px; }
.camp-name { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* Column picker */
.col-picker { position: relative; }
.col-picker summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; font-weight: 500;
}
.col-picker summary:hover { background: var(--surface-2); }
.col-picker summary::-webkit-details-marker { display: none; }
.col-picker summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(45deg) translate(-2px, -2px); }
.col-picker .col-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 260px; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-pop);
  display: grid; gap: 1px;
}
.col-picker label { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.col-picker label:hover { background: var(--surface-2); }
.col-picker input { accent-color: var(--accent); min-height: 0; }
.col-actions { display: flex; justify-content: space-between; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
button.link { background: none; border: 0; color: var(--accent-text); cursor: pointer; padding: 4px 8px; font-size: 13px; font-weight: 500; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.pill .glyph { font-size: 10px; width: 16px; height: 16px; border-radius: 5px; display: inline-grid; place-items: center; color: #fff; background: var(--text-3); flex: none; font-weight: 700; }
.tone-good .dot, .tone-good .glyph { background: var(--good); }
.tone-warning .dot, .tone-warning .glyph { background: var(--warning); color: #3a2a00; }
.tone-serious .dot, .tone-serious .glyph { background: var(--serious); }
.tone-critical .dot, .tone-critical .glyph { background: var(--critical); }
.tone-info .dot, .tone-info .glyph { background: var(--info); }
.tone-neutral .dot { background: var(--text-3); }
.tone-neutral .glyph { background: var(--surface-3); color: var(--text-2); }
.tone-muted { color: var(--text-3); }
.platform-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.platform-tag i { width: 8px; height: 8px; border-radius: 2px; }

/* ---------- Charts ---------- */
.trend > header { align-items: center; }
.chart { position: relative; min-height: 120px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.1; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; }
.chart .hover-dot, .chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .bar.partial { opacity: 0.55; }
.chart .ghost { opacity: 0.16; }
.chart .band { fill: transparent; }
.chart .band.on { fill: var(--surface-2); }
.chart .legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.chart .legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.chart .legend i.sq { width: 10px; height: 10px; border-radius: 3px; }
.chart-empty { color: var(--text-3); text-align: center; padding: 40px 0; margin: 0; }
.chart-note { margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 170px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-pop); font-size: 12px;
}
.tip-date { color: var(--text-3); margin-bottom: 6px; font-weight: 500; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; }
.tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.tip-sub { color: var(--text-3); font-size: 11px; margin: 2px 0 3px 14px; }
.tip-delta { margin-left: 8px; }

/* Properties: ranked horizontal bars, one row per property */
.hb-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.hb-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hb-legend .hb-avg-key { width: 2px; height: 12px; border-radius: 1px; background: var(--text-2); }
.card > header .hb-legend { margin: 0; }
.multiples-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px 24px; }
.multiple-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 2px; }
.multiple-head a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; text-decoration: none; }
.multiple-head a:hover { text-decoration: underline; }
.multiple-head b { font-variant-numeric: tabular-nums; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hbars li { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 4.5rem 5.5rem; align-items: center; gap: 10px; min-height: 30px; border-radius: 6px; padding: 0 4px; }
.hbars li:hover { background: var(--surface-2); }
.hb-name { font-size: 13px; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-name:hover { text-decoration: underline; }
.hb-track { position: relative; display: flex; gap: 2px; height: 14px; }
.hb-track > i { display: block; height: 100%; min-width: 0; }
.hb-track > i:first-child { border-radius: 2px 0 0 2px; }
.hb-track > i:last-of-type { border-radius: 0 4px 4px 0; }
.hb-track > i:only-of-type { border-radius: 2px 4px 4px 2px; }
.hb-avg { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text-2); }
.hb-val { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hb-delta { text-align: right; }
@media (max-width: 600px) {
  .hbars li { grid-template-columns: minmax(0, 1fr) auto auto; row-gap: 4px; }
  .hb-track { grid-column: 1 / -1; grid-row: 2; }
}
.tip-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.tip-line { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.tip-line > span:first-child { margin-right: auto; }
.tip-line b { font-variant-numeric: tabular-nums; }
.tip-why { margin-top: 2px; color: var(--text-2); max-width: 260px; }
.chart .tick.note { font-weight: 600; }
.chart .area-band { stroke: none; }
.chart .area-edge { fill: none; stroke: var(--surface); stroke-width: 1.5; }
.chart .area-label { fill: var(--text-2); font-size: 12px; }
.chart .area-label-value { fill: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-weight: 500; }
.chart .ref { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .ref-label { fill: var(--text-3); font-size: 11px; }
.chart .quadrant { fill: var(--text-3); font-size: 11px; font-style: italic; opacity: 0.85; }
.chart .dot-label { fill: var(--text-2); font-size: 11px; font-weight: 500; }
.chart .tick.note.good { fill: var(--good-text); }
.chart .tick.note.bad { fill: var(--bad-text); }
.chart .tick.note.warn { fill: var(--warning); }
.tip-warn { margin-top: 2px; color: var(--warning); max-width: 260px; }
.bd-chart { margin-bottom: 16px; }

/* ---------- Notices & states ---------- */
.notice { border: 1px solid var(--border); border-left: 3px solid var(--warning); background: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 13px; }
.notice.error { border-left-color: var(--critical); }
.notice.info { border-left-color: var(--info); margin-bottom: 12px; }
.notice[hidden] { display: none; }
.notice code, .setup code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.setup { display: grid; gap: 10px; color: var(--text-2); max-width: 720px; }
.setup ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.loading { color: var(--text-3); padding: 48px; text-align: center; }
.loading::before {
  content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 10px; vertical-align: -2px;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Issues ---------- */
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.issue-list li { display: grid; grid-template-columns: 92px 1fr; gap: 2px 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.issue-list li .pill { grid-row: span 3; align-self: start; padding-top: 1px; }
.issue-list strong { font-weight: 600; }
.issue-list .evidence { color: var(--text-2); font-size: 13px; }
.issue-list .action { color: var(--text-3); font-size: 13px; }

/* ---------- Rules ---------- */
details.rules summary { cursor: pointer; font-weight: 600; }
.rules-grid { display: grid; gap: 10px 24px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 14px; }
.rules-grid label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; }
.rules-grid input { width: 100px; text-align: right; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgb(8 10 14 / 0.5); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(780px, 100%); overflow: auto;
  background: var(--bg); border-left: 1px solid var(--border); padding: 24px 28px; display: grid; gap: 18px; align-content: start;
  box-shadow: var(--shadow-pop); animation: slide-in 220ms ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
#drawer-body { display: grid; gap: 24px; }
.drawer-close { position: absolute; top: 18px; right: 18px; z-index: 1; }
.drawer h2 { font-size: 18px; padding-right: 48px; }
.meta-line { color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; align-items: center; margin-top: -14px; }
.meta-line + .meta-line { margin-top: -18px; color: var(--text-3); }

.dr-verdict { border: 1px solid var(--border); border-left: 3px solid var(--text-3); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; display: grid; gap: 10px; }
.dr-verdict.tone-critical { border-left-color: var(--critical); }
.dr-verdict.tone-warning { border-left-color: var(--warning); }
.dr-verdict.tone-good { border-left-color: var(--good); }
.dr-verdict-head { display: flex; align-items: center; gap: 12px; }
.dr-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }
.dr-note { margin: 0; color: var(--text-2); }
.dr-verdict .issue-list li { background: var(--surface-2); border-color: transparent; }

.dr-section { display: grid; gap: 12px; }
.dr-section > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dr-section > header p { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
#dr-content { display: grid; gap: 14px; }
.dr-charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.dr-charts .card { padding: 14px 16px; }
.dr-charts .card > header { margin-bottom: 8px; }

/* One panel with hairline dividers instead of loose boxes */
.kv {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.kv > div { padding: 12px 14px; box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border); min-width: 0; }
.kv > div > span:first-child { display: block; color: var(--text-3); font-size: 12px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv b { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.kv .delta { display: flex; width: fit-content; margin-top: 6px; font-size: 11px; }

/* ---------- Browns: website card, GA4 page ---------- */
.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.site-grid > div { display: grid; gap: 4px; justify-items: start; }
.site-grid span { font-size: 12px; color: var(--text-3); }
.site-grid b { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.site-grid .delta { font-size: 11px; }
.site-proj { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
body[data-view='ga4'] #preset, body[data-view='ga4'] .range .dates,
body[data-view='ota'] #preset, body[data-view='ota'] .range .dates,
body[data-view='properties'] #preset, body[data-view='properties'] .range .dates,
body[data-view='property'] #preset, body[data-view='property'] .range .dates { display: none; }

/* OTA module: direct bookings */
.direct-top { display: grid; gap: 12px; }
.direct-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-right: 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.direct-strip .direct-stats { flex: 1 1 520px; margin: 0; border: 0; background: none; }
.direct-strip .field.commission { display: flex; align-items: center; gap: 8px; padding: 8px 0 8px 20px; }
.direct-strip .field.commission input { width: 110px; }
.direct-share .kpis { box-shadow: none; border-radius: var(--radius-sm); margin: 4px 0 12px; }
.direct-share .kpi { padding: 14px 16px; }
.direct-share .kpi-value { font-size: clamp(18px, 1.4vw, 24px); }
.direct-stats { margin: 4px 0 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.direct-chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.direct-chart-head h3 { margin: 0; font-size: 14px; }
#ota-segments { margin-top: 18px; }
.field.commission input { width: 130px; min-height: 34px; text-align: right; }
.card-foot { margin: 12px 0 0; font-size: 12px; color: var(--text-3); }

/* OTA report uploads */
.dropzone { display: grid; justify-items: center; gap: 6px; margin-top: 4px; padding: 22px 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); text-align: center; color: var(--text-2); font-size: 13px; }
.dropzone.over { border-color: var(--series-4); background: var(--surface-2); }
.dropzone.busy { opacity: 0.6; pointer-events: none; }
.dropzone small { color: var(--text-3); font-size: 12px; }
#ota-upload-status { margin: 10px 0 0; font-size: 13px; }
#ota-upload-status:empty { display: none; }
.upload-log { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; font-size: 13px; color: var(--text-2); }
.upload-log:empty { display: none; }
.upload-log li { display: flex; align-items: baseline; gap: 10px; }
.upload-log li .pill { flex: none; }
.coverage-title { margin: 20px 0 10px; font-size: 14px; }
table.coverage td { white-space: nowrap; }
.single-client { display: flex; align-items: center; min-height: 36px; font-weight: 600; }
/* Period picker: presets and comparisons as buttons, custom ranges opened in place */
.pp { display: grid; gap: 10px; flex: 1 1 100%; min-width: 0; }
.pp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.pp-label { flex: 0 0 96px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.pp .segmented { min-width: 0; max-width: 100%; flex-wrap: wrap; }
.pp .segmented button { min-height: 34px; white-space: nowrap; }
.pp .segmented button[aria-pressed='true'] { color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-soft), 0 1px 2px rgb(0 0 0 / 0.08); }
.pp-hint { font-size: 11px; font-weight: 400; color: var(--text-3); }
.pp-hint:empty { display: none; }
.pp-range { display: inline-flex; align-items: center; gap: 8px; padding: 3px 3px 3px 10px; border: 1px solid var(--accent-soft); border-radius: 10px; background: var(--surface-2); }
.pp-range[hidden] { display: none; }
.pp-range > span { font-size: 12px; color: var(--text-3); }
.pp-range select { min-width: 0; min-height: 32px; }
.pp-summary { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text-2); }
.pp-summary b { color: var(--text); font-weight: 600; }
.pp-summary:empty, .pp-fx:empty { display: none; }
.pp-fx { flex-basis: 100%; margin: -8px 0 0; font-size: 12px; color: var(--text-3); }
.quality-list { display: grid; gap: 10px; margin-top: 14px; }
.quality-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.quality-row p { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }
.quality-row .pill { align-self: start; white-space: normal; }
#eff-table { margin-top: 16px; }

/* ---------- Engagements & impact ---------- */
.eng-list { display: grid; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.eng-head, .eng-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 150px 120px; gap: 10px; align-items: center; padding: 10px 14px; }
.eng-head { font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--surface-2); }
.eng-row { border-top: 1px solid var(--grid); }
.eng-client { display: grid; gap: 4px; min-width: 0; }
.eng-client b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eng-client > span { display: flex; gap: 10px; }
.eng-row input { width: 100%; min-height: 34px; }
.eng-status { font-size: 12px; }
.eng-status .saved { color: var(--good-text); font-weight: 600; }
.eng-status .err { color: var(--bad-text); }
.impact-kv small { display: block; margin-top: 4px; font-size: 11px; color: var(--text-3); }
.chart .marker { stroke: var(--text); stroke-width: 1.5; }
.chart .marker-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart .bar.before { opacity: 0.45; }

/* ---------- Account (top right) ---------- */
.account-wrap { position: relative; }
.account-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px 0 4px; cursor: pointer; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; transition: background 150ms ease, border-color 150ms ease;
}
.account-btn:hover, .account-btn[aria-expanded='true'] { background: var(--surface-2); border-color: var(--border-strong); }
.account-btn svg { color: var(--text-3); }
.account-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  font-size: 12px; font-weight: 650; color: #fff; background: linear-gradient(135deg, #2a63d4, #6250d6);
}
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 45; width: 280px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop);
}
.account-who { display: flex; gap: 10px; align-items: center; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.account-who strong { display: block; font-size: 13px; }
.account-who small { display: block; color: var(--text-3); font-size: 12px; line-height: 1.45; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: none; cursor: pointer; font-weight: 500; text-align: left; color: var(--text-2);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); color: var(--text); }
.menu-item:disabled { opacity: 0.6; cursor: progress; }
@media (max-width: 600px) { .account-name { display: none; } .account-btn { padding-right: 6px; } }

/* ---------- Sign-in page ---------- */
.login-body {
  min-height: 100dvh; display: grid; place-items: center;
  background:
    radial-gradient(60rem 36rem at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(48rem 30rem at 110% 110%, color-mix(in srgb, #6250d6 14%, transparent), transparent 70%),
    var(--bg);
}
.login { width: 100%; max-width: 420px; padding: 32px 16px; display: grid; gap: 18px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop);
  padding: 32px 32px 28px; display: grid; gap: 6px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand strong { display: block; font-size: 14px; font-weight: 650; }
.login-brand small { display: block; color: var(--text-3); font-size: 12px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.login-lede { margin: 0 0 18px; color: var(--text-3); font-size: 13px; }
#login-form { display: grid; gap: 14px; }
.login-field { display: grid; gap: 6px; }
.login-field > span:first-child { font-size: 13px; font-weight: 500; color: var(--text-2); }
.login-field input { width: 100%; min-height: 42px; padding: 8px 12px; font-size: 15px; }
.login-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.login-password { position: relative; display: block; }
.login-password input { padding-right: 44px; }
.login-reveal {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-3); cursor: pointer;
}
.login-reveal:hover { color: var(--text); background: var(--surface-2); }
.login-reveal[aria-pressed='true'] .slash { display: none; }
.login-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.login-check input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
.login-error {
  margin: 0; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px;
  color: var(--bad-text); background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad-text) 25%, transparent);
}
.login-submit {
  min-height: 44px; margin-top: 4px; border: 0; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: 15px;
  color: #fff; background: var(--accent); transition: filter 150ms ease, opacity 150ms ease;
}
.login-submit:hover { filter: brightness(1.08); }
.login-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-submit:disabled { opacity: 0.7; cursor: progress; }
.login-foot { margin: 0; text-align: center; font-size: 12px; color: var(--text-3); }
@media (max-width: 480px) { .login-card { padding: 24px 20px 22px; } }

/* ---------- Settings ---------- */
.settings-wrap { position: relative; }
#settings[aria-expanded='true'] { background: var(--surface-2); border-color: var(--border-strong); }
.settings-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 45; width: 360px; max-height: calc(100dvh - 90px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 16px; display: grid; gap: 16px;
}
.settings-pop[hidden] { display: none; }
.settings-head h2 { font-size: 15px; }
.settings-section { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.settings-label { display: flex; justify-content: space-between; align-items: baseline; }
.settings-label h3 { font-size: 13px; }
.settings-label span { font-size: 12px; color: var(--text-3); }
.usage-google { display: grid; gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.usage-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; font-size: 13px; }
.usage-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.usage-note { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); }
.usage-meter { margin: 2px 0 0; height: 6px; }
.usage-meter.warn .meter-fill { background: var(--warning); }
.usage-meter.bad .meter-fill { background: var(--critical); }
.usage-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); }
.settings-field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.settings-hint, .settings-foot { margin: 0; font-size: 12px; color: var(--text-3); }
.usage-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.usage-table th { text-align: right; font-weight: 600; color: var(--text-3); padding: 4px 0; }
.usage-table td { text-align: right; padding: 5px 0; border-top: 1px solid var(--grid); }
.usage-table th:first-child, .usage-table td:first-child { text-align: left; }
.usage-table tr.today td { font-weight: 600; }

/* ---------- Responsive ---------- */
/* Large monitors: more room per KPI and chart. */
@media (min-width: 1800px) {
  .ov-split { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

/* Small laptops and tablets in landscape: the sidebar becomes an icon rail. */
@media (min-width: 901px) and (max-width: 1199px) {
  .app { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding: 16px 10px; align-items: center; }
  .brand { padding: 0; }
  .brand-text, .nav-text, .nav-label, .connections { display: none; }
  .nav { justify-items: center; gap: 4px; }
  .nav a { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .nav .swatch { margin: 0; width: 12px; height: 12px; }
  .nav .badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 16px; font-size: 10px; padding: 0 4px; }
}

@media (max-width: 999px) {
  .ov-split, .grid-2 { grid-template-columns: 1fr; }
}

/* Phones and portrait tablets: top navigation, stacked sections, page-level scrolling. */
@media (max-width: 900px) {
  .split-row { grid-template-columns: 1fr; gap: 6px; }
  .mix-body { justify-content: center; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: 12px;
    padding: 10px var(--gutter); border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto;
  }
  .brand small, .nav-label, .connections { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { white-space: nowrap; }
  .topbar { position: static; }
  .heading h1, .heading p { white-space: normal; }
  .range { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; }
  .range #preset { width: 100%; }
  .range .dates { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .range .dates input { flex: 1; min-width: 0; }
  main { padding-top: 16px; padding-bottom: 40px; }
  .field select { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .filterbar .btn { margin-left: 0; }
  .pp-label { flex-basis: 100%; }
  .pp .segmented { overflow: visible; }
  .pp-range { width: 100%; }
  .pp-range select { flex: 1; }
  .ms { min-width: 0; }
  .ms-panel { width: 100%; }
  .kpi-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-right: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; }
  .kpi-value { font-size: 20px; }
  .kpi-secondary { padding: 12px 16px; }
  .pacing, .pace-body { flex-direction: column; align-items: stretch; gap: 12px; }
  .pace-meter { min-width: 0; flex-basis: auto; }
  .brand strong { white-space: nowrap; }
  .card { padding: 16px; }
  .card > header { flex-direction: column; align-items: stretch; }
  .card > header .tools-slot { margin-left: 0; }
  .head-tools { justify-content: space-between; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .table-wrap { max-height: none; }
  .drawer-panel { padding: 16px; }
  .settings-pop { position: fixed; left: 16px; right: 16px; top: 120px; width: auto; }
  .eng-head { display: none; }
  .eng-row { grid-template-columns: 1fr 1fr; }
  .eng-client, .eng-status { grid-column: 1 / -1; }
  .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quality-row { grid-template-columns: 1fr; }
  .rules-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-main { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 18px; }
  .dates input { padding: 0 2px; font-size: 13px; }
  .plat-row dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mix-legend li { grid-template-columns: auto minmax(0, 1fr) 48px; }
}
