/* Portal shell and shared components (DESIGN.md, STAT-423/424). Loaded last on portal pages, after custom.css and
   ui-consistency.css, and uses the tokens from tokens.css so both themes follow the same palette. */

/* ── Icons ─────────────────────────────────────────────────────── */
.ls-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.ls-icon-sm {
  width: 0.95rem;
  height: 0.95rem;
}

/* Report status icons (softjoy_tags STATUS_ICON_PATHS): symbol and colour per status */
.sp-app-main .sp-note-ok {
  color: var(--ls-pass);
}

.sp-app-main .sp-note-note {
  color: var(--ls-link);
}

.sp-app-main .sp-note-warning {
  color: var(--ls-warn);
}

.sp-app-main .sp-note-info {
  color: var(--ls-muted);
}

/* ── Badges (status needs text as well as colour) ──────────────── */
.ls-badge {
  text-decoration: none;
  background: var(--ls-neutral-soft);
  color: var(--ls-text);
}

.ls-badge-pass {
  background: var(--ls-pass-soft);
  color: var(--ls-pass);
}

.ls-badge-warn {
  background: var(--ls-warn-soft);
  color: var(--ls-warn);
}

.ls-badge-fail {
  background: var(--ls-fail-soft);
  color: var(--ls-fail);
}

a.ls-badge:hover,
a.ls-badge:focus-visible {
  text-decoration: underline;
}

/* ── App shell ─────────────────────────────────────────────────── */
/* The sidebar is a dark band along the left edge, full height (owner 2026-10-12); the content has its own padding. */
.sp-app-shell {
  --sp-sidebar-width: 212px;
  --sp-sidebar-collapsed-width: 64px;
  gap: 0;
  padding: 0;
}

.sp-app-main {
  width: 100%;
  /* Content uses the same width as the top bar (owner 2026-10-13) */
  max-width: none;
  gap: 1.25rem;
  padding: 1rem 1.5rem 2rem;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
/* Full-height band that stays in place; no visible scrollbar (on very short screens it can still be scrolled). */
.sp-app-shell .sp-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
  background: var(--ls-panel);
  border: 0;
  border-right: 1px solid var(--ls-line);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.sp-app-shell .sp-sidebar::-webkit-scrollbar {
  display: none;
}

.sp-app-shell .sp-sidebar .offcanvas-body {
  padding: 0.75rem 0.6rem 0.9rem;
}

.sp-sidebar .ls-sidebar-header {
  padding: 0.15rem 0.4rem 0.6rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--ls-line);
}

