/* BGS Shop performance dashboard – design system
   One accent (brand blue), one identity hue for Meta (orange), everything else neutral. */
:root {
  --accent: #0a6bc8; --accent-ink: #084f94; --accent-soft: #e8f1fb; --accent-100: #cde2fb;
  --meta: #eb6834; --meta-soft: #fdeee7; --google: #0a6bc8; --google-soft: #e8f1fb;
  --neutral-series: #a3aab3; --neutral-soft: #e9ecef;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781; --hair: #e6e6e1; --border: rgba(11, 11, 11, .08);
  --page: #f6f7f9; --card: #ffffff; --card-2: #fafafa;
  --good: #006300; --good-bg: #e6f4e6; --bad: #b42323; --bad-bg: #fbeaea; --warn: #8a5a00; --warn-bg: #fff4d6; --serious: #9a3f16; --serious-bg: #fde9df; --info: #0a4f92; --info-bg: #e8f1fb;
  --r: 16px; --r-sm: 10px; --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 4px 16px rgba(11, 11, 11, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
h1, h2, h3 { font-weight: 650; letter-spacing: -.01em; margin: 0; }

/* ---------- header ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 28px; padding: 14px 32px; background: rgba(255, 255, 255, .86); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand img { height: 40px; width: auto; }
.brand-title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; white-space: nowrap; }
.tabs { display: flex; gap: 2px; background: #eceef1; padding: 4px; border-radius: 12px; margin-left: auto; }
.tabs button { white-space: nowrap; border: 0; background: transparent; padding: 9px 18px; border-radius: 9px; cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 14px; transition: background .15s, color .15s; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(11, 11, 11, .08), 0 1px 6px rgba(11, 11, 11, .06); }
.syncbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.syncbox #syncText { cursor: default; }
.syncbox .dot { width: 8px; height: 8px; border-radius: 50%; background: #0ca30c; display: inline-block; margin-right: 6px; }
.syncbox .dot.busy { background: #fab219; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px; transition: background .15s; }
.btn:hover { background: var(--accent-ink); }
.btn.small { padding: 7px 12px; font-size: 12.5px; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--border); }
.btn.ghost:hover { background: #f3f4f6; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; padding: 16px 32px; background: #fff; border-bottom: 1px solid var(--border); }
.filters label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.filters select, .filters input { font: inherit; font-size: 14px; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink); min-width: 150px; box-shadow: 0 1px 2px rgba(11, 11, 11, .03); }
.filters select { padding-right: 30px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%2352514e' stroke-width='1.8' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
.filters select:focus, .filters input:focus { outline: 2px solid var(--accent-100); border-color: var(--accent); }
.filters label.wide select { min-width: 260px; }
.range-info { width: 100%; color: var(--muted); font-size: 13px; }
.filters label.ppc-only { display: none; }
body.view-ppc .filters label.ppc-only { display: flex; }

/* ---------- layout ---------- */
main { padding: 28px 32px 56px; max-width: 1480px; margin: 0 auto; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.section { margin-bottom: 36px; }
.section-h { display: flex; align-items: baseline; gap: 14px; margin: 0 0 14px; flex-wrap: wrap; }
.section-h h2 { font-size: 21px; }
.section-h .hint { color: var(--muted); font-size: 13.5px; }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(4, 1fr); }
.grid.kpi-dense { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.split-2-1 { grid-template-columns: 2fr 1fr; }
.grid.split-1-2 { grid-template-columns: 1fr 2fr; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.card h3 { font-size: 15.5px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.card h3 + .sub { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* ---------- stat tiles ---------- */
.tile { display: flex; flex-direction: column; gap: 6px; position: relative; padding: 18px 20px 14px; }
.tile .label { color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.tile .value { font-size: 32px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; margin: 2px 0 4px; }
.tile.hero { background: linear-gradient(160deg, #ffffff, #eaf2fb); border-color: rgba(10, 107, 200, .18); }
.tile.hero .value { font-size: 44px; color: var(--accent-ink); }
.tile .cmp { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.tile .cmp .vs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tile .spark { height: 40px; margin-top: 6px; }
.tile .spark canvas { width: 100% !important; height: 40px !important; }
.tile.compact { padding: 14px 16px 12px; gap: 3px; }
.tile.compact .value { font-size: 24px; }
.tile.compact .spark { height: 28px; }
.tile.compact .spark canvas { height: 28px !important; }

.chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; font-weight: 650; font-size: 12px; background: var(--neutral-soft); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.na { background: #f1f2f4; color: #9a9a95; font-weight: 500; }

/* ---------- narrative ---------- */
.narrative { background: linear-gradient(150deg, #ffffff 0%, #eef4fb 100%); border-color: rgba(10, 107, 200, .14); }
.narrative ul { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 10px; }
.narrative li { position: relative; padding-left: 22px; font-size: 15.5px; line-height: 1.5; }
.narrative li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---------- charts ---------- */
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.tall { height: 360px; }
.chart-wrap.short { height: 240px; }
.chart-wrap.mini { height: 170px; }
.legend-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.chart-title { font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin: 10px 0 4px; }

/* share bar (part-to-whole) */
.share { margin: 6px 0 12px; }
.share .share-title { font-size: 13px; color: var(--ink-2); font-weight: 600; margin-bottom: 8px; display: flex; justify-content: space-between; }
.share .bar { display: flex; gap: 2px; height: 18px; border-radius: 6px; overflow: hidden; background: var(--neutral-soft); }
.share .seg { height: 100%; min-width: 2px; }
.share .keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.share .key { display: flex; align-items: center; gap: 7px; }
.share .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.share .key b { color: var(--ink); font-weight: 650; }
.share .key .pct { color: var(--muted); }

/* ---------- tables ---------- */
.table-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.table-tools input { font: inherit; font-size: 14px; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; min-width: 240px; }
.table-tools input:focus { outline: 2px solid var(--accent-100); border-color: var(--accent); }
.table-tools .count { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.table-wrap { overflow: auto; max-height: 600px; border: 1px solid var(--border); border-radius: 12px; }
table.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.dt th, table.dt td { padding: 11px 12px; border-bottom: 1px solid var(--hair); text-align: right; white-space: nowrap; vertical-align: middle; font-variant-numeric: tabular-nums; }
table.dt th:first-child, table.dt td:first-child, table.dt th.left, table.dt td.left { text-align: left; white-space: normal; }
table.dt th { background: #fafafa; color: var(--muted); font-weight: 600; cursor: pointer; position: sticky; top: 0; z-index: 1; user-select: none; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
table.dt th.sorted { color: var(--accent); }
table.dt tbody tr:last-child td { border-bottom: 0; }
table.dt tbody tr:hover td { background: #f7f9fc; }
table.dt tr.clickable { cursor: pointer; }
table.dt td .d { display: block; margin-top: 3px; }
table.dt td .d .chip { padding: 1px 6px; font-size: 11px; }
table.dt td.left .name { font-weight: 600; color: var(--ink); }
table.dt td.left .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; vertical-align: middle; margin-right: 10px; background: #eee; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 650; background: var(--neutral-soft); color: var(--ink-2); letter-spacing: .01em; }
.badge.Meta { background: var(--meta-soft); color: #9a3f16; }
.badge.Google { background: var(--google-soft); color: var(--accent-ink); }
.badge.on { background: var(--good-bg); color: var(--good); }
.badge.off { background: #f1f2f4; color: #9a9a95; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- alerts ---------- */
.alerts { display: grid; gap: 10px; }
.alert { display: grid; grid-template-columns: 118px 1fr; gap: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: #fff; align-items: start; }
.alert .sev { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.alert .sev::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.alert.critical .sev { background: var(--bad-bg); color: var(--bad); }
.alert.warning .sev { background: var(--warn-bg); color: var(--warn); }
.alert.opportunity .sev { background: var(--good-bg); color: var(--good); }
.alert.info .sev { background: var(--info-bg); color: var(--info); }
.alert .t { font-weight: 600; font-size: 14.5px; }
.alert .e { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.alert .dtl { font-size: 13.5px; margin-top: 4px; color: var(--ink-2); }
.alert-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.alert-summary .pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.alert-summary .pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.alert-summary .pill.critical { background: var(--bad-bg); color: var(--bad); }
.alert-summary .pill.warning { background: var(--warn-bg); color: var(--warn); }
.alert-summary .pill.opportunity { background: var(--good-bg); color: var(--good); }
.alert-summary .pill.info { background: var(--info-bg); color: var(--info); }
details.acc > summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; font-size: 14px; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: " ↓"; }
details.acc[open] > summary::after { content: " ↑"; }

/* ---------- sub tabs ---------- */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.subtabs button { border: 1px solid var(--border); background: #fff; padding: 9px 18px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 14px; transition: all .15s; }
.subtabs button:hover { border-color: #c9ccd1; color: var(--ink); }
.subtabs button.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- funnel ---------- */
.funnel { display: grid; gap: 8px; margin-top: 6px; }
.funnel .step { display: grid; grid-template-columns: 170px 1fr 110px; align-items: center; gap: 12px; font-size: 13.5px; }
.funnel .step .n { color: var(--ink-2); }
.funnel .track { height: 24px; background: transparent; }
.funnel .bar { height: 24px; border-radius: 0 6px 6px 0; min-width: 3px; }
.funnel .val { text-align: right; font-variant-numeric: tabular-nums; }
.funnel .val b { display: block; color: var(--ink); font-weight: 650; }
.funnel .val span { color: var(--muted); font-size: 12px; }

/* ---------- heatmap ---------- */
.heat { display: grid; grid-template-columns: 56px repeat(24, 1fr); gap: 2px; font-size: 11px; }
.heat .h { text-align: center; color: var(--muted); padding-bottom: 2px; }
.heat .cell { height: 26px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.heat .lbl { display: flex; align-items: center; color: var(--ink-2); font-weight: 600; }
.heat-scale { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.heat-scale .ramp { width: 140px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #dbe9fb, #0d366b); }

/* ---------- pacing / meters ---------- */
.pacing { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.meter { margin-top: 4px; }
.meter .m-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.meter .m-head .big { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.meter .m-head .big small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.bar-track { height: 12px; background: var(--accent-100); border-radius: 999px; overflow: visible; position: relative; }
.bar-track.green { background: #d9efd9; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-track.green .bar-fill { background: #0ca30c; }
.bar-mark { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--ink); border-radius: 1px; }
.meter .m-foot { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* ---------- glossary / status / misc ---------- */
.glossary dl { margin: 12px 0 0; display: grid; grid-template-columns: 240px 1fr; gap: 10px 16px; font-size: 14px; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--ink-2); }
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.6; }
.note { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); font-size: 14px; padding: 14px 0; }
.foot { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding: 18px 32px 36px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); max-width: 1480px; margin: 0 auto; }

@media (max-width: 1400px) { .brand-sub { display: none; } .syncbox .when { display: none; } }
@media (max-width: 1100px) { .grid.split-2-1, .grid.split-1-2 { grid-template-columns: 1fr; } .grid.kpi { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .grid.two, .grid.three { grid-template-columns: 1fr; } .top { gap: 14px; padding: 12px 18px; } .tabs { margin-left: 0; } main, .filters { padding-left: 18px; padding-right: 18px; } .heat { font-size: 8px; } .pacing { grid-template-columns: 1fr; } .glossary dl { grid-template-columns: 1fr; } .tile.hero .value { font-size: 36px; } .grid.kpi { grid-template-columns: 1fr; } }
