/* ==========================================================================
   AI SEO Manager — base + component layer
   Requires tokens.css to be loaded first. No raw colour values below this
   line: everything reads a role token.
   ========================================================================== */

/* ---------- reset ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--fg-primary);
  background: var(--plane);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

html[lang="ar"] body, [dir="rtl"] { font-family: var(--font-arabic); }

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: .9em; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection { background: var(--accent-soft); color: var(--accent-ink); }

.u-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--space-2); top: -100px; z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4); background: var(--surface-1);
  box-shadow: var(--shadow-md); border-radius: var(--radius-md);
}
.skip-link:focus { top: var(--space-2); }

/* ==========================================================================
   APP SHELL
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ---------- sidebar ----------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--surface-1);
  border-inline-end: 1px solid var(--border);
  overflow: hidden;
}

.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-h); padding-inline: var(--space-4);
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.sidebar__logo {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: var(--accent); color: var(--fg-on-accent);
  font-weight: var(--weight-bold); font-size: var(--text-sm);
}
.sidebar__brand-text { min-width: 0; }
.sidebar__title {
  font-size: var(--text-md); font-weight: var(--weight-semibold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__subtitle { font-size: var(--text-xs); color: var(--fg-muted); }

.sidebar__scroll { flex: 1 1 auto; overflow-y: auto; padding: var(--space-3) 0 var(--space-6); }

.nav-group { margin-bottom: var(--space-5); }
.nav-group__label {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--fg-muted);
}

.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; padding: var(--space-2) var(--space-4);
  font-size: var(--text-md); color: var(--fg-secondary);
  border-inline-start: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  text-align: start;
}
.nav-item:hover { background: var(--surface-2); color: var(--fg-primary); text-decoration: none; }
.nav-item[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent-ink);
  border-inline-start-color: var(--accent);
  font-weight: var(--weight-medium);
}
.nav-item__icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav-item__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item__count {
  margin-inline-start: auto; font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums; color: var(--fg-muted);
}
.app[data-sidebar="collapsed"] .nav-item__label,
.app[data-sidebar="collapsed"] .nav-group__label,
.app[data-sidebar="collapsed"] .sidebar__brand-text,
.app[data-sidebar="collapsed"] .nav-item__count { display: none; }

.sidebar__footer {
  flex: 0 0 auto; border-top: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-3);
}
.avatar {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: var(--radius-full);
  background: var(--surface-3); color: var(--fg-secondary);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.avatar--accent { background: var(--accent); color: var(--fg-on-accent); }

/* ---------- topbar ----------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-h); padding-inline: var(--space-5);
  background: color-mix(in oklab, var(--plane) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.topbar__spacer { flex: 1 1 auto; }

.content {
  padding: var(--space-6) var(--space-5) var(--space-12);
  width: 100%; max-width: var(--content-max); margin-inline: auto;
}

.page-head { margin-bottom: var(--space-6); }
.page-head__row { display: flex; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.page-title { font-size: var(--text-2xl); }
.page-subtitle { margin-top: var(--space-1); color: var(--fg-secondary); font-size: var(--text-md); }
.page-head__actions { margin-inline-start: auto; display: flex; gap: var(--space-2); }

.breadcrumbs { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--fg-muted); margin-bottom: var(--space-2); }
.breadcrumbs__sep { opacity: .5; }

/* ==========================================================================
   LAYOUT PRIMITIVES
   ========================================================================== */
.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--sidebar-right { grid-template-columns: minmax(0, 1fr) 320px; }
.stack > * + * { margin-top: var(--space-4); }
.stack--tight > * + * { margin-top: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }

/* ==========================================================================
   CARD
   ========================================================================== */
.card {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--ring);
}
.card--raised { box-shadow: var(--ring), var(--shadow-sm); }
.card__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: var(--text-lg); }
.card__subtitle { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 2px; }
.card__actions { margin-inline-start: auto; display: flex; gap: var(--space-2); }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }
.card__foot {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--fg-muted);
  display: flex; align-items: center; gap: var(--space-3);
}

