/* DOCAR colours on the console's --sahla-* names (redesign phase 1), matching the
   marketplace's src/app/styles/docar-tokens.css bridge; keep them in sync. This service stays isolated, so it carries its
   own copy instead of importing the marketplace stylesheet.

   Fonts: no remote fonts, and the service has no generic static-file handler
   (each public asset is an explicit route in routes/health.ts), so the stack
   names Readex Pro / IBM Plex Sans Arabic first and falls back to the system
   UI font when they are not installed locally. */
:root {
  /* Brand: primary DOCAR navy (the only primary/CTA colour) */
  --sahla-teal-900: #0a1420;
  --sahla-teal-700: #1b2b42;
  --sahla-teal-600: #0f1c2d;
  --sahla-teal-300: #7fa6f5;
  --sahla-teal-100: #d3e2fa;
  --sahla-teal-50: #e8f0fc;

  /* Accent "Saffron Sun": highlights only, always with ink text */
  --sahla-saffron-500: #f5a524;
  --sahla-saffron-600: #e0901a;
  --sahla-saffron-700: #a85a00;
  --sahla-saffron-900: #7a4100;
  --sahla-saffron-50: #fdf1dc;

  /* Neutrals "Sand & Ink" */
  --sahla-ink: #0f1c2d;
  --sahla-ink-2: #46546a;
  --sahla-ink-3: #5a6779;
  --sahla-sand-50: #f5f7fa;
  --sahla-sand-100: #ebeff4;
  --sahla-white: #ffffff;
  --sahla-line: #e1e6ed;
  --sahla-line-2: #c5ceda;
  --sahla-line-input: #7a8799;
  --sahla-night: #0f1c2d;
  --sahla-night-2: #1b2b42;
  --sahla-on-night-2: #b4bfce;

  /* Semantic */
  --sahla-success: #13773f;
  --sahla-success-soft: #e6f4ec;
  --sahla-warning: #a15c00;
  --sahla-warning-soft: #fdf3e1;
  --sahla-error: #c0261f;
  --sahla-error-soft: #fdecea;
  --sahla-info: #1d5fd0;
  --sahla-info-soft: #e8f0fc;
  --sahla-deal-neutral-soft: #eef0f1;

  /* Typography */
  --font-heading: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Shape */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* Elevation (ink-tinted) */
  --shadow-xs: 0 1px 2px rgba(15, 27, 36, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 27, 36, 0.08), 0 1px 2px rgba(15, 27, 36, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(15, 27, 36, 0.12), 0 2px 4px rgba(15, 27, 36, 0.05);
  --shadow-lg: 0 18px 40px -12px rgba(15, 27, 36, 0.22);

  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Focus */
  --focus-ring: 0 0 0 2px var(--sahla-white), 0 0 0 4px var(--sahla-teal-600);

  /* Console-only overlays and the dark log terminal, derived from the
     ink / night / teal / saffron palette above. */
  --console-scrim: rgba(15, 27, 36, 0.55);
  --console-overlay: rgba(15, 27, 36, 0.72);
  --console-glow: rgba(15, 28, 45, 0.25);
  --console-term-bg: var(--sahla-night);
  --console-term-surface: var(--sahla-night-2);
  --console-term-border: rgba(216, 207, 192, 0.18);
  --console-term-hover: rgba(250, 248, 244, 0.05);
  --console-term-text: var(--sahla-sand-100);
  --console-term-muted: var(--sahla-on-night-2);
  --console-term-accent: var(--sahla-teal-300);
  --console-term-accent-soft: rgba(95, 194, 184, 0.16);
  --console-term-warn: var(--sahla-saffron-500);
  --console-term-warn-soft: rgba(245, 165, 36, 0.18);
  --console-term-err: #f4a29c;
  --console-term-err-soft: rgba(192, 38, 31, 0.3);
  --console-term-mark: rgba(245, 165, 36, 0.4);

  /* Console aliases: the rest of this file uses these names. */
  --bg-primary: var(--sahla-sand-50);
  --bg-secondary: var(--sahla-white);
  --bg-tertiary: var(--sahla-sand-100);
  --brand: var(--sahla-teal-600);
  --brand-hover: var(--sahla-teal-700);
  --brand-active: var(--sahla-teal-900);
  --brand-soft: var(--sahla-teal-50);
  --border-color: var(--sahla-line);
  --border-input: var(--sahla-line-input);
  --text-primary: var(--sahla-ink);
  --text-secondary: var(--sahla-ink-2);
  --text-muted: var(--sahla-ink-3);
  --great: var(--sahla-success);
  --fair: var(--sahla-warning);
  --bad: var(--sahla-error);
  --bad-hover: color-mix(in srgb, var(--sahla-error) 82%, var(--sahla-ink));
  --green-soft: var(--sahla-success-soft);
  --amber-soft: var(--sahla-warning-soft);
  --red-soft: var(--sahla-error-soft);
  --neutral-soft: var(--sahla-deal-neutral-soft);
  --ok: var(--sahla-success);
  --warn: var(--sahla-warning);
  --danger: var(--sahla-error);
  --accent: var(--sahla-teal-600);
}
* {
  box-sizing: border-box;
}
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  line-height: 1.55;
}
h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
h1 {
  font-size: 1.75rem;
  margin: 0 0 0.35rem;
}
h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}
h3 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
}
a {
  color: var(--brand);
  text-decoration: none;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
a:hover {
  text-decoration: underline;
}
code {
  font-family: var(--font-mono);
  background: var(--bg-tertiary);
  padding-block: 0.1rem;
  padding-inline: 0.35rem;
  border-radius: var(--radius-xs);
  font-size: 0.9em;
}
p {
  color: var(--text-secondary);
}

.header {
  background: var(--bg-secondary);
  border-block-end: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  position: sticky;
  inset-block-start: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-primary);
}
.logo:hover {
  text-decoration: none;
}
.logo-icon {
  display: block;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}
