:root {
  color-scheme: light;
  /* Classic Volvo blue palette (heritage emblem / Pantone 295 family). */
  --bg: #eef2f8;
  --panel: #ffffff;
  --ink: #10243f;
  --muted: #4d5d72;
  --line: #d4ddeb;
  --accent: #1b54a8;
  --accent-strong: #0b2f66;
  --warn: #9b4d00;
  --accent-soft: #e9f0fb;        /* tinted accent surface (hover/selected) */
  --row-hover: #eef3fc;

  /* --- Additive design tokens: refine spacing/sizing/typography only.
         Brand palette above is unchanged. Values mirror current usage so
         adopting a token never shifts existing layout. --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --touch: 44px;                 /* minimum comfortable touch target */
  --tap-gap: 8px;                /* spacing between adjacent tap targets */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --shadow-card: 0 1px 2px rgba(16, 36, 63, 0.06);
  --shadow-pop: 0 14px 36px rgba(16, 36, 63, 0.16);
  --focus-ring: 0 0 0 3px rgba(27, 84, 168, 0.38);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* --- Global accessibility utilities (additive; apply app-wide incl. admin/auth) --- */
.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 18px 24px;
  border-bottom: 3px solid var(--accent);
  background: var(--accent-strong);
}

.topbar h1 {
  color: #ffffff;
  letter-spacing: 0.06em;
}

.topbar p {
  color: #b9cae6;
}

.topbar #userLabel {
  color: #cdd9ee;
}

.sessionActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 6px 0 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 18px 18px;
}

.results {
  position: relative;
  min-height: auto;
}

.operationOverlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 18px;
  background: rgba(238, 242, 248, 0.72);
}

.operationLoader {
  width: min(540px, 100%);
  border: 1px solid #b9c8df;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(16, 36, 63, 0.16);
}

.operationHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.operationProgress {
  height: 9px;
  overflow: hidden;
  margin-top: 10px;
  border-radius: 999px;
  background: #dbe5f3;
}

.operationProgress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #58a6ff);
  transition: width 120ms ease;
}

.operationProgress[data-mode="indeterminate"] span {
  width: 42%;
  animation: operationProgress 1.45s ease-in-out infinite;
}

.downloadDashboard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.dashboardHeader,
.dashboardActivity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.dashboardActivity {
  grid-template-columns: minmax(240px, .8fr) minmax(280px, 1.2fr);
  margin-top: 12px;
}

.statusPill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
}

.statusPill[data-status="running"] {
  border-color: #93b4e0;
  color: var(--accent-strong);
  background: #e9f0fb;
}

.statusPill[data-status="starting"] {
  border-color: #93b4e0;
  color: var(--accent-strong);
  background: #f0f5fe;
}

.statusPill[data-status="complete"] {
  border-color: #91c9a4;
  color: #176b35;
  background: #edf8f1;
}

.statusPill[data-status="stalled"] {
  border-color: #d9a35f;
  color: var(--warn);
  background: #fff7eb;
}

.statusPill[data-status="failed"] {
  border-color: #e2aaa2;
  color: #8a1f11;
  background: #fff1ef;
}

.statusPill[data-status="stopped"],
.statusPill[data-status="idle"] {
  border-color: var(--line);
  color: var(--muted);
  background: #f8fafc;
}

.progressTrack {
  height: 10px;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 999px;
  background: #e4ecf8;
}

.progressFill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: none;
}

.progressFill[data-status="running"],
.progressFill[data-status="starting"] {
  transition: width 240ms ease;
}

.dashboardGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfdfc;
}

.metric strong {
  display: block;
  font-size: 18px;
}

.metric span,
.eventRow span {
  color: var(--muted);
  font-size: 12px;
}

.eventList {
  display: grid;
  gap: 6px;
  max-height: 152px;
  overflow: auto;
}

.eventRow {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  font-size: 13px;
}

.eventRow strong {
  overflow-wrap: anywhere;
  font-weight: 550;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 12px;
}

.filterSearch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 240px;
  min-width: 0;
}

.filterSearchHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
}

.filterSearchHeader > label {
  min-width: 0;
}

.exactToggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: var(--fs-xs);
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.exactToggle input[type="checkbox"] {
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.filterAdvanced {
  display: flex;
  flex-wrap: wrap;
  flex: 3 1 540px;
  gap: 10px;
  min-width: 0;
}

.filterAdvanced .advancedField {
  flex: 1 1 150px;
  min-width: 0;
}

.filterActions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.filterActions button {
  min-height: 38px;
}

/* The "Filters" disclosure toggle is mobile-only; inline on desktop/tablet. */
.filterToggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.filterCount {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 650;
}

/* Desktop/tablet: flatten the advanced-filter wrapper so Search and the 4
   selects wrap as uniform siblings. Search absorbs the extra width; the selects
   never balloon (capped) — fixes Main Segment stretching huge when the row wraps. */
@media (min-width: 641px) {
  .filterAdvanced {
    display: contents;
  }

  .filterSearch {
    flex: 5 1 260px;
  }

  .filterAdvanced .advancedField {
    flex: 1 1 170px;
    max-width: 220px;
  }

  .filterActions {
    flex: 0 0 auto;
  }
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.dangerButton {
  border-color: #e2aaa2;
  color: #8a1f11;
}

.navButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  font-weight: 650;
  text-decoration: none;
}

.navButton:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.smallButton {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

/* Publication number cell: selectable value + one-tap copy button */
.numberWrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.numberValue {
  user-select: text;
}
.copyButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.copyButton:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.copyButton:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.copyButton svg {
  display: block;
}
.copyButton.copied {
  color: #1a7f37;
  border-color: #1a7f37;
}
.copyButton.copyFailed {
  color: #b42318;
  border-color: #b42318;
}

/* Compact background-systems status strip (admin only) on the main page.
   Rows size to their content and wrap as a group (all on one line when wide, one per line when
   narrow) so a row's "last activity" is never truncated. */
.systemStatus {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 26px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.systemStatusRow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.systemStatusName {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.systemStatusMeta {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
}

.openPdfButton {
  margin-top: 12px;
}

.resultCount {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Consent checkbox on the registration form */
.consentField {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
}
.consentField input {
  margin-top: 2px;
  width: auto;
  flex: 0 0 auto;
}

/* Readable legal/account document pages */
.legalDoc {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 64px;
  color: var(--ink);
  line-height: 1.6;
}
.legalDoc h1 { margin-bottom: 4px; }
.legalDoc h2 { margin-top: 28px; font-size: 18px; }
.legalDoc h3 { margin-top: 18px; font-size: 15px; }
.legalDoc table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.legalDoc th, .legalDoc td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; font-size: 14px; vertical-align: top; }
.legalDoc .fillme { background: #fff6da; padding: 0 4px; border-radius: 3px; font-style: italic; }
.legalDoc .docNav { display: flex; gap: 12px; margin-bottom: 16px; }

.sortBar {
  display: none; /* desktop/tablet sort via column headers; revealed on mobile cards */
}

.tableWrap {
  overflow: auto;
  max-height: calc(100vh - 238px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #e8eef9;
  color: #2b3d57;
  font-size: 12px;
  text-transform: uppercase;
}

.sortHeader {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  text-transform: inherit;
}

.sortHeader:hover,
.sortHeader.active {
  background: transparent;
  color: var(--accent-strong);
}

.sortIndicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 12px;
  color: var(--accent-strong);
}

.sortIndicator .filterGlyph {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.sortIndicator .sortArrow {
  font-size: 0.72em;
  line-height: 1;
}

.sortIndicator .sortArrow.sortable {
  color: var(--muted, #9aa);
  opacity: 0.6;
}

.sortHeader:hover .sortArrow.sortable {
  opacity: 0.85;
}

tr {
  cursor: pointer;
}

tr:hover td {
  background: #eef3fc;
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.detailBlock {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.path {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
}

.productsCell {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.authPage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.authShell {
  width: min(430px, 100%);
}

.authPanel,
.adminSection {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.authForm {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.authFooter {
  margin-top: 16px;
  color: var(--muted);
}

.authFooter a {
  color: var(--accent-strong);
  font-weight: 650;
}

.formMessage {
  min-height: 22px;
  color: var(--muted);
}

.formMessage[data-kind="error"] {
  color: #8a1f11;
}

.formMessage[data-kind="success"] {
  color: var(--accent-strong);
}

.adminWorkspace {
  gap: 16px;
}

.portalAdminSection {
  display: grid;
  gap: 12px;
}

.portalHeaderActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.portalOperations {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.portalOperation {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.portalOperation[data-state="running"],
.portalOperation[data-state="starting"] {
  border-left-color: var(--accent);
  background: #f6f9fe;
}

.portalOperation[data-state="complete"] {
  border-left-color: #2f9b55;
}

.portalOperation[data-state="failed"],
.portalOperation[data-state="stalled"] {
  border-left-color: #b43a27;
  background: #fff8f7;
}

.portalOperationHeader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.portalOperationHeader h3,
.portalEventPanel h3 {
  margin: 0;
  font-size: 15px;
}

.portalFacts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.portalFact {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.portalFact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.portalFact strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.portalFact.wideFact {
  grid-column: 1 / -1;
}

.portalFact.commandFact strong {
  font-family: Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
}

.portalProgress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe5f3;
}

.portalProgress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 240ms ease;
}

.portalProgress[data-status="running"] span {
  background: linear-gradient(90deg, var(--accent), #58a6ff);
}

.portalOperationActions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.portalOperationActions label {
  min-width: 170px;
}

.portalLinks {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.portalEventPanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.compactHeader {
  margin-bottom: 8px;
}

.actionBusy {
  opacity: 0.72;
}

.sectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.adminTableWrap {
  max-height: 360px;
}

.compactTable table {
  min-width: 760px;
}

.actionCell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: rgba(15, 24, 21, 0.34);
  padding: 18px;
}

.modalBackdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(1480px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(11, 31, 26, 0.22);
  padding: 18px;
}

.passwordModal {
  align-self: flex-start;
  width: min(460px, 100%);
}

.modalOpen {
  overflow: hidden;
}

.iconButton {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  line-height: 1;
}

.iconButton:hover {
  background: #e8eef9;
}

.closeButton {
  flex: 0 0 auto;
  z-index: 1;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detailHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin: -18px -18px 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.detailTitleGroup {
  min-width: 0;
}

.detailTitleGroup h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

.detailTitleGroup .muted {
  margin: 6px 0 0;
}

.detailBody {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 14px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.detailSide {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.detailPanel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.detailPanel h3 {
  margin: 0 0 12px;
}

.detailGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

.detailMeta {
  min-width: 0;
}

.detailMeta strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.detailMeta p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.productsValue {
  max-height: 8.5em;
  overflow: auto;
}

.matchesPanel {
  display: flex;
  flex-direction: column;
  min-height: 260px;
}

.versionsList {
  display: grid;
  gap: 8px;
}

.versionRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px;
  background: #fff;
}

.versionRow.current {
  border-color: #93b4e0;
  background: #eef4fd;
}

.versionRow strong,
.versionRow span {
  display: block;
}

.versionRow span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.matches {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.matchSummary {
  color: var(--muted);
  margin: 0 0 10px;
}

.match {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfdfc;
}

.matchHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.matchCount {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.pageLink {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  color: var(--accent-strong);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.pageLink:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.match p {
  margin-top: 6px;
}

.matchLoader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafe;
}

.loaderText {
  min-width: 0;
}

.loaderText strong,
.loaderText span {
  display: block;
}

.loaderText span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.snippetProgress {
  grid-column: 1 / -1;
}

@keyframes operationProgress {
  0% {
    transform: translateX(-110%);
  }
  65%,
  100% {
    transform: translateX(240%);
  }
}

mark {
  background: #fff1a8;
  color: var(--ink);
  padding: 0 2px;
}

@media (max-width: 1100px) {
  .dashboardGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboardGrid,
  .dashboardActivity,
  .portalOperations,
  .portalFacts {
    grid-template-columns: 1fr;
  }

  .portalHeaderActions,
  .portalOperationHeader,
  .portalOperationActions {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .portalOperationActions button,
  .portalOperationActions label,
  .portalLinks,
  .portalLinks .pageLink {
    width: 100%;
  }

  /* Filters: keep Search visible; collapse the 4 selects behind a disclosure */
  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filterSearch {
    order: 1;
    flex: 0 0 auto;
  }

  .filterToggle {
    order: 2;
    display: inline-flex;
    min-height: var(--touch);
  }

  .filterAdvanced {
    order: 3;
    display: none;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 8px;
  }

  .filterAdvanced .advancedField {
    flex: 0 0 auto;
  }

  .filters.advancedOpen .filterAdvanced {
    display: flex;
  }

  .filterActions {
    order: 4;
  }

  .filterActions #searchButton {
    flex: 1;
    min-height: var(--touch);
  }

  .filterActions #clearButton {
    min-height: var(--touch);
  }

  .tableWrap {
    max-height: calc(100vh - 430px);
  }

  .operationOverlay {
    padding: 10px;
  }

  .operationHeader,
  .matchLoader {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .operationHeader {
    flex-direction: column;
  }

  .operationHeader .smallButton,
  .matchLoader .smallButton {
    width: 100%;
  }

  .modalBackdrop {
    padding: 0;
  }

  .modal {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding: 12px;
  }

  .detail {
    gap: 10px;
  }

  .detailHeader {
    grid-template-columns: auto minmax(0, 1fr);
    margin: -12px -12px 0;
    padding: 12px;
    gap: 10px;
  }

  .detailHeader .openPdfButton {
    grid-column: 1 / -1;
    justify-self: stretch;
    min-height: 42px;
  }

  .detailTitleGroup h2 {
    font-size: 22px;
    line-height: 1.15;
  }

  .detailBody {
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: auto;
  }

  .detailPanel {
    padding: 12px;
  }

  .detailSide {
    gap: 12px;
  }

  .detailGrid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .productsValue {
    max-height: 6.5em;
  }

  .matchesPanel {
    min-height: min(48dvh, 420px);
    max-height: 70dvh;
  }

  .matches {
    max-height: 54dvh;
  }

  .matchHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .pageLink {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   Mobile card list (<=640px): the results table renders as
   scannable cards. Same <tr>/<td> DOM — only CSS + data-label.
   Scoped strictly to .results so admin/auth tables stay tables.
   ============================================================ */
@media (max-width: 640px) {
  .sortBar {
    display: flex;
    align-items: end;
    gap: 8px;
    margin-bottom: 10px;
  }

  .sortBarField {
    flex: 1;
    min-width: 0;
  }

  .sortDirButton {
    display: inline-grid;
    place-items: center;
    min-width: var(--touch);
    min-height: var(--touch);
    padding: 0 12px;
    font-size: var(--fs-md);
  }

  .results .tableWrap {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .results table {
    min-width: 0;
    display: block;
  }

  .results thead {
    display: none;
  }

  .results tbody {
    display: grid;
    gap: 10px;
    padding: 2px;
  }

  .results tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-card);
    content-visibility: auto;          /* skip painting off-screen cards */
    contain-intrinsic-size: auto 96px; /* estimated card height for scrollbar */
  }

  .results tbody tr:hover td {
    background: transparent;
  }

  .results tbody tr:active {
    border-color: #9fb6d8;
    background: var(--accent-soft);
  }

  .results tbody td {
    max-width: none;
    padding: 0;
    border: 0;
    font-size: var(--fs-base);
  }

  /* Title — full width, prominent, may wrap */
  .results .cellTitle {
    grid-column: 1 / -1;
    margin-bottom: var(--space-1);
    color: var(--ink);
    font-size: var(--fs-md);
    font-weight: 650;
    line-height: 1.25;
  }

  /* Secondary columns already live in the detail view — hide on cards */
  .results td[data-label="Type"],
  .results td[data-label="Family"],
  .results td[data-label="Products"] {
    display: none;
  }

  /* Number + Issue Date — compact muted meta, stacked in the left column */
  .results .cellNumber,
  .results .cellDate {
    grid-column: 1;
    color: var(--muted);
    font-size: var(--fs-sm);
    line-height: 1.35;
  }

  .results .cellNumber:not(:empty)::before {
    content: "No. ";
  }

  /* Larger touch target for the copy button on phones */
  .results .cellNumber .copyButton {
    width: 30px;
    height: 30px;
  }

  .results .cellDate:not(:empty)::before {
    content: "Updated ";
  }

  /* PDF action — pinned right, vertically centered, comfortable touch size */
  .results .cellPdf {
    grid-column: 2;
    grid-row: 2 / span 2;
    align-self: center;
    justify-self: end;
  }

  .results .cellPdf .smallButton {
    min-height: var(--touch);
    padding: 0 18px;
    font-size: var(--fs-base);
  }

  /* Empty-state / message row stays a plain line, not a card */
  .results tbody tr.messageRow {
    display: block;
    padding: var(--space-4) var(--space-1);
    border: 0;
    background: transparent;
    box-shadow: none;
    cursor: default;
  }
}

/* ============================================================
   Tablet (641-1100px): keep the table paradigm but fit it to the
   viewport by dropping the lowest-priority columns (their data
   stays in the detail view). Scoped to .results so admin tables,
   which need their own horizontal scroll, are untouched.
   ============================================================ */
@media (min-width: 641px) and (max-width: 1100px) {
  .results table {
    min-width: 0;
  }

  /* Associated Products is the widest, least-scannable column */
  .results thead th:nth-child(4),
  .results td[data-label="Products"] {
    display: none;
  }
}

@media (min-width: 641px) and (max-width: 860px) {
  /* Narrow tablets / large phones landscape: also drop Type + Family */
  .results thead th:nth-child(2),
  .results thead th:nth-child(3),
  .results td[data-label="Type"],
  .results td[data-label="Family"] {
    display: none;
  }
}
