/* ==========================================================================
   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 {
  /* The reset above clears the border on `button` but not on inputs, so every
     field was still carrying the browser default `2px inset #767676` underneath
     the token-coloured ring — which is why fields read as heavy black boxes
     while the rest of the UI is hairlines. The ring IS the border here. */
  border: 0;
  appearance: none;
  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);
}
/* Safari puts a rounded inner shadow on search inputs and hides the token ring. */
.input[type="search"] { -webkit-appearance: none; }
.input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.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.
   ========================================================================== */
/* `img, svg { max-width: 100% }` in the reset let the gauge collapse to 48px
   whenever it shared a flex row with a text block — the ring and the figure
   then overlapped. Pin it: a gauge is a fixed instrument, not fluid media. */
.gauge { display: inline-grid; place-items: center; position: relative; flex: 0 0 auto; }
.gauge svg { transform: rotate(-90deg); overflow: visible; width: 104px; height: 104px; max-width: none; flex: 0 0 auto; }
.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); }
/* [hidden] alone loses to display:grid, which is why filtered rows kept
   showing. Stated explicitly rather than relying on attribute order. */
.finding[hidden] { display: none !important; }
.finding[data-resolved] { opacity: .45; }
.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 is declared after .stat__spark, so its width:100% won every time
   and the trend line sprayed across the whole stat tile. Same-element combo
   selector, so the intent survives however the file is later reordered. */
.sparkline.stat__spark {
  width: 84px; height: 28px; flex: 0 0 auto; max-width: 84px; overflow: hidden;
}
.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); }

/* ==========================================================================
   EXECUTIVE SUMMARY BAND
   --------------------------------------------------------------------------
   One sentence in plain English above the instruments. Directors read this and
   nothing else, so it gets the top of the page and a full-width measure — but
   it is styled as a note rather than a hero, because it must never compete
   with the data it introduces.
   ========================================================================== */
.summary {
  display: flex; gap: var(--space-4); align-items: flex-start;
  padding: var(--space-5);
  background: var(--surface-1); border-radius: var(--radius-lg);
  box-shadow: var(--ring);
  border-inline-start: 3px solid var(--fg-muted);
}
.summary--good     { border-inline-start-color: var(--sev-good); }
.summary--warning  { border-inline-start-color: var(--sev-warning); }
.summary--critical { border-inline-start-color: var(--sev-critical); }
.summary--info     { border-inline-start-color: var(--sev-info); }

.summary__mark {
  flex: 0 0 auto; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: var(--radius-full);
  font-size: var(--text-md); font-weight: var(--weight-semibold);
  background: var(--sev-neutral-bg); color: var(--sev-neutral-ink);
}
.summary--good     .summary__mark { background: var(--sev-good-bg);     color: var(--sev-good-ink); }
.summary--warning  .summary__mark { background: var(--sev-warning-bg);  color: var(--sev-warning-ink); }
.summary--critical .summary__mark { background: var(--sev-critical-bg); color: var(--sev-critical-ink); }
.summary--info     .summary__mark { background: var(--sev-info-bg);     color: var(--sev-info-ink); }

.summary__body { min-width: 0; }
.summary__title { font-size: var(--text-xl); }
.summary__text {
  margin-top: var(--space-2); font-size: var(--text-md);
  color: var(--fg-secondary); max-width: 78ch; line-height: var(--leading-relaxed);
}
.summary__next {
  margin-top: var(--space-3); font-size: var(--text-sm);
  display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap;
}
.summary__next-label {
  flex: 0 0 auto;
  font-size: var(--text-2xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--fg-muted);
}

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

/* Scrim behind the mobile drawer. Desktop never sees it. */
.app__scrim { display: none; }
@media (max-width: 900px) {
  .app[data-sidebar="open"] .app__scrim {
    display: block; position: fixed; inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: var(--scrim); animation: fade var(--dur-base) var(--ease-out);
  }
}

/* Collapsed sidebar: the label is gone, so the name arrives as a tooltip.
   Without this, a collapsed sidebar is a column of glyphs nobody can read. */