.logo-pill {
  display: inline-flex;
  align-items: center;
  padding-block: 0.2rem;
  padding-inline: 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--sahla-sand-100);
  color: var(--sahla-ink-2);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav {
  display: flex;
  gap: 0.35rem;
  margin-inline-start: auto;
  align-items: center;
  flex-wrap: wrap;
}
.nav-link {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
}
.nav-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-link.active {
  background: var(--brand-soft);
  color: var(--sahla-teal-700);
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}
.nav-mobile-shell {
  display: contents;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-head {
  margin-bottom: 1.5rem;
}
.page-head p {
  margin: 0;
}

/* The UA rule for [hidden] loses to any component display rule (.btn is
     inline-flex), so el.hidden silently does nothing on those. Make the
     attribute authoritative. */
[hidden] {
  display: none !important;
}
/* Guided vendor wizard */
.wizard-rail {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.wizard-rail-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.wizard-rail-item.active {
  border-color: var(--brand);
  color: var(--text-primary);
  font-weight: 600;
}
.wizard-rail-item.done {
  opacity: 0.75;
}
.wizard-rail-item[data-nav-active] {
  cursor: pointer;
}
.wizard-rail-item[data-nav-active]:hover {
  border-color: var(--brand);
}
.wizard-rail-item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.wizard-rail-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: var(--bg-primary);
  font-size: 0.7rem;
}
.wizard-step-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.1rem;
}
.wizard-step-help {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.wizard-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.wizard-probe {
  margin: 0.5rem 0 1rem;
}
.wizard-probe .probe-ok {
  color: var(--ok);
}
.wizard-probe .probe-bad {
  color: var(--danger);
  font-weight: 600;
}
.wizard-probe .probe-warn {
  color: var(--warn);
}
.probe-samples {
  margin-block: 0.25rem 0.5rem;
  margin-inline: 1rem 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
}
.probe-samples-rejected {
  opacity: 0.8;
}
.wizard-access {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.wizard-selectors td {
  vertical-align: top;
}
.wizard-selectors .selector-result {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-word;
}
.wizard-selectors .selector-result.probe-ok {
  color: var(--ok);
}
.wizard-selectors .selector-result.probe-bad {
  color: var(--danger);
}
.wizard-advanced {
  margin-top: 1rem;
}
.wizard-preset-preview {
  margin: 0.5rem 0;
  padding: 0.6rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}
.wizard-budget-over {
  color: var(--danger);
  font-weight: 600;
}
.wizard-review-block {
  margin-bottom: 1.25rem;
}
.ai-findings {
  margin-block: 0.4rem 0;
  margin-inline: 1rem 0;
  padding: 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.ai-findings li.probe-bad {
  color: var(--danger);
}
.ai-findings li.probe-warn {
  color: var(--warn);
}
.field-invalid {
  color: var(--danger);
  font-size: 0.8rem;
  margin: 0.25rem 0 0;
}
.draft-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.draft-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.2;
  padding-block: 0.5rem;
  padding-inline: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  text-align: center;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.btn:hover {
  text-decoration: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
/* Primary: the only filled CTA style (teal, white text). */
.btn-primary {
  background: var(--brand);
  color: var(--sahla-white);
}
.btn-primary:hover {
  background: var(--brand-hover);
}
.btn-primary:active {
  background: var(--brand-active);
}
/* Secondary: white with a teal border and teal text. */
.btn-outline {
  background: var(--sahla-white);
  color: var(--sahla-teal-700);
  border-color: var(--sahla-teal-600);
}
.btn-outline:hover {
  background: var(--brand-soft);
  border-color: var(--sahla-teal-700);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.btn-sm {
  min-height: 32px;
  padding-block: 0.35rem;
  padding-inline: 0.85rem;
  font-size: 0.8125rem;
}
.btn-danger {
  background: var(--bad);
  color: var(--sahla-white);
}
.btn-danger:hover {
  background: var(--bad-hover);
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.metric-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.metric-card::after {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  height: 3px;
  width: 100%;
  background: var(--brand);
}
.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.metric-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

dl.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
dl.meta > div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
dl.meta dt {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}
dl.meta dd {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-word;
}
dl.meta code {
  font-size: 0.82rem;
}

table.data {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1100px;
  margin: 1rem 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table.data th,
table.data td {
  text-align: start;
  padding-block: 0.6rem;
  padding-inline: 0.85rem;
  border-block-end: 1px solid var(--sahla-line);
  font-size: 0.84375rem;
  vertical-align: middle;
}
table.data th {
  background: var(--sahla-sand-100);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
table.data tbody tr:last-child td,
table.data tr:last-child td {
  border-block-end: none;
}
table.data tbody tr:hover td {
  background: var(--sahla-sand-50);
}
.col-status,
.col-actions,
.col-language,
.col-select {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.col-url {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 28rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding-block: 0.2rem;
  padding-inline: 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-great {
  background: var(--green-soft);
  color: var(--great);
}
.badge-fair {
  background: var(--amber-soft);
  color: var(--fair);
}
.badge-bad {
  background: var(--red-soft);
  color: var(--bad);
}
.badge-neutral {
  background: var(--neutral-soft);
  color: var(--text-secondary);
}

.alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0 0 1rem;
}
.alert:empty {
  display: none;
}
.alert-danger {
  background: var(--red-soft);
  color: var(--bad);
}
.alert-info {
  background: var(--neutral-soft);
  color: var(--text-secondary);
}
.alert-warning {
  background: var(--amber-soft);
  color: var(--fair);
}

.run-kicker {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}
.run-kicker code {
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}
.run-detail-head h1 {
  overflow-wrap: anywhere;
}
.run-diagnosis {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border-color);
  border-inline-start: 4px solid var(--bad);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.run-diagnosis[data-tone="fair"] {
  border-inline-start-color: var(--fair);
}
.run-diagnosis h2 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}
.run-diagnosis p {
  margin: 0 0 0.85rem;
  color: var(--text-primary);
  line-height: 1.45;
}
.run-diagnosis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}
.run-diagnosis-actions .btn {
  min-height: 44px;
}
.run-diagnosis-fixes {
  margin: 0 0 0.85rem;
  padding: 0;
  list-style: none;
}
.run-diagnosis-fixes li {
  margin: 0 0 0.55rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.run-diagnosis-raw {
  margin: 0;
  padding: 0.7rem 0.85rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.counts-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 0.75rem;
}
.run-autofix-disclaimer {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.run-autofix-notes {
  margin: 0;
  padding-inline-start: 1.2rem;
}
.run-autofix-notes li {
  margin: 0 0 0.4rem;
  overflow-wrap: anywhere;
}

.listing-spec-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1rem 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.listing-spec-table th,
.listing-spec-table td {
  text-align: start;
  padding-block: 0.6rem;
  padding-inline: 0.85rem;
  border-block-end: 1px solid var(--sahla-line);
  font-size: 0.84375rem;
  vertical-align: top;
}
.listing-spec-table tr:last-child th,
.listing-spec-table tr:last-child td {
  border-block-end: none;
}
.listing-spec-table th {
  width: 38%;
  max-width: 14rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--sahla-sand-100);
  white-space: nowrap;
}
.listing-spec-table td {
  color: var(--text-primary);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.listing-spec-table code {
  font-size: 0.82rem;
}
.visibility-badge {
  white-space: normal;
}
.visibility-reasons {
  margin: 0.35rem 0 0;
  padding-inline-start: 1.1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.listing-gallery {
  margin: 1rem 0 1.5rem;
}
.listing-gallery-stage {
  position: relative;
  background: var(--sahla-night);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16 / 10;
}
.listing-gallery-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--sahla-night);
}
.listing-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--console-overlay);
  color: var(--sahla-white);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}
.listing-gallery-nav:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.listing-gallery-nav[data-gallery-prev] {
  inset-inline-start: 0.6rem;
}
.listing-gallery-nav[data-gallery-next] {
  inset-inline-end: 0.6rem;
}
.listing-gallery-counter {
  position: absolute;
  inset-inline-end: 0.7rem;
  inset-block-end: 0.7rem;
  background: var(--console-overlay);
  color: var(--sahla-white);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.listing-gallery-thumbs {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  margin-top: 0.65rem;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
}
.listing-gallery-thumb {
  flex: 0 0 auto;
  width: 76px;
  height: 56px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
  cursor: pointer;
}
.listing-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.listing-gallery-thumb.is-current {
  border-color: var(--brand);
}
@media (prefers-reduced-motion: reduce) {
  .listing-gallery-stage img {
    transition: none;
  }
}

form.inline {
  display: inline;
  margin: 0;
}

.run-overrides {
  display: inline-block;
  margin-inline-start: 0.35rem;
  vertical-align: middle;
}
.run-overrides summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  text-decoration: underline;
}
.run-overrides input {
  margin-top: 0.35rem;
  width: 16rem;
  max-width: 60vw;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
}

.breakdown-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.breakdown-badges .badge {
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
}

.form-grid {
  display: grid;
  gap: 0.9rem;
}
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}
.form-input {
  width: 100%;
  min-height: 44px;
  padding-block: 0.55rem;
  padding-inline: 0.8rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--sahla-white);
  color: var(--text-primary);
}
.form-input:focus {
  outline: none;
  border-color: var(--brand);
}
.form-input:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-block-start: 1px solid var(--border-color);
}

.login-shell {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
}

/* Guide page */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.steps li {
  position: relative;
  padding-block: 0 1.25rem;
  padding-inline: 3rem 0;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0;
  width: 2rem;
  height: 2rem;
  background: var(--brand);
  color: var(--sahla-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
}
.steps li::after {
  content: "";
  position: absolute;
  inset-inline-start: 0.95rem;
  inset-block-start: 2rem;
  inset-block-end: 0;
  width: 2px;
  background: var(--border-color);
}
.steps li:last-child::after {
  display: none;
}
.steps strong {
  font-family: var(--font-heading);
}
.diagram {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
}
.diagram svg {
  max-width: 100%;
  height: auto;
}
.explain {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.explain .card h3 {
  margin-top: 0;
}

/* Interactive Pipeline Diagram & Simulator Styles */
.guide-controls-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.guide-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.guide-filter-btn {
  appearance: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.guide-filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}
.guide-filter-btn.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--sahla-teal-700);
  font-weight: 600;
}
.guide-filter-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.pipeline-canvas {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}
.pipeline-canvas svg {
  min-width: 900px;
  width: 100%;
  height: auto;
  display: block;
}
.pipeline-node {
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
  outline: none;
}
.pipeline-node:hover rect {
  filter: drop-shadow(0 4px 8px var(--console-glow));
  stroke-width: 2px;
}
.pipeline-node:focus-visible rect {
  stroke: var(--brand);
  stroke-width: 2.5px;
}
.pipeline-node.is-active rect.p-box,
.pipeline-node.is-active rect.p-box-brand,
.pipeline-node.is-active rect.p-box-accent {
  stroke: var(--brand) !important;
  stroke-width: 2.5px !important;
  fill: var(--brand-soft) !important;
  filter: drop-shadow(0 0 10px var(--console-glow));
}
.pipeline-node.is-active .stage-title {
  fill: var(--brand) !important;
  font-weight: 700;
}
.pipeline-node.is-dimmed {
  opacity: 0.35;
}

.flow-pulse {
  stroke-dasharray: 6 6;
  animation: flowPulse 1.2s linear infinite;
}
@keyframes flowPulse {
  from {
    stroke-dashoffset: 24;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .flow-pulse {
    animation: none;
    stroke-dasharray: none;
  }
  .pipeline-node {
    transition: none;
  }
}

.simulator-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.simulator-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.simulator-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.simulator-track {
  width: 140px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}
.simulator-bar {
  height: 100%;
  width: 14.28%;
  background: var(--brand);
  transition: width 0.25s ease;
}

.inspector-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1rem 0;
}
.inspector-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.inspector-badge {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-block: 0.25rem;
  padding-inline: 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--sahla-teal-700);
}
.inspector-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}
.inspector-pill {
  font-size: 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding-block: 0.2rem;
  padding-inline: 0.6rem;
  color: var(--text-primary);
}
.inspector-pill.guardrail {
  border-color: var(--sahla-teal-100);
  background: var(--brand-soft);
  color: var(--sahla-teal-700);
  font-weight: 600;
}

.inspector-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-color);
  margin: 1rem 0 0.75rem;
}
.inspector-tab-btn {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.inspector-tab-btn:hover {
  color: var(--text-primary);
}
.inspector-tab-btn.is-active {
  color: var(--sahla-teal-700);
  border-block-end-color: var(--brand);
}
.inspector-tab-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.inspector-code-block {
  background: var(--console-term-bg);
  color: var(--console-term-text);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  line-height: 1.5;
  position: relative;
  margin: 0.5rem 0;
}
.inspector-code-block pre,
.inspector-code-block code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
.inspector-code-block pre {
  margin: 0;
  white-space: pre;
}
.copy-snippet-btn {
  position: absolute;
  inset-inline-end: 0.6rem;
  inset-block-start: 0.6rem;
  font-size: 0.7rem;
  padding-block: 0.25rem;
  padding-inline: 0.5rem;
  background: var(--console-term-surface);
  border: 1px solid var(--console-term-border);
  color: var(--console-term-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.copy-snippet-btn:hover {
  background: var(--console-term-hover);
}

.deep-dive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.deep-dive-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.deep-dive-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.deep-dive-card p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Table scrolling primitive — compact columns stay on one line; overflow scrolls inside the card. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  min-height: 380px;
}
.table-scroll table {
  margin: 0;
  border: 0;
}
.table-scroll table.data {
  border-radius: 0;
  border: 0;
  overflow: visible;
}
#vendors-table {
  min-height: 380px;
}

/* Vendor row 3-dots action dropdown */
.vendor-actions {
  position: relative;
  text-align: end;
}
.action-menu {
  position: relative;
  display: inline-block;
  text-align: start;
}
.action-menu summary.action-menu-trigger {
  list-style: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.action-menu summary::-webkit-details-marker {
  display: none;
}
.action-menu summary.action-menu-trigger:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.action-menu[open] summary.action-menu-trigger {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--sahla-teal-700);
}
.action-menu-dropdown {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: calc(100% + 4px);
  z-index: 100;
  width: 210px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.4rem 0;
  text-align: start;
}
.action-menu.dropup .action-menu-dropdown {
  inset-block-start: auto;
  inset-block-end: calc(100% + 4px);
}
.action-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: start;
  background: none;
  border: none;
  padding-block: 0.5rem;
  padding-inline: 0.85rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.action-menu-item:hover,
.action-menu-item:focus-visible {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.action-menu-item:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--brand);
}
.action-menu-item.action-danger {
  color: var(--bad);
}
.action-menu-item.action-danger:hover,
.action-menu-item.action-danger:focus-visible {
  background: var(--red-soft);
  color: var(--bad);
}
.action-menu-form {
  margin: 0;
}
.action-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.35rem 0;
}
.run-overrides-menu {
  padding: 0.2rem 0.85rem 0.45rem;
}
.run-overrides-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  margin-bottom: 0.25rem;
}
.run-overrides-box {
  margin-top: 0.3rem;
}
.run-overrides-box input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
}

