/* GEO Engine: design tokens and components. Logical properties throughout, so RTL (Hebrew) and LTR both work. */
:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --sidebar: #fbfcff;
  --ink: #192d4d;
  --ink-2: #3c5275;
  --muted: #7889a6;
  --faint: #a3b0c6;
  --line: #e4eaf4;
  --line-2: #edf1f8;
  --nav: #17243a;
  --nav-2: #1f3050;
  --nav-ink: #eef3ff;
  --primary: #7057f5;
  --primary-soft: #eef2ff;
  --primary-ink: #5d51e9;
  --blue: #3978ff;
  --teal: #0db69d;
  --orange: #ff9638;
  --pink: #ed4d87;
  --up: #08a887;
  --down: #e5484d;
  --warn: #e19a1d;
  --up-soft: #e3f7f2;
  --down-soft: #fde9ee;
  --warn-soft: #fff3df;
  --chatgpt: #0db69d;
  --gemini: #3978ff;
  --perplexity: #7057f5;
  --google_ai_overview: #ff9638;
  --google_ai_mode: #a18aff;
  --shadow: 0 2px 8px rgba(27, 54, 80, .045);
  --shadow-lift: 0 8px 24px rgba(27, 54, 80, .1);
  --r: 13px;
  --r-s: 10px;
  --font: "Heebo", "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1726;
  --surface: #172236;
  --surface-2: #1c2940;
  --sidebar: #132033;
  --ink: #e7edf8;
  --ink-2: #c3cee2;
  --muted: #8ea0bf;
  --faint: #5f7192;
  --line: #24344f;
  --line-2: #203049;
  --nav: #0b1220;
  --nav-2: #16223a;
  --primary-soft: #262a5a;
  --primary-ink: #a99bff;
  --up-soft: #12322c;
  --down-soft: #3a1d27;
  --warn-soft: #3a2c14;
  --shadow: none;
  --shadow-lift: 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { margin: 0; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 18px; padding: 0 24px;
  background: linear-gradient(90deg, #1b2940, #142139); color: var(--nav-ink); }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-size: 19px; font-weight: 800; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { max-height: 28px; max-width: 140px; object-fit: contain; border-radius: 4px; }
.brand-form .swatch { display: flex; align-items: center; gap: 10px; }
.brand-form input[type=color] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; }
.brand-preview { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: linear-gradient(90deg, #1b2940, #142139); color: #fff; font-weight: 800; min-height: 48px; }
.brand-ring { width: 22px; height: 22px; border-radius: 50%; border: 5px solid #7563ff; border-inline-end-color: #40517f; }
.topbar .crumb { color: #c5d0e6; white-space: nowrap; }
.topbar .crumb:hover { color: #fff; }
.spacer { flex: 1; }
.pill-btn, .icon-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 11px;
  border: 1px solid #ffffff24; background: #ffffff0a; color: var(--nav-ink); white-space: nowrap; }
.pill-btn:hover, .icon-btn:hover { background: #ffffff16; }
.icon-btn { width: 36px; padding: 0; justify-content: center; }
.project-select { position: relative; }
.project-select select { appearance: none; height: 36px; border-radius: 11px; border: 1px solid #ffffff24; background: #ffffff0a; color: #fff;
  padding-inline: 14px 34px; min-width: 190px; max-width: 260px; }
.project-select select option { color: #192d4d; }
.project-select::after { content: ""; position: absolute; inset-inline-end: 13px; top: 15px; width: 7px; height: 7px; border: solid #c5d0e6;
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 225px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar { background: var(--sidebar); border-inline-end: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.main { padding: 24px 24px 40px; min-width: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.nav-item svg { flex: none; }
.nav-count { margin-inline-start: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 600;
  display: inline-grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.nav-count.alert { background: var(--down-soft); color: var(--down); border-color: transparent; }
.side-label { font-size: 12px; font-weight: 600; color: var(--faint); padding: 14px 12px 4px; }
.side-spacer { flex: 1; min-height: 16px; }
.side-field { padding: 0 2px 8px; }
.side-field input[type=search] { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); }
.side-option { display: flex; gap: 9px; align-items: center; padding: 6px 12px; color: var(--ink-2); cursor: pointer; font-size: 13.5px; }

.next-card { border: 1px solid #dfe6fb; background: linear-gradient(160deg, #f1f5ff, #e8efff); border-radius: 14px; padding: 16px 14px; }
:root[data-theme="dark"] .next-card { border-color: var(--line); background: linear-gradient(160deg, #1c2a46, #18233b); }
.next-card .eyebrow { font-size: 12px; font-weight: 600; color: var(--primary-ink); display: flex; gap: 6px; align-items: center; }
.next-card h3 { font-size: 14px; margin: 6px 0; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.next-card p { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.next-card .btn-dark { width: 100%; }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 2px 18px; }
.page-head h1 { font-size: 30px; line-height: 1.2; font-weight: 800; letter-spacing: -.4px; }
.page-head .subtitle { color: var(--muted); margin-top: 4px; }
.head-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fresh { color: var(--up); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fresh::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.fresh.stale { color: var(--warn); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); box-shadow: var(--shadow); font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn-primary:hover { background: #6249ec; border-color: #6249ec; }
.btn-dark { background: #1b2c48; border-color: #1b2c48; color: #fff; font-weight: 700; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.select { position: relative; display: inline-flex; }
.select select { appearance: none; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding-inline: 14px 34px; box-shadow: var(--shadow); }
.select::after { content: ""; position: absolute; inset-inline-end: 14px; top: 14px; width: 7px; height: 7px; border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.search { flex: 1; min-width: 180px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.panel-title h2 { font-size: 15px; font-weight: 800; }
.panel-title small, .panel-title a.more { color: var(--muted); font-size: 12px; }
.panel-title a.more:hover { color: var(--primary-ink); }
.panel-body { padding: 15px 17px; }
.stack { display: grid; gap: 14px; min-width: 0; align-content: start; }
.content-grid { display: grid; grid-template-columns: minmax(0, .94fr) minmax(0, 1.12fr); gap: 14px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 14px; min-height: 182px; display: flex; flex-direction: column; color: inherit; transition: box-shadow .15s, transform .15s; }
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: #526a90; font-size: 12.5px; font-weight: 600; }
:root[data-theme="dark"] .kpi-head { color: var(--muted); }
.kpi-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); flex: none; }
.kpi-value { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 2px; }
.kpi-value .metric { font-size: 29px; line-height: 1.2; font-weight: 800; letter-spacing: -.5px; }
.kpi-note { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.kpi-foot { margin-top: auto; padding-top: 10px; }
.delta { font-size: 12px; font-weight: 700; white-space: nowrap; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.flat { color: var(--faint); }
.score-chip { display: inline-grid; place-items: center; min-width: 50px; height: 34px; padding: 0 10px; border-radius: 17px; color: #fff; font-size: 20px; font-weight: 800; }
.score-chip.good { background: var(--up); } .score-chip.mid { background: var(--warn); } .score-chip.low { background: var(--down); } .score-chip.none { background: var(--faint); }
.engine-list { display: grid; gap: 5px; margin-top: 8px; }
.engine-row { display: grid; grid-template-columns: 7px minmax(0, 1fr) 34px; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ink-2); }
.engine-row b { font-weight: 600; text-align: end; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.progress { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.progress.multi > span { background: linear-gradient(90deg, var(--teal), var(--blue), var(--primary)); }
[dir="rtl"] .progress.multi > span { background: linear-gradient(270deg, var(--teal), var(--blue), var(--primary)); }

/* charts */
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; overflow: visible; }
.chart text { font: 10.5px var(--font); fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: 12px; margin-bottom: 10px; }
.legend button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; color: inherit; }
.legend button[aria-pressed="false"] { opacity: .4; }
.tooltip { position: absolute; z-index: 5; pointer-events: none; background: #17243a; color: #fff; font-size: 12px; padding: 7px 10px; border-radius: 8px;
  box-shadow: var(--shadow-lift); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .1s; }
.tooltip.show { opacity: 1; }
.tooltip .t-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.empty-chart { display: grid; place-items: center; text-align: center; min-height: 150px; color: var(--muted); padding: 10px; border: 1px dashed var(--line); border-radius: var(--r-s); }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { position: relative; width: 132px; height: 132px; flex: none; }
.donut svg { transform: rotate(-90deg); }
.donut path { cursor: pointer; transition: opacity .15s; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-weight: 800; font-size: 22px; line-height: 1.1; }
.donut-center small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; }
.donut-legend { display: grid; gap: 7px; flex: 1; min-width: 0; }
.donut-legend .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.donut-legend .row span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }

/* question list */
.qlist a { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); font-size: 13px; }
.qlist a:last-child { border-bottom: 0; }
.qlist a:hover { color: var(--primary-ink); text-decoration: none; }
.qlist .q-text { flex: 1; min-width: 0; }
.qlist .q-rate { font-weight: 700; color: var(--ink); }

/* heat matrix */
.matrix { display: grid; grid-template-columns: minmax(130px, 1fr) repeat(5, minmax(34px, 54px)) 58px; align-items: center; font-size: 11.5px; }
.matrix .cell { padding: 8px 4px; border-bottom: 1px solid var(--line-2); text-align: center; min-width: 0; }
.matrix .cell.topic { text-align: start; color: var(--ink-2); line-height: 1.4; padding-inline-end: 10px; }
.matrix .cell.head { font-weight: 700; color: var(--ink-2); font-size: 11px; position: sticky; top: 56px; background: var(--surface); }
.matrix .cell.head i { display: block; height: 3px; border-radius: 2px; margin: 4px auto 0; width: 70%; }
.matrix .score { font-weight: 800; color: var(--ink); }
.heat { height: 13px; border-radius: 4px; margin: auto; width: 88%; background: var(--line-2); }
.heat.na { background: repeating-linear-gradient(45deg, var(--line) 0 2px, transparent 2px 6px); }
.matrix-scroll { max-height: 560px; overflow: auto; margin: -15px -17px; padding: 0 17px 15px; }
.matrix-scroll .cell.head { top: 0; z-index: 1; padding-top: 12px; }

/* insights */
.insights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.insight { padding: 18px 12px; text-align: center; border-inline-start: 1px solid var(--line); color: inherit; }
.insight:first-child { border-inline-start: 0; }
a.insight:hover { background: var(--surface-2); text-decoration: none; }
.insight .ins-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 8px; }
.insight .ins-num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.insight h3 { font-size: 12.5px; margin: 4px 0; }
.insight p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.6; }

/* bars */
.bars { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) 44px; gap: 12px; align-items: center; font-size: 13px; }
.bar-row .label { display: flex; align-items: center; gap: 7px; min-width: 0; }
.bar-row .track { height: 9px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 6px; }
.bar-row .v { text-align: end; font-weight: 700; }

/* tables */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable[aria-sort]::after { content: " ↓"; }
th.sortable[aria-sort="ascending"]::after { content: " ↑"; }
.t-num { text-align: end; white-space: nowrap; }
.clip { display: block; max-width: 560px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pips { display: inline-flex; gap: 3px; }
.pip { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.pip.on { background: var(--primary); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 17px; border-bottom: 1px solid var(--line); }

/* tags */
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.primary { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.tag.up { background: var(--up-soft); color: var(--up); border-color: transparent; }
.tag.down { background: var(--down-soft); color: var(--down); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* facts, lists */
.fact { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 14px 17px; border-bottom: 1px solid var(--line-2); }
.fact:last-child { border-bottom: 0; }
.fact .claim { font-weight: 600; }
.fact .evidence { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.fact blockquote { margin: 6px 0 0; padding: 6px 12px; border-inline-start: 3px solid var(--line); color: var(--muted); font-size: 12.5px; }
details > summary { cursor: pointer; color: var(--primary-ink); font-size: 13px; font-weight: 600; }
.list-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 8px 17px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list-row:last-child { border-bottom: 0; }
.group-title { display: flex; gap: 8px; align-items: center; padding: 10px 17px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; }

/* projects list */
.project-card + .project-card { margin-top: 14px; }
.project-top { display: flex; align-items: center; gap: 14px; padding: 14px 17px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.favicon { position: relative; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-ink); font-weight: 800; flex: none; overflow: hidden; }
.favicon img { position: absolute; inset: 9px; width: 22px; height: 22px; }
.project-name { font-size: 16px; font-weight: 800; color: var(--ink); }
.project-name:hover { color: var(--primary-ink); text-decoration: none; }
.project-top .end { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.project-card .kpis { margin: 0; padding: 12px; }
.project-card .kpi { min-height: 150px; box-shadow: none; }

/* tasks */
.task { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 2px 14px; padding: 16px 17px; border-bottom: 1px solid var(--line-2); }
.task:last-child { border-bottom: 0; }
.task.done .title, .task.skipped .title { text-decoration: line-through; color: var(--muted); }
.task .rank { font-weight: 800; color: var(--faint); font-size: 16px; text-align: center; }
.task .title { font-weight: 700; }
.task .why { color: var(--muted); font-size: 13px; }
.task .tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 7px; }
.task .actions { display: flex; gap: 5px; align-self: start; }
.task .body { grid-column: 2 / -1; }
.task ol { margin: 8px 0 0; padding-inline-start: 20px; font-size: 13px; }
.task details { margin-top: 8px; }
.draft { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px 14px; margin-top: 8px; font-size: 13px; unicode-bidi: plaintext; text-align: start; }
.draft-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }

.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.skeleton { height: 182px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50; background: #17243a; color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }
.demo-banner { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: 12.5px; padding: 6px; font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1300px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar .crumb, .hide-sm { display: none; }
  .project-select select { min-width: 0; max-width: 46vw; }
  .layout { display: block; }
  .sidebar { position: sticky; top: 56px; z-index: 20; height: auto; flex-direction: row; overflow-x: auto; padding: 8px 10px; gap: 4px;
    border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .sidebar .nav-item { padding: 8px 11px; white-space: nowrap; font-size: 13.5px; }
  .sidebar .side-spacer, .sidebar .next-card, .sidebar .side-label, .sidebar .side-option, .sidebar .side-field { display: none; }
  .main { padding: 16px 12px 32px; }
  .page-head h1 { font-size: 24px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insight:nth-child(3) { border-inline-start: 0; }
  .insight:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .task { grid-template-columns: 26px minmax(0, 1fr); }
  .task .actions { grid-column: 2; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-height: 160px; }
  .kpi-value .metric { font-size: 25px; }
  .matrix { grid-template-columns: minmax(100px, 1fr) repeat(5, minmax(24px, 1fr)) 42px; font-size: 10.5px; }
  .matrix .cell.head { font-size: 9.5px; padding-inline: 1px; overflow: hidden; text-overflow: ellipsis; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut { margin: 0 auto; }
  .bar-row { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* share of voice */
.range-bars { display: grid; gap: 9px; }
.range-row { display: grid; grid-template-columns: minmax(110px, 200px) minmax(0, 1fr) 46px; gap: 12px; align-items: center; font-size: 13px; }
.range-row .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.range-row.strong .label, .range-row.strong .v { font-weight: 800; color: var(--primary-ink); }
.range-track { position: relative; height: 12px; border-radius: 6px; background: var(--line-2); }
.range-track .fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 6px; }
.range-track .whisker { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--ink); opacity: .45; }
.range-track .whisker::before, .range-track .whisker::after { content: ""; position: absolute; top: -4px; width: 2px; height: 10px; background: inherit; }
.range-track .whisker::before { inset-inline-start: 0; } .range-track .whisker::after { inset-inline-end: 0; }
.range-row .v { text-align: end; font-weight: 700; }
.hero-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.hero-stat { padding: 16px 17px; border-inline-start: 1px solid var(--line); }
.hero-stat:first-child { border-inline-start: 0; }
.hero-stat .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hero-stat .val { font-size: 27px; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.hero-stat .sub { font-size: 12px; color: var(--muted); }
.stack-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line-2); margin-top: 10px; }
.stack-bar i { display: block; height: 100%; }
@media (max-width: 1100px) { .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero-stat:nth-child(odd) { border-inline-start: 0; } .hero-stat { border-bottom: 1px solid var(--line); } }
@media (max-width: 640px) { .range-row { grid-template-columns: minmax(80px, 120px) minmax(0, 1fr) 40px; } }

/* ---------- hosted service: sign-in, forms, onboarding, review, account, admin ---------- */
body.no-sidebar .layout { grid-template-columns: minmax(0, 1fr); }
body.no-sidebar .sidebar { display: none; }
body.no-sidebar .main { max-width: 1120px; width: 100%; margin-inline: auto; }
.topbar .crumb.keep { display: inline; }
.auth-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: min(420px, 100%); padding: 30px 28px; display: flex; flex-direction: column; gap: 12px; }
.auth-card h1 { font-size: 22px; }
.auth-card p { margin: 0; }
.auth-brand { color: var(--ink); font-weight: 800; display: flex; align-items: center; gap: 9px; font-size: 16px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-wide { max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field input, .field select, .field textarea, .review-add input, .review-row textarea, td select {
  font-weight: 400; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 9px 11px; min-height: 40px; width: 100%; }
td select { min-height: 32px; padding: 4px 8px; width: auto; max-width: 180px; }
.field textarea { resize: vertical; font: inherit; }
.field input:focus, .field select:focus, .field textarea:focus, .review-row textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.field input:disabled { opacity: .5; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-error { margin: 0; color: var(--down); background: var(--down-soft); padding: 9px 12px; border-radius: var(--r-s); font-size: 13px; }
.form-ok { margin: 0; color: var(--up); background: var(--up-soft); padding: 11px 13px; border-radius: var(--r-s); }
.form-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.form .btn-primary { align-self: flex-start; }
.auth-card .form .btn-primary { align-self: stretch; height: 42px; }
.status-box { display: flex; gap: 18px; align-items: flex-start; padding: 24px; }
.status-box h2 { font-size: 17px; margin-bottom: 4px; }
.status-box p { margin: 0 0 12px; max-width: 60ch; }
.spinner { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.review-list { list-style: none; counter-reset: q; margin: 8px 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.review-row { counter-increment: q; display: grid; grid-template-columns: 26px minmax(0, 1fr) 36px; gap: 10px; align-items: start; }
.review-row::before { content: counter(q); color: var(--faint); font-size: 12px; text-align: end; font-variant-numeric: tabular-nums; padding-top: 10px; }
.review-q { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.review-row textarea { min-height: 40px; resize: none; font: inherit; field-sizing: content; }
.remove-btn { width: 36px; height: 40px; border: 1px solid transparent; border-radius: var(--r-s); background: none; color: var(--muted); font-size: 20px; line-height: 1; }
.remove-btn:hover { color: var(--down); background: var(--down-soft); }
.review-add { display: flex; gap: 8px; margin-bottom: 14px; }
.review-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.business-tools { margin-bottom: 14px; }
.tools-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; }
.plan-now { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 6px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.plan-card { border: 1px solid var(--line); border-radius: var(--r-s); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.plan-card.current { border-color: var(--primary); background: var(--primary-soft); }
.notice { padding: 12px 16px; margin-bottom: 14px; background: var(--warn-soft); border-color: transparent; }
.job-log { margin: 0; padding: 14px 16px; max-height: 420px; overflow: auto; font: 12px/1.5 ui-monospace, Consolas, monospace; background: var(--surface-2); border-top: 1px solid var(--line); white-space: pre-wrap; }
.tag.job-failed { color: var(--down); background: var(--down-soft); border-color: transparent; }
.tag.job-done { color: var(--up); background: var(--up-soft); border-color: transparent; }
.tag.job-running, .tag.job-queued, .tag-pending { color: var(--primary-ink); background: var(--primary-soft); border-color: transparent; }
code { font: 12px ui-monospace, Consolas, monospace; word-break: break-all; }
@media (max-width: 640px) {
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .review-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .review-row::before { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .brand { font-size: 0; gap: 0; }
  .topbar .pill-btn, .topbar .icon-btn { padding: 0 9px; height: 32px; }
  .topbar .project-select select { max-width: 110px; }
  .topbar [data-action="theme"] { display: none; }
  .auth-card { padding: 24px 18px; }
}
.budget-input { width: 64px; min-height: 30px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