.app[data-sidebar="collapsed"] .nav-item { position: relative; justify-content: center; }
.app[data-sidebar="collapsed"] .nav-item[data-tip]:hover::after,
.app[data-sidebar="collapsed"] .nav-item[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute; inset-inline-start: calc(100% + 8px); top: 50%;
  transform: translateY(-50%);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-inverse); color: var(--fg-inverse);
  border-radius: var(--radius-sm); font-size: var(--text-xs);
  white-space: nowrap; z-index: var(--z-tooltip); box-shadow: var(--shadow-md);
}
.app[data-sidebar="collapsed"] .sidebar__filter,
.app[data-sidebar="collapsed"] .nav-item__kbd,
.app[data-sidebar="collapsed"] .usermenu__who,
.app[data-sidebar="collapsed"] .usermenu__caret { display: none; }
.app[data-sidebar="collapsed"] .sidebar__footer { justify-content: center; }

.nav-group__hint {
  float: inline-end; text-transform: none; letter-spacing: 0;
  font-weight: var(--weight-normal); opacity: .8;
}
.nav-item__kbd {
  margin-inline-start: auto; font-size: var(--text-2xs);
  color: var(--fg-muted); opacity: 0;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 0 4px; line-height: 1.4;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.sidebar:hover .nav-item__kbd { opacity: .7; }
.nav-item__count + .nav-item__kbd,
.nav-item__kbd + .nav-item__count { margin-inline-start: var(--space-2); }
.sidebar__filter { padding: var(--space-1) var(--space-4) var(--space-2); }
.sidebar__filter .input { font-size: var(--text-sm); padding-block: var(--space-1); }
.nav-item[hidden] { display: none; }

/* Account menu — a <details> element, so it works with JavaScript disabled and
   closes on Escape without a keydown handler. */
.usermenu { position: relative; width: 100%; }
.usermenu__trigger {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; cursor: pointer; list-style: none;
  border-radius: var(--radius-md); padding: var(--space-1);
}
.usermenu__trigger::-webkit-details-marker { display: none; }
.usermenu__trigger:hover { background: var(--surface-2); }
.usermenu__who { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; text-align: start; }
.usermenu__caret { margin-inline-start: auto; color: var(--fg-muted); font-size: var(--text-xs); }
.usermenu[open] .usermenu__caret { transform: rotate(180deg); }
.usermenu__panel {
  position: absolute; inset-block-end: calc(100% + 6px); inset-inline: 0;
  background: var(--surface-1); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), var(--ring);
  padding: var(--space-1); z-index: var(--z-modal);
  animation: rise var(--dur-fast) var(--ease-out);
}
.usermenu__email { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); word-break: break-all; }
.usermenu__item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  width: 100%; padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm); color: var(--fg-secondary);
  border-radius: var(--radius-sm); text-align: start;
}
.usermenu__item:hover { background: var(--surface-2); color: var(--fg-primary); text-decoration: none; }
.usermenu__item--danger { color: var(--sev-critical-ink); }
.usermenu__item--danger:hover { background: var(--sev-critical-bg); color: var(--sev-critical-ink); }

/* Run state in the topbar: a determinate bar once the crawl reports totals.
   A spinner says "something is happening"; a bar says how much is left. */
.runstate { min-width: 200px; display: flex; flex-direction: column; gap: var(--space-1); }
.runstate__row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--fg-secondary); }
.runstate .progress { width: 100%; }
.runstate.is-determinate .progress { }
.runstate.is-determinate .progress--indeterminate .progress__bar { animation: none; }

.appfoot {
  margin-top: auto; display: flex; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-2xs); color: var(--fg-muted);
}

kbd {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  padding: 1px var(--space-2); border-radius: var(--radius-xs);
  background: var(--surface-2); box-shadow: var(--ring); color: var(--fg-secondary);
}

/* Inline "why does this number mean that" affordance. A dashboard for mixed
   audiences needs the explanation next to the figure, not in a wiki. */
.info {
  display: inline-grid; place-items: center;
  width: 14px; height: 14px; border-radius: 50%;
  font-size: 9px; font-weight: var(--weight-bold); line-height: 1;
  background: var(--surface-3); color: var(--fg-muted); cursor: help;
}
.info:hover, .info:focus-visible { background: var(--accent-soft); color: var(--accent-ink); }

