/* ============ GSC Reporter design system ============
   Data-dense dashboard, Swiss / minimal. Tokens first; components use tokens only.
   Shared classes for page work (see also the header of js/common.js):
   .status-line (+ .ok .bad .warn .busy), .empty-state (.es-title .es-line .es-action), .help-text,
   .form-label, .nowrap-pair, .table-form, .progress.reserve, .rk .rk-1..rk-5 .rk-nf .rk-na,
   .sticky-first / .scroll-shadow (tables), utilities .m-0 .mt-1..4 .ml-auto .grow .w-sm .w-md .w-lg
   .visually-hidden .skip-link .nowrap .label-caps. */

/* Self-hosted Inter (node_modules/@fontsource-variable/inter, served at /vendor/inter). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/vendor/inter/inter-latin-wght-normal.woff2") format("woff2-variations"), url("/vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations"), url("/vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* surfaces + text */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --field-border: #8a99ad;          /* form fields, about 3:1 on white */
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;                /* smallest readable grey (4.7:1) */
  --deco: #94a3b8;                  /* borders / decoration only, never text */
  /* accent (solid, no gradients) */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eaf1ff;
  --accent-border: #bcd0f8;
  --highlight: #d97706;
  /* semantic */
  --good: #15803d; --good-soft: #dcfce7; --good-tint: #f0fdf4;
  --bad: #b91c1c;  --bad-soft: #fee2e2;  --bad-tint: #fef2f2; --bad-hover: #991b1b;
  --warn: #92400e; --warn-soft: #fef3c7; --warn-tint: #fffbeb;
  --info: #1e40af; --info-soft: #dbeafe; --info-tint: #eff6ff;
  /* chart series (read in JS with seriesColors()) */
  --series-1: #2563eb; --series-2: #7c3aed; --series-3: #0d9488; --series-4: #d97706; --series-5: #db2777; --series-6: #64748b;
  /* rank colour pairs (background / ink), read in JS with rankColor(rank) */
  --rank-1: #15803d; --rank-1-ink: #ffffff;   /* 1-3 */
  --rank-2: #65a30d; --rank-2-ink: #0f172a;   /* 4-6 */
  --rank-3: #ca8a04; --rank-3-ink: #0f172a;   /* 7-10 */
  --rank-4: #c2410c; --rank-4-ink: #ffffff;   /* 11-15 */
  --rank-5: #b91c1c; --rank-5-ink: #ffffff;   /* 16-20 */
  --rank-nf: #7f1d1d; --rank-nf-ink: #ffffff; /* not found */
  /* spacing (4px scale) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-7: 28px; --sp-8: 32px;
  /* type scale */
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 16px; --fs-lg: 18px; --fs-xl: 22px;
  /* controls */
  --ctl-h: 36px;
  --ctl-h-sm: 30px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-pop: 0 12px 32px rgba(15, 23, 42, .28);
  /* layers */
  --z-sticky: 1; --z-sidebar: 40; --z-appbar: 50; --z-overlay: 55; --z-drawer: 60; --z-pop: 1000; --z-modal: 2000; --z-toast: 3000;
  --appbar-h: 57px;
  --sb-w: 236px;
  --font: "Inter", "Inter Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* legacy names still used in a few places */
  --text-primary: var(--text); --text-secondary: var(--text-2); --accent-light: var(--accent-soft);
  --bg-top: var(--surface-2); --row-alt: var(--surface-2);
  --soft: var(--surface-2); --card: var(--surface); --brand: var(--accent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--appbar-h) + 8px); }
body { margin: 0; font-family: var(--font); font-size: var(--fs-base); line-height: 1.5; color: var(--text); background: var(--bg);
  min-height: 100vh; min-height: 100dvh; font-optical-sizing: auto; }
a { color: var(--accent); }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; font-size: var(--fs-xs); font-family: var(--font-mono); }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--text-3); opacity: 1; }

/* ---------- accessibility helpers ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--sp-2); top: -100px; z-index: var(--z-toast); background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: var(--sp-2); }

/* ---------- app bar ---------- */
.appbar { position: sticky; top: 0; z-index: var(--z-appbar); background: var(--surface); border-bottom: 1px solid var(--border); }
.appbar-inner { max-width: 1320px; margin: 0 auto; padding: 0 20px; min-height: calc(var(--appbar-h) - 1px); display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: var(--fs-md); color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800; background: var(--accent); }
.topnav { display: flex; gap: 4px; }
.topnav a { color: var(--text-2); text-decoration: none; font-weight: 600; padding: 7px 12px; border-radius: var(--radius-sm); }
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.appbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- layout ---------- */
.app-shell { max-width: 1320px; margin: 20px auto; padding: 0 20px 48px; }
.app-shell:focus { outline: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.panel-head { margin-bottom: var(--sp-3); }
.panel-head h2, .gh-top h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.panel-head p { margin: 2px 0 0; color: var(--text-2); }
.subcard { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); background: var(--surface); }
.subcard h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.section-title { margin: 22px 0 8px; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.muted { color: var(--text-2); font-size: var(--fs-sm); }
.tiny { font-size: 11px; line-height: 1.2; }
.help-text { font-size: var(--fs-xs); line-height: 1.5; color: var(--text-2); text-wrap: pretty; margin: 4px 0 8px; }
.label-caps, .tab-group-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }

