/* SearchLab — design tokens + layout.
   Aesthetic: high-end / soft. 8pt spacing grid, restrained color, calm surfaces.
   Chart color roles follow the validated dataviz reference palette. */

:root {
  color-scheme: light;
  /* surfaces + ink */
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6e6c66;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  /* series (validated categorical slots 1 + 2) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --band: #f0efec;
  /* status */
  --good: #0ca30c;
  --good-text: #006300;
  --warn: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  /* ui */
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px rgba(11, 11, 11, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Iowan Old Style", "Palatino", Georgia, serif;
  --sp-1: 8px; --sp-2: 16px; --sp-3: 24px; --sp-4: 32px; --sp-6: 48px; --sp-8: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --band: #383835;
    --good-text: #0ca30c;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--plane);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 var(--sp-3) var(--sp-8); }
.topbar {
  display: flex; align-items: baseline; gap: var(--sp-4);
  padding: var(--sp-3) 0 var(--sp-2);
  border-bottom: 1px solid var(--grid);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.brand { font-family: var(--font-display); font-size: 22px; letter-spacing: 0.01em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand span { color: var(--ink-3); font-family: var(--font); font-size: 12px; margin-left: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; gap: var(--sp-2); margin-left: auto; }
.nav a {
  color: var(--ink-2); font-size: 14px; padding: 6px 12px; border-radius: 999px;
}
.nav a:hover { text-decoration: none; color: var(--ink); background: var(--band); }
.nav a.active { background: var(--ink); color: var(--surface); }

.view-title { font-family: var(--font-display); font-size: 30px; font-weight: 500; margin-bottom: var(--sp-1); }
.view-sub { color: var(--ink-2); margin: 0 0 var(--sp-4); max-width: 62ch; }

/* ---------- cards + tiles ---------- */
.card {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: var(--sp-3);
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-4); }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: var(--radius); padding: var(--sp-2) var(--sp-3); }
.tile .label { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.tile .value { font-size: 30px; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.tile .hint { font-size: 12.5px; color: var(--ink-2); }

/* ---------- filters + forms ---------- */
.filters { display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-bottom: var(--sp-3); align-items: center; }
input, select, textarea, button {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--baseline);
  border-radius: 8px; padding: 8px 12px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { width: 100%; min-height: 120px; resize: vertical; }
label.field { display: block; margin-bottom: var(--sp-2); }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--ink-2); }
.btn {
  cursor: pointer; font-weight: 600; border: 1px solid var(--baseline);
  background: var(--surface);
}
.btn:hover { background: var(--band); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.88; }
.btn.danger { color: var(--critical); border-color: var(--critical); background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
/* Site-wide DR is directional context, not a metric to compete on: it sits in
   the table but never reads as loud as the page-level counts beside it. */
td.muted-col, th.muted-col { color: var(--ink-3); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Numeric headers wrap to two short lines rather than forcing the whole table
   into horizontal scroll: eleven columns of on-page metrics add up fast. */
th.num { white-space: normal; max-width: 9ch; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--band); }
tr.target-row td { background: color-mix(in oklab, var(--series-2) 7%, var(--surface)); }
td .sub { color: var(--ink-3); font-size: 12.5px; display: block; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Domain plus path, so a row is never mistaken for the site's homepage. */
.urlcell { display: block; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leadcell { display: block; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urlcell .path { color: var(--ink); font-weight: 600; }
.urlcell .path:hover { text-decoration: underline; }

.chip {
  display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px;
  background: var(--band); color: var(--ink-2); margin-right: 6px; white-space: nowrap;
}
.chip.status-warn { background: transparent; border: 1px solid var(--serious); color: var(--ink-2); }
.chip.status-bad { background: transparent; border: 1px solid var(--critical); color: var(--ink-2); }
.chip.target { background: color-mix(in oklab, var(--series-2) 15%, var(--surface)); color: var(--ink); }
.chip.good-chip { background: color-mix(in oklab, var(--good) 12%, var(--surface)); color: var(--ink-2); }

/* ---------- sections ---------- */
.section { margin-top: var(--sp-6); }
.section > h2 { font-family: var(--font-display); font-size: 21px; font-weight: 500; margin-bottom: 4px; }
.section > .section-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 var(--sp-2); max-width: 72ch; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- benchmark cards ---------- */
.bench { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-2); }
.bench .tile .value { font-size: 24px; }
.bench .range { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- charts ---------- */
.chart { margin-top: var(--sp-2); }
.chart .crow { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; margin: 7px 0; }
.chart .clabel { font-size: 13px; color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart .clabel a { color: var(--ink-2); }
.chart .track { position: relative; height: 20px; }
.chart .bar {
  position: absolute; left: 0; top: 2px; height: 16px; min-width: 2px;
  background: var(--series-1); border-radius: 0 4px 4px 0;
}
.chart .bar.alt { background: var(--series-2); }
.chart .cval {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart .band { position: absolute; top: -2px; bottom: -2px; background: var(--band); border-radius: 3px; }
.chart .medline { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--ink-3); }
.chart .dot {
  position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--series-1); box-shadow: 0 0 0 2px var(--surface);
}
.chart .dot.alt { background: var(--series-2); }
.chart .axis { display: grid; grid-template-columns: 150px 1fr; gap: 10px; margin-top: 4px; }
.chart .axis .scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; border-top: 1px solid var(--grid); padding-top: 3px; }
.legend { display: flex; gap: var(--sp-2); font-size: 13px; color: var(--ink-2); margin-top: var(--sp-1); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--series-1); display: inline-block; }
.legend .swatch.alt { background: var(--series-2); }
.legend .swatch.band-key { background: var(--band); border: 1px solid var(--grid); }

/* tooltip */
#tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--surface);
  font-size: 12.5px; padding: 6px 10px; border-radius: 7px;
  max-width: 340px; display: none; line-height: 1.4;
}

/* ---------- keyword tables ---------- */
.kw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-2); }
.kw-col h4 { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; font-weight: 600; }
.kw-col table { font-size: 13px; }
.kw-col td, .kw-col th { padding: 4px 8px; }
.kw-col td:first-child { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

details.page-kw { border: 1px solid var(--ring); border-radius: var(--radius); background: var(--surface); margin-bottom: var(--sp-1); }
details.page-kw > summary {
  cursor: pointer; padding: 12px var(--sp-2); font-weight: 600; font-size: 14px;
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; list-style: none;
}
details.page-kw > summary::-webkit-details-marker { display: none; }
details.page-kw > summary::before { content: "+"; color: var(--ink-3); font-weight: 400; }
details.page-kw[open] > summary::before { content: "\2212"; }
details.page-kw > summary .sub { font-weight: 400; color: var(--ink-3); font-size: 13px; }
details.page-kw > .body { padding: 0 var(--sp-2) var(--sp-2); }

/* tabs */
.tabs { display: flex; gap: 4px; margin-bottom: var(--sp-2); flex-wrap: wrap; }
.tabs button { border: 1px solid var(--baseline); background: var(--surface); border-radius: 999px; padding: 5px 14px; font-size: 13px; cursor: pointer; }
.tabs button.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------- states ---------- */
.empty { color: var(--ink-2); padding: var(--sp-4); text-align: center; border: 1px dashed var(--baseline); border-radius: var(--radius-lg); }
.notice { background: var(--band); border-radius: var(--radius); padding: 10px var(--sp-2); font-size: 13.5px; color: var(--ink-2); }
.error-note { color: var(--critical); font-size: 13.5px; }
.progress { display: flex; align-items: center; gap: 10px; color: var(--ink-2); padding: var(--sp-2) 0; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--grid); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* login gate */
#gate {
  position: fixed; inset: 0; background: var(--plane); z-index: 100;
  display: none; align-items: center; justify-content: center;
}
#gate .card { width: min(360px, 90vw); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
footer.colophon { margin-top: var(--sp-8); color: var(--ink-3); font-size: 12.5px; border-top: 1px solid var(--grid); padding-top: var(--sp-2); }