.vendor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0 0.5rem;
}
.vendor-toolbar-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
dialog {
  width: min(620px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: var(--console-scrim);
}
.dialog-body {
  padding: 1.4rem;
  overflow: auto;
  max-height: calc(100vh - 2rem);
}
.dialog-head {
  margin-bottom: 1rem;
}
.dialog-head p {
  margin: 0;
  color: var(--text-secondary);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.combobox-wrap {
  position: relative;
}
.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.search-row .form-input {
  flex: 1;
  min-width: 0;
}
.suggestions {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.35rem;
}
.suggestion {
  width: 100%;
  text-align: start;
  padding: 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
}
.suggestion[aria-selected="true"],
.suggestion:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.suggestion span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.field-help {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.check-field {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  min-height: 44px;
}
.check-field input {
  width: 20px;
  height: 20px;
}
.batch-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
  padding: 0.55rem 0;
}
.batch-row > input {
  width: 20px;
  height: 20px;
  margin-top: 0.65rem;
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 768px) {
  .header-inner {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    flex-wrap: nowrap;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
  }
  .nav-mobile-shell {
    display: none;
    width: 100%;
    order: 3;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.35rem 0 0.5rem;
    border-block-start: 1px solid var(--border-color);
  }
  .header-inner.nav-open {
    flex-wrap: wrap;
  }
  .header-inner.nav-open .nav-mobile-shell {
    display: flex;
  }
  .nav {
    width: 100%;
    margin-inline-start: 0;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0.25rem;
  }
  .nav-link {
    padding: 0.7rem 0.85rem;
    font-size: 0.9rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .nav .inline {
    width: 100%;
  }
  .nav .inline .btn {
    width: 100%;
    min-height: 44px;
  }
  .container {
    padding: 1.25rem 1rem 3rem;
  }
  .table-scroll {
    border: 0;
  }
  table.data {
    font-size: 0.82rem;
  }
  table.data th,
  table.data td {
    padding: 0.55rem 0.6rem;
  }
  .card {
    padding: 1.1rem;
  }
  .login-shell {
    min-height: 60vh;
  }
  .metrics {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.65rem;
  }
  .metric-card {
    padding: 0.75rem 0.85rem;
  }
  .metric-value {
    font-size: 1.3rem;
  }
  .field label {
    font-size: 0.78rem;
  }
  .form-input {
    min-height: 44px;
    padding: 0.6rem 0.8rem;
  }
  .btn {
    min-height: 44px;
  }
  .listing-spec-table th {
    white-space: normal;
  }
  .listing-gallery-stage {
    aspect-ratio: 4 / 3;
  }
}
.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
}
.nav-icon-btn:hover {
  background: var(--bg-tertiary);
}
.operator-tour-popover.driver-popover,
.driver-popover.operator-tour-popover {
  max-width: min(360px, calc(100vw - 24px));
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}
.driver-popover.operator-tour-popover .driver-popover-title {
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-size: 1.05rem;
}
.driver-popover.operator-tour-popover .driver-popover-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}
.driver-popover.operator-tour-popover .driver-popover-next-btn,
.driver-popover.operator-tour-popover .driver-popover-done-btn {
  background: var(--brand);
  color: var(--sahla-white);
  border: 0;
  text-shadow: none;
}
.driver-popover.operator-tour-popover .driver-popover-prev-btn {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  text-shadow: none;
}
.driver-popover.operator-tour-popover .driver-popover-close-btn {
  color: var(--text-secondary);
}

@media (max-width: 860px) {
  .vendor-toolbar,
  .vendor-toolbar-actions {
    align-items: stretch;
  }
  .filter-bar .filter-input,
  .filter-bar .filter-select,
  .filter-bar .btn {
    min-height: 44px;
  }
  .vendor-toolbar-actions {
    width: 100%;
  }
  .vendor-toolbar-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
    min-height: 44px;
  }
  .action-menu summary.action-menu-trigger {
    width: 44px;
    height: 44px;
  }
  .action-menu-item {
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
  }
  .vendor-select,
  #select-all-vendors {
    width: 44px;
    height: 44px;
    margin: 0;
  }
  .dialog-actions {
    position: sticky;
    bottom: -1.4rem;
    background: var(--bg-secondary);
    padding: 0.8rem 0 1.4rem;
  }
  .dialog-actions .btn {
    min-height: 44px;
    flex: 1 1 auto;
    justify-content: center;
  }
  .run-diagnosis-actions .btn {
    min-height: 44px;
  }
  .listing-gallery-nav {
    min-width: 44px;
    min-height: 44px;
  }
  .nav-icon-btn {
    min-width: 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .tab-btn {
    min-height: 44px;
  }
  .driver-popover.operator-tour-popover .driver-popover-next-btn,
  .driver-popover.operator-tour-popover .driver-popover-prev-btn,
  .driver-popover.operator-tour-popover .driver-popover-done-btn,
  .driver-popover.operator-tour-popover .driver-popover-close-btn {
    min-height: 44px;
    min-width: 44px;
  }
}
@media (max-width: 380px) {
  .header-inner {
    padding: 0.65rem 0.85rem;
  }
  .logo {
    font-size: 1.05rem;
  }
  .logo-pill {
    display: none;
  }
  .nav {
    gap: 0.15rem;
  }
  .nav-link {
    padding: 0.45rem 0.45rem;
    font-size: 0.76rem;
  }
  .card {
    padding: 0.9rem;
  }
  dl.meta {
    grid-template-columns: 1fr;
  }
}

