:root {
  --bg-canvas: #f6f6f4;
  --bg-surface: #ffffff;
  --bg-subtle: #eeeeeb;
  --text-primary: #1b1b1a;
  --text-secondary: #55544f;
  --text-muted: #6a6963;
  --text-inverse: #ffffff;
  --border-default: #d9d8d3;
  --border-strong: #b5b3ab;
  --border-control: #858480;
  --accent: #2447d6;
  --accent-subtle: #e8edfc;
  --status-warn: #8a4b00;
  --status-warn-subtle: #fff1d9;
  --status-error: #a8201a;
  --status-error-subtle: #fbe6e4;
  --status-ok: #17653f;
  --status-ok-subtle: #e3f3ea;
  --data-measured: #17653f;
  --data-provider: #6b3fa0;
  --data-serp: #2447d6;
  --data-crawl: #8a4b00;
  --data-operator: #55544f;
  --data-derived: #0f6e78;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-dialog: 10px;
  --radius-pill: 999px;
  --font: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--text-primary);
  background: var(--bg-canvas);
  font: 400 14px/20px var(--font);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 63px;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}
.wordmark { margin: 0; font-size: 14px; font-weight: 600; line-height: 20px; text-decoration: none; }
.selector {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
}
.selector .caret { color: var(--text-secondary); font-weight: 400; }
.selector-wrap { position: relative; }
.menu-scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.4); }
.menu-scrim[hidden] { display: none !important; }
.campaign-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 380px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-dialog);
  background: var(--bg-surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}