/* ---------- utilities ---------- */
.m-0 { margin: 0 !important; }
.mt-1 { margin-top: var(--sp-1) !important; } .mt-2 { margin-top: var(--sp-2) !important; }
.mt-3 { margin-top: var(--sp-3) !important; } .mt-4 { margin-top: var(--sp-4) !important; }
.ml-auto { margin-left: auto !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.w-sm { width: 120px; max-width: 100%; } .w-md { width: 200px; max-width: 100%; } .w-lg { width: 320px; max-width: 100%; }
.nowrap { white-space: nowrap; }
.nowrap-pair { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

/* ---------- controls ---------- */
.controls { padding-bottom: var(--sp-3); }
.control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px 22px; }
.form-label, .control > label { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inline select { min-width: 0; flex: 1 1 160px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.filters .control select, .filters .control input { width: 100%; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: var(--sp-4); padding-top: 14px; border-top: 1px solid var(--border); }
.field-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: 10px; }
.field-row > label { color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.toolbar { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 4px; }
label.check { display: inline-flex; align-items: flex-start; gap: 6px; color: var(--text); font-weight: 500; cursor: pointer; }
label.check > input[type="checkbox"], label.check > input[type="radio"] { margin: 3px 0 0; flex: none; }
.w-num { width: 64px; }

/* status lines: setStatus(el, text, kind) in common.js sets role=status + one of the kind classes */
.status-line { display: block; font-size: var(--fs-sm); color: var(--text-2); margin: 8px 0 10px; min-height: 18px; }
.status-line:empty { min-height: 0; margin: 0; }
.status-line.ok { color: var(--good); }
.status-line.bad { color: var(--bad); }
.status-line.warn { color: var(--warn); }
.status-line.busy { color: var(--text-2); }
.status-line.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--accent-border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* empty state block: emptyState({title, line, actionHtml}) in common.js */
.empty-state { padding: var(--sp-6) var(--sp-4); text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); margin: var(--sp-2) 0; }
.empty-state .es-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.empty-state .es-line { margin: 4px auto 0; max-width: 560px; font-size: var(--fs-sm); text-wrap: pretty; }
.empty-state .es-action { margin-top: var(--sp-3); display: flex; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; }

/* form fields: one height for input, select and button */
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], input[type="search"],
input[type="url"], input[type="tel"], input[type="month"], input[type="time"], input[type="datetime-local"], input:not([type]), select, textarea {
  font: inherit; font-size: var(--fs-base); padding: 0 10px; border: 1px solid var(--field-border); border-radius: var(--radius-sm);
  background-color: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s; vertical-align: middle; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], input[type="search"],
input[type="url"], input[type="tel"], input[type="month"], input[type="time"], input[type="datetime-local"], input:not([type]), select { height: var(--ctl-h); }
select { padding-right: 6px; }
textarea { width: 100%; resize: vertical; font-size: var(--fs-sm); padding: 7px 10px; }
input.small, select.small { height: var(--ctl-h-sm); font-size: var(--fs-sm); padding: 0 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .35); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
input[type="file"] { font-size: var(--fs-sm); max-width: 240px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- buttons ---------- */
button, .btn { font: inherit; font-weight: 600; font-size: var(--fs-base); min-height: var(--ctl-h); padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; vertical-align: middle; line-height: 1.2;
  cursor: pointer; background: var(--accent); color: #fff; transition: background-color .15s, border-color .15s, color .15s; white-space: nowrap; text-decoration: none; }
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
button.busy, button[aria-busy="true"] { cursor: progress; }
button.secondary, .btn.secondary { background: #fff; color: var(--accent); border-color: var(--accent-border); }
button.secondary:hover, .btn.secondary:hover { background: var(--accent-soft); }
button.ghost, a.ghost { background: transparent; color: var(--text-2); border-color: transparent; font-weight: 600; text-decoration: none; padding: 0 10px; border-radius: var(--radius-sm); font-size: var(--fs-sm);
  min-height: var(--ctl-h); display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
button.ghost:hover, a.ghost:hover { background: var(--surface-3); color: var(--text); }
button.small, a.small, .btn.small { min-height: var(--ctl-h-sm); padding: 0 10px; font-size: var(--fs-sm); }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.danger:hover { background: #fecaca; color: var(--bad-hover); }
.danger-text { color: var(--bad) !important; }
button.danger-text:hover, a.danger-text:hover { color: var(--bad-hover) !important; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; padding: 4px; min-height: 0; cursor: pointer; text-decoration: none; display: inline; }
.link-btn:hover { background: none; text-decoration: underline; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px 0 18px; flex-wrap: wrap; }
.tabs.grouped { gap: 18px; padding-bottom: 0; }
.tab-group { display: flex; align-items: flex-end; gap: 2px; position: relative; padding-top: 16px; }
.tab-group-label { position: absolute; top: 0; left: 10px; font-size: 10px; letter-spacing: .08em; }
.tab-btn { background: transparent; color: var(--text-2); border: none; border-radius: 0; padding: 9px 12px; min-height: 0; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { background: transparent; color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; animation: fade .15s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ---------- tables ---------- */
.table-scroll { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.table-scroll.short { max-height: 320px; }
.table-scroll:has(table:empty) { display: none; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { font-variant-numeric: tabular-nums; }
thead th { position: sticky; top: 0; z-index: var(--z-sticky); background: var(--surface-3); color: var(--text-2); text-align: left; font-weight: 600; font-size: var(--fs-xs);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 7px 10px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
/* sticky first column on phones (opt out: .no-sticky on the .table-scroll); low specificity so row tints still win */
@media (max-width: 640px) {
  :where(.table-scroll:not(.no-sticky), .sticky-first) tbody td:first-child { position: sticky; left: 0; background-color: var(--surface); z-index: var(--z-sticky); }
  :where(.table-scroll:not(.no-sticky), .sticky-first) thead th:first-child { position: sticky; left: 0; z-index: calc(var(--z-sticky) + 1); }
  .table-scroll { background:
    linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .16), rgba(15, 23, 42, 0)) right / 10px 100% no-repeat scroll, #fff; }
}
/* scroll edge shadow at any width (right edge shows a shadow while more columns are hidden) */
.scroll-shadow { background:
  linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left / 32px 100% no-repeat local,
  linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right / 32px 100% no-repeat local,
  radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .16), rgba(15, 23, 42, 0)) left / 10px 100% no-repeat scroll,
  radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .16), rgba(15, 23, 42, 0)) right / 10px 100% no-repeat scroll, #fff; }
tbody tr:hover td { background: #f5f8ff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.url { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr.clickable { cursor: pointer; }
caption { font-size: var(--fs-xs); }
.table-form td { vertical-align: middle; }
.table-more { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 10px; font-size: var(--fs-sm); color: var(--text-2); }
.pivot td, .pivot th { white-space: nowrap; }
.pivot td:first-child, .pivot th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
.pivot th:first-child { background: var(--surface-3); z-index: 2; }
.cell-up { background: var(--good-tint); color: var(--good); }
.cell-down { background: var(--bad-tint); color: var(--bad); }
.cell-base { box-shadow: inset 0 0 0 2px #93c5fd; }
tr.row-base td { background: var(--info-tint); }
/* sortable headings (js/tablesort.js puts the label in a button.th-sort) */
table:not(.no-sort) > thead th:not(.no-sort) { cursor: pointer; user-select: none; }
button.th-sort { all: unset; display: inline; cursor: pointer; color: inherit; font: inherit; border-radius: 3px; white-space: nowrap; }
button.th-sort:hover { background: none; text-decoration: underline dotted; }
button.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ts-ind { font-size: 10px; margin-left: 4px; opacity: .75; white-space: nowrap; }

/* row highlights mapped to semantic tokens */
.row-High td { background: var(--bad-soft); } .row-Medium td { background: var(--warn-soft); } .row-Low td { background: var(--good-tint); }
.row-unreliable td { background: var(--warn-soft); } .row-error td { background: var(--bad-soft); } .row-na td { background: var(--surface-3); color: var(--text-2); }
.row-notindexed td { background: var(--bad-soft); } .row-excluded td { color: var(--text-3); }
.row-Up td { background: var(--good-tint); } .row-Down td { background: var(--bad-tint); }
.row-New td { background: var(--info-tint); } .row-New td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.row-Lost td { background: var(--bad-soft); } .row-Lost td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.row-sev-High td { background: var(--bad-soft); }

/* ---------- stats, pills, badges ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.stat-row:empty { display: none; }
.stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); }
.stat .k { font-size: var(--fs-xs); color: var(--text-2); font-weight: 500; }
.stat .v { font-size: var(--fs-xl); font-weight: 700; margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat .d, .stat .rk { font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; }
.up { color: var(--good); } .down { color: var(--bad); } .flat { color: var(--text-2); }
.v.up { color: var(--good); } .v.down { color: var(--bad); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge { display: inline-block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.badge:not(:empty) { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; }
.badge.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* rank colour classes (rankClass(rank) in common.js) */
.rk { display: inline-block; min-width: 42px; text-align: center; padding: 2px 7px; border-radius: 5px; color: #fff; font-weight: 700; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.rk-1 { background: var(--rank-1); color: var(--rank-1-ink); }
.rk-2 { background: var(--rank-2); color: var(--rank-2-ink); }
.rk-3 { background: var(--rank-3); color: var(--rank-3-ink); }
.rk-4 { background: var(--rank-4); color: var(--rank-4-ink); }
.rk-5 { background: var(--rank-5); color: var(--rank-5-ink); }
.rk-nf { background: var(--rank-nf); color: var(--rank-nf-ink); }
.rk-na { background: var(--surface-3); color: var(--text-2); }

/* ---------- progress, charts, detail ---------- */
/* pollJob sets --p (0..1) on .progress-bar; .progress.reserve keeps its space while idle (no layout jump) */
.progress { height: 6px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; margin: 4px 0 8px; }
.progress-bar { height: 100%; width: 100%; background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left center; transition: transform .3s ease; }
.progress.reserve { display: block !important; }
.progress.reserve:not(.on) { visibility: hidden; }
.chart-box { position: relative; height: 300px; margin: 8px 0 14px; }
.detail { border: 1px solid var(--accent-border); background: #fbfdff; border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 14px; }
.detail-head { display: flex; justify-content: space-between; align-items: center; }
.detail-head h3 { margin: 0; font-size: 15px; }

/* ---------- info "i" popovers ---------- */
/* visual 18px circle, 24px hit area via the transparent border box */
.help-i { display: inline-grid; place-items: center; width: 24px; height: 24px; min-height: 0; padding: 0; margin: -3px -3px -3px 1px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text-2); font: italic 700 11px/1 Georgia, serif;
  cursor: help; vertical-align: middle; text-transform: none; letter-spacing: 0; flex: none; position: relative; }
.help-i::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 1px solid var(--deco); background: #fff; z-index: -1; }
.help-i:hover, .help-i.on { background: transparent; color: #fff; }
.help-i:hover::before, .help-i.on::before { background: var(--accent); border-color: var(--accent); }
.help-i { isolation: isolate; }
/* (i) placed after a summary / button / link host hides with it */
[hidden] + .help-i, [style*="display: none"] + .help-i, [style*="display:none"] + .help-i { display: none; }
details.help-host:not([open]) { display: inline-block; vertical-align: middle; }
.help-anchor { display: inline-flex; margin-right: 6px; }
.help-pop { position: absolute; z-index: var(--z-pop); display: none; background: #0f172a; color: #e2e8f0; border-radius: var(--radius); padding: 12px 14px 12px;
  box-shadow: var(--shadow-pop); font-size: var(--fs-sm); line-height: 1.5; }
.help-pop:focus { outline: none; }
.help-pop .help-title { font-weight: 700; color: #fff; margin: 0 18px 4px 0; }
.help-pop .help-out { margin-top: 8px; padding-top: 8px; border-top: 1px solid #334155; color: #bfdbfe; }
.help-pop b { color: #fff; }
.help-pop code { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.help-close { position: absolute; top: 4px; right: 4px; background: none; border: none; color: #94a3b8; font-size: 18px; width: 28px; height: 28px; min-height: 0; padding: 0; line-height: 1; }
.help-close:hover { background: none; color: #fff; }

/* ---------- modal (showModal in common.js) ---------- */
.ui-modal { position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.ui-modal-box { background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); width: min(480px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: var(--sp-5); }
.ui-modal-box h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); font-weight: 600; }
.ui-modal-body { color: var(--text-2); font-size: var(--fs-base); }
.ui-modal-body p { margin: 0 0 var(--sp-2); }
.ui-modal-input { width: 100%; margin-top: var(--sp-2); }
.ui-modal-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); flex-wrap: wrap; }
button.solid-danger { background: var(--bad); color: #fff; }
button.solid-danger:hover { background: var(--bad-hover); }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: 190px 1fr; gap: 10px 14px; align-items: center; max-width: 900px; }
.settings-grid > label { display: inline-flex; align-items: center; gap: 3px; }
.settings-grid > label:not(.check) { font-weight: 600; }
.settings-grid > label:has(> input[type="checkbox"], > input[type="radio"]) { font-weight: 500; align-items: flex-start; gap: 6px; cursor: pointer; }
.settings-grid > label > input[type="checkbox"], .settings-grid > label > input[type="radio"] { margin: 3px 0 0; flex: none; }
.settings-grid input[type="text"], .settings-grid input[type="email"], .settings-grid input[type="password"], .settings-grid select { width: 100%; }
.settings-grid .field-row { flex-wrap: wrap; }
.settings-grid .field-row > select, .settings-grid .field-row > input { width: auto; flex: 1 1 130px; min-width: 0; }
.hint { font-size: var(--fs-xs); color: var(--text-2); grid-column: 2; margin-top: -6px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-4); margin-bottom: var(--sp-3); background: #fff; }
.panel h2 { margin: 0 0 12px; font-size: var(--fs-md); font-weight: 600; display: flex; align-items: center; gap: 4px; }
.share-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-box input { flex: 1; min-width: 260px; }

/* ---------- login ---------- */
.login-shell { max-width: 380px; margin: 14vh auto; padding: 0 16px; }
.login-shell .card { padding: 32px; }
.login-shell h1 { font-size: 20px; margin: 0 0 20px; text-align: center; }
.login-shell input { width: 100%; margin-bottom: 12px; }
.login-shell button { width: 100%; }
.error-text { color: var(--bad); font-size: var(--fs-sm); margin: 8px 0; }

/* ---------- old header (share page) ---------- */
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }

/* ---------- credits under the email (sidebar.js) ---------- */
.user-stack { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.credit-line { font-size: 11.5px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.credit-line a { color: inherit; text-decoration: none; }
.credit-line .cl-item b { color: var(--text); font-weight: 600; }
.credit-line .cl-item.low b { color: var(--bad); }

/* ---------- left sidebar (sidebar.js builds the markup; every app page has body.has-sidebar) ---------- */
.sidebar { position: fixed; top: var(--appbar-h); left: 0; bottom: 0; width: var(--sb-w); background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; overscroll-behavior: contain; padding: 12px 10px 24px; z-index: var(--z-sidebar); }
body.has-sidebar .app-shell { margin-left: calc(var(--sb-w) + 20px); margin-right: 20px; max-width: none; padding-left: 0; padding-right: 0; }
body.has-sidebar .appbar-inner { max-width: none; }
body.has-sidebar .topnav { display: none; }
body.has-sidebar .tabs.grouped, body.has-sidebar #settingsTabs { display: none; }
.sb-top { display: none; }
.sb-search input { width: 100%; height: var(--ctl-h); padding: 0 10px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--surface-2); font: inherit; font-size: var(--fs-sm); }
.sb-search input::placeholder { color: var(--text-2); }
.sb-search input:focus { border-color: var(--accent); background: var(--surface); }
.sb-nav { margin-top: 10px; }
.sb-group { margin-bottom: 4px; }
.sb-head { width: 100%; display: flex; align-items: center; gap: 9px; min-height: 0; padding: 8px; border: 0; background: none; color: var(--text); font: inherit; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; cursor: pointer; border-radius: var(--radius-sm); }
.sb-head:hover { background: var(--surface-2); }
.sb-head svg { width: 17px; height: 17px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sb-head span { flex: 1; text-align: left; }
.sb-caret { flex: none; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
.sb-group.collapsed .sb-caret { transform: rotate(-45deg); }
.sb-group.collapsed .sb-items { display: none; }
.sb-items { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.sb-item { display: block; padding: 7px 10px 7px 34px; color: var(--text-2); text-decoration: none; font-weight: 500; border-radius: var(--radius-sm); font-size: 13.5px; }
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sb-hidden, .sb-nomatch { display: none !important; }
button.sb-toggle { display: none; flex-direction: column; justify-content: center; gap: 4px; padding: 8px; min-width: var(--ctl-h); }
.sb-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
button.sb-close { display: none; }
.sb-user { font-size: var(--fs-sm); color: var(--text-2); word-break: break-all; }
.sb-user .credit-line { justify-content: flex-start; margin-top: 2px; }
@media (max-width: 900px) {
  .sidebar { top: 0; padding-top: 12px; z-index: var(--z-drawer); box-shadow: var(--shadow-pop); width: min(300px, 86vw);
    transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  body.sb-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  body.sb-open { overflow: hidden; }
  body.sb-open::after { content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .3); z-index: var(--z-overlay); }
  body.has-sidebar .app-shell { margin-left: 12px; margin-right: 12px; }
  button.sb-toggle { display: inline-flex; }
  .sb-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  button.sb-close { display: inline-flex; flex: none; width: var(--ctl-h); padding: 0; font-size: 22px; }
}
@media (min-width: 641px) { .sb-top .sb-user { display: none; } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .split, .two-col { grid-template-columns: 1fr; }
  .appbar-inner { gap: 12px; flex-wrap: wrap; }
  .appbar-user { margin-left: auto; }
}
@media (max-width: 640px) {
  .app-shell { padding: 0 12px 40px; margin-top: 12px; }
  .appbar-inner { padding: 0 12px; flex-wrap: nowrap; }
  .appbar-user .user-stack, .appbar-user > #userEmail { display: none; }
  .card { padding: var(--sp-4); }
  .settings-grid { grid-template-columns: 1fr; }
  .hint { grid-column: 1; }
  .tabs.grouped { gap: 6px; }
  .topnav a { padding: 6px 8px; }
  .gh-layers { margin-left: 0; }
  td.url { max-width: 200px; }
}

/* Map Grid */
.gh-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.gh-top > div:first-child { flex: 1 1 260px; }
.gh-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { background: var(--surface); color: var(--text-2); border: 0; border-radius: 0; padding: 0 16px; font-weight: 600; }
.seg-btn:hover { background: var(--surface-3); }
.seg-btn.on { background: var(--accent); color: #fff; }
.gh-card { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 12px; }
.gh-card > div { padding: 14px 16px; border-right: 1px solid var(--border); min-width: 0; }
.gh-card > div:last-child { border-right: 0; }
.gh-card .biz-name { font-weight: 700; font-size: 16px; }
.gh-card .stars { color: #b45309; letter-spacing: 1px; }
.gh-card .kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 5px 0; font-size: 13px; }
.gh-card .kv b { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.gh-card .links a { margin-right: 12px; font-size: 13px; }
.gh-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.gh-controls label { font-weight: 600; }
.gh-layers { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; }
.gh-layers button { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); padding: 0 12px; font-weight: 600; }
.gh-layers button:hover { background: var(--surface-3); }
.gh-layers button.on { color: var(--accent); border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.gh-layers button:disabled { opacity: .45; cursor: not-allowed; }
.gh-toggle { margin-left: auto; font-weight: 500 !important; display: inline-flex; gap: 6px; align-items: center; }
.gh-tablebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 16px 0 8px; flex-wrap: wrap; }
.grid-map { width: 100%; height: 600px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.grid-map .empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 14px; padding: 20px; text-align: center; }
.gpin { border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 700 12px/1 var(--font); color: #111; border: 1.5px solid rgba(0,0,0,.55); box-shadow: 0 1px 3px rgba(0,0,0,.35); cursor: pointer; width: 100%; height: 100%; box-sizing: border-box; }
.gpin.light { color: #fff; }
.gpin.center { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #111827; }
.leaflet-tooltip.gbiz-label { font-weight: 700; }
.grid-legend { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.grid-legend .gl { color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
#gridCompTable tr.me td { background: var(--accent-soft); font-weight: 600; }
#gridCompTable th { cursor: pointer; }
.gp-modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: 24px; }
.gp-box { background: var(--surface); border-radius: var(--radius); width: min(1200px, 100%); max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.gp-head { background: #1e293b; color: #fff; padding: 16px 20px; display: flex; justify-content: space-between; align-items: flex-start; }
.gp-head h3 { margin: 0 0 4px; color: #fff; }
.gp-head .tiny { color: #cbd5e1; }
.gp-head button { color: #fff; font-size: 24px; line-height: 1; }
.gp-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); min-height: 0; flex: 1; }
.gp-list { overflow-y: auto; padding: 8px 16px; max-height: calc(92vh - 80px); }
.gp-map { min-height: 520px; }
.gp-item { display: grid; grid-template-columns: 52px 1fr 190px; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: start; }
.gp-item.me { background: var(--accent-soft); }
.gp-num { width: 44px; height: 44px; border-radius: 50%; border: 2px solid #14b8a6; color: #0f766e; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.gp-item .nm { font-weight: 700; }
.gp-item .sub { font-size: 12px; color: var(--text-2); }
.gp-item .st .kv { display: flex; justify-content: space-between; font-size: 12px; margin: 2px 0; gap: 6px; }
@media (max-width: 1000px) { .gh-card { grid-template-columns: 1fr 1fr; } .gp-body { grid-template-columns: 1fr; } .gp-map { min-height: 300px; } .grid-map { height: 440px; } }
@media (max-width: 640px) { .gh-card { grid-template-columns: 1fr; } .gp-item { grid-template-columns: 40px 1fr; } .gp-item .st { grid-column: 2; } }
.gbiz { width: 18px; height: 18px; border-radius: 50%; background: #111827; border: 3px solid #fff; box-shadow: 0 0 0 2px #111827; }

/* ---- analysis tools: AI / schedule control, results ---- */
.tool-ctl:empty { display: none; }
.tc-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; margin: 8px 0 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tc-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); margin-left: 4px; }
.ai-answer { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: var(--radius-sm); }
.cause-list { list-style: none; padding: 0; margin: 8px 0; }
.cause-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.subcard h3.wrap, .subcard h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 640px) { .tc-row input[data-k="model"] { width: 100% !important; } }

/* Map Grid compare */
.cmp-maps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 10px 0 6px; }
.cmp-maps h4 { margin: 0 0 6px; font-size: 13px; }
.cmp-map { height: 320px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-3); }
@media (max-width: 900px) { .cmp-maps { grid-template-columns: 1fr; } }

/* Websites added by hand */
.manual-note { margin: 0 0 12px; padding: 10px 14px; border: 1px solid #fde68a; background: var(--warn-tint); border-radius: var(--radius-sm); font-size: 13px; color: #78350f; }

/* Summary report */
.code-box { margin: 4px 0; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font: 12px/1.45 var(--font-mono); white-space: pre-wrap; word-break: break-word; }
.sum-item summary { cursor: pointer; }
.sum-val { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--border); vertical-align: middle; overflow: hidden; }
.sum-val i { display: block; height: 100%; background: var(--accent); }
.serp { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--surface); }
.serp .u { color: #188038; font-size: 12px; } .serp .t { color: #1a0dab; font-size: 16px; line-height: 1.3; } .serp .d { color: #4d5156; font-size: 13px; }
.sum-shot { max-width: 180px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-right: 10px; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}

/* ===== Phase B2: Settings, Dashboard, Login / Invite (settings.html, dashboard.html, login.html, invite.html) ===== */
/* Settings header picker (same .control markup as the Reports page) */
.settings-pick { max-width: 900px; margin-bottom: var(--sp-2); }
/* small visible labels over grouped fields (Market, Lead value, Spend cap, Add website) */
.field-row.mini-fields { align-items: flex-end; gap: var(--sp-2) var(--sp-3); }
.field-row > label.mini-field, .mini-field { display: flex; flex-direction: column; align-items: stretch; gap: 3px; flex: 1 1 140px; min-width: 0;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.mini-field.mf-wide { flex: 2 1 240px; }
.mini-field > input, .mini-field > select { width: 100%; min-width: 0; }
.settings-grid .mini-field > input, .settings-grid .mini-field > select { width: 100%; }
.input-affix { display: flex; align-items: center; gap: 6px; }
.input-affix > input { flex: 1 1 auto; width: 100%; min-width: 0; }
.input-affix .affix { flex: none; font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.settings-grid > .hint:empty { display: none; }
/* sticky Save bar at the bottom of Site Settings */
.save-bar { position: sticky; bottom: 0; z-index: calc(var(--z-sticky) + 2); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  margin: var(--sp-3) calc(-1 * var(--sp-4)) var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--surface);
  border-top: 1px solid var(--border); box-shadow: 0 -6px 16px rgba(15, 23, 42, .06); }
.save-bar .status-line { margin: 0; min-height: 0; }
.dirty-dot { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--warn); }
.dirty-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--highlight); }
.dirty-dot[hidden] { display: none; }
.danger-zone { border-color: #fecaca; background: var(--bad-tint); }
.danger-zone h2 { color: var(--bad); }
/* Dashboard */
.dash-controls { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.dash-controls .control { flex: 0 1 320px; min-width: 0; }
.dash-controls .control select { width: 100%; }
.dash-controls .help-text { margin: 4px 0 0; }
td.client-cell a { font-weight: 600; text-decoration: none; }
td.client-cell a:hover { text-decoration: underline; }
/* Login / Invite */
.login-shell { margin: 10vh auto; }
.login-shell .auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: var(--fs-md); margin-bottom: var(--sp-4); }
.login-shell h1 { margin: 0 0 4px; font-size: var(--fs-xl); font-weight: 600; }
.login-shell .auth-sub { text-align: center; margin: 0 0 var(--sp-5); }
.login-shell .form-label { margin-bottom: 4px; }
.login-shell .auth-foot { margin-top: var(--sp-4); text-align: center; }
@media (max-width: 640px) { .login-shell { margin: 6vh auto; } .login-shell .card { padding: var(--sp-5); } .save-bar { gap: var(--sp-2); } }
/* ===== end Phase B2 ===== */

/* ===== Phase B1b: Map Grid, tools, growth / insights / traffic tabs ===== */
/* Map Grid legend: .gl pills take the shared rank pairs (background + ink) from .rk-* */
.grid-legend .gl.rk-1 { color: var(--rank-1-ink); } .grid-legend .gl.rk-2 { color: var(--rank-2-ink); }
.grid-legend .gl.rk-3 { color: var(--rank-3-ink); } .grid-legend .gl.rk-4 { color: var(--rank-4-ink); }
.grid-legend .gl.rk-5 { color: var(--rank-5-ink); } .grid-legend .gl.rk-nf { color: var(--rank-nf-ink); }
.gh-layers { max-width: 100%; }
@media (max-width: 640px) { .gh-layers { flex: 1 1 100%; margin-left: 0; } } /* after the Map Grid rules, so it wins over margin-left: 8px */
/* row buttons in clickable table rows (keyboard): look like the text they replace, wrap like it */
td .link-btn { white-space: normal; text-align: left; padding: 0; font-size: inherit; line-height: inherit; color: var(--accent); }
td .link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
/* Site Audit picker: room for "date UTC: score, pages" and the "No audits yet" placeholder */
#audSel { min-width: 260px; max-width: 100%; }
.warn-text { color: var(--warn); }
/* ===== end Phase B1b ===== */

/* ===== Phase B1: Reports page (index.html) report card, Leads, Rank Tracker, Live Rank, Action Plan ===== */
:root { --lead-whatsapp: #22c55e; } /* Leads chart: WhatsApp green next to Call teal (--series-3) */
/* Report card: context bar (client, dates, account, export) on every tab; the fetch block only on tabs
   whose panel has data-needs-fetch (app.js toggles .no-fetch). Phones: one line + "Change" (.open). */
.report-card { padding-top: var(--sp-3); }
.ctx-summary { display: none; }
.ctx-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) var(--sp-6); align-items: end; }
@media (min-width: 1560px) { .ctx-grid { grid-template-columns: minmax(240px, 1.2fr) auto minmax(220px, 1fr) auto; } }
.ctx-grid .control { min-width: 0; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: 5px; }
.label-row .form-label { margin-bottom: 0; }
a.small-link { font-size: var(--fs-xs); font-weight: 600; padding: 2px 0; }
.report-card .inline > select { flex: 1 1 160px; }
.report-card .inline > select.w-quick, .w-quick { flex: 0 0 136px; width: 136px; }
.report-card .inline > button.small, .report-card .inline .nowrap-pair > button.small { min-height: var(--ctl-h); }
.icon-btn { font-size: 17px; min-width: var(--ctl-h); padding: 0 6px; }
.ctl-dates input[type="date"] { width: 150px; flex: 0 1 150px; min-width: 0; }
/* small "Manage" menu next to the account list (Remove this account lives here) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: var(--ctl-h); padding: 0 10px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; color: var(--accent); user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -3px; }
.menu > summary:hover, .menu[open] > summary { background: var(--accent-soft); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: var(--z-pop); min-width: 200px; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(15, 23, 42, .14); }
.menu-pop button { width: 100%; justify-content: flex-start; }
/* fetch block */
.fetch-block { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.report-card.no-fetch .fetch-block { display: none; }
.fetch-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); }
.fetch-row .fetch-go { margin-left: var(--sp-2); }
.fetch-row .filters { flex-basis: 100%; }
.filter-toggle .caret { display: inline-block; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -3px 0 0 2px; transition: transform .15s; }
.filter-toggle[aria-expanded="true"] .caret { transform: rotate(-135deg); margin-top: 3px; }
.report-card .status-line { margin: var(--sp-3) 0 0; }
.report-card .status-line:empty { margin: 0; }
@media (max-width: 640px) {
  .ctx-summary { display: flex; align-items: center; gap: var(--sp-2); }
  .ctx-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--fs-sm); }
  .report-card:not(.open) .ctx-body { display: none; }
  .report-card.open .ctx-body { margin-top: var(--sp-3); }
  .ctx-grid { grid-template-columns: minmax(0, 1fr); }
  .ctl-dates input[type="date"] { flex: 1 1 130px; width: auto; }
  .report-card.no-fetch:not(.open) .status-line:not(.bad):not(.warn) { display: none; }
  .fetch-row .fetch-go { margin-left: auto; }
}
/* ghost buttons that do something read as actions: accent text + hover background (finding 23) */
#reportCard button.ghost:not(.danger-text), #toolCard button.ghost:not(.danger-text):not(#gpClose), #toolCard a.ghost:not(.danger-text) { color: var(--accent); }
#reportCard button.ghost:not(.danger-text):hover, #toolCard button.ghost:not(.danger-text):not(#gpClose):hover, #toolCard a.ghost:not(.danger-text):hover { background: var(--accent-soft); color: var(--accent-hover); }
/* one control height inside a row of fields (finding 14): small buttons next to 36px inputs / selects */
#toolCard :is(.field-row, .gh-actions) > button.small, #toolCard :is(.field-row, .gh-actions) > .nowrap-pair > button.small,
#toolCard :is(.field-row, .gh-actions) > a.btn.small, #toolCard .lb-actions button.small, #toolCard .ex-group > button.small { min-height: var(--ctl-h); }
/* file input drawn as a "Choose file" button + the picked file name */
.file-pick { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; position: relative; }
.file-input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input:focus-visible + .file-btn { outline: 2px solid var(--accent); outline-offset: 2px; }
#toolCard .file-btn { min-height: var(--ctl-h); }
.file-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* small helpers used by these panels */
.mb-0 { margin-bottom: 0 !important; }
.pre-text { white-space: pre-line; line-height: 1.6; }
.steps { margin: 0; padding-left: 18px; line-height: 1.8; }
.gh-top p { margin: 4px 0 0; }
.w-month { width: 150px; flex: none; }
.w-prop { min-width: 240px; max-width: 100%; }
/* Leads toolbar + Action Plan export row: labelled groups that wrap as a whole */
.lead-bar, .export-row { gap: var(--sp-2) var(--sp-4); }
.lb-group, .ex-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.lb-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lead-bar .form-label, .export-row .form-label { white-space: nowrap; }
@media (max-width: 640px) { .w-prop { min-width: 0; flex: 1 1 200px; } .lb-group { flex: 1 1 100%; } .lb-group > select { flex: 1 1 auto; min-width: 0; } }
/* clickable table rows: the first cell holds a real button (finding 7) */
td .link-btn.row-open { font-weight: 700; color: var(--text); }
td .link-btn.row-open:hover { color: var(--accent); text-decoration: underline; }
td .link-btn.num-open { font-weight: 600; color: inherit; text-decoration: underline dotted; }
/* table bar: heading left, search + filter grouped on the right (Site Audit "Pages crawled") */
.gh-tablebar .tb-tools { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-left: auto; }
@media (max-width: 640px) { .gh-tablebar .tb-tools { flex: 1 1 100%; margin-left: 0; } .gh-tablebar .tb-tools > input { flex: 1 1 160px; max-width: none !important; } }
/* ===== end Phase B1 ===== */
/* ===== wb-map: Map Grid, Live Rank, client pages (wave B) ===== */
/* grid children may shrink below their table width: the table scrolls inside its box (UB9) */
.two-col > *, .split > * { min-width: 0; }
/* sort buttons in headings: at least 24px high hit area (UD21, WCAG target size) */
button.th-sort { padding-block: 5px; display: inline-block; min-width: 24px; min-height: 24px; }
/* Map Grid: cost of Scan now beside the button, first-use steps, town table edge */
.grid-cost { font-size: var(--fs-xs); color: var(--text-2); align-self: center; white-space: nowrap; }
.grid-cost.warn { color: var(--warn, #b45309); font-weight: 600; }
#gridHeat.grid-unready { display: none; }
.grid-first-body { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.grid-steps { margin: 6px auto 0; padding-left: 20px; text-align: left; max-width: 520px; font-size: var(--fs-sm); line-height: 1.7; }
/* client pages (share + portal): section headings are h2 with the old size, one "Checked" line,
   on phones the keyword column keeps about 40% of the width (frozen column cap) */
h2.section-title { font-size: 15px; }
.cu-checked { margin: 0 0 6px; font-size: var(--fs-sm); color: var(--text-2); }
@media (max-width: 640px) {
  table.cu-kw td:first-child, table.cu-kw th:first-child { min-width: 40vw; max-width: 40vw; white-space: normal; overflow-wrap: anywhere; }
  .cu-prepared .cu-sep { margin: 0 4px; }
}
/* ===== end wb-map ===== */
/* ===== wb-tabs-b (Wave B: tool tabs, Site Health, Index check) ===== */
/* UC12: a long option never makes a select wider than its box; long key file address wraps */
select { max-width: 100%; }
.steps a, .steps code { overflow-wrap: anywhere; word-break: break-word; }
/* UC10: AI / schedule row line: saved / not saved / error colours */
.tc-row [data-k="info"].ok { color: var(--good); }
.tc-row [data-k="info"].warn { color: var(--warn); font-weight: 600; }
.tc-row [data-k="info"].bad { color: var(--bad); }
/* UC7: Site Health shared progress + status at the top, kept in view while a check runs */
.hlt-run { position: sticky; top: var(--appbar-h, 0px); z-index: calc(var(--z-sticky) + 2); background: var(--surface); }
.hlt-run:has(.progress[style*="block"]), .hlt-run:has(.status-line.busy) { padding: 4px 0; border-bottom: 1px solid var(--border); }
#tab-hlt .field-row > span.ok { color: var(--good); }
#tab-hlt .field-row > span.warn { color: var(--warn); }
#tab-hlt .field-row > span.bad { color: var(--bad); }
/* UC8: a finding's own status line next to its buttons */
.sum-card-status { flex: 1 1 200px; min-height: 0; }
.sum-card-status:empty { display: none; }
/* a closed details with its (i) after it: leave room so the (i) stays on the same line */
details.help-host:not([open]) { max-width: calc(100% - 36px); }
/* Site Audit score parts */
.aud-score-parts { margin: 2px 0 4px; color: var(--text-2); }
@media (max-width: 640px) {
  /* UC3: the frozen first column takes at most about 40% of the table box */
  td.wrap { max-width: 140px; }
  :where(.table-scroll:not(.no-sticky), .sticky-first) tbody td:first-child,
  :where(.table-scroll:not(.no-sticky), .sticky-first) thead th:first-child { max-width: 40vw; }
  :where(.table-scroll:not(.no-sticky), .sticky-first) tbody td:first-child { overflow: hidden; text-overflow: ellipsis; }
  .sum-ex td:nth-child(2), .sum-ex td:nth-child(3), .sum-ex th:nth-child(2), .sum-ex th:nth-child(3) { min-width: 180px; }
  /* UC16: tables with a tick box first: tick box and page / step name both stay in view */
  .table-scroll.tick-first tbody td:first-child, .table-scroll.tick-first thead th:first-child { width: 36px; min-width: 36px; max-width: 36px; }
  .table-scroll.tick-first tbody td:nth-child(2) { position: sticky; left: 36px; background-color: var(--surface); z-index: var(--z-sticky); max-width: 34vw; overflow: hidden; text-overflow: ellipsis; box-shadow: 1px 0 0 var(--border); }
  .table-scroll.tick-first thead th:nth-child(2) { position: sticky; left: 36px; z-index: calc(var(--z-sticky) + 1); }
  #sumPlan .table-scroll { max-height: none; }
}
/* ===== end wb-tabs-b ===== */

/* ===== wb-settings: Settings, Dashboard, setup wizard, Overview, sidebar find, help popover ===== */
:root { --fs-2xs: 11px; }
.tiny { font-size: var(--fs-2xs); line-height: 1.4; }
/* (i) popover: long texts scroll inside it, it never runs off the screen (help.js clamps its top) */
.help-pop { max-height: 60vh; overflow: auto; overscroll-behavior: contain; }
/* setup wizard (was a style block in setup.html) */
.wiz { max-width: 760px; margin: 0 auto; }
.wiz .steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; padding: 0; list-style: none; line-height: 1.5; }
.wiz .steps li { padding: 4px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.wiz .steps li.on { background: var(--accent); color: var(--surface); border-color: transparent; }
.wiz .steps li.done { background: var(--good-soft); color: var(--good); border-color: transparent; }
.wiz .step-count { margin: 0 0 14px; font-size: var(--fs-sm); color: var(--text-2); }
.wiz .step { display: none; }
.wiz .step.on { display: block; }
.wiz .step p { line-height: 1.6; }
.wiz .step textarea { width: 100%; min-height: 120px; }
.wiz .wiz-nav { display: flex; justify-content: space-between; margin-top: 18px; gap: 8px; flex-wrap: wrap; }
.wiz ol.howto { line-height: 1.8; padding-left: 20px; }
.wiz [hidden] { display: none !important; }
.wiz h4 { margin: var(--sp-4) 0 var(--sp-1); font-size: var(--fs-base); display: inline-flex; align-items: center; gap: 4px; }
.wiz-next { list-style: none; margin: 0; padding: 0; line-height: 1.9; }
.wiz-next .wiz-tick { display: inline-block; width: 1.2em; color: var(--text-3); }
.wiz-next li.done .wiz-tick { color: var(--good); font-weight: 700; }
.wiz-next li.done a { color: var(--text-2); }
/* Overview cards (was a style block in overview.html) */
.ov-grid { display: grid; gap: var(--sp-4); }
.ov-card h3 { margin: 0; font-size: var(--fs-lg); }
.ov-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ov-say { margin: 10px 0 0; padding-left: 18px; line-height: 1.6; }
.ov-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-3); margin-top: 10px; }
.ov-list { margin: 4px 0 0; padding-left: 18px; font-size: var(--fs-base); line-height: 1.6; }
.ov-none { margin: 4px 0; }
.ov-sum { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: var(--radius-sm); margin-top: var(--sp-3); white-space: pre-line; line-height: 1.55; }
.ov-alert { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: var(--radius-sm); margin-top: 10px; font-weight: 600; }
/* Dashboard: paused clients stay listed, quieter */
tr.row-paused td { color: var(--text-2); }
tr.row-paused .client-cell a { color: var(--text-2); }
/* sidebar find box: "No tool found" line */
.sb-empty { margin: 0 var(--sp-3) var(--sp-2); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.sb-empty[hidden] { display: none; }
/* Settings: App health and Google accounts */
.ops-table { width: 100%; border-collapse: collapse; }
.ops-table th[scope="row"] { text-align: left; font-weight: 600; white-space: nowrap; padding: 6px 12px 6px 0; vertical-align: top; }
.ops-table td { padding: 6px 12px 6px 0; vertical-align: top; }
.ops-table td.ops-text { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .ops-table, .ops-table tbody, .ops-table tr, .ops-table th[scope="row"], .ops-table td { display: block; }
  .ops-table tr { padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
  .ops-table th[scope="row"], .ops-table td { padding: 2px 0; }
}
.ops-list { margin: var(--sp-1) 0 0; padding-left: 18px; line-height: 1.6; overflow-wrap: anywhere; }
#gaTable td .tiny { margin-top: 2px; max-width: 46ch; }
#activityBox > summary { font-weight: 600; font-size: var(--fs-md); cursor: pointer; }
.save-bar .help-anchor { margin-left: -6px; }
/* AI tables (My Account, App Settings): field widths without inline styles */
.ai-w-name { width: 150px; } input.ai-w-name[data-f="name"] { font-weight: 600; }
.ai-w-key { min-width: 180px; } .ai-w-model { width: 170px; } .ai-w-base { min-width: 240px; flex: 1 1 240px; }
.field-row.ai-add { flex-wrap: wrap; gap: 6px; }
.dash-scroll { max-height: 640px; }
td.dash-note { white-space: normal; min-width: 220px; }
/* ===== end wb-settings ===== */
/* ===== wb-tabs-a (wave B UI pass) ===== */
/* Date range on tabs that do not read it: a note under the fields (app.js sets .no-dates) */
.dates-note { display: none; }
.report-card.no-dates .dates-note { display: block; margin-top: 4px; }
/* number boxes: room for the value next to the spinner */
input[type="number"].w-num { width: 84px; }
/* Rank Tracker: the keyword column keeps a readable width (desktop and phone) */
#rnkTable th:first-child, #rnkTable td:first-child { min-width: 180px; }
@media (max-width: 640px) { #rnkTable th:first-child, #rnkTable td:first-child { min-width: 130px; } }
/* fields inside an in-page dialog (Action Plan "Add task", watched pages) */
.ui-modal .settings-grid input, .ui-modal .settings-grid select, .ui-modal .settings-grid textarea { width: 100%; min-width: 0; }
.ui-modal textarea { font: inherit; }
.ui-modal .settings-grid { grid-template-columns: 90px minmax(0, 1fr); }
@media (max-width: 640px) { .ui-modal .settings-grid { grid-template-columns: minmax(0, 1fr); } }
/* notes under a status line (Monthly plan QC) */
.status-line details { margin-top: 4px; }
.status-line details summary { cursor: pointer; }
/* AI Visibility: (live search) / (memory) tag on the provider line */
#aivProviders .check { align-items: center; }
/* Action Plan: done / no longer needed tasks read as finished without fading below AA contrast */
.plan-task.plan-done b { color: var(--text-2); text-decoration: line-through; font-weight: 600; }
.plan-task.plan-done .tiny.muted { text-decoration: line-through; }
/* ===== end wb-tabs-a ===== */

/* ---- Map Grid settings as rows that open and close (like an FAQ) + the check before a scan ---- */
.grid-settings { padding: 0; overflow: hidden; }
.grid-acc-head, .grid-sec-head {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; color: var(--text);
  border: 0; border-radius: 0; box-shadow: none; padding: 12px var(--sp-4); min-height: 44px; font: inherit; cursor: pointer;
  justify-content: flex-start; height: auto; white-space: normal;
}
.grid-acc-head:hover, .grid-sec-head:hover { background: var(--surface-2); }
.grid-acc-head:focus-visible, .grid-sec-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid-acc-title { font-weight: 600; font-size: 15px; flex: none; }
.grid-sec-title { font-weight: 600; flex: none; min-width: 150px; }
.grid-sec-sum { color: var(--text-2); font-size: 13px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-sec-chev { flex: none; width: 10px; height: 10px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2); transform: rotate(-45deg); transition: transform .15s ease; margin: 0 2px; }
[aria-expanded="true"] > .grid-sec-chev { transform: rotate(45deg); }
#gridSetBody { padding: 0 var(--sp-4) var(--sp-3); border-top: 1px solid var(--border); }
.grid-sec { border-bottom: 1px solid var(--border); }
.grid-sec:last-of-type { border-bottom: 0; }
.grid-sec-head { padding-left: 0; padding-right: 0; }
.grid-sec-body { padding: 4px 0 14px 22px; }
.grid-preview { border-color: var(--accent); }
@media (max-width: 640px) {
  .grid-sec-title { min-width: 0; }
  .grid-sec-head, .grid-acc-head { flex-wrap: wrap; row-gap: 2px; }
  .grid-sec-sum { flex-basis: 100%; white-space: normal; padding-left: 24px; }
  .grid-sec-body { padding-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .grid-sec-chev { transition: none; } }
/* While the check before a scan is open, the heatmap view shows only the map (and its editing note). */
#gridHeat.grid-previewing > :not(#gridMap):not(.grid-legend):not(#gridDrawBar) { display: none !important; }
#gridHeat.grid-previewing .grid-legend > .gl { display: none; }
/* Map Grid: another business shown on the map (picked in the business table). */
.grid-focus-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; margin: 0 0 8px; padding: 8px 12px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }
#gridCompTable tr.grid-shown td { box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
#gridCompTable tr.grid-shown td:first-child { box-shadow: inset 3px 0 0 var(--accent), inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
/* Map Grid: draw the service area (pin edit mode). */
.grid-draw-bar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin: 0 0 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.grid-draw-bar .grid-draw-note { flex-basis: 100%; }