/* Pagination controls ---------------------------------------------------- */
.pagination {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0 0.5rem;
  flex-wrap: wrap;
}
.pagination-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-inline-end: 0.5rem;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.pagination a:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.pagination .current {
  background: var(--brand);
  color: var(--sahla-white);
  border-color: var(--brand);
}
.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}
.pagination-ellipsis {
  border: 0 !important;
  background: transparent !important;
  color: var(--text-muted) !important;
}
.pagination-size {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-inline-start: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.pagination-size select {
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--bg-secondary);
}

/* Sortable column headers ------------------------------------------------ */
.sort-header {
  white-space: nowrap;
}
.sort-header a {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.sort-header a:hover {
  color: var(--sahla-teal-700);
}
.sort-header .sort-dir {
  font-size: 0.7rem;
  opacity: 0.5;
}
.sort-header a[aria-current] {
  color: var(--sahla-teal-700);
}
.sort-header a[aria-current] .sort-dir {
  opacity: 1;
}

/* Filter bar -------------------------------------------------------------- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 0 0 0.75rem;
}
.filter-bar .filter-input,
.filter-bar .filter-select {
  min-height: 44px;
  padding-block: 0.4rem;
  padding-inline: 0.7rem;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--sahla-white);
  color: var(--text-primary);
  min-width: 0;
}
.filter-bar .filter-input:focus-visible,
.filter-bar .filter-select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.filter-bar .filter-input {
  flex: 1 1 160px;
  max-width: 280px;
}
.filter-bar .filter-select {
  flex: 0 0 auto;
}
@media (max-width: 768px) {
  .filter-bar .filter-input {
    max-width: none;
    flex: 1 1 100%;
  }
  .pagination {
    gap: 0.2rem;
  }
  .pagination a,
  .pagination span {
    min-width: 1.6rem;
    height: 1.6rem;
    font-size: 0.78rem;
  }
}

/* Run Detail Tabs & Execution Terminal ----------------------------------- */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  margin: 1.5rem 0 1.25rem;
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-secondary);
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition:
    color 0.15s,
    border-color 0.15s;
}
.tab-btn:hover {
  color: var(--text-primary);
}
.tab-btn.active {
  color: var(--sahla-teal-700);
  border-block-end-color: var(--brand);
}
.tab-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.tab-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--text-secondary);
}
.tab-btn.active .tab-badge {
  background: var(--brand-soft);
  color: var(--sahla-teal-700);
}