.campaign-menu[hidden] { display: none !important; }
.campaign-menu .sheet-head,
.campaign-menu .kind { display: none; }
.campaign-menu .field { width: 100%; }
.campaign-menu .campaign-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 20px;
  text-decoration: none;
}
.campaign-menu form.campaign-option-form { display: contents; }
button.campaign-option,
button.row-link {
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
form.card { margin: 0; }
.campaign-menu .name { flex: 1; }
.campaign-menu .campaign-option.selected { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }
.campaign-menu .menu-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; }
.campaign-menu .secondary { align-self: flex-start; }
.spacer { flex: 1; }
.top-link { font-size: 14px; font-weight: 500; line-height: 20px; text-decoration: none; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
}
.chip.warn { background: var(--status-warn-subtle); border-color: var(--status-warn); color: var(--status-warn); }
.chip.error { background: var(--status-error-subtle); border-color: var(--status-error); color: var(--status-error); }
.chip.ok { background: var(--status-ok-subtle); border-color: var(--status-ok); color: var(--status-ok); }
.chip.info { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
.domain-view { display: none; flex-direction: column; gap: 16px; }
.compared { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.compared .label { color: var(--text-secondary); font-size: 12px; font-weight: 500; line-height: 16px; }
body.rankings.competitors-view .distribution,
body.rankings.competitors-view .banner.populated,
body.rankings.competitors-view .filters .check,
body.rankings.competitors-view .filters .field,
body.rankings.competitors-view .filters .spacer,
body.rankings.competitors-view .rank-table,
body.rankings.competitors-view .cards,
body.rankings.competitors-view .legend,
body.rankings.competitors-view .sourcebar.populated,
body.rankings.competitors-view .range,
body.rankings.competitors-view .estimate,
body.rankings.competitors-view [data-open="collect"] { display: none; }
body.rankings.competitors-view .domain-view { display: flex; }
.drawer.history { width: 640px; }
.history-chart { width: 592px; height: 220px; }
.chart-legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 16px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 4px; border-radius: 999px; vertical-align: -1px; }
.chart-legend .you { background: var(--accent); }
.chart-legend .one { background: var(--status-warn); }
.chart-legend .two { background: var(--text-muted); }
.chart-legend .fail { background: transparent; border: 2px solid var(--status-error); box-sizing: border-box; }
.history-note { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.demo-chip, button.menu, a.menu, .bottom-tabs, .actionbar { display: none; }

.shell { display: flex; align-items: stretch; min-height: calc(100vh - 63px); }
.sidenav {
  width: 232px;
  flex: none;
  padding: 16px 12px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
}
.nav-label {
  margin: 0;
  padding: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}
.sidenav > a {
  display: flex;
  align-items: center;
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-decoration: none;
}
.sidenav > a.here { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }
.sidenav .nav-label + a { margin-top: 4px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
body.rankings .page-header {
  position: relative;
  display: grid;
  grid-template-columns: 306px 240px 190px minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 4px;
  align-items: end;
}
.titles { min-width: 0; }
body.rankings .titles { grid-column: 1; grid-row: 1 / span 2; align-self: center; width: 306px; }
h1 { margin: 0; font-size: 24px; font-weight: 600; line-height: 32px; }
.subhead { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; font-weight: 400; line-height: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span, .dialog label span {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}
.field.target { width: 240px; }
.field.range { width: 190px; }
.field.compact { width: 140px; }
select, .control {
  height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}
.secondary, .primary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  text-decoration: none;
  cursor: pointer;
}
.secondary { border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text-primary); }
.primary { border: 0; background: var(--accent); color: var(--text-inverse); }
.primary:disabled {
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  cursor: default;
}
.empty-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.empty-panel h2 { margin: 0; font-size: 14px; font-weight: 600; line-height: 20px; }
.empty-panel > p:not(.sourcebar) { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 20px; }
.empty-actions { display: flex; gap: 12px; }
body.empty .main { gap: 16px; }
.danger { border: 0; background: var(--status-error); color: var(--text-inverse); }
.header-actions { display: flex; gap: 16px; align-items: center; }
body.rankings .header-actions { grid-column: 4; grid-row: 1; justify-self: end; align-self: center; transform: translateY(-1px); }
body.rankings .header-actions .primary { margin-left: 38px; width: 106px; }
body.rankings .header-actions .secondary, body.rankings .header-actions .primary { height: 34px; }
body.rankings .header-actions .secondary:nth-child(1) { width: 108px; }
body.rankings .header-actions .secondary:nth-child(2) { width: 76px; }
.estimate {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}
body.rankings .estimate {
  position: absolute;
  top: 50px;
  right: 0;
  width: 144px;
  text-align: right;
}

.sourcebar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  min-height: 32px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
  flex-wrap: wrap;
  white-space: normal;
}
.sourcebar strong { color: var(--text-primary); font-weight: 500; }
.sourcebar .extra { color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }

.distribution {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .label { color: var(--text-muted); font-size: 12px; line-height: 16px; }
.stat .value { font-size: 16px; font-weight: 600; line-height: 24px; }
.stat .sub { color: var(--text-secondary); font-size: 12px; line-height: 16px; }
.distribution .grow { flex: 1; }
.uncollected { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.uncollected p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0;
}
.pair { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; }

.banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-subtle);
  font-size: 13px;
  line-height: 18px;
}
.banner strong { color: var(--accent); font-weight: 500; }
.banner.warn { border-color: var(--status-warn); background: var(--status-warn-subtle); }
.banner.warn strong { color: var(--status-warn); }
.banner.error { border-color: var(--status-error); background: var(--status-error-subtle); }
.banner.error strong { color: var(--status-error); }
.banner.ok { border-color: var(--status-ok); background: var(--status-ok-subtle); }
.banner.ok strong { color: var(--status-ok); }
.compare-scrim { padding-top: 200px; }
.stop-scrim { padding-top: 240px; }
.stop-dialog { width: 520px; }
.retry-dialog { width: 540px; }
.import-scrim { padding-top: 90px; overflow: auto; }
.import-dialog { width: 760px; }
.file-drop { margin: 0; padding: 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--bg-subtle); text-align: center; }
.file-drop strong { display: block; color: var(--text-primary); font-weight: 500; }
.file-drop span { color: var(--text-secondary); font-size: 13px; line-height: 18px; }
.flag-scrim { padding-top: 230px; }
.flag-dialog { width: 560px; }
.flag-dialog .fine, .flag-dialog .banner { margin: 0; }
.flag-dialog .fine { color: var(--text-muted); font-size: 12px; line-height: 16px; }
.retry-dialog .fine { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.stop-dialog p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 20px; }
button.danger { background: var(--status-error); color: var(--text-inverse); border: 0; }
.compare-dialog { width: 560px; }
.compare-dialog .pair { display: flex; gap: 12px; }
.compare-dialog .pair .field { flex: 1; }
html.rk-states body.rankings .page-header { display: flex; }
html.rk-states body.rankings .titles { width: auto; }
html.rk-states body.rankings .target,
html.rk-states body.rankings .range,
html.rk-states body.rankings .header-actions,
html.rk-states body.rankings .estimate,
html.rk-states body.rankings .populated,
html.rk-states body.rankings .actionbar,
html.rk-states body.rankings .bottom-tabs { display: none; }
html.rk-states section.rk-states { display: flex; }
html.rk-history body.rankings .page-header { display: flex; }
html.rk-history body.rankings .titles { width: auto; }
html.rk-history body.rankings .target,
html.rk-history body.rankings .range,
html.rk-history body.rankings .header-actions .secondary,
html.rk-history body.rankings .estimate,
html.rk-history body.rankings .populated,
html.rk-history body.rankings .domain-view,
html.rk-history body.rankings .rk-states,
html.rk-history body.rankings .actionbar,
html.rk-history body.rankings .bottom-tabs { display: none; }
html.rk-history body.rankings .header-actions .primary { margin-left: 0; }
html.rk-history .run-history { display: flex; }
html.rk-run body.rankings .page-header { display: flex; }
html.rk-run body.rankings .titles { width: auto; }
html.rk-run body.rankings .target,
html.rk-run body.rankings .range,
html.rk-run body.rankings .header-actions,
html.rk-run body.rankings .estimate,
html.rk-run body.rankings .populated,
html.rk-run body.rankings .domain-view,
html.rk-run body.rankings .rk-states,
html.rk-run body.rankings .run-history,
html.rk-run body.rankings .actionbar,
html.rk-run body.rankings .bottom-tabs { display: none; }
html.rk-run .run-detail { display: flex; }
.run-detail { display: none; flex-direction: column; gap: 16px; }
.run-actions { display: flex; gap: 12px; justify-content: flex-end; }
.run-stats { display: flex; gap: 32px; padding: 16px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); }
.run-stats .stat { display: flex; flex-direction: column; gap: 4px; }
.run-stats .label { color: var(--text-muted); font-size: 12px; line-height: 16px; }
.run-stats .value { font-size: 16px; font-weight: 600; line-height: 24px; }
.run-stats .sub { color: var(--text-secondary); font-size: 12px; line-height: 16px; }
.run-history { display: none; flex-direction: column; gap: 16px; }
.run-history .pager { display: flex; align-items: center; gap: 12px; }
.run-history .pager p { margin: 0; flex: 1; color: var(--text-secondary); font-size: 13px; line-height: 18px; }
.run-history .note { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
section.rk-states { display: none; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
html.rk-empty body.rankings .target,
html.rk-empty body.rankings .range,
html.rk-empty body.rankings .header-actions .secondary,
html.rk-empty body.rankings .estimate { display: none; }
html.rk-empty body.rankings #empty-state { display: flex; flex-direction: column; gap: 16px; }
html.rk-empty body.rankings .header-actions .primary { width: auto; margin-left: 0; padding: 0 12px; }
html.rk-stopped body.rankings .page-header { display: flex; }
html.rk-stopped body.rankings .titles { width: auto; }
html.rk-stopped body.rankings .target,
html.rk-stopped body.rankings .range,
html.rk-stopped body.rankings .header-actions,
html.rk-stopped body.rankings .estimate,
html.rk-stopped body.rankings .populated,
html.rk-stopped body.rankings .actionbar,
html.rk-stopped body.rankings .bottom-tabs { display: none; }
.collecting-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); }
.collecting-card[hidden],
#stopped-run[hidden] { display: none; }
.collecting-card h2,
.collecting-card p { margin: 0; }
.collecting-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.progress { height: 8px; border-radius: var(--radius-pill); background: var(--bg-subtle); overflow: hidden; }
.progress span { display: block; width: 67%; height: 100%; background: var(--accent); }
#stopped-run { flex-direction: column; gap: 16px; }
#stopped-run:not([hidden]) { display: flex; }
.rk-states .state-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 360px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}
.rk-states .kicker {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  text-transform: uppercase;
}
.rk-states .legend-row { display: flex; align-items: center; gap: 12px; }
.rk-states .legend-row p { margin: 0; flex: 1; color: var(--text-secondary); font-size: 13px; line-height: 18px; }
.rk-states .skeleton { display: flex; flex-direction: column; gap: 8px; }
.rk-states .skeleton i { display: block; width: 300px; height: 14px; border-radius: 4px; background: var(--bg-subtle); }