.sp-sidebar .sp-logo-link img {
  width: 140px;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.sp-sidebar .links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sp-sidebar .sp-sidebar-group {
  margin: 0.7rem 0.6rem 0.2rem;
  color: var(--ls-faint);
  opacity: 1; /* custom.css dims it to 0.6, which drops the contrast below 4.5:1 (STAT-430) */
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sp-sidebar .sp-sidebar-link {
  gap: 0.6rem;
  padding: 0.3rem 0.6rem;
  min-height: 32px;
  border-radius: var(--ls-radius-sm);
  color: var(--ls-muted);
  font-weight: 500;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sp-sidebar .sp-sidebar-icon {
  display: inline-flex;
  color: var(--ls-faint);
}

.sp-sidebar .sp-sidebar-link:hover,
.sp-sidebar .sp-sidebar-link:focus-visible {
  background: var(--ls-accent-soft);
  color: var(--ls-text);
}

.sp-sidebar .sp-sidebar-link:hover .sp-sidebar-icon,
.sp-sidebar .sp-sidebar-link:focus-visible .sp-sidebar-icon {
  color: var(--ls-link);
}

.sp-sidebar .sp-sidebar-link.active {
  background: var(--ls-accent-soft);
  border-color: var(--ls-line-strong);
  color: var(--ls-text);
  font-weight: 600;
}

.sp-sidebar .sp-sidebar-link.active .sp-sidebar-icon {
  color: var(--ls-link);
}

.sp-sidebar .sp-sidebar-label {
  font-size: 0.875rem;
  line-height: 1.3;
}

.sp-sidebar .sp-sidebar-icon .ls-icon {
  width: 1.1rem;
  height: 1.1rem;
}

/* Collapsed sidebar: the group headings become divider lines and the logo shrinks to the shield (owner 2026-10-12) */
body[data-sidebar="collapsed"] .sp-sidebar .sp-sidebar-group,
body.sidebar-collapsed .sp-sidebar .sp-sidebar-group {
  display: block;
  height: 1px;
  margin: 0.6rem 0.75rem;
  overflow: hidden;
  background: var(--ls-line-strong);
  color: transparent;
}

body[data-sidebar="collapsed"] .sp-sidebar .ls-sidebar-header,
body.sidebar-collapsed .sp-sidebar .ls-sidebar-header {
  display: flex;
  justify-content: center;
  padding: 0.15rem 0 0.5rem;
}

body[data-sidebar="collapsed"] .sp-sidebar .sp-logo-link img,
body.sidebar-collapsed .sp-sidebar .sp-logo-link img {
  width: 40px;
  object-fit: cover;
  object-position: left center;
  height: 35px;
}

/* Light theme: the sidebar stays dark navy like the logo and the public site (owner 2026-10-12). The dark tokens are
   re-scoped on the sidebar, so all sidebar rules above keep working. */
html[data-bs-theme="light"] .sp-app-shell .sp-sidebar {
  color-scheme: dark;
  --ls-panel: #0b1631;
  --ls-text: #e8eef6;
  --ls-muted: #b6c3d3;
  --ls-faint: #8a9bb1;
  --ls-line: rgba(148, 197, 230, 0.16);
  --ls-line-strong: rgba(125, 211, 252, 0.34);
  --ls-link: #7dd3fc;
  --ls-accent-soft: rgba(125, 211, 252, 0.14);
  border-color: transparent;
}

html[data-bs-theme="light"] .sp-sidebar .sp-logo-dark {
  display: inline-block;
}

html[data-bs-theme="light"] .sp-sidebar .sp-logo-light {
  display: none;
}

/* ── Top bar ───────────────────────────────────────────────────── */
.sp-app-main .sp-topbar {
  padding: 0.7rem 1rem;
  background: var(--ls-panel);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
  box-shadow: var(--ls-shadow);
  backdrop-filter: none;
}

.sp-topbar .sp-sidebar-toggle-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius-sm);
  background: transparent;
  color: var(--ls-muted);
}

.sp-topbar .sp-sidebar-toggle-btn:hover,
.sp-topbar .sp-sidebar-toggle-btn:focus-visible {
  background: var(--ls-accent-soft);
  color: var(--ls-text);
}

.sp-topbar .sp-topbar-account {
  gap: 0;
  min-width: 0;
}

.sp-topbar .sp-topbar-eyebrow {
  color: var(--ls-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sp-topbar .sp-topbar-account-title {
  color: var(--ls-text);
  font-size: 1.05rem;
  font-weight: 600;
}

.sp-topbar a.sp-topbar-account-title:hover,
.sp-topbar a.sp-topbar-account-title:focus-visible {
  color: var(--ls-link);
}

.sp-topbar .form-select,
html[data-bs-theme="light"] .sp-topbar .form-select {
  min-width: 14rem;
  border: 1px solid var(--ls-line-strong);
  border-radius: 999px;
  background-color: var(--ls-surface);
  color: var(--ls-text);
  font-weight: 500;
}

.sp-topbar .sp-user-trigger {
  width: 40px;
  height: 40px;
  border: 1px solid var(--ls-line-strong);
  background: var(--ls-accent-soft);
  color: var(--ls-text);
  font-weight: 700;
}

/* The light-theme selector outranks custom.css's translucent light panel, so page text never shows through (STAT-516) */
.sp-topbar .sp-user-menu .sp-user-panel,
html[data-bs-theme="light"] .sp-topbar .sp-user-menu .sp-user-panel {
  min-width: 17rem;
  padding: 0.5rem;
  background: var(--ls-panel);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
  box-shadow: var(--ls-shadow);
}

.sp-user-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.5rem 0.6rem;
}

.sp-user-identity .sp-user-name {
  color: var(--ls-text);
  overflow-wrap: anywhere;
}

.sp-user-identity .sp-user-type {
  color: var(--ls-muted);
  font-size: 0.85rem;
}

.sp-user-identity .sp-mfa-status-badge {
  margin: 0.25rem 0 0;
}

.sp-user-panel .sp-user-section-title {
  display: block;
  margin: 0.6rem 0.6rem 0.3rem;
  color: var(--ls-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sp-user-panel .sp-language-form {
  display: block;
  padding: 0 0.6rem;
}

.sp-user-panel .sp-language-select {
  width: 100%;
}

.sp-user-panel .sp-user-action {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: var(--ls-radius-sm);
  background: transparent;
  color: var(--ls-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
}

.sp-user-panel .sp-user-action:hover,
.sp-user-panel .sp-user-action:focus-visible {
  background: var(--ls-accent-soft);
}

.sp-user-panel .sp-user-action-danger {
  color: var(--ls-fail);
}

.sp-user-panel .sp-user-divider {
  margin: 0.4rem 0;
  border-top: 1px solid var(--ls-line);
}

.sp-user-panel form {
  display: block;
}

/* The theme button shows the theme it switches to */
.sp-theme-icon-light,
.sp-theme-icon-dark {
  display: inline-flex;
}

html[data-bs-theme="dark"] .sp-theme-icon-dark,
html[data-bs-theme="light"] .sp-theme-icon-light {
  display: none;
}

/* ── Focus ─────────────────────────────────────────────────────── */
.sp-app-shell :focus-visible {
  outline: 2px solid var(--ls-accent);
  outline-offset: 2px;
}

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sp-app-main {
    padding: 0.75rem 1rem 1.5rem;
  }

  /* The sidebar is a drawer over the page, opened with the menu button in the top bar (sidebar.js) */
  .sp-app-shell,
  body[data-sidebar] .sp-app-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0;
  }

  .sp-app-shell .sp-sidebar,
  body[data-sidebar] .sp-app-shell .sp-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    width: min(18rem, 85vw);
    min-width: 0;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    border-right: 1px solid var(--ls-line);
    box-shadow: var(--ls-shadow);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }

  body[data-sidebar="mobile-open"] .sp-app-shell .sp-sidebar {
    transform: none;
    visibility: visible;
  }

  body[data-sidebar="mobile-open"] {
    overflow: hidden;
  }

  .sp-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(2, 6, 14, 0.6);
  }

  .sp-sidebar-backdrop[hidden] {
    display: none;
  }

  /* Top bar stays one compact row; the account switcher takes the remaining width */
  .sp-topbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
  }

  .sp-topbar-right {
    flex: 1 1 14rem;
    justify-content: flex-end;
    min-width: 0;
  }

  .sp-topbar-field {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 20rem;
  }

  /* Without an account switcher (non-consultants) the right side only holds the user menu, so the bar stays one row */
  .sp-topbar-right:not(:has(.sp-account-selector)) {
    flex: 0 0 auto;
  }

  .sp-topbar-field:not(:has(.sp-account-selector)) {
    display: none;
  }

  .sp-topbar .form-select,
  html[data-bs-theme="light"] .sp-topbar .form-select {
    min-width: 0;
    max-width: 12rem;
  }

  /* The user panel aligns with the top bar instead of the round trigger, so it stays inside the screen (STAT-516) */
  .sp-topbar .sp-user-menu {
    position: static;
  }

  .sp-topbar .sp-user-menu .sp-user-panel,
  html[data-bs-theme="light"] .sp-topbar .sp-user-menu .sp-user-panel {
    right: 0;
    min-width: 0;
    width: min(20rem, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sp-app-shell .sp-sidebar,
  .sp-sidebar .sp-sidebar-link,
  .sp-user-panel .sp-user-action {
    transition: none;
  }
}

/* ══ Component layer (STAT-424) ═══════════════════════════════════
   Restyles the Bootstrap and legacy portal components on every portal page with the shared tokens, so all pages get
   the same cards, tables, badges, buttons, forms and alerts in both themes. Page-specific layouts stay in their files. */

/* ── Cards and sections ────────────────────────────────────────── */
.sp-app-main .card,
.sp-app-main main article,
.sp-app-main .sp-glass:not(.sp-topbar) {
  background: var(--ls-panel);
  color: var(--ls-text);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
  box-shadow: var(--ls-shadow);
  backdrop-filter: none;
}

.sp-app-main main article article,
.sp-app-main .card .card {
  background: var(--ls-surface);
  box-shadow: none;
}

.sp-app-main main h1 {
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ls-text);
}

.sp-app-main main h2 {
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--ls-text);
}

