:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6e69;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --accent: #1f66c2;
  --accent-fill: #1f66c2; /* backgrounds behind white text */
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #8a5a00;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #b02a2a;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Themes: light (the defaults above), blue (navy) and dark (charcoal). With no
   data-theme attribute the page follows the device: blue when it is in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #0a1428;
    --surface: #111f3a;
    --surface-2: #1a2b4d;
    --text: #ffffff;
    --text-2: #b9c6e0;
    --muted: #8393b5;
    --grid: #1f3155;
    --axis: #2d4370;
    --border: rgba(150, 180, 255, 0.14);
    --accent: #3d8bf2;
    --accent-fill: #2867cc;
    --series-1: #3d8bf2;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --good-ink: #2fc35a;
    --warning-ink: #fab219;
    --critical-ink: #ef7b7b;
    --shadow: none;
  }
}
:root[data-theme="blue"] {
  color-scheme: dark;
  --page: #0a1428;
  --surface: #111f3a;
  --surface-2: #1a2b4d;
  --text: #ffffff;
  --text-2: #b9c6e0;
  --muted: #8393b5;
  --grid: #1f3155;
  --axis: #2d4370;
  --border: rgba(150, 180, 255, 0.14);
  --accent: #3d8bf2;
  --accent-fill: #2867cc;
  --series-1: #3d8bf2;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --good-ink: #2fc35a;
  --warning-ink: #fab219;
  --critical-ink: #ef7b7b;
  --shadow: none;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c0c0d;
  --surface: #161618;
  --surface-2: #222225;
  --text: #ffffff;
  --text-2: #bdbcb6;
  --muted: #8c8b86;
  --grid: #2a2a2e;
  --axis: #3b3b40;
  --border: rgba(255, 255, 255, 0.11);
  --accent: #3d8bf2;
  --accent-fill: #2867cc;
  --series-1: #3d8bf2;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --good-ink: #2fc35a;
  --warning-ink: #fab219;
  --critical-ink: #ef7b7b;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; margin: 6px 0 0; max-height: 240px; overflow: auto; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.truncate { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- layout ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .inner { display: flex; align-items: center; gap: 20px; height: 58px; }
.logo { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent-fill); display: grid; place-items: center; color: #fff; font-size: 14px; }
.topbar nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { white-space: nowrap; }
.topbar nav a { color: var(--text-2); padding: 6px 10px; border-radius: 8px; }
.topbar nav a.active, .topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 28px; padding-bottom: 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.cols-1 { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) {
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .cols-4.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats .card { padding: 14px; }
  .stat .value { font-size: 1.45rem; }
  .topbar nav a { padding: 6px 6px; }
  .topbar .inner { gap: 10px; }
  .hide-sm { display: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
section.report-section { margin-top: 36px; }
section.report-section > h2 { font-size: 1.35rem; margin-bottom: 4px; }
section.report-section > p.lead { color: var(--text-2); margin-bottom: 16px; }

/* ---- forms & buttons ---- */
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--text-2); font-size: 0.82rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 8px; padding: 9px 12px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-bottom: 10px; }
.check input { margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--axis); border-radius: 8px; padding: 8px 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical-ink); }
.btn.lg { padding: 11px 20px; font-size: 1rem; }
.btn.sm { padding: 4px 10px; font-size: 0.82rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid var(--border); }
.alert.error { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); color: var(--critical-ink); }
.alert.success { background: color-mix(in srgb, var(--good) 10%, var(--surface)); color: var(--good-ink); }
.alert.info { background: var(--surface-2); color: var(--text-2); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* ---- status & score badges (status always paired with icon + label) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.pass, .badge.good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.badge.warn, .badge.ok { color: var(--warning-ink); background: color-mix(in srgb, var(--warning) 16%, var(--surface)); }
.badge.fail, .badge.bad { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 12%, var(--surface)); }
.badge.info, .badge.na { color: var(--text-2); }
.badge.plain::before { display: none; }
.badge.high { color: var(--critical-ink); }
.badge.medium { color: var(--warning-ink); }
.badge.low { color: var(--text-2); }
.status-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.status-icon.pass { background: #0a8a0a; }
.status-icon.warn { background: var(--warning); color: #3a2a00; }
.status-icon.fail { background: var(--critical); }
.status-icon.info { background: #6b6a66; }
.score-pill { display: inline-block; min-width: 42px; text-align: center; font-weight: 700; padding: 3px 8px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.score-pill.good { background: color-mix(in srgb, var(--good) 15%, var(--surface)); color: var(--good-ink); }
.score-pill.ok { background: color-mix(in srgb, var(--warning) 20%, var(--surface)); color: var(--warning-ink); }
.score-pill.bad { background: color-mix(in srgb, var(--critical) 14%, var(--surface)); color: var(--critical-ink); }
.score-pill.na { background: var(--surface-2); color: var(--muted); }

/* ---- stat tiles ---- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { color: var(--text-2); font-size: 0.82rem; font-weight: 600; }
.stat .value { font-size: 1.8rem; font-weight: 700; line-height: 1.15; }
.stat .sub { color: var(--text-2); font-size: 0.82rem; }

/* ---- report hero ---- */
.hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 28px; align-items: center; }
.hero h1 { font-size: 1.7rem; margin-bottom: 4px; word-break: break-word; }
.hero .meta { color: var(--text-2); font-size: 0.9rem; display: flex; gap: 14px; flex-wrap: wrap; }
.gauge { position: relative; width: 168px; height: 168px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .track { stroke: var(--surface-2); }
.gauge .bar { transition: stroke-dashoffset 0.8s ease; }
.gauge .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge .center .n { font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--text); }
.gauge .center .g { color: var(--text-2); font-size: 0.85rem; font-weight: 600; margin-top: 4px; }
.gauge.small { width: 84px; height: 84px; }
.gauge.small .center .n { font-size: 1.35rem; }
.gauge.small .center .g { font-size: 0.72rem; margin-top: 1px; }
.shots { display: flex; gap: 12px; align-items: flex-end; }
.shot { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.shot img { display: block; }
.shot.desktop img { width: 240px; }
.shot.mobile img { width: 82px; }
@media (max-width: 900px) {
  .hero { grid-template-columns: auto minmax(0, 1fr); }
  .shots { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .hero { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .shot.desktop img { width: 200px; }
}

/* ---- category cards ---- */
.cat-card { display: flex; gap: 14px; align-items: center; }
.cat-card .body { min-width: 0; }
.cat-card h3 { margin: 0 0 2px; font-size: 0.98rem; }
.cat-card .counts { display: flex; gap: 10px; font-size: 0.8rem; color: var(--text-2); flex-wrap: wrap; }
.cat-card .counts span { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.pass { background: var(--good); }
.dot.warn { background: var(--warning); }
.dot.fail { background: var(--critical); }

/* ---- checks list ---- */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--grid); }
.checks li:last-child { border-bottom: 0; }
.checks .row1 { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.checks .title { font-weight: 600; }
.checks .value { color: var(--text-2); font-size: 0.88rem; word-break: break-word; }
.checks .rec { font-size: 0.88rem; margin-top: 4px; }
.checks details summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; margin-top: 4px; }
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.filter-bar button { font: inherit; font-size: 0.82rem; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--axis); background: var(--surface); color: var(--text-2); cursor: pointer; }
.filter-bar button[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ---- recommendations ---- */
.recs { counter-reset: rec; list-style: none; padding: 0; margin: 0; }
.recs li { counter-increment: rec; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--grid); }
.recs li:last-child { border-bottom: 0; }
.recs li::before { content: counter(rec); width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; color: var(--text-2); }
.recs .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 2px; }
.recs .head strong { margin-right: 4px; }

/* ---- charts ---- */
.chart-box { position: relative; width: 100%; }
.chart-box.h-220 { height: 220px; }
.chart-box.h-260 { height: 260px; }
.chart-box.h-300 { height: 300px; }
.chart-box.h-360 { height: 360px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.82rem; color: var(--text-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bars .bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 44px; gap: 12px; align-items: center; font-size: 0.88rem; }
.bars .track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 5px; background: var(--series-1); }
.bars .fill.good { background: var(--good); }
.bars .fill.ok { background: var(--warning); }
.bars .fill.bad { background: var(--critical); }
@media (max-width: 560px) { .bars .bar-row { grid-template-columns: 120px minmax(0, 1fr) 36px; } }

/* ---- vitals ---- */
.vital { border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.vital .name { font-size: 0.8rem; color: var(--text-2); font-weight: 600; }
.vital .v { font-size: 1.5rem; font-weight: 700; margin: 2px 0 6px; }
.psi-scores { display: flex; gap: 18px; flex-wrap: wrap; }
.psi-scores .item { text-align: center; font-size: 0.78rem; color: var(--text-2); font-weight: 600; }

/* ---- progress ---- */
.progress { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.5s ease; }

/* ---- admin toolbar ---- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 20px; }
.share-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-box input { width: min(460px, 100%); font-family: ui-monospace, monospace; font-size: 0.82rem; }

/* ---- login ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(400px, 100%); }

/* ---- public report header ---- */
.public-head { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.public-head .inner { display: flex; justify-content: space-between; align-items: center; height: 58px; gap: 12px; }
.notes { white-space: pre-wrap; }
.footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 32px 0; }

.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.kw-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-list .badge { font-weight: 500; }

/* ---- report section navigation ---- */
:root { --header-h: 58px; --section-nav-h: 52px; }
.section-nav {
  position: sticky; top: var(--header-h); z-index: 9;
  margin: 16px -16px 0; padding: 8px 16px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.section-nav ul { position: relative; list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.section-nav ul::-webkit-scrollbar { display: none; }
.section-nav a {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; white-space: nowrap;
  font-size: 0.86rem; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
}
.section-nav a:hover { color: var(--text); text-decoration: none; border-color: var(--axis); }
.section-nav a[aria-current="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.report-anchor, section.report-section { scroll-margin-top: calc(var(--header-h) + var(--section-nav-h) + 12px); }
.to-top {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 11;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--axis); background: var(--surface); color: var(--text);
  font-size: 1.2rem; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.to-top:hover { border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---- print ---- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; font-size: 12px; }
  .topbar, .toolbar, .no-print, .filter-bar, .public-head .btn, .section-nav, .to-top { display: none !important; }
  .public-head { position: static; }
  .card { box-shadow: none; break-inside: avoid; }
  section.report-section { break-inside: auto; }
  details { display: block; }
  details > summary { display: none; }
  main.container { padding-top: 0; }
}

/* ---- rank tracker ---- */
.project-card { display: flex; flex-direction: column; gap: 12px; color: inherit; }
.project-card:hover { text-decoration: none; border-color: var(--axis); }
.project-card h3 { margin: 0 0 2px; }
.pc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-stats .n { display: block; font-size: 1.35rem; font-weight: 700; }
.pc-stats .l { font-size: 0.78rem; color: var(--text-2); }
.engine-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.engine-tabs a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 0.86rem; font-weight: 600; }
.engine-tabs a[aria-current="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.engine-tabs a:hover { text-decoration: none; color: var(--text); }
.engine-one { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 0.88rem; color: var(--text-2); }
.chg { font-weight: 700; font-variant-numeric: tabular-nums; }
.chg.up { color: var(--good-ink); }
.chg.down { color: var(--critical-ink); }
.beats { color: var(--critical-ink); font-weight: 700; }
.kw-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.kw-table th button { all: unset; cursor: pointer; }
.kw-table th button:hover, .kw-table th button:focus-visible { color: var(--text); text-decoration: underline; }
.kw-table th button[aria-sort="ascending"]::after { content: " ↑"; }
.kw-table th button[aria-sort="descending"]::after { content: " ↓"; }
.kw-table th.comp { max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { display: block; }

/* wizard dialog */
.wizard { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); overflow: hidden; }
.wizard[open] { display: flex; flex-direction: column; }
.wizard::backdrop { background: rgba(4, 10, 24, 0.7); }
.wz-head { background: var(--accent-fill); color: #fff; padding: 18px 22px 0; }
.wz-title-row { display: flex; justify-content: space-between; align-items: center; }
.wz-title-row h2 { margin: 0; font-size: 1.35rem; }
.wz-icon { all: unset; cursor: pointer; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 1.1rem; }
.wz-icon:hover, .wz-icon:focus-visible { background: rgba(255, 255, 255, 0.18); }
.wz-steps { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); margin: 22px 0 0; padding: 0 0 20px; counter-reset: s; }
.wz-steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: rgba(255, 255, 255, 0.7); font-size: 0.92rem; }
.wz-steps li:not(:last-child)::after { content: ""; position: absolute; top: 15px; left: calc(50% + 22px); right: calc(-50% + 22px); height: 1px; background: rgba(255, 255, 255, 0.45); }
.wz-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, 0.22); font-size: 0.85rem; font-weight: 700; color: #fff; }
.wz-steps li.current, .wz-steps li.done { color: #fff; font-weight: 700; }
.wz-steps li.current .wz-dot, .wz-steps li.done .wz-dot { background: #fff; color: var(--accent-fill); }
.wz-label small { display: block; font-weight: 400; font-size: 0.75rem; opacity: 0.8; margin-top: 2px; }
.wz-subhead { display: flex; align-items: center; gap: 12px; margin: 0 -22px; padding: 12px 22px; border-top: 1px solid rgba(255, 255, 255, 0.2); font-size: 1.15rem; font-weight: 600; }
.wz-subhead span { flex: 1; }
.wz-subhead input { flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 2px solid rgba(255, 255, 255, 0.7); border-radius: 0; color: #fff; font-size: 1.05rem; padding: 6px 2px; }
.wz-subhead input::placeholder { color: rgba(255, 255, 255, 0.7); }
.wz-subhead input:focus { outline: none; border-bottom-color: #fff; }
.wz-body { position: relative; padding: 22px; overflow-y: auto; min-height: 300px; flex: 1; }
.wz-foot { display: flex; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--border); }
.wz-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 0; border-bottom: 1px solid var(--grid); }
.wz-row-main { flex: 1; font-size: 1rem; }
.wz-field { font-weight: 400; margin: 0; }
.wz-field select { flex: 1; max-width: 340px; margin-left: auto; }
.wz-k { min-width: 90px; font-weight: 600; }
.wz-loc-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 0; cursor: pointer; border-bottom: 1px solid var(--grid); }
.wz-loc-btn:hover .wz-v, .wz-loc-btn:focus-visible .wz-v { color: var(--text); }
.wz-v { color: var(--accent); }
.wz-v.set { color: var(--text); }
#wz-loc-clear { margin-top: 12px; }
.wz-google { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #4285f4; font-weight: 800; font-family: Arial, sans-serif; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 0.85rem; padding: 6px 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; }
.wz-engines { list-style: none; margin: 0; padding: 0; }
.wz-engines li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--grid); }
.wz-engines .wz-icon { width: 30px; height: 30px; color: var(--text-2); }
.wz-engines .wz-icon:hover { background: var(--surface-2); }
.wz-fab { position: absolute; right: 22px; bottom: 22px; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent-fill); color: #fff; font-size: 1.6rem; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
.wz-fab:hover { filter: brightness(1.1); }
.wz-loc-results { list-style: none; margin: 0; padding: 0; }
.wz-loc-results button { all: unset; box-sizing: border-box; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; width: 100%; padding: 12px 8px; border-radius: 8px; cursor: pointer; }
.wz-loc-results button:hover, .wz-loc-results button:focus-visible { background: var(--surface-2); }
.wz-loc-results .place { font-size: 1.02rem; color: var(--text); }
.wz-loc-results .region { color: var(--text-2); font-size: 0.88rem; }
.wz-loc-results .type { margin-left: auto; color: var(--muted); font-size: 0.78rem; }
@media (max-width: 640px) {
  .wz-steps .wz-label { font-size: 0.75rem; }
  .wz-field select { max-width: none; }
  .wz-k { min-width: 70px; }
}

/* rank tracker overview panel */
.rt-panel { padding: 0; overflow: hidden; }
.rt-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.rt-engine { display: flex; align-items: center; gap: 14px; min-width: 0; }
.rt-engine .wz-google { width: 32px; height: 32px; font-size: 1.05rem; }
.rt-title { font-size: 1.05rem; font-weight: 600; }
.rt-sub { color: var(--text-2); font-size: 0.9rem; }
.rt-select { width: auto; max-width: 100%; padding: 6px 10px; font-size: 0.9rem; }
.rt-group { display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.rt-group label { margin: 0; font-weight: 600; color: var(--text); font-size: 1rem; }
.rt-chart-title { position: relative; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 18px 22px 0; color: var(--text-2); font-size: 1.05rem; }
.rt-help { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-2); background: none; color: var(--text-2); font-weight: 700; font-size: 0.8rem; line-height: 1; cursor: help; padding: 0; }
.rt-tip { display: none; position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5; width: min(360px, 90vw); padding: 10px 12px; border-radius: 8px; background: var(--text); color: var(--page); font-size: 0.85rem; line-height: 1.45; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.rt-help:hover + .rt-tip, .rt-help:focus + .rt-tip { display: block; }
.rt-panel .chart-box { padding: 6px 22px 0; box-sizing: border-box; }
.rt-note { text-align: center; margin: 4px 22px 0; }
.rt-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 24px; margin: 14px 0 0; padding: 18px 22px 20px; border-top: 1px solid var(--border); }
.rt-stats div { text-align: center; }
.rt-stats dt { padding-bottom: 8px; border-bottom: 1px solid var(--axis); color: var(--text); font-weight: 600; font-size: 0.95rem; }
.rt-stats dd { margin: 10px 0 0; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.rt-panel > p.muted { padding: 0 22px 16px; }
.kw-group { font-weight: 500; margin-left: 4px; }
@media (max-width: 760px) { .rt-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rt-engine { flex: 1 1 320px; }
.rt-engine > div { min-width: 0; flex: 1; }
#rt-engine { width: 100%; max-width: 460px; text-overflow: ellipsis; }

/* project tabs + AI visibility */
.project-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 14px; }
.project-tabs a { padding: 10px 16px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.project-tabs a:hover { color: var(--text); text-decoration: none; }
.project-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.ai-mark { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, var(--series-1), var(--series-5)); color: #fff; font-weight: 800; font-size: 0.8rem; }
.wz-ai-platforms .check { margin-bottom: 6px; }
.ai-table td.ai-cell { white-space: nowrap; }
.ai-link { display: inline-block; font-size: 0.72rem; font-weight: 700; color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; margin-left: 4px; }
.ai-none { color: var(--muted); font-size: 0.85rem; }
.ai-err { color: var(--critical-ink); font-size: 0.85rem; }
.ai-prompt { all: unset; cursor: pointer; font-weight: 700; }
.ai-prompt:hover, .ai-prompt:focus-visible { color: var(--accent); text-decoration: underline; }
.ai-prompt::before { content: "▸ "; color: var(--muted); }
.ai-prompt[aria-expanded="true"]::before { content: "▾ "; }
.ai-detail td { background: var(--surface-2); }
.ai-answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; padding: 6px 0; }
.ai-answer { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.ai-answer h4 { margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ai-answer .text { font-size: 0.86rem; line-height: 1.5; max-height: 340px; overflow: auto; color: var(--text-2); }
.ai-answer .text p { margin: 0 0 8px; }
.ai-answer .text p.h { color: var(--text); font-weight: 700; margin-top: 10px; }
.ai-answer .text p.row { margin: 0 0 4px; }
.ai-answer .text ol, .ai-answer .text ul { margin: 0 0 8px; padding-left: 20px; }
.ai-answer .text li { margin-bottom: 4px; }
.ai-answer .text strong { color: var(--text); }
.ai-answer mark { background: color-mix(in srgb, var(--series-1) 35%, transparent); color: var(--text); border-radius: 3px; padding: 0 2px; }
.ai-answer mark.comp { background: color-mix(in srgb, var(--series-2) 30%, transparent); }
.ai-answer .srcs { margin: 8px 0 0; padding-left: 18px; font-size: 0.8rem; }
.ai-answer .srcs li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-key { margin-left: 10px; white-space: nowrap; }

/* keyword / prompt manager */
.manager { width: min(1180px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); overflow: hidden; }
.manager[open] { display: flex; flex-direction: column; }
.manager::backdrop { background: rgba(4, 10, 24, 0.7); }
.mgr-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; background: var(--accent-fill); color: #fff; }
.mgr-head h2 { margin: 0; font-size: 1.3rem; }
.mgr-body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); overflow: hidden; flex: 1; min-height: 0; }
.mgr-col { padding: 18px 22px; overflow-y: auto; min-width: 0; }
.mgr-col + .mgr-col { border-left: 1px solid var(--border); }
.mgr-col h3 { margin: 0 0 12px; }
.mgr-add-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.mgr-add-row input[type="text"] { flex: 1; min-width: 160px; }
.mgr-list { margin-top: 16px; }
.mgr-group { margin-bottom: 14px; }
.mgr-group-name { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); margin-bottom: 4px; }
.mgr-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0 6px 2px; border-bottom: 1px solid var(--grid); font-size: 0.92rem; }
.mgr-item .wz-icon { width: 26px; height: 26px; font-size: 0.85rem; color: var(--text-2); flex: none; }
.mgr-item .wz-icon:hover { background: var(--surface-2); color: var(--critical-ink); }
.mgr-settings { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.mgr-settings summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }
.mgr-sources { margin-bottom: 14px; display: flex; flex-wrap: wrap; }
.mgr-source .btn { margin-top: 4px; }
.mgr-results-bar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0; }
.mgr-table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.mgr-table th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mgr-table td:first-child, .mgr-table th:first-child { width: 28px; }
.mgr-table tr.added td { opacity: 0.6; }
@media (max-width: 860px) {
  .mgr-body { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .mgr-col { overflow: visible; }
  .mgr-col + .mgr-col { border-left: 0; border-top: 1px solid var(--border); }
}

/* ---- audits list selection ---- */
.audits-table th.sel, .audits-table td.sel { width: 28px; padding-right: 0; }
.bulk-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: 0.9rem; }

/* ---- theme picker ---- */
.theme-picker { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); flex: none; }
.theme-picker button { all: unset; box-sizing: border-box; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.theme-picker button::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, 0.55); background: var(--swatch); }
.theme-picker button[data-theme-choice="blue"] { --swatch: #2456b0; }
.theme-picker button[data-theme-choice="dark"] { --swatch: #1c1c1e; }
.theme-picker button[data-theme-choice="light"] { --swatch: #fcfcfb; }
.theme-picker button:hover { background: var(--surface); }
.theme-picker button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); background: var(--surface); }
.theme-picker button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media print { .theme-picker { display: none !important; } }