.filters { display: flex; align-items: flex-end; gap: 16px; }
.tabs { display: flex; gap: 8px; align-items: flex-end; }
.tabs button {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.tabs button span { padding: 8px 12px; font-size: 14px; font-weight: 500; line-height: 20px; color: var(--text-secondary); }
.tabs button i { display: block; height: 2px; background: transparent; }
.tabs button[aria-selected="true"] span { color: var(--accent); }
.tabs button[aria-selected="true"] i { background: var(--accent); }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  font-size: 14px;
  line-height: 20px;
}
.check input, .tick {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
}
.check input:checked::after, .tick:checked::after { content: "✓"; font-size: 12px; font-weight: 500; line-height: 16px; }
.check input:not(:checked), .tick:not(:checked) { background: var(--bg-surface); border-color: var(--border-control); }

.table-wrap {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-default);
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  text-align: left;
  vertical-align: middle;
}
th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.strong { font-weight: 500; }
tr.selected td { background: var(--accent-subtle); }
tr[hidden] { display: none; }
.keyword {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.legend { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
body.rankings .rank-table { margin-top: 32px; }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2;
}
.drawer {
  position: fixed;
  z-index: 3;
  top: 0;
  right: 0;
  width: 560px;
  height: 100vh;
  overflow: auto;
  padding: 24px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.drawer-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 34px; }
.drawer h2, .dialog h2 { margin: 0; font-size: 16px; font-weight: 600; line-height: 24px; }
.close, .dialog-actions .text-button, .dialog-actions .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 8px 16px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  line-height: 18px;
  cursor: pointer;
}
.dialog-actions .primary {
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 13px;
}
.dialog-actions .text-button { font-size: 13px; }
.features { display: flex; align-items: center; gap: 8px; }
.features p { margin: 0; font-size: 14px; font-weight: 500; line-height: 20px; white-space: nowrap; }
#drawer-root .drawer th { white-space: nowrap; height: 32px; padding-top: 7px; padding-bottom: 7px; }
#drawer-root .drawer td { white-space: nowrap; }
@media (min-width: 1025px) { #drawer-root .drawer td { height: 35px; } }
#drawer-root .drawer tr.selected td { background: var(--accent-subtle); }
.history { margin: 0; font-size: 13px; line-height: 16px; }
.notes {
  box-sizing: border-box;
  height: 132px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}
.notes h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; line-height: 20px; }
.notes p { margin: 0 0 12px; color: var(--text-secondary); font-size: 14px; line-height: 20px; }
.cards { display: none; }
.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  text-align: left;
  cursor: pointer;
}
.card strong { font-size: 14px; font-weight: 500; line-height: 20px; }
.card span { color: var(--text-secondary); font-size: 13px; line-height: 18px; }
.card.selected { background: var(--accent-subtle); }
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  cursor: pointer;
}