.sp-app-main main h3 {
  font-size: 1rem;
  font-weight: 650;
}

/* Headings promoted to h2 for a correct outline (STAT-430) keep the size of the level they had:
   .h3 = the portal h3 above, .h4 = Bootstrap's h4 */
.sp-app-main main h2.h3 {
  font-size: 1rem;
}

/* Host report summary cards: h6 promoted to h2 (STAT-520) */
.sp-app-main main h2.h6 {
  font-size: 1rem;
  font-weight: 500;
}

.sp-app-main main h2.h4 {
  font-size: calc(1.275rem + 0.3vw);
  font-weight: 500;
}

@media (min-width: 1200px) {
  .sp-app-main main h2.h4 {
    font-size: 1.5rem;
  }
}

.sp-app-main main p,
.sp-app-main main small,
.sp-app-main .text-muted {
  color: var(--ls-muted) !important;
}

.sp-app-main main small {
  font-size: 0.875rem;
}

/* Eyebrow above a heading, as on the public site */
.ls-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--ls-link) !important;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ── Page header component (templates/components/page_header.html) ── */
.ls-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0 1.25rem;
}

.ls-page-header h1 {
  margin: 0;
}

.ls-page-header .ls-page-purpose {
  max-width: 72ch;
  margin: 0.4rem 0 0;
}

.ls-page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Badges: Bootstrap text-bg-* become soft status badges ──────── */
/* One badge size everywhere (owner 2026-10-12): Bootstrap .badge, .ls-badge and the table badges .sp-badge */
.sp-app-main .badge,
.sp-app-main .sp-badge,
.sp-app-main .sp-domain-status,
.ls-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}

/* Table badges (scanner/tables.py) on the token palette: A pass, B info, C neutral, D warn, E/F fail */
.sp-app-main .sp-status-success,
.sp-app-main .sp-status-grade-a {
  background: var(--ls-pass-soft);
  color: var(--ls-pass);
}

.sp-app-main .sp-status-info,
.sp-app-main .sp-status-grade-b {
  background: var(--ls-accent-soft);
  color: var(--ls-link);
}

.sp-app-main .sp-status-neutral,
.sp-app-main .sp-status-grade-c {
  background: var(--ls-neutral-soft);
  color: var(--ls-text);
}

.sp-app-main .sp-status-warning,
.sp-app-main .sp-status-grade-d {
  background: var(--ls-warn-soft);
  color: var(--ls-warn);
}

.sp-app-main .sp-status-danger,
.sp-app-main .sp-status-grade-f {
  background: var(--ls-fail-soft);
  color: var(--ls-fail);
}

/* Report status badges (scanner/views.py status classes); long values may wrap inside the summary cards */
.sp-app-main .sp-domain-status {
  max-width: 100%;
  border: 0;
  white-space: normal;
  text-align: center;
}

.sp-app-main .sp-domain-status-success {
  background: var(--ls-pass-soft);
  color: var(--ls-pass);
}

.sp-app-main .sp-domain-status-warning {
  background: var(--ls-warn-soft);
  color: var(--ls-warn);
}

.sp-app-main .sp-domain-status-danger {
  background: var(--ls-fail-soft);
  color: var(--ls-fail);
}

.sp-app-main .sp-domain-status-neutral {
  background: var(--ls-accent-soft);
  color: var(--ls-link);
}

/* Grade and redirect badges side by side in table cells */
.sp-app-main td .sp-grade-badges {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin-left: 0;
}

.sp-app-main .badge.text-bg-danger {
  background-color: var(--ls-fail-soft) !important;
  color: var(--ls-fail) !important;
}

.sp-app-main .badge.text-bg-warning {
  background-color: var(--ls-warn-soft) !important;
  color: var(--ls-warn) !important;
}

.sp-app-main .badge.text-bg-success {
  background-color: var(--ls-pass-soft) !important;
  color: var(--ls-pass) !important;
}

.sp-app-main .badge.text-bg-secondary,
.sp-app-main .badge.text-bg-light,
.sp-app-main .badge.text-bg-dark {
  background-color: var(--ls-neutral-soft) !important;
  color: var(--ls-text) !important;
}

.sp-app-main .badge.text-bg-primary,
.sp-app-main .badge.text-bg-info {
  background-color: var(--ls-accent-soft) !important;
  color: var(--ls-link) !important;
}

/* The small "i" help pills */
.sp-app-main .ls-info-pill {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--ls-line-strong);
  background: transparent !important;
  color: var(--ls-muted) !important;
  font-family: var(--ls-font);
  cursor: help;
}

/* ── Grade badge component (templates/components/grade_badge.html) ── */
.ls-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: 10px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  background: var(--ls-neutral-soft);
  color: var(--ls-text);
}

.ls-grade-lg {
  min-width: 3.5rem;
  height: 3.5rem;
  border-radius: 14px;
  font-size: 1.6rem;
}

.ls-grade-xl {
  min-width: 4.5rem;
  height: 4.5rem;
  padding: 0 0.75rem;
  border-radius: 18px;
  font-size: 2rem;
}

.ls-grade-info {
  background: var(--ls-accent-soft);
  color: var(--ls-link);
}

.ls-grade-pass {
  background: var(--ls-pass-soft);
  color: var(--ls-pass);
}

.ls-grade-warn {
  background: var(--ls-warn-soft);
  color: var(--ls-warn);
}