.progress-bar {
  background: var(--bg-tertiary);
  border-radius: 999px;
  height: 0.5rem;
  overflow: hidden;
  max-width: 22rem;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
}
.coverage-legend {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.coverage-legend li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.45rem 0.85rem;
  align-items: start;
}
.coverage-legend li.legend-note {
  grid-template-columns: 1fr;
}
.coverage-legend .legend-token {
  min-width: 0;
}
.coverage-legend .legend-token .progress-bar {
  width: 6.5rem;
  max-width: 6.5rem;
}
.coverage-legend p {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.coverage-legend strong {
  font-size: 0.88rem;
}
.guide-coverage {
  margin: 1.25rem 0;
  scroll-margin-top: 4.5rem;
}
.guide-coverage ul {
  margin: 0.6rem 0 0;
  padding-inline-start: 1.15rem;
}
.guide-coverage li {
  margin: 0.35rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
@media (max-width: 560px) {
  .coverage-legend li {
    grid-template-columns: 1fr;
  }
}

.stages-pipeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}
@media (max-width: 960px) {
  .stages-pipeline {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .stages-pipeline {
    grid-template-columns: 1fr;
  }
}
.stage-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  position: relative;
  overflow: visible;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    transform 0.12s,
    border-color 0.12s,
    box-shadow 0.12s;
}
.stage-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stage-card.status-completed {
  border-inline-start: 4px solid var(--great);
}
.stage-card.status-running {
  border-inline-start: 4px solid var(--brand);
}
.stage-card.status-failed {
  border-inline-start: 4px solid var(--bad);
}
.stage-card.status-skipped {
  border-inline-start: 4px solid var(--text-muted);
  opacity: 0.75;
}
.stage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  position: relative;
}
.stage-card-title {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.stage-index {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--neutral-soft);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.stage-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-status-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
  flex-shrink: 0;
}
.stage-status-tag {
  padding-block: 0.12rem;
  padding-inline: 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.stage-card.status-completed .stage-status-tag {
  background: var(--green-soft);
  color: var(--great);
}
.stage-card.status-running .stage-status-tag {
  background: var(--brand-soft);
  color: var(--sahla-teal-700);
}
.stage-card.status-failed .stage-status-tag {
  background: var(--red-soft);
  color: var(--bad);
}
.stage-card.status-skipped .stage-status-tag {
  background: var(--neutral-soft);
  color: var(--text-muted);
}
.stage-reason-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.stage-reason-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.stage-reason-btn:hover,
.stage-reason-btn:focus-visible {
  color: var(--text-primary);
  border-color: var(--brand);
  background: var(--neutral-soft);
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.stage-card.status-failed .stage-reason-btn {
  border-color: var(--bad);
  color: var(--bad);
  background: var(--red-soft);
}
.stage-card.status-failed .stage-reason-btn:hover,
.stage-card.status-failed .stage-reason-btn:focus-visible {
  background: var(--bad);
  color: var(--sahla-white);
  box-shadow: 0 0 0 2px var(--red-soft);
}
.stage-reason-popover {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  width: 260px;
  max-width: calc(100vw - 2rem);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.7rem 0.85rem;
  z-index: 60;
  font-size: 0.78rem;
  color: var(--text-primary);
  line-height: 1.45;
  text-align: start;
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  cursor: default;
}
.stage-reason-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-color);
}
.stage-reason-popover-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.stage-reason-popover-body {
  font-size: 0.78rem;
  color: var(--text-primary);
  word-break: break-word;
}
@media (max-width: 860px) {
  .stage-reason-btn {
    width: 44px;
    height: 44px;
  }
}
.stage-metrics {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.stage-duration {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.82rem;
}
.stage-events-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
}