/* ==========================================================================
   BUTTON
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); white-space: nowrap;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-md); font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn__icon { width: 16px; height: 16px; flex: 0 0 auto; }

.btn--primary { background: var(--accent); color: var(--fg-on-accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-active); }

.btn--secondary { background: var(--surface-2); color: var(--fg-primary); box-shadow: var(--ring); }
.btn--secondary:hover { background: var(--surface-3); }

.btn--ghost { color: var(--fg-secondary); }
.btn--ghost:hover { background: var(--surface-2); color: var(--fg-primary); }

.btn--danger { background: var(--sev-critical); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }

.btn--sm { padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.btn--lg { padding: var(--space-3) var(--space-5); font-size: var(--text-lg); }
.btn--icon { padding: var(--space-2); width: 34px; height: 34px; }
.btn--block { width: 100%; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  color: var(--fg-on-accent);
  animation: spin .7s linear infinite;
}
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after { color: var(--fg-secondary); }
@keyframes spin { to { transform: rotate(1turn); } }

.btn-group { display: inline-flex; box-shadow: var(--ring); border-radius: var(--radius-md); overflow: hidden; }
.btn-group .btn { border-radius: 0; box-shadow: none; }
.btn-group .btn + .btn { border-inline-start: 1px solid var(--border); }

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-secondary); }
.hint { font-size: var(--text-xs); color: var(--fg-muted); }
.error-text { font-size: var(--text-xs); color: var(--sev-critical-ink); }

.input, .select, .textarea {
  width: 100%; padding: var(--space-2) var(--space-3);
  font-size: var(--text-md); color: var(--fg-primary);
  background: var(--surface-1); border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-muted); }
.input:hover, .select:hover, .textarea:hover { box-shadow: inset 0 0 0 1px var(--fg-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft);
}
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--sev-critical); }
.textarea { min-height: 88px; resize: vertical; line-height: var(--leading-normal); }

.select {
  appearance: none; padding-inline-end: var(--space-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

.search { position: relative; }
.search .input { padding-inline-start: var(--space-8); }
.search__icon {
  position: absolute; inset-inline-start: var(--space-3); top: 50%;
  transform: translateY(-50%); width: 16px; height: 16px;
  color: var(--fg-muted); pointer-events: none;
}

.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 38px; height: 22px; border-radius: var(--radius-full);
  background: var(--surface-3); box-shadow: var(--ring);
  transition: background var(--dur-base) var(--ease-out); position: relative;
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface-1); box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
[dir="rtl"] .switch input:checked + .switch__track::after { transform: translateX(-16px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* segmented control — the filter row lives above the charts, one row */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border-radius: var(--radius-md); box-shadow: var(--ring);
}
.segmented__item {
  padding: var(--space-1) var(--space-3); font-size: var(--text-sm);
  color: var(--fg-secondary); border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-out);
}
.segmented__item:hover { color: var(--fg-primary); }
.segmented__item[aria-pressed="true"], .segmented__item[aria-selected="true"] {
  background: var(--surface-1); color: var(--fg-primary);
  font-weight: var(--weight-medium); box-shadow: var(--shadow-sm);
}

.filter-bar {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1); border-radius: var(--radius-lg);
  box-shadow: var(--ring); margin-bottom: var(--space-4);
}

/* ==========================================================================
   SEVERITY BADGE  —  never colour alone: icon + label, always
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  line-height: 1.45; border-radius: var(--radius-full); white-space: nowrap;
  background: var(--sev-neutral-bg); color: var(--sev-neutral-ink);
}
.badge__glyph { font-size: 1em; line-height: 1; }
.badge--critical { background: var(--sev-critical-bg); color: var(--sev-critical-ink); }
.badge--high,
.badge--serious  { background: var(--sev-serious-bg);  color: var(--sev-serious-ink); }
.badge--medium,
.badge--warning  { background: var(--sev-warning-bg);  color: var(--sev-warning-ink); }
.badge--low,
.badge--info     { background: var(--sev-info-bg);     color: var(--sev-info-ink); }
.badge--good,
.badge--pass     { background: var(--sev-good-bg);     color: var(--sev-good-ink); }
.badge--p0 { background: var(--sev-critical-bg); color: var(--sev-critical-ink); }
.badge--p1 { background: var(--sev-serious-bg);  color: var(--sev-serious-ink); }
.badge--p2 { background: var(--sev-warning-bg);  color: var(--sev-warning-ink); }
.badge--p3 { background: var(--sev-info-bg);     color: var(--sev-info-ink); }
.badge--square { border-radius: var(--radius-xs); }

/* evidence tier — flag how much a finding can be trusted */
.tier {
  font-size: var(--text-2xs); letter-spacing: var(--tracking-wide);
  text-transform: uppercase; font-weight: var(--weight-semibold);
  padding: 1px var(--space-2); border-radius: var(--radius-xs);
  box-shadow: var(--ring); color: var(--fg-muted);
}
.tier--primary { color: var(--sev-good-ink); background: var(--sev-good-bg); box-shadow: none; }
.tier--third-party { color: var(--sev-info-ink); background: var(--sev-info-bg); box-shadow: none; }
.tier--weak { color: var(--sev-warning-ink); background: var(--sev-warning-bg); box-shadow: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--fg-muted); }
.dot--critical { background: var(--sev-critical); }
.dot--serious  { background: var(--sev-serious); }
.dot--warning  { background: var(--sev-warning); }
.dot--good     { background: var(--sev-good); }
.dot--pulse { animation: pulse 1.6s var(--ease-in-out) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); font-size: var(--text-xs);
  border-radius: var(--radius-sm); background: var(--surface-2);
  color: var(--fg-secondary); box-shadow: var(--ring);
}
.chip--removable { padding-inline-end: var(--space-1); }