.ls-grade-fail {
  background: var(--ls-fail-soft);
  color: var(--ls-fail);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.sp-app-main .btn {
  border-radius: 999px;
  font-weight: 600;
}

.sp-app-main .btn-sm {
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

.sp-app-main .btn-outline-primary,
.sp-app-main .btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--ls-line-strong);
  color: var(--ls-link);
}

.sp-app-main .btn-outline-primary:hover,
.sp-app-main .btn-outline-primary:focus-visible,
.sp-app-main .btn-outline-secondary:hover,
.sp-app-main .btn-outline-secondary:focus-visible {
  background: var(--ls-accent-soft);
  border-color: var(--ls-link);
  color: var(--ls-text);
}

.sp-app-main .btn-outline-danger {
  background: transparent;
  border: 1px solid var(--ls-fail);
  color: var(--ls-fail);
}

.sp-app-main .btn-outline-danger:hover,
.sp-app-main .btn-outline-danger:focus-visible {
  background: var(--ls-fail-soft);
  color: var(--ls-fail);
}

.sp-app-main .btn-primary,
html[data-bs-theme="light"] .sp-app-main .btn-primary {
  box-shadow: none;
}

/* Form actions (STAT-507): one row under every form, buttons as wide as their text, Delete set apart on the right.
   Save is the primary button with the save icon, Cancel a quiet link with the close icon, Delete outlined in danger
   with the trash icon. The row wraps on narrow screens. Here, not in ui-consistency.css, because the supplier portal
   loads portal.css only; the icon gap is repeated for the same reason. */
.ls-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1.5rem;
}

.ls-form-actions .sp-btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ls-form-actions-danger {
  margin-left: auto;
}

/* ── Tables ────────────────────────────────────────────────────── */
.sp-app-main .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ls-text);
  --bs-table-border-color: var(--ls-line);
  --bs-table-striped-bg: var(--ls-neutral-soft);
  --bs-table-striped-color: var(--ls-text);
  --bs-table-hover-bg: var(--ls-accent-soft);
  --bs-table-hover-color: var(--ls-text);
  --bs-table-active-bg: var(--ls-accent-soft);
  color: var(--ls-text);
  font-variant-numeric: tabular-nums;
}

.sp-app-main .table > :not(caption) > * > * {
  background-color: var(--bs-table-bg);
  border-bottom-color: var(--ls-line);
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}

/* Links in list rows are at least 24 px high (WCAG 2.5.8 target size; Lighthouse measured 21 px, STAT-496) */
.sp-app-main .sp-table tbody td a:not(.btn, .badge, .ls-risk-badge) {
  display: inline-block;
  min-height: 24px;
  padding-block: 2px;
}

/* django-tables2 lists render class "sp-table" without Bootstrap's "table": same header style (STAT-529) */
.sp-app-main :is(.table, .sp-table) thead th,
.sp-app-main :is(.table, .sp-table) thead th a {
  color: var(--ls-faint);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* One header style for every portal table (STAT-529): the sort buttons in the DMARC top lists look like the other
   headers instead of light-blue links */
.sp-app-main :is(.table, .sp-table) thead th .sp-th-sort {
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  white-space: inherit;
}

/* Sortable headers show an arrow, not only a link colour: up-down until the column is sorted. The sorted column's
   arrow is the up or down arrow (django-tables2 th.asc/th.desc; the top lists write it in the button text) */
.sp-app-main :is(.table, .sp-table) thead th.orderable > a::after,
.sp-app-main :is(.table, .sp-table) thead th[aria-sort="none"] .sp-th-sort::after {
  content: " \2195";
  content: " \2195" / "";
  opacity: 0.85;  /* at least 3:1 against the header background in both themes (STAT-529 review) */
}

.sp-app-main :is(.table, .sp-table) thead th.orderable.asc > a::after {
  content: " \2191";
  content: " \2191" / "";
  opacity: 1;
}

.sp-app-main :is(.table, .sp-table) thead th.orderable.desc > a::after {
  content: " \2193";
  content: " \2193" / "";
  opacity: 1;
}

/* Tables sorted in the browser by sortable.js get the same arrows; the script writes aria-sort on the clicked header */
.sp-app-main table.sortable thead th:not(.no-sort)::after {
  content: " \2195";
  content: " \2195" / "";
  opacity: 0.85;
}

.sp-app-main table.sortable thead th:not(.no-sort)[aria-sort="ascending"]::after {
  content: " \2191";
  content: " \2191" / "";
  opacity: 1;
}

.sp-app-main table.sortable thead th:not(.no-sort)[aria-sort="descending"]::after {
  content: " \2193";
  content: " \2193" / "";
  opacity: 1;
}

.sp-app-main :is(.table, .sp-table) thead th .sp-th-sort:focus-visible {
  outline: 2px solid var(--ls-accent);
  outline-offset: 2px;
}

.sp-app-main .table tbody tr:hover > * {
  background-color: var(--ls-accent-soft);
}

/* ── Alerts ────────────────────────────────────────────────────── */
.sp-app-main .alert {
  border: 1px solid var(--ls-line);
  border-left-width: 4px;
  border-radius: var(--ls-radius-sm);
  background: var(--ls-surface);
  color: var(--ls-text);
}

.sp-app-main .alert-info,
.sp-app-main .alert-primary,
.sp-app-main .alert-secondary {
  border-left-color: var(--ls-accent);
}

.sp-app-main .alert-warning {
  border-left-color: var(--ls-warn);
  background: var(--ls-warn-soft);
}

.sp-app-main .alert-danger {
  border-left-color: var(--ls-fail);
  background: var(--ls-fail-soft);
}

.sp-app-main .alert-success {
  border-left-color: var(--ls-pass);
  background: var(--ls-pass-soft);
}

.sp-app-main .alert p,
.sp-app-main .alert small {
  color: var(--ls-text) !important;
}

/* ── Forms ─────────────────────────────────────────────────────── */
.sp-app-main main .form-control,
.sp-app-main main .form-select,
.sp-app-main main input[type="text"],
.sp-app-main main input[type="search"],
.sp-app-main main input[type="email"],
.sp-app-main main input[type="number"],
.sp-app-main main input[type="url"],
.sp-app-main main textarea,
.sp-app-main main select {
  background-color: var(--ls-surface);
  border: 1px solid var(--ls-faint);
  border-radius: var(--ls-radius-sm);
  color: var(--ls-text);
}

.sp-app-main main .form-control::placeholder {
  color: var(--ls-faint);
}

.sp-app-main main .form-control:focus,
.sp-app-main main .form-select:focus,
.sp-app-main main input:focus,
.sp-app-main main textarea:focus,
.sp-app-main main select:focus {
  border-color: var(--ls-accent);
  box-shadow: 0 0 0 3px var(--ls-accent-soft);
  outline: none;
}

.sp-app-main main label,
.sp-app-main main .form-label {
  color: var(--ls-muted);
  font-weight: 600;
}

/* ── Metric lists (label left, value right) ────────────────────── */
.sp-app-main .ls-metric-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ls-line);
}