/* Evidence, collapsed by default. */
.evidence { margin-top: var(--space-2); }
.evidence__toggle {
  cursor: pointer; font-size: var(--text-xs); color: var(--fg-muted);
  display: inline-flex; align-items: center; gap: var(--space-1);
  list-style: none; user-select: none;
}
.evidence__toggle::-webkit-details-marker { display: none; }
.evidence__toggle::before { content: "▸"; font-size: .8em; transition: transform var(--dur-fast) var(--ease-out); }
.evidence[open] .evidence__toggle::before { transform: rotate(90deg); }
.evidence__toggle:hover { color: var(--fg-secondary); }

/* Sortable column headings. The whole cell is the target, not a 12px glyph. */
.table thead th[data-sort] { cursor: pointer; user-select: none; }
.table thead th[data-sort]:hover { color: var(--fg-primary); }
.table thead th[data-sort]::after { content: "⇅"; opacity: .35; margin-inline-start: 4px; font-size: .9em; }
.table thead th[aria-sort="ascending"]::after  { content: "▲"; opacity: 1; font-size: .7em; }
.table thead th[aria-sort="descending"]::after { content: "▼"; opacity: 1; font-size: .7em; }
.table tbody tr[hidden] { display: none; }

/* Floating tooltip built by app.js for [data-tip-text] — a real element rather
   than title=, which never appears on keyboard focus and cannot be styled. */
.tip {
  position: fixed; z-index: var(--z-tooltip); pointer-events: none;
  max-width: 300px; 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); line-height: var(--leading-snug); white-space: pre-line;
  animation: fade var(--dur-fast) var(--ease-out);
}

/* ==========================================================================
   SIGN-IN
   ========================================================================== */
.auth-body { background: var(--plane); }
.auth {
  min-height: 100vh;
  display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
}
.auth__panel {
  padding: var(--space-10) var(--space-8);
  display: flex; flex-direction: column; justify-content: center;
  background: var(--surface-1);
  max-width: 480px; width: 100%; margin-inline: auto;
}
.auth__brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-8); }
.auth__brand-title { font-weight: var(--weight-semibold); }
.auth__brand-sub { font-size: var(--text-xs); color: var(--fg-muted); }
.auth__title { font-size: var(--text-2xl); }
.auth__lede { margin-top: var(--space-2); color: var(--fg-secondary); font-size: var(--text-sm); max-width: 46ch; }
.auth__form { margin-top: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.auth__pw { position: relative; display: flex; align-items: center; }
.auth__pw .input { padding-inline-end: 64px; }
.auth__pw-toggle { position: absolute; inset-inline-end: 4px; }
.auth__strength { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-1); }
.auth__strength .progress__bar { background: var(--sev-critical); }
.auth__strength[data-level="2"] .progress__bar { background: var(--sev-warning); }
.auth__strength[data-level="3"] .progress__bar { background: var(--sev-serious); }
.auth__strength[data-level="4"] .progress__bar { background: var(--sev-good); }
.auth__foot { margin-top: var(--space-6); font-size: var(--text-xs); color: var(--fg-muted); line-height: var(--leading-relaxed); }

.auth__aside {
  display: grid; place-items: center; padding: var(--space-10);
  background:
    radial-gradient(120% 90% at 20% 0%, var(--accent-soft) 0%, transparent 60%),
    var(--plane);
  border-inline-start: 1px solid var(--border);
}
.auth__aside-inner { max-width: 46ch; }
.auth__quote { font-size: var(--text-xl); line-height: var(--leading-snug); color: var(--fg-primary); }
.auth__points { margin-top: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); }
.auth__points li { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--fg-secondary); }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__aside { display: none; }
  .auth__panel { padding: var(--space-8) var(--space-5); }
}

/* ==========================================================================
   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: center; flex-direction: row;
    gap: var(--space-2); flex-wrap: wrap;
  }
  .finding__impact-label { margin-inline-end: auto; }
  .summary { flex-direction: column; gap: var(--space-3); }
  .topbar { padding-inline: var(--space-4); }
  .runstate { display: none; }
  .topbar .btn-group .btn:not(:last-child) { display: none; }  /* keep the primary action only */
}
@media (max-width: 600px) {
  .page-title { font-size: var(--text-xl); }
  .stat__value { font-size: var(--text-2xl); }
  .summary__title { font-size: var(--text-lg); }
  .hero-figure { font-size: var(--text-4xl); }
  .table__url { max-width: 22ch; }
  .filter-bar { gap: var(--space-2); }
  .filter-bar .segmented { width: 100%; overflow-x: auto; }
  .page-head__actions { margin-inline-start: 0; width: 100%; }
  /* A card heading and its buttons competing for 320px squeezed the subtitle
     into a two-word-per-line column. Let them stack instead. */
  .card__head { flex-wrap: wrap; }
  .card__actions { margin-inline-start: 0; width: 100%; }
}