/* ==========================================================================
   STAT TILE  —  label · value · delta · sparkline
   ========================================================================== */
.stat {
  padding: var(--space-4) var(--space-5);
  background: var(--surface-1); border-radius: var(--radius-lg); box-shadow: var(--ring);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.stat__label {
  font-size: var(--text-xs); color: var(--fg-muted);
  display: flex; align-items: center; gap: var(--space-1);
}
.stat__value {
  font-size: var(--text-3xl); font-weight: var(--weight-semibold);
  line-height: var(--leading-tight); letter-spacing: var(--tracking-tight);
  /* proportional figures on purpose — tabular-nums looks loose at this size */
}
.stat__row { display: flex; align-items: flex-end; gap: var(--space-3); }
.stat__delta {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--fg-muted);
}
.stat__delta--good { color: var(--delta-up-good); }
.stat__delta--bad  { color: var(--delta-down-bad); }
.stat__period { font-size: var(--text-2xs); color: var(--fg-muted); }
.stat__spark { margin-inline-start: auto; width: 84px; height: 28px; }

/* hero figure — exactly one per view */
.hero-figure {
  font-size: var(--text-hero); font-weight: var(--weight-semibold);
  line-height: 1; letter-spacing: -0.02em;
}
.hero-figure__caption { font-size: var(--text-sm); color: var(--fg-secondary); margin-top: var(--space-2); }

/* ==========================================================================
   SCORE GAUGE (radial) + METER (linear)
   Fill carries severity; the track is a lighter step of the SAME ramp so
   state reads across the whole bar.
   ========================================================================== */
.gauge { display: inline-grid; place-items: center; position: relative; }
.gauge svg { transform: rotate(-90deg); overflow: visible; }
.gauge__track { fill: none; stroke: var(--surface-3); }
.gauge__fill {
  fill: none; stroke-linecap: round;
  stroke: var(--accent);
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out);
}
.gauge[data-band="critical"] .gauge__fill { stroke: var(--sev-critical); }
.gauge[data-band="serious"]  .gauge__fill { stroke: var(--sev-serious); }
.gauge[data-band="warning"]  .gauge__fill { stroke: var(--sev-warning); }
.gauge[data-band="good"]     .gauge__fill { stroke: var(--sev-good); }
.gauge__label { position: absolute; text-align: center; }
.gauge__value { font-size: var(--text-3xl); font-weight: var(--weight-semibold); line-height: 1; }
.gauge__unit { font-size: var(--text-xs); color: var(--fg-muted); }

/* a capped score shows its ceiling — the hard-gate case */
.gauge__ceiling {
  font-size: var(--text-2xs); color: var(--sev-critical-ink);
  background: var(--sev-critical-bg); border-radius: var(--radius-xs);
  padding: 0 var(--space-1); margin-top: var(--space-1); display: inline-block;
}

.meter { display: flex; flex-direction: column; gap: var(--space-1); }
.meter__head { display: flex; align-items: baseline; gap: var(--space-2); font-size: var(--text-sm); }
.meter__name { color: var(--fg-secondary); }
.meter__value { margin-inline-start: auto; font-variant-numeric: tabular-nums; font-weight: var(--weight-medium); }
.meter__track {
  height: 6px; border-radius: var(--radius-full);
  background: var(--seq-100); overflow: hidden;
}
:root[data-theme="dark"] .meter__track { background: var(--seq-700); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .meter__track { background: var(--seq-700); }
}
.meter__fill {
  height: 100%; border-radius: var(--radius-full);
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}
.meter[data-band="critical"] .meter__fill { background: var(--sev-critical); }
.meter[data-band="serious"]  .meter__fill { background: var(--sev-serious); }
.meter[data-band="warning"]  .meter__fill { background: var(--sev-warning); }
.meter[data-band="good"]     .meter__fill { background: var(--sev-good); }