.sp-app-main .ls-metric-list > div:last-child {
  border-bottom: 0;
}

.sp-app-main .ls-metric-list small {
  color: var(--ls-muted) !important;
  font-size: 0.9rem;
}

/* ── Empty state component (templates/components/empty_state.html) ── */
.ls-empty {
  display: grid;
  justify-items: start;
  gap: 0.5rem;
  padding: 1.5rem;
  border: 1px dashed var(--ls-line-strong);
  border-radius: var(--ls-radius);
  background: var(--ls-surface);
}

.ls-empty-icon {
  display: inline-flex;
  padding: 0.6rem;
  border-radius: 12px;
  background: var(--ls-accent-soft);
  color: var(--ls-link);
}

.ls-empty h2,
.ls-empty h3 {
  margin: 0;
  font-size: 1.05rem;
}

.ls-empty p {
  margin: 0;
  max-width: 60ch;
}

/* ── Pagination ────────────────────────────────────────────────── */
.sp-app-main .pagination {
  --bs-pagination-bg: transparent;
  --bs-pagination-color: var(--ls-link);
  --bs-pagination-border-color: var(--ls-line);
  --bs-pagination-hover-bg: var(--ls-accent-soft);
  --bs-pagination-hover-color: var(--ls-text);
  --bs-pagination-active-bg: var(--ls-button);
  --bs-pagination-active-border-color: var(--ls-button);
  --bs-pagination-active-color: var(--ls-button-text);
  --bs-pagination-disabled-bg: transparent;
  --bs-pagination-disabled-color: var(--ls-faint);
}

/* ── Page wrappers: header above the content, not beside it ────── */
.sp-app-main .sp-form-page {
  flex-direction: column;
  align-items: center;
}

.sp-app-main .sp-form-page > .ls-page-header {
  align-self: stretch;
}

/* ── DMARC Insights: legacy blue panels follow the tokens (STAT-428) ── */
html .sp-app-main .sp-dmarc-page .sp-dmarc-page-card {
  background: var(--ls-panel);
  border-color: var(--ls-line);
}

html .sp-app-main .sp-dmarc-page .card {
  background: var(--ls-surface);
  border-color: var(--ls-line);
  box-shadow: none;
}

html .sp-app-main .sp-dmarc-page .sp-dmarc-top-list-table thead {
  background-color: transparent !important;
}

/* The top lists' header row sticks to the top of its scroll box, so it needs the card's own, opaque colour; transparent,
   as above, let the rows scroll through the header (owner 2026-11-15). The cells get it, as a sticky thead's own
   background is not painted behind its cells in every browser. */
html .sp-app-main .sp-dmarc-page .sp-dmarc-top-list-table thead.sp-dmarc-thead-sticky,
html .sp-app-main .sp-dmarc-page .sp-dmarc-top-list-table thead.sp-dmarc-thead-sticky > tr > th {
  background-color: var(--ls-surface) !important;
}

html .sp-app-main .sp-dmarc-page .sp-dmarc-top-list-table tbody td {
  border-color: var(--ls-line);
}

/* ── Network Scan targets as cards (STAT-428) ──────────────────── */
.sp-app-main .scantarget-item > details {
  background: var(--ls-panel);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
  box-shadow: var(--ls-shadow);
  padding: 1rem 1.25rem;
}

.sp-app-main .scantarget-item > details > summary,
.sp-app-main .ls-inline-details > summary {
  position: relative;
  list-style: none;
  cursor: pointer;
}

.sp-app-main .scantarget-item > details > summary {
  padding-left: 1.75rem;
}

.sp-app-main .scantarget-item > details > summary::-webkit-details-marker,
.sp-app-main .ls-inline-details > summary::-webkit-details-marker {
  display: none;
}

/* Chevron that turns when the card opens */
.sp-app-main .scantarget-item > details > summary::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.45rem;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--ls-muted);
  border-bottom: 2px solid var(--ls-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.sp-app-main .scantarget-item > details[open] > summary::before {
  transform: rotate(45deg);
}

.sp-app-main .scantarget-item h6 {
  color: var(--ls-text);
  font-size: 1rem;
  font-weight: 650;
}

.sp-app-main .ls-inline-details > summary {
  display: inline-block;
  color: var(--ls-link);
  font-weight: 600;
}

.sp-app-main .ls-inline-details > summary::after {
  content: " +";
}

.sp-app-main .ls-inline-details[open] > summary::after {
  content: " −";
}

@media (prefers-reduced-motion: reduce) {
  .sp-app-main .scantarget-item > details > summary::before {
    transition: none;
  }
}

/* ── Search form and hints in list pages ───────────────────────── */
.sp-app-main .ls-search-form {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  max-width: 32rem;
  margin-bottom: 1rem;
}

.sp-app-main .ls-hint {
  margin: 0.75rem 0 0;
  color: var(--ls-faint) !important;
  font-size: 0.85rem;
}

/* ── Nav tabs (list/map and report tabs) ───────────────────────── */
/* One tab component for the portal (STAT-529): an underlined row; on a wide screen it wraps when the tabs need more room */
.sp-app-main .nav-tabs {
  border-bottom: 1px solid var(--ls-line);
}

/* Square corners and no fill: the global button rule in custom.css would draw the tab as a grey pill.
   No negative bottom margin, so the 2 px underline is not cut off where the row scrolls on a phone. */
.sp-app-main .nav-tabs .nav-link {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--ls-muted);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0;
  padding: 0.5rem 0.8rem;
  white-space: nowrap;
}