.terminal-container {
  background: var(--console-term-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--console-term-border);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin: 1.25rem 0;
  color: var(--console-term-text);
  font-family: var(--font-mono);
}
.terminal-header {
  background: var(--console-term-surface);
  padding: 0.75rem 1rem;
  border-block-end: 1px solid var(--console-term-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}
.terminal-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.terminal-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--console-term-muted);
}
.terminal-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--console-term-accent);
  display: inline-block;
  box-shadow: 0 0 8px var(--console-term-accent);
  animation: live-pulse 1.5s infinite;
}
@keyframes live-pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
  }
}
.terminal-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.terminal-select,
.terminal-search {
  background: var(--console-term-bg);
  border: 1px solid var(--console-term-border);
  color: var(--console-term-text);
  font-family: inherit;
  font-size: 0.8rem;
  padding-block: 0.35rem;
  padding-inline: 0.6rem;
  border-radius: var(--radius-xs);
}
.terminal-select:focus,
.terminal-search:focus {
  outline: none;
  border-color: var(--console-term-accent);
}
.terminal-search {
  width: 180px;
}
.terminal-btn {
  background: var(--console-term-surface);
  border: 1px solid var(--console-term-border);
  color: var(--console-term-text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding-block: 0.35rem;
  padding-inline: 0.65rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.terminal-btn:hover {
  background: var(--console-term-hover);
  color: var(--sahla-white);
}
.terminal-btn.active {
  background: var(--brand);
  color: var(--sahla-white);
  border-color: var(--console-term-accent);
}
.terminal-toggle-label {
  font-size: 0.78rem;
  color: var(--console-term-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}
.terminal-toggle-label input {
  accent-color: var(--console-term-accent);
}
.terminal-body {
  height: 480px;
  max-height: 65vh;
  overflow-y: auto;
  overflow-x: auto;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  line-height: 1.6;
  background: var(--console-term-bg);
}
.terminal-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.terminal-body::-webkit-scrollbar-track {
  background: var(--console-term-bg);
}
.terminal-body::-webkit-scrollbar-thumb {
  background: var(--console-term-surface);
  border-radius: var(--radius-xs);
}
.log-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.2rem 0;
  border-block-end: 1px solid var(--console-term-hover);
}
.log-line:hover {
  background: var(--console-term-hover);
}
.log-ts {
  color: var(--console-term-muted);
  font-size: 0.78rem;
  min-width: 80px;
  flex-shrink: 0;
}
.log-lvl {
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0 0.3rem;
  border-radius: var(--radius-xs);
  min-width: 48px;
  text-align: center;
  flex-shrink: 0;
}
.log-lvl.lvl-info {
  background: var(--console-term-accent-soft);
  color: var(--console-term-accent);
}
.log-lvl.lvl-warn {
  background: var(--console-term-warn-soft);
  color: var(--console-term-warn);
}
.log-lvl.lvl-err {
  background: var(--console-term-err-soft);
  color: var(--console-term-err);
  font-weight: 700;
}
.log-lvl.lvl-debug {
  background: var(--console-term-hover);
  color: var(--console-term-muted);
}
.log-stage {
  color: var(--console-term-accent);
  font-weight: 600;
  font-size: 0.78rem;
  flex-shrink: 0;
  min-width: 90px;
}
.log-msg {
  color: var(--console-term-text);
  flex: 1 1 12rem;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.log-msg mark {
  background: var(--console-term-mark);
  color: var(--sahla-white);
  padding: 0 2px;
  border-radius: 2px;
}
.log-meta {
  flex-basis: 100%;
  margin-top: 0.2rem;
  width: 100%;
}
.meta-toggle {
  color: var(--console-term-accent);
  cursor: pointer;
  font-size: 0.75rem;
  user-select: none;
}
.meta-json {
  background: var(--console-term-surface);
  border: 1px solid var(--console-term-border);
  border-radius: var(--radius-xs);
  padding: 0.5rem;
  margin: 0.3rem 0;
  color: var(--console-term-muted);
  font-size: 0.75rem;
  overflow-x: auto;
}
.btn-jump-record {
  background: var(--console-term-surface);
  border: 1px solid var(--console-term-border);
  color: var(--console-term-accent);
  font-size: 0.7rem;
  padding-block: 0.1rem;
  padding-inline: 0.4rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  margin-inline-start: 0.5rem;
}
.btn-jump-record:hover {
  background: var(--brand);
  color: var(--sahla-white);
}
.terminal-empty {
  padding: 3rem;
  text-align: center;
  color: var(--console-term-muted);
  font-style: italic;
}
.highlight-row {
  animation: highlight-flash 3s;
}
@keyframes highlight-flash {
  0% {
    background: var(--sahla-saffron-50);
  }
  70% {
    background: var(--sahla-saffron-50);
  }
  100% {
    background: transparent;
  }
}