.dialog-scrim { position: fixed; inset: 0; z-index: 4; background: rgba(0, 0, 0, 0.4); display: flex; justify-content: center; align-items: flex-start; padding-top: 260px; }
.dialog {
  width: 480px;
  max-width: calc(100% - 32px);
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-dialog);
  background: var(--bg-surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dialog > p { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 20px; }
.drawer .fine { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.dialog textarea {
  width: 100%;
  height: 58px;
  padding: 8px 12px;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  line-height: 20px;
  resize: none;
  overflow: hidden;
}
.dialog label { display: flex; flex-direction: column; gap: 4px; }
.dialog label.choice,
.dialog .include label { flex-direction: row; align-items: center; gap: 8px; }
.dialog-actions { justify-content: flex-end; }
#note-form { padding-bottom: 24px; }
.hint { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.dialog .hint { margin: 0; }
.collect-scrim { padding-top: 180px; background: rgba(0, 0, 0, 0.4); overflow: auto; }
.collect-dialog {
  width: 560px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}
.drawer.panel { border-left: 0; box-shadow: -6px 0 24px rgba(0, 0, 0, 0.18); }
.drawer.panel > .banner { margin-top: 22px; }
.scrim.dim { background: rgba(0, 0, 0, 0.4); }
.group-label { margin: 0 0 8px; color: var(--text-secondary); font-size: 12px; font-weight: 500; line-height: 16px; }
.choice-row { display: flex; gap: 24px; flex-wrap: wrap; }
.choice { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; line-height: 20px; }
.choice input {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
}
.choice input:checked {
  border: 0;
  background: url("/static/radio-selected.svg") center / 16px 16px no-repeat;
}
.add-row, .split { display: flex; gap: 12px; align-items: flex-end; }
.field.grow { flex: 1; min-width: 0; }
.field.grow select { width: 100%; }
.panel-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.panel-actions .secondary, .panel-actions .primary, .panel-actions .danger, .panel-actions .text-button {
  height: 34px;
  padding: 8px 16px;
}
.include { display: flex; flex-direction: column; gap: 8px; }
.include label { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 20px; }
.fixture-note { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.sr-only { position: absolute; top: 0; left: 0; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.cost-table table { table-layout: auto; }
.cost-table th, .cost-table td { white-space: nowrap; }
.collect-dialog .table-wrap { margin-bottom: -2px; }
[hidden] { display: none !important; }

@media (max-width: 1024px) {
  .sidenav { display: none; position: fixed; z-index: 5; top: 56px; bottom: 0; left: 0; height: auto; }
  .sidenav.open, .sidenav:target { display: block; }
  .sidenav.open::after, .sidenav:target::after {
    content: "";
    position: fixed;
    z-index: -1;
    top: 56px;
    left: 232px;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
  }
  .topbar .menu {
    display: inline-flex;
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--accent);
  }
  .campaigns-link, .full-chip { display: none; }
  .topbar { height: 56px; padding: 12px 16px; gap: 12px; }
  .shell { min-height: calc(100vh - 56px); }
  .main { padding: 24px; gap: 16px; }
  body.rankings .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
  }
  body.rankings .titles { order: 1; width: 100%; grid-column: auto; grid-row: auto; }
  body.rankings .header-actions { order: 2; width: 100%; justify-content: flex-start; gap: 12px; align-self: auto; transform: none; grid-column: auto; }
  body.rankings .header-actions .primary { margin-left: 0; width: auto; }
  body.rankings .header-actions .secondary, body.rankings .header-actions .primary { height: 44px; width: auto; }
  html.rk-empty body.rankings .empty-actions { flex-direction: column; align-items: stretch; }
  html.rk-empty body.rankings .empty-actions .primary,
  html.rk-empty body.rankings .empty-actions .secondary { width: 100%; }
  body.rankings .drawer .table-wrap thead { display: none; }
  body.rankings .drawer .table-wrap tr { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--border-default); }
  body.rankings .drawer .table-wrap td { display: block; border: 0; padding: 0; }
  .field.target, .field.range { order: 3; flex: 1 1 calc(50% - 8px); width: auto; }
  .field.target, .field.range, .field.compact { gap: 2px; }
  body.rankings .estimate { position: static; top: auto; right: auto; order: 4; width: 100%; text-align: left; }
  body.rankings .main > .sourcebar { height: 26px; padding-top: 5px; padding-bottom: 5px; }
  .distribution {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 12px;
    row-gap: 16px;
    border: 0;
    padding: 0;
    background: transparent;
  }
  .distribution .stat { min-height: 64px; }
  .distribution .stat:nth-child(5), .uncollected { grid-column: 1 / -1; }
  .distribution .grow { display: none; }
  .uncollected { display: flex; flex-direction: column; gap: 16px; }
  .uncollected p { white-space: nowrap; }
  .pair { height: 44px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: center; }
  .tabs, .check, .field.compact:last-child { grid-column: 1 / -1; }
  .field.compact { width: auto; }
  .tabs { height: 44px; align-items: center; }
  .tabs button { height: 44px; justify-content: center; }
  .tabs button i { display: none; }
  .tabs button span {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 4px 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    background: var(--bg-surface);
    font-size: 12px;
    line-height: 16px;
  }
  .tabs button[aria-selected="true"] span { background: var(--accent-subtle); border-color: var(--accent); }
  body.rankings .estimate { color: var(--text-secondary); }
  body.rankings .rank-table { display: none; margin-top: 0; }
  body.rankings .cards { display: flex; flex-direction: column; margin-top: -8px; border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden; }
}
@media (max-width: 767px) {
  .wordmark, .top-link, .full-chip { display: none; }
  .demo-chip { display: inline-flex; }
  body.rankings .page-header { gap: 12px; }
  .field.target, .field.range { flex-basis: 100%; }
  .main { padding: 16px; gap: 12px; }
  body.rankings .main > .sourcebar {
    display: block;
    height: 48px;
    overflow: hidden;
    white-space: normal;
    width: 100%;
    padding: 8px 12px;
    line-height: 16px;
    letter-spacing: -0.02em;
  }
  body.rankings .main > .sourcebar > * { display: inline; }
  body.rankings .main > .sourcebar .dot { display: inline-block; vertical-align: 1px; }
  .distribution { grid-template-columns: 1fr 1fr; column-gap: 12px; row-gap: 12px; }
  .uncollected { gap: 12px; }
  .export-action { display: none; }
  .actionbar .secondary, .actionbar .primary { height: 44px; }
  .actionbar {
    display: flex;
    gap: 12px;
    position: fixed;
    z-index: 3;
    left: 0;
    right: 0;
    bottom: 56px;
    padding: 16px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
  }
  .actionbar .secondary, .actionbar .primary { flex: 1; }
  body.rankings .header-actions { display: none; }
  .bottom-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    z-index: 4;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
  }
  .bottom-tabs a {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    text-decoration: none;
  }
  .bottom-tabs a.here { color: var(--accent); }
  .main { padding-bottom: 160px; }
  .card span { letter-spacing: -0.03em; }
  .filters { grid-template-columns: 1fr; }
  .table-wrap { overflow: auto; }
  .drawer { width: 100%; }
  body.rankings .dialog { width: calc(100vw - 48px); }
  body.rankings .dialog-actions { flex-wrap: wrap; justify-content: stretch; }
}

/* Responsive row cards. Desktop tables stay; each row becomes a card at tablet and mobile. */
.metric-line { display: none; }

@media (max-width: 1024px) {
  .sourcebar {
    width: 100%;
    height: auto;
    flex-wrap: wrap;
    white-space: normal;
    box-sizing: border-box;
  }
  .metric-line {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
  }
  .table-wrap:has(.metric-line) { overflow: hidden; }
  .table-wrap:has(.metric-line) thead { display: none; }
  .table-wrap:has(.metric-line) table,
  .table-wrap:has(.metric-line) tbody { display: block; width: 100%; }
  tr:has(.metric-line) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-surface);
  }
  tr.selected:has(.metric-line) { background: var(--accent-subtle); }
  .table-wrap.keep-table .metric-line { display: none !important; }
  body .table-wrap:not(.keep-table) tr:has(.metric-line) > td:not(:has(.metric-line)):not(:has(button)):not(:has(input)):not(:has(a)):not(:has(.chip)) {
    display: none !important;
  }
  tr:has(.metric-line) td {
    width: auto;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
  }
  tr:has(.metric-line) td:has(.metric-line),
  tr:has(.metric-line) td:has(input),
  tr:has(.metric-line) td:has(button),
  tr:has(.metric-line) td:has(.chip),
  tr:has(.metric-line) td:has(a.secondary),
  tr:has(.metric-line) td:has(a.primary),
  tr:has(.metric-line) td:has(a.text-button) {
    display: block;
  }
  tr:has(.metric-line) td:has(.metric-line) { flex: 1 0 100%; min-width: 0; }
  tr:has(.metric-line) td:has(button),
  tr:has(.metric-line) td:has(a.secondary),
  tr:has(.metric-line) td:has(a.primary) {
    flex: 1 0 100%;
  }
  tr:has(.metric-line) td:has(button) button,
  tr:has(.metric-line) td:has(button) .secondary,
  tr:has(.metric-line) td:has(a.secondary) a,
  tr:has(.metric-line) td:has(a.primary) a {
    width: 100%;
    box-sizing: border-box;
  }
}