/* Phones: the row stays on one line and scrolls sideways; the cut-off last tab shows there is more */
@media (max-width: 575.98px) {
  .sp-app-main .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .sp-app-main .nav-tabs::-webkit-scrollbar {
    display: none;
  }
}

.sp-app-main .nav-tabs .nav-link:hover {
  color: var(--ls-text);
}

.sp-app-main .nav-tabs .nav-link:focus-visible {
  box-shadow: none;
  outline: 2px solid var(--ls-accent);
  outline-offset: -2px;
}

.sp-app-main .nav-tabs .nav-link.active {
  background: transparent;
  border-bottom-color: var(--ls-accent);
  color: var(--ls-text);
}

/* ── Charts (ECharts containers, STAT-425) ─────────────────────── */
.ls-chart {
  width: 100%;
  height: 260px;
}

.ls-chart-timeline {
  height: 240px;
}

.sp-app-main .chartBox {
  max-height: none;
  padding: 0.5rem 0;
}

/* ── Report headers (domain, server, organisation reports; STAT-424) ── */
.ls-report-header {
  align-items: flex-start;
}

.ls-report-header-main {
  flex: 1 1 32rem;
  min-width: 0;
}

.sp-app-main main .ls-report-header h1 {
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  overflow-wrap: anywhere;
}

.ls-report-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

/* Grade and score together in one card (domain report, STAT-530) */
.ls-report-grade-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.9rem;
  background: var(--ls-panel);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
}

.ls-report-grade-score {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ls-report-grade-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ls-faint);
}

.ls-report-grade-score strong {
  font-size: 1.5rem;
}

.ls-report-grade-max {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ls-faint);
}

.ls-report-meta {
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem 1.5rem;
}

.ls-report-meta dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ls-faint);
}

.ls-report-meta dd {
  margin: 0.2rem 0 0;
  font-weight: 600;
}

.sp-app-main .sp-host-report-summary {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.sp-app-main .sp-host-summary-card {
  display: block;
  padding: 1rem;
  text-align: center;
  background: var(--ls-panel);
  border: 1px solid var(--ls-line);
  border-radius: var(--ls-radius);
}

.sp-app-main .sp-host-summary-card .ls-grade {
  margin: 0.25rem auto;
}

.sp-app-main .sp-host-report-grade-grid {
  align-items: start;
}

.sp-app-main .sp-host-report-grade-grid > .ls-grade {
  justify-self: end;
}

@media (max-width: 640px) {
  .ls-report-header-side {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: space-between;
  }
}

/* Report score cells (includes/tablerow_score.html) as soft tints on the web; the PDF keeps its own colours */
.sp-app-main td[class*="score-"] {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sp-app-main td.score-darkgreen,
.sp-app-main td.score-green {
  background: var(--ls-pass-soft);
  color: var(--ls-pass);
}

.sp-app-main td.score-blue {
  background: var(--ls-accent-soft);
  color: var(--ls-link);
}

.sp-app-main td.score-yellow,
.sp-app-main td.score-orange {
  background: var(--ls-warn-soft);
  color: var(--ls-warn);
}

.sp-app-main td.score-lightred,
.sp-app-main td.score-red,
.sp-app-main td.score-darkred {
  background: var(--ls-fail-soft);
  color: var(--ls-fail);
}

.sp-app-main td.score-gray {
  background: var(--ls-neutral-soft);
  color: var(--ls-muted);
}

/* PDF download as a primary button: label and loading text follow the button colour */
.sp-app-main .btn.sp-pdf-download .sp-domain-pdf-label,
.sp-app-main .btn.sp-pdf-download .sp-pdf-loading-text {
  color: inherit;
  font-size: inherit;
}

/* ── KPI cards (components/kpi_card.html; STAT-424) ───────────────── */
/* The dashboard's risk cards (dashboard.css) keep their own colours on top of this base. */
.ls-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.75rem;
}

.ls-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  height: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--sp-card-border);
  border-left: 4px solid var(--ls-muted);
  border-radius: 12px;
  background: var(--ls-neutral-soft);
  color: var(--ls-text);
  text-decoration: none;
}

/* Hover and focus leave the status stripe on the left alone */
a.ls-kpi:hover,
a.ls-kpi:focus-visible {
  border-top-color: var(--ls-accent);
  border-right-color: var(--ls-accent);
  border-bottom-color: var(--ls-accent);
}

.sp-app-main .ls-kpi-label {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
}