/* ==========================================================================
   PRINT — the page IS the report. No separate export template to drift.
   ========================================================================== */
@media print {
  :root { color-scheme: light; }
  .sidebar, .topbar, .app__scrim, .page-head__actions, .chart__tools,
  .toast-stack, .filter-bar, .modal-backdrop, .usermenu,
  .finding__side .btn, .skip-link, .sidebar__filter { display: none !important; }

  /* Buttons in a card header go; a verdict badge in one stays. Dropping the
     whole block took "2 retrieval crawlers blocked" off the printed page and
     left the grid of glyphs it was there to explain. */
  .card__actions .btn, .card__actions form { display: none !important; }
  .card__actions:empty { display: none; }

  .app { grid-template-columns: 1fr; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; font-size: 11pt; }

  .card, .chart, .stat, .summary {
    box-shadow: none; border: 1px solid #ccc; break-inside: avoid;
  }
  .summary { border-inline-start-width: 3px; }
  .grid--sidebar-right, .grid--4 { grid-template-columns: 1fr; }

  /* Evidence is proof: a printed report that hides it is not auditable.
     CSS alone cannot do this — a closed <details> is hidden by the user agent
     through content-visibility, not through its child's display — so app.js
     opens every one on `beforeprint` and closes them again after. This rule
     only removes the now-pointless disclosure triangle. */
  .evidence__toggle { display: none; }
  .finding__evidence { white-space: pre-wrap; }

  /* A filtered view must not print as though it were the whole list.
     `display: revert` was wrong here: it reverts to the user-agent origin,
     which is exactly where `[hidden] { display: none }` lives, so the rule
     computed to none and did nothing. Name the layout each element needs. */
  .finding[hidden] { display: grid !important; }
  .table tbody tr[hidden] { display: table-row !important; }
  .nav-item[hidden] { display: none !important; }

  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; word-break: break-all; }
  .finding, .table tbody tr { break-inside: avoid; }
  h1, h2 { break-after: avoid; }

  /* A filed PDF that says "17 hours ago" and nothing else is undateable, so the
     footer with the "times are UTC" note stays, and app.js restores the exact
     stamp in the <time> elements before the dialog opens. */
  .appfoot { display: flex !important; border-top: 1px solid #ccc; color: #555; }
}

/* ==========================================================================
   SITE ANALYZE · CALENDAR · ARTICLES
   Added with the content pipeline. Same tokens, no new colours.
   ========================================================================== */