/* determinate progress for a running crawl */
.progress { height: 4px; background: var(--surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); transition: width var(--dur-base) var(--ease-out); }
.progress--indeterminate .progress__bar { width: 35%; animation: indet 1.4s var(--ease-in-out) infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

/* ==========================================================================
   TABLE  —  dense, sticky head, tabular figures in columns
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  padding: var(--space-2) var(--space-4);
  text-align: start; white-space: nowrap;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--fg-muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table__num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table__url {
  font-family: var(--font-mono); font-size: var(--text-xs);
  max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-block; vertical-align: bottom;
}
.table__sort { display: inline-flex; align-items: center; gap: var(--space-1); color: inherit; }
.table__sort[aria-sort="ascending"]::after  { content: "▲"; font-size: .6em; }
.table__sort[aria-sort="descending"]::after { content: "▼"; font-size: .6em; }
.table--compact tbody td { padding: var(--space-2) var(--space-3); }
.table tr.is-new td { box-shadow: inset 3px 0 0 var(--sev-info); }
.table tr.is-fixed td { opacity: .55; }

.table-caption {
  padding: var(--space-2) var(--space-4); font-size: var(--text-xs);
  color: var(--fg-muted); border-top: 1px solid var(--border);
}

.pagination { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-4); }
.pagination__info { margin-inline-end: auto; font-size: var(--text-xs); color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   FINDING ROW  —  the developer's work queue
   ========================================================================== */
.finding {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.finding:last-child { border-bottom: 0; }
.finding:hover { background: var(--surface-2); }
.finding__code {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  color: var(--fg-muted); padding-top: 2px;
}
.finding__title { font-size: var(--text-md); font-weight: var(--weight-medium); }
.finding__meta {
  margin-top: var(--space-1); display: flex; flex-wrap: wrap;
  gap: var(--space-2); align-items: center;
  font-size: var(--text-xs); color: var(--fg-muted);
}
.finding__detail { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--fg-secondary); }
.finding__evidence {
  margin-top: var(--space-2); padding: var(--space-2) var(--space-3);
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--fg-secondary); overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.finding__side { text-align: end; display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-end; }
.finding__impact { font-size: var(--text-sm); font-variant-numeric: tabular-nums; font-weight: var(--weight-medium); }
.finding__impact-label { font-size: var(--text-2xs); color: var(--fg-muted); }

/* ==========================================================================
   CRAWLER ACCESS MATRIX  —  sequential ramp = magnitude; state = status
   ========================================================================== */
.matrix { overflow-x: auto; }
.matrix__grid { border-collapse: separate; border-spacing: 2px; font-size: var(--text-xs); }
.matrix__grid th {
  font-weight: var(--weight-medium); color: var(--fg-secondary);
  padding: var(--space-1) var(--space-2); text-align: start; white-space: nowrap;
}
.matrix__grid thead th { writing-mode: vertical-rl; transform: rotate(180deg); height: 96px; padding: var(--space-2) 0; }
.matrix__cell {
  width: 34px; height: 30px; border-radius: var(--radius-xs);
  text-align: center; vertical-align: middle;
  background: var(--surface-2); color: var(--fg-muted);
  font-weight: var(--weight-semibold);
}
.matrix__cell[data-state="allowed"] { background: var(--sev-good-bg);     color: var(--sev-good-ink); }
.matrix__cell[data-state="blocked"] { background: var(--sev-critical-bg); color: var(--sev-critical-ink); }
.matrix__cell[data-state="policy"]  { background: var(--sev-warning-bg);  color: var(--sev-warning-ink); }
.matrix__cell[data-state="paywall"] { background: var(--sev-info-bg);     color: var(--sev-info-ink); }
.matrix__cell[data-state="unknown"] { background: var(--surface-2);       color: var(--fg-muted); }
.matrix__cell:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.matrix__rowlabel { color: var(--fg-primary); font-weight: var(--weight-medium); }
.matrix__class { font-size: var(--text-2xs); color: var(--fg-muted); font-weight: var(--weight-normal); }

/* heat cells for a magnitude grid — one hue, light→dark */
.heat[data-step="1"] { background: var(--seq-100); }
.heat[data-step="2"] { background: var(--seq-200); }
.heat[data-step="3"] { background: var(--seq-300); }
.heat[data-step="4"] { background: var(--seq-400); }
.heat[data-step="5"] { background: var(--seq-500); }
.heat[data-step="6"] { background: var(--seq-600); }
.heat[data-step="7"] { background: var(--seq-700); color: #fff; }

/* ==========================================================================
   CHART FRAME  —  legend always present for ≥2 series, table view always
   ========================================================================== */
.chart { background: var(--surface-1); border-radius: var(--radius-lg); box-shadow: var(--ring); }
.chart__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5) var(--space-2); }
.chart__title { font-size: var(--text-lg); }
.chart__subtitle { font-size: var(--text-xs); color: var(--fg-muted); margin-top: 2px; }
.chart__tools { margin-inline-start: auto; display: flex; gap: var(--space-1); }
.chart__plot { padding: var(--space-2) var(--space-5) var(--space-4); }
.chart__plot svg { overflow: visible; width: 100%; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); padding: 0 var(--space-5) var(--space-4); }
.legend__item { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--fg-secondary); }
.legend__key { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.legend__key--dot { width: 9px; height: 9px; border-radius: 50%; }
.legend__item[aria-pressed="false"] { opacity: .4; }

.viz-grid line { stroke: var(--gridline); stroke-width: 1; }
.viz-axis line, .viz-axis path { stroke: var(--axis); stroke-width: 1; }
.viz-axis text { fill: var(--fg-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { fill-opacity: .10; stroke: none; }
.viz-bar { rx: 4; }                                  /* rounded data-end       */
.viz-dot { r: 4.5; stroke: var(--surface-1); stroke-width: 2; }  /* surface ring */
.viz-label { fill: var(--fg-secondary); font-size: var(--text-xs); }
.viz-crosshair { stroke: var(--fg-muted); stroke-width: 1; stroke-dasharray: 0; opacity: .5; }

.s1 { color: var(--series-1); } .s2 { color: var(--series-2); }
.s3 { color: var(--series-3); } .s4 { color: var(--series-4); }
.s5 { color: var(--series-5); } .s6 { color: var(--series-6); }
.s7 { color: var(--series-7); } .s8 { color: var(--series-8); }
.viz-line.s1, .viz-line.s2, .viz-line.s3, .viz-line.s4,
.viz-line.s5, .viz-line.s6, .viz-line.s7, .viz-line.s8 { stroke: currentColor; }
.viz-bar.s1, .viz-bar.s2, .viz-bar.s3, .viz-bar.s4,
.viz-bar.s5, .viz-bar.s6, .viz-bar.s7, .viz-bar.s8,
.viz-area.s1, .viz-area.s2, .viz-area.s3, .viz-dot.s1, .viz-dot.s2, .viz-dot.s3 { fill: currentColor; }
.legend__key.s1, .legend__key.s2, .legend__key.s3, .legend__key.s4,
.legend__key.s5, .legend__key.s6, .legend__key.s7, .legend__key.s8 { background: currentColor; }

/* texture backup channel — CVD / print / forced-colors only, never default */
.u-texture-on .viz-bar.s2, .u-texture-on .viz-area.s2 { fill: url(#tex-45); }
.u-texture-on .viz-bar.s3, .u-texture-on .viz-area.s3 { fill: url(#tex-135); }
@media print { .viz-bar.s2 { fill: url(#tex-45); } .viz-bar.s3 { fill: url(#tex-135); } }

.sparkline { display: block; width: 100%; height: 100%; overflow: visible; }
.sparkline__path { fill: none; stroke: var(--fg-muted); stroke-width: 1.5; stroke-linejoin: round; }
.sparkline__path--accent { stroke: var(--accent); }
.sparkline__end { fill: var(--accent); r: 2.5; }

.tooltip {
  position: absolute; z-index: var(--z-tooltip); pointer-events: none;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-inverse); color: var(--fg-inverse);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: var(--text-xs); max-width: 260px;
}
.tooltip__title { font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.tooltip__row { display: flex; align-items: center; gap: var(--space-2); }
.tooltip__row-value { margin-inline-start: auto; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   ALERT / BANNER
   ========================================================================== */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); font-size: var(--text-sm);
  background: var(--sev-info-bg); color: var(--sev-info-ink);
}
.alert--critical { background: var(--sev-critical-bg); color: var(--sev-critical-ink); }
.alert--warning  { background: var(--sev-warning-bg);  color: var(--sev-warning-ink); }
.alert--good     { background: var(--sev-good-bg);     color: var(--sev-good-ink); }
.alert__icon { flex: 0 0 auto; width: 18px; height: 18px; }
.alert__body { min-width: 0; }
.alert__title { font-weight: var(--weight-semibold); }
.alert__actions { margin-inline-start: auto; display: flex; gap: var(--space-2); flex: 0 0 auto; }

.empty {
  padding: var(--space-12) var(--space-6); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
}
.empty__icon { width: 40px; height: 40px; color: var(--fg-muted); opacity: .7; }
.empty__title { font-size: var(--text-lg); }
.empty__text { color: var(--fg-secondary); max-width: 46ch; font-size: var(--text-sm); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; border-radius: var(--radius-sm);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton--text { height: 12px; margin-block: 6px; }
.skeleton--title { height: 20px; width: 40%; }
.skeleton--block { height: 120px; }

/* ==========================================================================
   TABS
   ========================================================================== */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab {
  padding: var(--space-2) var(--space-3); font-size: var(--text-md);
  color: var(--fg-secondary); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--fg-primary); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: var(--weight-medium); }
.tab__count {
  margin-inline-start: var(--space-1); padding: 0 var(--space-1);
  font-size: var(--text-2xs); border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--fg-muted); font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   MODAL · DRAWER · TOAST
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--scrim); display: grid; place-items: center; padding: var(--space-4);
  animation: fade var(--dur-base) var(--ease-out);
}
.modal {
  width: 100%; max-width: 560px; max-height: 86vh; overflow: auto;
  background: var(--surface-1); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--ring);
  animation: rise var(--dur-base) var(--ease-out);
}
.modal--wide { max-width: 920px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; z-index: var(--z-drawer);
  width: min(560px, 100%); background: var(--surface-1);
  border-inline-start: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slide-in var(--dur-slow) var(--ease-out);
}
@keyframes slide-in { from { transform: translateX(100%); } }
[dir="rtl"] .drawer { animation-name: slide-in-rtl; }
@keyframes slide-in-rtl { from { transform: translateX(-100%); } }

.toast-stack {
  position: fixed; inset-block-end: var(--space-5); inset-inline-end: var(--space-5);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2);
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  min-width: 280px; max-width: 380px; padding: var(--space-3) var(--space-4);
  background: var(--surface-1); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--ring); font-size: var(--text-sm);
  animation: rise var(--dur-base) var(--ease-out);
}
.toast__bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent); flex: 0 0 auto; }
.toast--good .toast__bar { background: var(--sev-good); }
.toast--critical .toast__bar { background: var(--sev-critical); }

/* ==========================================================================
   UTILITIES
   ========================================================================== */
.u-muted { color: var(--fg-muted); }
.u-secondary { color: var(--fg-secondary); }
.u-nowrap { white-space: nowrap; }
.u-tnum { font-variant-numeric: tabular-nums; }
.u-mono { font-family: var(--font-mono); }
.u-xs { font-size: var(--text-xs); }
.u-sm { font-size: var(--text-sm); }
.u-semibold { font-weight: var(--weight-semibold); }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-hidden { display: none !important; }
.u-mt-0 { margin-top: 0; } .u-mt-2 { margin-top: var(--space-2); }
.u-mt-4 { margin-top: var(--space-4); } .u-mt-6 { margin-top: var(--space-6); }
.u-ml-auto { margin-inline-start: auto; }
.u-divide > * + * { border-top: 1px solid var(--border); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  .grid--sidebar-right { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: var(--z-drawer);
    width: var(--sidebar-w); transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .app[data-sidebar="open"] .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .content { padding-inline: var(--space-4); }
  .finding { grid-template-columns: minmax(0, 1fr); }
  .finding__side { text-align: start; align-items: flex-start; }
}
@media (max-width: 600px) {
  .page-title { font-size: var(--text-xl); }
  .stat__value { font-size: var(--text-2xl); }
  .hero-figure { font-size: var(--text-4xl); }
  .table__url { max-width: 22ch; }
}

@media print {
  .sidebar, .topbar, .page-head__actions, .chart__tools, .toast-stack { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card, .chart, .stat { box-shadow: none; border: 1px solid var(--border); break-inside: avoid; }
  body { background: #fff; }
}