.sp-app-main .ls-kpi-value {
  margin-top: auto;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.sp-app-main .ls-kpi-help {
  color: var(--ls-muted);
  font-size: 0.875rem;
}

.ls-kpi-pass {
  border-left-color: var(--ls-pass);
}

.sp-app-main .ls-kpi-pass .ls-kpi-value {
  color: var(--ls-pass);
}

.ls-kpi-warn {
  border-left-color: var(--ls-warn);
}

.sp-app-main .ls-kpi-warn .ls-kpi-value {
  color: var(--ls-warn);
}

.ls-kpi-fail {
  border-left-color: var(--ls-fail);
}

.sp-app-main .ls-kpi-fail .ls-kpi-value {
  color: var(--ls-fail);
}

.ls-kpi-info {
  border-left-color: var(--ls-link);
}

/* Smaller figures inside a KPI panel (IP footprint, top ASN) */
.sp-app-main .ls-kpi-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.sp-app-main .ls-kpi-facts dt {
  color: var(--ls-muted);
  font-weight: 400;
}

.sp-app-main .ls-kpi-facts dd {
  margin: 0;
  font-weight: 700;
}

.sp-app-main .ls-kpi-list {
  display: grid;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.sp-app-main .ls-kpi-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.sp-app-main .ls-kpi-list li span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Action cards side by side (MFA management; STAT-424) ─────────── */
.ls-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
}

.sp-app-main .ls-action-card {
  display: flex;
  flex-direction: column;
  max-width: none;
  margin: 0;
}

.sp-app-main .ls-action-card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.sp-app-main .ls-action-card h2 .ls-icon {
  color: var(--ls-link);
}

.sp-app-main .ls-action-card-danger h2 .ls-icon {
  color: var(--ls-fail);
}

.sp-app-main .ls-page-purpose .ls-badge {
  margin-right: 0.4rem;
}

/* ── Assessment progress (account assessment; STAT-424) ──────────── */
.ls-progress-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ls-progress-summary strong {
  font-size: 1.75rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.sp-app-main .ls-progress {
  height: 0.5rem;
  background: var(--ls-surface);
  border-radius: 999px;
}

.sp-app-main .ls-progress .progress-bar {
  background: var(--ls-button);
  border-radius: 999px;
}

.sp-app-main .ls-assessment-item {
  max-width: none;
  margin: 0;
}

/* Raw service banners (network scan): one line per header, about four lines visible, then scroll */
.sp-app-main .sp-network-scan-raw pre,
.sp-app-main .ns-findings-raw pre {
  max-height: calc(4 * 1.5em + 1rem);
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Release notes use the full content width like the other pages (owner 2026-10-13) */
.sp-app-main .sp-release-notes-wrap {
  width: 100%;
}

/* DMARC tables: at least the card width, scroll only when the columns do not fit (was a fixed 920/1320 px) */
#dmarc-v2-content .sp-dmarc-domain-table-scroll table,
#dmarc-v2-content .sp-dmarc-event-table-scroll table {
  min-width: 100%;
}

/* Content edges line up with the top bar: no extra side padding inside the main area */
.sp-app-main .sp-main-content,
.sp-app-main .sp-container-fluid {
  padding-inline: 0;
}

/* Release notes: the card is full width, the text keeps a comfortable line length */
.sp-app-main .sp-release-notes-content :is(p, ul, ol, h2, h3, h4) {
  max-width: 90ch;
}

/* Radio buttons and checkboxes: a visible ring when unchecked, logo blue when checked (both themes) */
.sp-app-main .form-check-input {
  flex: none;
  padding: 0;
  background-color: var(--ls-surface);
  border: 1.5px solid var(--ls-muted);
}

/* Round and square controls keep a fixed size; switches keep Bootstrap's wide shape */
.sp-app-main :not(.form-switch) > .form-check-input {
  width: 1.15em;
  height: 1.15em;
}

/* A checkbox that is a setting on its own meets the WCAG 2.2 target size minimum of 24 x 24 CSS px (STAT-520) */
.sp-app-main :not(.form-switch) > .form-check-input.ls-check-target {
  width: 24px;
  height: 24px;
}

.sp-app-main .form-check-input:checked {
  background-color: var(--ls-button);
  border-color: var(--ls-button);
}

.sp-app-main .form-check-input:focus {
  border-color: var(--ls-accent);
  box-shadow: 0 0 0 0.2rem var(--ls-accent-soft);
}

/* Assessment question: text, answers and comment share one readable width */
.sp-app-main .ls-assessment-question > * {
  max-width: 62rem;
}

.sp-app-main .ls-assessment-question h2 {
  font-size: 1.25rem;
}

/* Form grids: label, field, errors and help line up across columns even when a label wraps (subgrid) */
.sp-app-main .ls-form-grid {
  row-gap: 0.35rem;
  column-gap: 1.1rem;
}

.sp-app-main .ls-form-grid > div {
  display: grid;
  grid-row: span 4;
  grid-template-rows: subgrid;
  row-gap: 0.35rem;
  align-content: start;
}

.sp-app-main .ls-form-grid > div > label {
  align-self: end;
  margin: 0;
}

/* A checkbox column sits on the field row */
.sp-app-main .ls-form-grid > .ls-form-grid-check > label {
  grid-row: 2;
  align-self: center;
}

/* History charts: the chart card fills the width (a column flex container with centred items shrank it to 0) */
.sp-app-main .charts-container .chartCard {
  align-self: stretch;
  width: 100%;
  margin: 0;
}

/* Server report summary: the three grade cards have the same height */
.sp-app-main .sp-host-summary-grid {
  align-items: stretch;
}

.sp-app-main .sp-host-summary-card > a {
  display: block;
  height: 100%;
}

/* The muted body-text rule above must not grey out eyebrows, errors and Bootstrap status text */
.sp-app-main main .ls-eyebrow {
  color: var(--ls-link) !important;
}

.sp-app-main main .errornote,
.sp-app-main main .text-danger {
  color: var(--ls-fail) !important;
}

.sp-app-main main .text-warning {
  color: var(--ls-warn) !important;
}

.sp-app-main main .text-success {
  color: var(--ls-pass) !important;
}

/* PDF button while the report is generated: hide the icon under the loading text */
.sp-pdf-download.is-loading .ls-icon {
  visibility: hidden;
}

/* Form grids stay grids also when the legacy .sp-button-group (display: flex) is on the same element */
.sp-app-main .ls-form-grid {
  display: grid;
}

/* Scroll containers contain absolutely positioned children (e.g. .visually-hidden in table cells), so those do not
   widen the page at narrow widths (STAT-430) */
.sp-app-main .table-responsive,
.sp-app-main .sp-table-scroll {
  position: relative;
}

/* Long URLs and tokens in running text wrap instead of widening the page at narrow widths (STAT-430) */
.sp-main-content p,
.sp-main-content li,
.sp-main-content dd {
  overflow-wrap: break-word;
}

/* Skip link (WCAG 2.4.1): hidden until focused, then shown above the sidebar (STAT-430) */
.sp-skip-link.visually-hidden-focusable:focus,
.sp-skip-link.visually-hidden-focusable:focus-visible {
  position: fixed !important;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2000;
  padding: 0.5rem 0.9rem;
  border-radius: var(--ls-radius-sm);
  background: var(--ls-surface, #fff);
  color: var(--ls-text, #0f172a);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
}

#main-content:focus {
  outline: none;
}

/* On a phone a table shows its name, grade and report link: columns marked .sp-col-optional are hidden and the table
   drops its desktop minimum width, so it fits without sideways scrolling (STAT-489) */
@media (max-width: 575.98px) {
  .sp-app-main .sp-col-optional {
    display: none;
  }

  .sp-app-main .sp-table-scroll table,
  .sp-app-main .sp-domain-list-table-wrap table {
    min-width: 0;
  }

  .sp-app-main .sp-table-scroll thead th,
  .sp-app-main .sp-table-scroll :is(.table, .sp-table) thead th,
  .sp-app-main .sp-table-scroll :is(.table, .sp-table) thead th a,
  .sp-app-main .table-responsive :is(.table, .sp-table) thead th,
  .sp-app-main .table-responsive :is(.table, .sp-table) thead th a,
  .sp-app-main .sp-domain-list-table-wrap td {
    white-space: normal;
  }

  /* Badges such as "Spoofing protection" wrap between words */
  .sp-app-main .sp-table-scroll th,
  .sp-app-main .sp-table-scroll td,
  .sp-app-main .table-responsive th,
  .sp-app-main .table-responsive td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  /* Domain names, e-mail addresses and URLs in the first column stay whole and wrap only where the browser may break
     a line (after a slash, at a space); a name longer than the screen makes the table scroll inside its container,
     with the edge fade below as the hint, instead of breaking mid-word (STAT-515, replaces overflow-wrap: anywhere) */
  .sp-app-main .sp-table-scroll td:first-child,
  .sp-app-main .table-responsive td:first-child {
    overflow-wrap: break-word;
    word-break: normal;
  }

  .sp-app-main .sp-table-scroll .sp-badge,
  .sp-app-main .table-responsive .sp-badge {
    white-space: normal;
  }
}

/* A table wider than its scroll container fades out at the edge it can scroll towards, so a column off-screen (often
   the report column on a phone) is visibly there (STAT-515). The fade follows the scroll position through a scroll
   timeline: at the start only the right edge fades, at the end only the left. A table that fits has no active timeline
   and keeps both fade widths at 0, so it is unchanged; browsers without scroll timelines keep the plain scroller. */
@property --sp-scroll-fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --sp-scroll-fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes sp-table-scroll-fade {
  0% {
    --sp-scroll-fade-start: 0px;
    --sp-scroll-fade-end: 2.5rem;
  }

  10% {
    --sp-scroll-fade-start: 2.5rem;
  }

  90% {
    --sp-scroll-fade-end: 2.5rem;
  }

  100% {
    --sp-scroll-fade-start: 2.5rem;
    --sp-scroll-fade-end: 0px;
  }
}

@supports (animation-timeline: scroll()) {
  .sp-app-main .table-responsive,
  .sp-app-main .sp-table-scroll,
  .sp-app-main .sp-domain-list-table-wrap {
    animation: sp-table-scroll-fade linear both;
    animation-timeline: scroll(self inline);
    -webkit-mask-image: linear-gradient(
      to right,
      transparent 0,
      #000 var(--sp-scroll-fade-start),
      #000 calc(100% - var(--sp-scroll-fade-end)),
      transparent 100%
    );
    mask-image: linear-gradient(
      to right,
      transparent 0,
      #000 var(--sp-scroll-fade-start),
      #000 calc(100% - var(--sp-scroll-fade-end)),
      transparent 100%
    );
  }
}

/* A requested rescan: the report shown is the previous one (host list and report list) */
.sp-rescan-marker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ls-warn);
  vertical-align: middle;
}

/* A WAF or CDN refuses the server's web scan, so there is no report (STAT-577; host list and report list) */
.sp-scan-blocked-marker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ls-warn);
  vertical-align: middle;
}