/* ---------- country picker ---------------------------------------------- */
.picker {
  display: grid; gap: var(--space-1);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-height: 460px; overflow-y: auto;
}
.picker__item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); cursor: pointer;
  box-shadow: var(--ring);
  transition: background var(--dur-fast) var(--ease-out);
}
.picker__item:hover { background: var(--surface-2); }
.picker__item.is-on { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.picker__label { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.picker__name { font-size: var(--text-sm); }
.picker__meta { font-size: var(--text-2xs); color: var(--fg-muted); }
/* The primary radio is a small, quiet affordance — it is a tie-breaker, not a
   second decision competing with the checkbox. */
.picker__primary { margin-inline-start: auto; accent-color: var(--accent); }
.picker__item[hidden] { display: none; }

/* ---------- calendar slots ----------------------------------------------- */
.slot {
  display: grid; grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: var(--space-4); align-items: start;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.slot:last-child { border-bottom: 0; }
.slot:hover { background: var(--surface-2); }
.slot--empty { opacity: .72; }
.slot--published { background: color-mix(in oklab, var(--sev-good-bg) 35%, transparent); }

.slot__when { text-align: center; padding-top: 2px; }
.slot__day {
  font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); color: var(--fg-muted);
}
.slot__date { font-size: var(--text-lg); font-weight: var(--weight-semibold); line-height: 1.1; }
.slot__no { font-size: var(--text-2xs); color: var(--fg-muted); }
.slot__body { min-width: 0; }
.slot__title { font-size: var(--text-md); font-weight: var(--weight-medium); }
.slot__meta {
  margin-top: var(--space-1); display: flex; flex-wrap: wrap;
  gap: var(--space-2); align-items: center;
}
.slot__actions { display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-end; }

/* ---------- brief ---------------------------------------------------------- */
.brief { padding: var(--space-3) 0 0; }
.brief__grid {
  display: grid; gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.brief__grid > div { display: flex; flex-direction: column; }
.brief__k {
  font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); color: var(--fg-muted);
}
.brief__v { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

/* ---------- article ------------------------------------------------------ */
.article-hero { margin-bottom: var(--space-5); }
.article-hero img { border-radius: var(--radius-lg); width: 100%; }
.article-hero figcaption { margin-top: var(--space-2); }
.thumb { border-radius: var(--radius-md); width: 100%; box-shadow: var(--ring); }

/* Reading measure, not full width. A 1,900-word article set across 1,200px is
   a page nobody finishes, and finishing it is the entire review. */
.prose { max-width: 72ch; font-size: var(--text-lg); line-height: var(--leading-relaxed); }
.prose h1, .prose h2, .prose h3 { margin-top: var(--space-8); margin-bottom: var(--space-2); }
.prose h2 { font-size: var(--text-xl); }
.prose h3 { font-size: var(--text-lg); }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table { margin-bottom: var(--space-4); }
.prose ul, .prose ol { padding-inline-start: var(--space-6); }
.prose ul li { list-style: disc; }
.prose ol li { list-style: decimal; }
.prose li { margin-bottom: var(--space-1); }
.prose blockquote {
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: var(--space-4); color: var(--fg-secondary);
}
.prose table { width: 100%; border-collapse: collapse; font-size: var(--text-md); }
.prose th, .prose td { border: 1px solid var(--border); padding: var(--space-2) var(--space-3); text-align: start; }
.prose th { background: var(--surface-2); font-size: var(--text-sm); }
.prose pre { background: var(--surface-2); padding: var(--space-4); border-radius: var(--radius-md); overflow-x: auto; }
.prose code { background: var(--surface-2); padding: 1px 4px; border-radius: var(--radius-xs); }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-8) 0; }

/* Numeric claims, listed so they get checked rather than skimmed. */
.claims { display: flex; flex-direction: column; }
.claims__item {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm); color: var(--fg-secondary);
}
.claims__item:last-child { border-bottom: 0; }
.claims__item:hover { background: var(--surface-2); color: var(--fg-primary); }

.nav-item__count--alert {
  background: var(--sev-warning-bg); color: var(--sev-warning-ink);
  border-radius: var(--radius-full); padding: 0 6px; font-weight: var(--weight-semibold);
}

@media (max-width: 900px) {
  .slot { grid-template-columns: 64px minmax(0, 1fr); }
  .slot__actions { grid-column: 2; flex-direction: row; align-items: center; }
  .prose { font-size: var(--text-md); }
}

@media print {
  /* An article prints as the article. */
  /* The Read/Edit toggle sits in the card head, a SIBLING of .article-read —
     never inside it — so ".article-read .segmented" matched nothing and the
     toggle printed on every article. Target the control itself. */
  .slot__actions,
  .segmented:has([data-article-view]),
  [data-article-view],
  [data-article-pane="edit"],
  .page-head__actions,
  [data-print] { display: none !important; }
  .prose { max-width: none; font-size: 11pt; }
  .picker { max-height: none; overflow: visible; }
}

/* Revision history on the article screen.
   Not built on .evidence: those summaries are single-line and this needs a
   note, a timestamp and an action stacked in a narrow sidebar column, where an
   inline-flex summary wrapped into an unreadable tangle. */
.revisions { list-style: none; margin: 0; padding: 0; }
.revisions__item {
  padding: var(--space-3) var(--space-4);
  border-block-start: 1px solid var(--border-subtle);
  display: grid; gap: var(--space-1); justify-items: start;
}
.revisions__item:first-child { border-block-start: 0; }
.revisions__note { font-size: var(--text-sm); color: var(--fg-primary); }
.revisions__meta { font-size: var(--text-xs); color: var(--fg-muted); }
.revisions__item form { margin-block-start: var(--space-1); }