@media (max-width: 1024px) {
  .campaign-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(420px, 100%);
    height: auto;
    padding: 16px;
    border: 0;
    border-left: 1px solid var(--border-default);
    border-radius: 0;
    box-shadow: none;
    overflow: auto;
  }
  .campaign-menu .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
  }
  .campaign-menu .sheet-head strong { font-size: 16px; font-weight: 600; line-height: 24px; }
  .campaign-menu .desktop-search { display: none; }
  .campaign-menu .campaign-option {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-default);
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    font-weight: 500;
  }
  .campaign-menu .name { grid-column: 1; grid-row: 1; }
  .campaign-menu .kind {
    display: block;
    grid-column: 1;
    grid-row: 2;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
  }
  .campaign-menu .chip {
    grid-column: 2;
    grid-row: 1 / span 2;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font-weight: 400;
  }
  .campaign-menu .menu-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: auto;
    padding-top: 16px;
  }
}

@media (max-width: 767px) {
  .campaign-menu {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 80vh;
    border-left: 0;
    border-top: 1px solid var(--border-default);
    border-radius: 12px 12px 0 0;
  }
  .campaign-menu .menu-actions { flex-direction: column-reverse; align-items: stretch; }
  .campaign-menu .menu-actions .secondary,
  .campaign-menu .menu-actions .text-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    box-sizing: border-box;
  }
}