/* Getting-started checklist (STAT-492): the steps marked from the account's data, on the getting-started page and the dashboard */
.sp-checklist-progress {
  margin: 0 0 0.5rem;
  color: var(--ls-muted);
  font-weight: 600;
}

.sp-checklist {
  display: grid;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.sp-checklist-step {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 1.75rem;
}

.sp-checklist-mark {
  display: inline-flex;
  flex: 0 0 1.5rem;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid var(--ls-line);
  border-radius: 50%;
  color: var(--ls-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.sp-checklist-step.is-done .sp-checklist-mark {
  border-color: var(--ls-pass);
  background: var(--ls-pass-soft);
  color: var(--ls-pass);
}

.sp-checklist-step.is-done > span:not(.sp-checklist-mark):not(.visually-hidden) {
  color: var(--ls-muted);
}

.sp-dashboard-getting-started {
  margin-bottom: 1.2rem;
}

/* STAT-550: recipient domains with weak DMARC; each row opens its explanation */
.sp-weak-recipients-list > li + li {
  border-top: 1px solid var(--ls-line);
}

.sp-weak-recipient summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  cursor: pointer;
  list-style: none;
}

.sp-weak-recipient summary::-webkit-details-marker {
  display: none;
}

/* display: flex hides the browser's own marker, so the row shows that it opens */
.sp-weak-recipient summary::before {
  content: "\25B8" / "";
  color: var(--ls-muted);
  transition: transform 0.15s ease;
}

.sp-weak-recipient[open] summary::before {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
  .sp-weak-recipient summary::before {
    transition: none;
  }
}

.sp-weak-recipient-domain {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.sp-weak-recipient[open] summary {
  padding-bottom: 0.25rem;
}

.sp-weak-recipient p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--ls-muted);
}

/* Domain and server lists (STAT-591): facts that lost their own column sit as a muted second line in a cell, and a
   server's path follows its name */
.sp-cell-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--ls-muted);
  white-space: normal;
}

.sp-cell-meta a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sp-cell-path {
  color: var(--ls-muted);
}
