/* ==========================================================================
   Visual CI - Premium Dark Developer Theme
   Exact Recreation: Rich Card Gradients, Large Circular Icons & Subtle Curves
   ========================================================================== */

/* Google Fonts fallback for offline/isolated CI environments */
/* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap'); */

:root {
  /* Dark theme (the default, and what you get without JavaScript). The light theme
     overrides every colour token in :root[data-theme="light"] at the end of this file. */
  color-scheme: dark;

  /* Surfaces */
  --bg-main: #0B1020;
  --bg-secondary: #111827;
  --bg-surface: #151F33;
  --bg-card: #151F33;
  --bg-table: #111A2B;
  --border-color: #26344D;
  /* Boundary of form controls (search box, theme toggle): >= 3:1 against the page */
  --control-border: #64779A;

  /* Brand Accents */
  --primary-blue: #2997FF;
  --bright-cyan: #38BDF8;
  --success-green: #10B981;
  --approved-purple: #8B5CF6;
  /* M6 contrast fix: was #F43F5E (4.2:1 on the failed-pill tint) */
  --error-red: #F9657C;

  /* Text */
  --text-primary: #F8FAFC;
  --text-secondary: #A5B4CF;
  /* M6 contrast fix: was #64748B (4.0:1 on --bg-main, 3.5:1 on --bg-card) */
  --text-muted: #8391A7;
  /* Text on a solid accent fill (hovered Approve / Reject / Inspect, slider handle) */
  --on-accent: #0B1020;

  /* Card Specific Palette */
  --kpi-blue-start: #142C55;
  --kpi-blue-end: #0756A5;
  --kpi-blue-border: #285DA0;

  --kpi-green-start: #103D36;
  --kpi-green-end: #065F46;
  --kpi-green-border: #167A62;

  --kpi-red-start: #351B30;
  --kpi-red-end: #4C1932;
  --kpi-red-border: #79334B;

  /* M6 contrast fix: KPI labels used --text-secondary (3.5:1 on the blue card) */
  --kpi-label: #CBD5E6;
  --kpi-value: #FFFFFF;
  --kpi-value-green: #34D399;
  --kpi-value-red: #FDA4AF;
  --kpi-blue-icon: #FFFFFF;
  --kpi-green-icon: #A7F3D0;
  --kpi-red-icon: #FDA4AF;
  --kpi-blue-icon-bg: rgba(41, 151, 255, 0.22);
  --kpi-blue-icon-border: rgba(41, 151, 255, 0.42);
  --kpi-blue-icon-shadow: rgba(7, 86, 165, 0.4);
  --kpi-green-icon-bg: rgba(16, 185, 129, 0.22);
  --kpi-green-icon-border: rgba(16, 185, 129, 0.42);
  --kpi-green-icon-shadow: rgba(6, 95, 70, 0.4);
  --kpi-red-icon-bg: rgba(244, 63, 94, 0.22);
  --kpi-red-icon-border: rgba(244, 63, 94, 0.42);
  --kpi-red-icon-shadow: rgba(76, 25, 50, 0.4);
  /* Decorative curves (drawn at 28% / 14% opacity) */
  --kpi-blue-curve: #FFFFFF;
  --kpi-green-curve: #A7F3D0;
  --kpi-red-curve: #FDA4AF;

  /* Page heading icon and navbar brand */
  --hero-gradient-start: #2563EB;
  --hero-gradient-end: #7C3AED;
  --hero-icon: #FFFFFF;
  --hero-shadow: rgba(37, 99, 235, 0.35);
  --brand-icon-bg-start: rgba(41, 151, 255, 0.25);
  --brand-icon-bg-end: rgba(56, 189, 248, 0.08);
  --brand-icon-border: rgba(41, 151, 255, 0.45);

  /* Tints and overlays */
  --hover-overlay: rgba(255, 255, 255, 0.05);
  --row-hover: rgba(255, 255, 255, 0.035);
  --subtle-fill: rgba(255, 255, 255, 0.06);
  --badge-bg: rgba(17, 24, 39, 0.85);
  --tab-active-bg: var(--bg-secondary);
  --primary-tint-bg: rgba(41, 151, 255, 0.16);
  --primary-on-tint: #4DA8FF; /* blue text on a blue tint: AA on any surface */
  --primary-tint-border: rgba(41, 151, 255, 0.4);
  --primary-glow: rgba(41, 151, 255, 0.35);
  --focus-ring: rgba(41, 151, 255, 0.25);
  --success-tint-bg: rgba(16, 185, 129, 0.16);
  --success-tint-border: rgba(16, 185, 129, 0.45);
  --success-glow: rgba(16, 185, 129, 0.6);
  --danger-tint-bg: rgba(244, 63, 94, 0.16);
  --danger-tint-border: rgba(244, 63, 94, 0.45);

  /* Shadows */
  --shadow-tab: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-kpi: 0 6px 24px rgba(0, 0, 0, 0.28);
  --shadow-kpi-hover: 0 8px 28px rgba(0, 0, 0, 0.36);
  --shadow-table: 0 6px 24px rgba(0, 0, 0, 0.3);
  --shadow-snapshot: 0 4px 20px rgba(0, 0, 0, 0.25);
  --shadow-handle: 0 4px 14px rgba(0, 0, 0, 0.7);
  --shadow-dialog: 0 20px 60px rgba(0, 0, 0, 0.6);
  --dialog-backdrop: rgba(0, 0, 0, 0.6);

  /* Backward Compatibility Aliases */
  --bg-primary: var(--bg-main);
  --accent-blue: var(--bright-cyan);
  /* Status pill text: used for text, so each one meets 4.5:1 on its tint */
  --status-passed-text: var(--success-green);
  --status-failed-text: var(--error-red);
  /* M6 contrast fix: --approved-purple is 3.5:1 on its tint; it stays for strokes */
  --status-approved-text: #A78BFA;

  /* Status Colors with Clean Alpha Tints */
  --status-passed-bg: rgba(16, 185, 129, 0.14);
  --status-passed-border: rgba(16, 185, 129, 0.4);
  --status-approved-bg: rgba(139, 92, 246, 0.14);
  --status-approved-border: rgba(139, 92, 246, 0.4);
  --status-failed-bg: rgba(244, 63, 94, 0.14);
  --status-failed-border: rgba(244, 63, 94, 0.4);
  --status-rejected-bg: rgba(244, 63, 94, 0.14);
  --status-rejected-border: rgba(244, 63, 94, 0.4);
  --status-new-bg: rgba(56, 189, 248, 0.14);
  --status-new-border: rgba(56, 189, 248, 0.4);
  --status-new-text: var(--bright-cyan);
  /* Page dimmed behind the "drop to import" hint */
  --overlay-backdrop: rgba(11, 16, 32, 0.82);

  /* "What changed" (1.1.0): numbered region boxes over the diff image. The diff image
     keeps its own (mostly light) colours in both themes, so the outline is dark with a
     white halo that keeps it visible on any pixel; the same colours label the list. */
  --region-outline: #1D4ED8;
  --region-outline-active: #7C3AED;
  --region-halo: #FFFFFF;
  --region-fill-active: rgba(124, 58, 237, 0.14);
  --region-label-bg: #1D4ED8;
  --region-label-text: #FFFFFF;
  --region-label-active-bg: #6D28D9;
  --region-label-active-text: #FFFFFF;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-card: 14px;
  --transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary-blue);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--bright-cyan);
}

/* Top Navigation Bar */
.navbar {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

.navbar-inner {
  width: 92%;
  max-width: 1600px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.navbar-brand-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-icon-bg-start) 0%, var(--brand-icon-bg-end) 100%);
  border: 1px solid var(--brand-icon-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-blue);
}

.breadcrumb-separator {
  color: var(--border-color);
  font-size: 15px;
}

.breadcrumb-current {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-link {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.navbar-link:hover {
  color: var(--text-primary);
  background-color: var(--hover-overlay);
}

/* Static demo (GitHub Pages build): banner under the navbar + note after a simulated action */
.demo-banner {
  background-color: var(--status-new-bg);
  border-bottom: 1px solid var(--status-new-border);
}

.demo-banner-inner {
  width: 92%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-banner-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--status-new-text);
  border: 1px solid var(--status-new-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}

.demo-banner-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.demo-banner-link {
  color: var(--bright-cyan);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.demo-banner-link:hover {
  color: var(--text-primary);
}

.demo-banner-link:focus-visible {
  outline: 2px solid var(--bright-cyan);
  outline-offset: 2px;
  border-radius: 2px;
}

.demo-note {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Main Spacious Container: 92% viewport, max 1600px */
.container {
  width: 92%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 36px 0 64px 0;
}

/* ─────────────────────────────────────────────────────────────
   1. Page Heading Section
   ───────────────────────────────────────────────────────────── */
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 20px;
}

.page-heading-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Square rounded icon container with blue/purple gradient */
.heading-icon-container {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--hero-gradient-end) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px var(--hero-shadow);
  flex-shrink: 0;
}

.heading-icon-container svg {
  color: var(--hero-icon);
}

.heading-text-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

.page-heading-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-md);
}

.action-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success-green);
  box-shadow: 0 0 10px var(--success-glow);
}

/* ─────────────────────────────────────────────────────────────
   2. KPI Statistics Cards (Exactly 3, 125-140px tall, circular icons)
   ───────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  height: 132px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-kpi);
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-kpi-hover);
}

/* Blue Card: #142C55 to #0756A5, border #285DA0 */
.kpi-card-blue {
  background: linear-gradient(115deg, var(--kpi-blue-start) 0%, var(--kpi-blue-end) 100%);
  border: 1px solid var(--kpi-blue-border);
}

/* Green Card: #103D36 to #065F46, border #167A62 */
.kpi-card-green {
  background: linear-gradient(115deg, var(--kpi-green-start) 0%, var(--kpi-green-end) 100%);
  border: 1px solid var(--kpi-green-border);
}

/* Red Card: #351B30 to #4C1932, border #79334B */
.kpi-card-red {
  background: linear-gradient(115deg, var(--kpi-red-start) 0%, var(--kpi-red-end) 100%);
  border: 1px solid var(--kpi-red-border);
}

/* Large circular icon background on the left (64-70px) */
.kpi-icon-circle {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}

.kpi-card-blue .kpi-icon-circle {
  background: var(--kpi-blue-icon-bg);
  border: 1px solid var(--kpi-blue-icon-border);
  box-shadow: 0 4px 14px var(--kpi-blue-icon-shadow);
}

.kpi-card-green .kpi-icon-circle {
  background: var(--kpi-green-icon-bg);
  border: 1px solid var(--kpi-green-icon-border);
  box-shadow: 0 4px 14px var(--kpi-green-icon-shadow);
}

.kpi-card-red .kpi-icon-circle {
  background: var(--kpi-red-icon-bg);
  border: 1px solid var(--kpi-red-icon-border);
  box-shadow: 0 4px 14px var(--kpi-red-icon-shadow);
}

.kpi-icon-circle svg {
  color: var(--kpi-blue-icon);
}

.kpi-card-green .kpi-icon-circle svg {
  color: var(--kpi-green-icon);
}

.kpi-card-red .kpi-icon-circle svg {
  color: var(--kpi-red-icon);
}

.kpi-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 2;
}

.kpi-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--kpi-label);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--kpi-value);
}

.kpi-value-green {
  color: var(--kpi-value-green);
}

.kpi-value-red {
  color: var(--kpi-value-red);
}

/* Decorative subtle curved SVG line along bottom-right */
.kpi-curve {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 170px;
  height: 85px;
  pointer-events: none;
  opacity: 0.8;
  z-index: 1;
}

/* ─────────────────────────────────────────────────────────────
   3. Table Toolbar & Search
   ───────────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: inline-flex;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.filter-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.filter-tab:hover {
  color: var(--text-primary);
}

.filter-tab.active {
  background-color: var(--tab-active-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-tab);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  background-color: var(--bg-surface);
  border: 1px solid var(--control-border);
  color: var(--text-primary);
  font-size: 13px;
  padding: 9px 14px 9px 38px;
  border-radius: var(--radius-md);
  outline: none;
  width: 280px;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.search-input::placeholder {
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────
   4. Test Runs Table
   ───────────────────────────────────────────────────────────── */
.table-card {
  background-color: var(--bg-table);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-table);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  /* Positioned, so absolutely positioned descendants (e.g. visually hidden text in
     the Inspect buttons) are clipped here instead of widening the whole page */
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

thead th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

/* 58px row height */
tbody td {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background-color: var(--row-hover);
}

/* Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-pill-passed {
  background-color: var(--status-passed-bg);
  color: var(--status-passed-text);
  border-color: var(--status-passed-border);
}

.status-pill-approved {
  background-color: var(--status-approved-bg);
  color: var(--status-approved-text);
  border-color: var(--status-approved-border);
}

.status-pill-failed {
  background-color: var(--status-failed-bg);
  color: var(--status-failed-text);
  border-color: var(--status-failed-border);
}

.status-pill-rejected {
  background-color: var(--status-rejected-bg);
  color: var(--status-failed-text);
  border-color: var(--status-rejected-border);
}

.status-pill-new {
  background-color: var(--status-new-bg);
  color: var(--status-new-text);
  border-color: var(--status-new-border);
}

/* Run ID Link */
.run-id-link {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--bright-cyan);
  text-decoration: none;
  transition: var(--transition);
}

.run-id-link:hover {
  color: var(--primary-blue);
  text-decoration: underline;
}

/* Git Context Badges */
.git-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.git-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--badge-bg);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.git-icon {
  color: var(--success-green);
  flex-shrink: 0;
}

.git-commit {
  color: var(--text-secondary);
}

/* Snapshots Column */
.snapshots-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

.snapshots-count {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.snapshots-sub {
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.match-count {
  color: var(--success-green);
  font-weight: 600;
}

.diff-count {
  color: var(--error-red);
  font-weight: 600;
}

/* Created Timestamp */
.timestamp-text {
  color: var(--text-secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Action Buttons */
.btn-inspect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--primary-tint-bg);
  color: var(--primary-on-tint);
  border: 1px solid var(--primary-tint-border);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.btn-inspect:hover {
  background-color: var(--primary-blue);
  color: var(--on-accent);
  border-color: var(--primary-blue);
  box-shadow: 0 2px 10px var(--primary-glow);
  text-decoration: none;
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination-btn {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
  background-color: var(--border-color);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ==========================================================================
   Run Detail Page Styling
   ========================================================================== */

.detail-header-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 28px 32px;
  margin-bottom: 28px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.detail-run-id {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--bright-cyan);
}

.detail-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-secondary);
}

.snapshot-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  margin-bottom: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-snapshot);
}

.snapshot-header {
  padding: 18px 24px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.snapshot-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}

.route-pill {
  font-family: var(--font-mono);
  background-color: var(--bg-table);
  border: 1px solid var(--border-color);
  color: var(--bright-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.viewport-badge {
  background-color: var(--subtle-fill);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-mono);
}

.snapshot-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-approve {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--success-tint-bg);
  color: var(--success-green);
  border: 1px solid var(--success-tint-border);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-approve:hover {
  background-color: var(--success-green);
  color: var(--on-accent);
}

.btn-reject {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--danger-tint-bg);
  color: var(--error-red);
  border: 1px solid var(--danger-tint-border);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-reject:hover {
  background-color: var(--error-red);
  color: var(--on-accent);
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  background-color: var(--bg-table);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  gap: 6px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--primary-blue);
  border-bottom-color: var(--primary-blue);
}

.tab-panel {
  display: none;
  padding: 28px;
}

.tab-panel.active {
  display: block;
}

/* Side-by-Side */
.side-by-side {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 28px;
}

.image-preview-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-preview-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.image-frame {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 800px;
  overflow-y: auto;
}

.image-frame img {
  width: 100%;
  height: auto;
  display: block;
}

/* Draggable Split Slider */
.slider-view-container {
  position: relative;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 800px;
  overflow-y: auto;
  user-select: none;
}

.slider-wrapper {
  position: relative;
  width: 100%;
}

.slider-img-under {
  display: block;
  width: 100%;
  height: auto;
}

.slider-img-over-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
  border-right: 2px solid var(--primary-blue);
}

.slider-img-over {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left top;
}

.slider-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background-color: var(--primary-blue);
  cursor: ew-resize;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.slider-handle-pill {
  width: 36px;
  height: 36px;
  background-color: var(--primary-blue);
  border: 2px solid var(--bg-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-handle);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 700;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px auto;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
  .side-by-side {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .container {
    width: 95%;
    padding: 24px 0;
  }
  .navbar-inner {
    width: 95%;
  }
  .demo-banner-inner {
    width: 95%;
    align-items: flex-start;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .page-heading {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Screen-reader-only content (e.g. the #live-region status announcer) */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ==========================================================================
   Approve all pending (run detail header) - M3
   Same look as .btn-approve (green tint), sized for the run header.
   ========================================================================== */

.run-status-container {
  display: inline-flex;
  align-items: center;
}

.btn-approve-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--success-tint-bg);
  color: var(--success-green);
  border: 1px solid var(--success-tint-border);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-approve-all:hover:not(:disabled) {
  background-color: var(--success-green);
  color: var(--on-accent);
}

.btn-approve-all:focus-visible {
  outline: 2px solid var(--bright-cyan);
  outline-offset: 2px;
}

.btn-approve-all:disabled {
  cursor: progress;
  opacity: 0.7;
}

/* display: inline-flex above would otherwise override the hidden attribute */
.btn-approve-all[hidden] {
  display: none;
}

/* ==========================================================================
   History page (GET /history/:slug/:viewport) and run-detail "History" links
   ========================================================================== */
.history-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-blue);
  padding: 4px 10px;
  border: 1px solid var(--primary-tint-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}

.history-link:hover,
.history-link:focus-visible {
  background-color: var(--primary-tint-bg);
  text-decoration: none;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.history-chart-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  margin-bottom: 28px;
}

.history-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.history-chart-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-chart-sub {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 13px;
}

.history-chart-stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
}

.history-chart-stats div {
  display: flex;
  gap: 6px;
}

.history-chart-stats dt {
  color: var(--text-muted);
}

.history-chart-stats dd {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.history-sparkline {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.history-sparkline-axis {
  stroke: var(--border-color);
  stroke-width: 1;
}

.history-sparkline-line {
  fill: none;
  stroke: var(--bright-cyan);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.history-sparkline-dot {
  fill: var(--bright-cyan);
}

.history-sparkline-dot.is-latest {
  fill: var(--bg-surface);
  stroke: var(--bright-cyan);
  stroke-width: 2;
}

.history-sparkline-change {
  stroke: var(--approved-purple);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.history-chart-legend {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-legend-swatch {
  display: inline-block;
  width: 18px;
  border-top: 2px dashed var(--approved-purple);
}

.history-table td {
  vertical-align: top;
}

.history-time {
  margin-top: 4px;
}

.history-mismatch {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.history-baseline-marker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--status-approved-text);
  background-color: var(--status-approved-bg);
  border: 1px dashed var(--status-approved-border);
}

.history-row-baseline-changed td:first-child {
  box-shadow: inset 3px 0 0 var(--approved-purple);
}

.history-thumb-link {
  display: inline-block;
  border-radius: var(--radius-sm);
}

.history-thumb {
  display: block;
  width: 160px;
  height: 100px;
  object-fit: cover;
  object-position: top;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.history-thumb-link:hover .history-thumb,
.history-thumb-link:focus-visible .history-thumb {
  border-color: var(--primary-blue);
}

/* The History link makes snapshot titles longer: let them wrap instead of overflowing */
.snapshot-title {
  flex-wrap: wrap;
}

/* Phones: long breadcrumbs (history pages, run ids) pushed the navbar wider than the
   screen. Keep the brand and the CURRENT page, hide the middle crumbs, make the right-hand
   link icon-only (its text stays available to screen readers), and let the current page
   name truncate with an ellipsis. */
@media (max-width: 680px) {
  .navbar-left {
    min-width: 0;
    flex: 1 1 auto;
    gap: 8px;
    overflow: hidden;
  }
  .navbar-left > .crumb-middle {
    display: none;
  }
  .navbar-left > * {
    white-space: nowrap;
    flex-shrink: 0;
  }
  .navbar-left > :last-child:not(.navbar-brand) {
    display: block;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .navbar-right {
    flex-shrink: 0;
  }
  .navbar-right .navbar-link-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ==========================================================================
   M6: light theme, theme toggle, snapshot counts and phone layout
   ========================================================================== */

/* Light theme. Set on <html> by the inline script in partials/header.ejs (stored
   'vrt-theme', else prefers-color-scheme) and by js/theme.js. Overrides every colour
   token from :root; screenshots and diff images keep their own colours. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg-main: #EEF2F8;
  --bg-secondary: #F6F8FC;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-table: #FFFFFF;
  --border-color: #D8DFEA;
  --control-border: #76869D;

  --primary-blue: #0A66C2;
  --bright-cyan: #0C6B85;
  --success-green: #047857;
  --approved-purple: #7C3AED;
  --error-red: #BE123C;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #5A6A80;
  --on-accent: #FFFFFF;

  --kpi-blue-start: #EEF5FF;
  --kpi-blue-end: #D3E4FB;
  --kpi-blue-border: #B4CDEE;
  --kpi-green-start: #EDF9F3;
  --kpi-green-end: #CFEEDF;
  --kpi-green-border: #A6D9C2;
  --kpi-red-start: #FEF1F4;
  --kpi-red-end: #F9DAE3;
  --kpi-red-border: #EDB4C4;

  --kpi-label: #334155;
  --kpi-value: #0B3F7A;
  --kpi-value-green: #065F46;
  --kpi-value-red: #9F1239;
  --kpi-blue-icon: #0A66C2;
  --kpi-green-icon: #047857;
  --kpi-red-icon: #BE123C;
  --kpi-blue-icon-bg: rgba(255, 255, 255, 0.7);
  --kpi-blue-icon-border: rgba(10, 102, 194, 0.3);
  --kpi-blue-icon-shadow: rgba(10, 102, 194, 0.12);
  --kpi-green-icon-bg: rgba(255, 255, 255, 0.7);
  --kpi-green-icon-border: rgba(4, 120, 87, 0.3);
  --kpi-green-icon-shadow: rgba(4, 120, 87, 0.12);
  --kpi-red-icon-bg: rgba(255, 255, 255, 0.7);
  --kpi-red-icon-border: rgba(190, 18, 60, 0.3);
  --kpi-red-icon-shadow: rgba(190, 18, 60, 0.12);
  --kpi-blue-curve: #0A66C2;
  --kpi-green-curve: #047857;
  --kpi-red-curve: #BE123C;

  --hero-gradient-start: #2563EB;
  --hero-gradient-end: #7C3AED;
  --hero-icon: #FFFFFF;
  --hero-shadow: rgba(37, 99, 235, 0.25);
  --brand-icon-bg-start: rgba(10, 102, 194, 0.14);
  --brand-icon-bg-end: rgba(12, 107, 133, 0.04);
  --brand-icon-border: rgba(10, 102, 194, 0.35);

  --hover-overlay: rgba(15, 23, 42, 0.05);
  --row-hover: rgba(15, 23, 42, 0.03);
  --subtle-fill: rgba(15, 23, 42, 0.04);
  --badge-bg: #F1F5F9;
  --tab-active-bg: #E2EAF6;
  --primary-tint-bg: rgba(10, 102, 194, 0.08);
  --primary-on-tint: #0A66C2;
  --primary-tint-border: rgba(10, 102, 194, 0.35);
  --primary-glow: rgba(10, 102, 194, 0.25);
  --focus-ring: rgba(10, 102, 194, 0.25);
  --success-tint-bg: rgba(4, 120, 87, 0.07);
  --success-tint-border: rgba(4, 120, 87, 0.4);
  --success-glow: rgba(4, 120, 87, 0.35);
  --danger-tint-bg: rgba(190, 18, 60, 0.06);
  --danger-tint-border: rgba(190, 18, 60, 0.4);

  --shadow-tab: 0 1px 2px rgba(15, 23, 42, 0.12);
  --shadow-kpi: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-kpi-hover: 0 2px 4px rgba(15, 23, 42, 0.06), 0 10px 24px rgba(15, 23, 42, 0.1);
  --shadow-table: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 18px rgba(15, 23, 42, 0.05);
  --shadow-snapshot: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 18px rgba(15, 23, 42, 0.05);
  --shadow-handle: 0 2px 8px rgba(15, 23, 42, 0.35);
  --shadow-dialog: 0 20px 50px rgba(15, 23, 42, 0.18);
  --dialog-backdrop: rgba(15, 23, 42, 0.45);

  --status-approved-text: #6D28D9;
  --status-passed-bg: rgba(4, 120, 87, 0.08);
  --status-passed-border: rgba(4, 120, 87, 0.35);
  --status-approved-bg: rgba(124, 58, 237, 0.08);
  --status-approved-border: rgba(124, 58, 237, 0.35);
  --status-failed-bg: rgba(190, 18, 60, 0.07);
  --status-failed-border: rgba(190, 18, 60, 0.35);
  --status-rejected-bg: rgba(190, 18, 60, 0.07);
  --status-rejected-border: rgba(190, 18, 60, 0.35);
  --status-new-bg: rgba(12, 107, 133, 0.08);
  --status-new-border: rgba(12, 107, 133, 0.35);
  --overlay-backdrop: rgba(241, 245, 249, 0.88);

  /* "What changed" region boxes: drawn on the diff image, which looks the same in both
     themes, so they keep the dark theme's colours. */
  --region-outline: #1D4ED8;
  --region-outline-active: #7C3AED;
  --region-halo: #FFFFFF;
  --region-fill-active: rgba(124, 58, 237, 0.14);
  --region-label-bg: #1D4ED8;
  --region-label-text: #FFFFFF;
  --region-label-active-bg: #6D28D9;
  --region-label-active-text: #FFFFFF;
}

/* Theme toggle (navbar). Needs JS, so it stays hidden until the head script has run. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  background-color: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle:hover {
  color: var(--text-primary);
  background-color: var(--hover-overlay);
}

:root:not([data-theme]) .theme-toggle,
.theme-icon-sun,
:root[data-theme="light"] .theme-icon-moon {
  display: none;
}

:root[data-theme="light"] .theme-icon-sun {
  display: block;
}

/* KPI curves are drawn in currentColor (index.ejs) */
.kpi-card-blue .kpi-curve { color: var(--kpi-blue-curve); }
.kpi-card-green .kpi-curve { color: var(--kpi-green-curve); }
.kpi-card-red .kpi-curve { color: var(--kpi-red-curve); }

/* Snapshots column: total on top, then one coloured count per status in the run */
.snapshots-summary {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.snapshots-sub {
  flex-wrap: wrap;
}

.snapshots-sub {
  column-gap: 8px;
  row-gap: 2px;
}

.new-count {
  color: var(--status-new-text);
  font-weight: 600;
}

.approved-count {
  color: var(--status-approved-text);
  font-weight: 600;
}

.rejected-count {
  color: var(--error-red);
  font-weight: 600;
}

/* Slider: touches that start on the divider drag it instead of scrolling the page,
   and the divider is easier to grab than its 2px line. */
.slider-divider {
  touch-action: none;
}

.slider-handle-pill {
  flex-shrink: 0; /* it sits in the 2px-wide divider and was squeezed into an oval */
}

.slider-divider::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -14px;
  right: -14px;
}

/* Long branch names truncate (full name in the title attribute) */
.git-badge {
  min-width: 0;
  max-width: 100%;
}

.git-badge > span,
.git-badge-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.git-badge-text {
  display: inline-block;
}

.git-context {
  max-width: 100%;
}

/* Tables size columns by content, so give the badge a hard cap there */
#test-runs-table .git-badge,
.history-table .git-badge {
  max-width: 240px;
}

/* Tablets / small laptops (until the phone card layout takes over): the cap alone
   still pushed the history table past its container, so shorten it further */
@media (min-width: 681px) and (max-width: 1200px) {
  #test-runs-table .git-badge,
  .history-table .git-badge {
    max-width: 150px;
  }
}

.error-container {
  overflow-wrap: anywhere;
}

/* Phones (360-680px) */
@media (max-width: 680px) {
  .navbar-right {
    gap: 4px;
  }
  .theme-toggle {
    width: 44px;
    height: 44px;
  }

  /* Toolbar: 2x2 filter tabs, full-width search */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .filter-tab {
    min-height: 44px;
    padding: 8px 6px;
  }
  .search-input-wrapper,
  .search-input {
    width: 100%;
  }
  .search-input {
    min-height: 44px;
  }

  /* Runs table and history table -> stacked cards; labels come from data-label */
  #test-runs-table thead,
  .history-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  #test-runs-table,
  #test-runs-table tbody,
  .history-table,
  .history-table tbody {
    display: block;
    width: 100%;
  }
  #test-runs-table tbody tr,
  .history-table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
  }
  #test-runs-table tbody tr:last-child,
  .history-table tbody tr:last-child {
    border-bottom: none;
  }
  #test-runs-table tbody td,
  .history-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    padding: 0;
    border-bottom: none;
    text-align: right;
  }
  #test-runs-table tbody td[colspan] {
    display: block;
  }
  #test-runs-table tbody td[data-label]::before,
  .history-table tbody td[data-label]::before {
    content: attr(data-label);
    /* Empty alt text: screen readers already get the column header from <thead> */
    content: attr(data-label) / "";
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
  }
  #test-runs-table .run-id-link,
  .history-table .run-id-link {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .git-context {
    justify-content: flex-end;
    min-width: 0;
    max-width: 100%;
  }
  #test-runs-table .git-badge,
  .history-table .git-badge {
    max-width: 100%;
  }
  .history-table .git-badge {
    display: block;
  }
  .snapshots-summary {
    align-items: flex-end;
  }
  .snapshots-sub {
    justify-content: flex-end;
  }
  #test-runs-table td.run-actions-cell {
    text-align: left !important;
  }
  #test-runs-table td.run-actions-cell .btn-inspect {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  /* History cards: thumbnail on top, run link + time full width */
  .history-table tbody td.history-thumb-cell {
    order: -1;
    display: block;
  }
  .history-thumb-link {
    display: block;
  }
  .history-thumb {
    width: 100%;
    height: 160px;
  }
  .history-table tbody td.history-run-cell {
    display: block;
    text-align: left;
  }
  .history-row-baseline-changed td:first-child {
    box-shadow: none;
  }
  .history-table tbody tr.history-row-baseline-changed {
    box-shadow: inset 3px 0 0 var(--approved-purple);
  }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
    text-align: center;
  }
  .pagination-controls {
    justify-content: space-between;
  }
  .pagination-btn {
    min-height: 44px;
  }

  /* Run detail */
  .detail-header-card,
  .history-chart-card {
    padding: 18px 16px;
  }
  .detail-run-id {
    font-size: 19px;
    overflow-wrap: anywhere;
    min-width: 0;
  }
  .detail-title-row > * {
    min-width: 0;
  }
  .btn-approve-all {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  .detail-meta-row {
    gap: 6px 12px;
    font-size: 13px;
  }
  .snapshot-header {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }
  .snapshot-title {
    min-width: 0;
    gap: 8px;
  }
  .route-pill {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .snapshot-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .btn-approve,
  .btn-reject {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  .tabs-nav {
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
  }
  .tab-btn {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 13px;
  }
  .tab-panel {
    padding: 14px;
  }
  .side-by-side {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .slider-handle-pill {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}

/* ==========================================================================
   Accessibility & keyboard shortcuts - M5
   Skip link, focus rings, slider/tab focus, action error regions, the run page's
   shortcut hint and help dialog. Uses existing colour tokens only (contrast and
   theming are handled separately).
   ========================================================================== */

/* Skip link: off-screen until focused (first Tab stop on every page) */
.skip-link {
  position: absolute;
  left: 16px;
  top: 8px;
  z-index: 1000;
  transform: translateY(-200%);
  padding: 10px 16px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 2px solid var(--bright-cyan);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

/* One visible focus ring for every keyboard-focusable element */
:focus-visible {
  outline: 2px solid var(--bright-cyan);
  outline-offset: 2px;
}

/* Programmatic focus targets (skip link destination, j/k cards) need no ring of their own;
   the current card is marked by .is-current below. */
#main:focus,
.snapshot-card:focus {
  outline: none;
}

/* j/k: the current snapshot card. scroll-margin keeps it clear of the sticky navbar. */
.snapshot-card {
  scroll-margin-top: 76px;
}

.snapshot-card.is-current {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 1px var(--primary-blue), var(--shadow-snapshot);
}

/* Slider: horizontal drags move the divider, vertical swipes still scroll the page */
.slider-view-container {
  touch-action: pan-y;
}

/* The handle sits in the 2px-wide divider and used to shrink to ~19px: keep its full
   36px (pointer target size, and room for the focus ring) */
.slider-handle-pill {
  flex-shrink: 0;
}

.slider-divider:focus-visible {
  outline: none;
}

.slider-divider:focus-visible .slider-handle-pill {
  outline: 2px solid var(--bright-cyan);
  outline-offset: 3px;
}

/* Inactive tab panels carry the hidden attribute (tabs.js) */
.tab-panel[hidden] {
  display: none;
}

/* Error page heading (was an h2 before the page got its h1) */
.error-container h1 {
  font-size: 1.5em;
}

/* Approve/reject errors (role="alert"); takes no space while empty */
.action-error:not(:empty) {
  margin: 0 24px 16px;
  padding: 10px 14px;
  background-color: var(--status-failed-bg);
  border: 1px solid var(--status-failed-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.detail-header-card .action-error:not(:empty) {
  margin: 14px 0 0;
}

.action-error p {
  margin: 0;
}

.action-error-button {
  margin-left: 6px;
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* "Press ? for keyboard shortcuts" (run detail header) */
.shortcuts-hint {
  background: none;
  border: none;
  padding: 0;
  margin-left: auto;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}

.shortcuts-hint:hover {
  color: var(--text-primary);
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9em;
  line-height: 1.4;
  text-align: center;
}

/* Keyboard shortcuts help (native <dialog>) */
.shortcuts-dialog {
  margin: auto; /* centred (the global reset removes the browser's own margin) */
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 22px 24px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-dialog);
}

.shortcuts-dialog::backdrop {
  background-color: var(--dialog-backdrop);
}

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

.shortcuts-dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.shortcuts-dialog-close {
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
}

.shortcuts-dialog-close:hover {
  color: var(--text-primary);
}

.shortcuts-list {
  margin: 0 0 14px;
}

.shortcuts-list > div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-color);
}

.shortcuts-list dt {
  white-space: nowrap;
}

.shortcuts-list dd {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.shortcuts-note {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.shortcuts-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-weight: 600;
}

.shortcuts-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-blue);
}

/* ==========================================================================
   Imported runs (visual-ci import) - M2
   ========================================================================== */

/* "Imported" badge: dashboard row and run header */
.imported-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin-left: 6px;
  background-color: var(--primary-tint-bg);
  color: var(--primary-on-tint);
  border: 1px solid var(--primary-tint-border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.detail-title-row .imported-badge {
  margin-left: 0;
}

/* The local baseline is not the one CI compared against: approval would be refused */
.baseline-stale-note {
  margin: 0 24px 16px;
  padding: 10px 14px;
  background-color: var(--status-new-bg);
  border: 1px solid var(--status-new-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.detail-header-card .baseline-stale-note {
  margin: 14px 0 0;
}

.baseline-stale-note[hidden] {
  display: none;
}

/* Approve buttons disabled because of a stale baseline (not "busy") */
.btn-approve.is-blocked,
.btn-approve-all.is-blocked:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-approve.is-blocked:hover {
  background-color: var(--success-tint-bg);
  color: var(--success-green);
}

/* ==========================================================================
   Import a CI run (dashboard, live mode only) - M8
   ========================================================================== */

.import-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.btn-import {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--primary-tint-bg);
  color: var(--primary-on-tint);
  border: 1px solid var(--primary-tint-border);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-import:hover:not(:disabled) {
  background-color: var(--primary-blue);
  color: var(--on-accent);
}

.btn-import:focus-visible {
  outline: 2px solid var(--bright-cyan);
  outline-offset: 2px;
}

.btn-import:disabled {
  cursor: progress;
  opacity: 0.7;
}

.import-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Progress / result of an import (role="status"). Takes no space while empty but stays
   rendered: display: none would drop the live region, and "Importing..." might not be
   announced. */
.import-status {
  margin: 0;
  font-size: 13px;
  color: var(--text-primary);
}

.import-status:not(:empty) {
  margin: 0 0 16px;
}

.import-status ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.import-status a {
  color: var(--bright-cyan);
}

.import-feedback .action-error:not(:empty) {
  margin: 0 0 16px;
}

/* Shown while a file is dragged over the page */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--overlay-backdrop);
  pointer-events: none;
}

.drop-overlay[hidden] {
  display: none;
}

.drop-overlay-inner {
  max-width: 520px;
  padding: 40px 32px;
  border: 2px dashed var(--primary-blue);
  border-radius: var(--radius-card);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

@media (max-width: 680px) {
  .page-heading-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  .import-control {
    align-items: stretch;
    width: 100%;
  }
  .btn-import {
    min-height: 44px;
    justify-content: center;
  }
}

/* ==========================================================================
   What changed (1.1.0): the panel under each DIFF snapshot's views, and the
   numbered region boxes over its diff image (what-changed.js)
   ========================================================================== */

.what-changed {
  padding: 24px 28px 28px;
  border-top: 1px solid var(--border-color);
}

/* Focused by the w shortcut: a ring only when the keyboard put it there */
.what-changed:focus {
  outline: none;
}

.what-changed:focus-visible {
  outline: 2px solid var(--bright-cyan);
  outline-offset: -4px;
}

.what-changed-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 14px;
}

.what-changed-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.what-changed-summary {
  font-size: 13px;
  color: var(--text-secondary);
}

.what-changed-message {
  padding: 12px 14px;
  background-color: var(--subtle-fill);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
}

.what-changed-message + .wc-regions {
  margin-top: 14px;
}

.wc-regions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wc-region {
  min-width: 0;
  padding: 14px 16px;
  background-color: var(--bg-table);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wc-region.is-active {
  border-color: var(--region-outline-active);
  box-shadow: 0 0 0 1px var(--region-outline-active);
}

.wc-region-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 10px;
}

/* The region's number, as on its box over the diff */
.wc-region-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background-color: var(--region-label-bg);
  color: var(--region-label-text);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

/* Not only another colour: a ring around the badge marks the highlighted region */
.wc-region.is-active .wc-region-num {
  background-color: var(--region-label-active-bg);
  color: var(--region-label-active-text);
  box-shadow: 0 0 0 2px var(--bg-table), 0 0 0 4px var(--region-outline-active);
}

.wc-region-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.wc-region-area {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Same family as the Import / Inspect buttons (blue tint) */
.btn-show-region {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-left: auto;
  padding: 6px 12px;
  background-color: var(--primary-tint-bg);
  color: var(--primary-on-tint);
  border: 1px solid var(--primary-tint-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-show-region:hover {
  background-color: var(--primary-blue);
  color: var(--on-accent);
}

.wc-changes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wc-change {
  min-width: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.wc-change + .wc-change {
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.wc-change-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-bottom: 6px;
}

.wc-kind {
  padding: 1px 6px;
  background-color: var(--subtle-fill);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.wc-change code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.wc-change .wc-element {
  min-width: 0;
  font-size: 13px;
  color: var(--bright-cyan);
}

.wc-element-none {
  font-style: italic;
}

.wc-props {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.wc-prop {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
}

.wc-change .wc-prop-name {
  min-width: 9em;
  color: var(--text-secondary);
}

.wc-values,
.wc-value {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

/* Decorative: the value is printed next to it */
.wc-swatch {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 1px solid var(--control-border);
  border-radius: 3px;
}

.wc-arrow {
  color: var(--text-muted);
}

.wc-detail {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.wc-detail q {
  color: var(--text-primary);
}

.wc-more,
.wc-prop-more {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.wc-notes {
  margin-top: 14px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Region boxes over the diff image: positioned in % of the image's own box (.diff-stage),
   so they scale with it and scroll with it inside the frame. */
.diff-stage {
  position: relative;
}

.region-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.region-box {
  position: absolute;
  min-width: 4px;
  min-height: 4px;
  border: 2px solid var(--region-outline);
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--region-halo), inset 0 0 0 1px var(--region-halo);
  scroll-margin: 48px;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.region-box-label {
  position: absolute;
  top: -1px;
  left: -1px;
  min-width: 18px;
  padding: 0 4px;
  background-color: var(--region-label-bg);
  color: var(--region-label-text);
  border-radius: 0 0 3px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* One region highlighted: the others step back */
.region-overlay.has-active .region-box:not(.is-active) {
  opacity: 0.45;
}

.region-box.is-active {
  z-index: 1;
  border-width: 3px;
  border-color: var(--region-outline-active);
  background-color: var(--region-fill-active);
  animation: region-pulse 0.7s ease-out 1;
}

.region-box.is-active .region-box-label {
  background-color: var(--region-label-active-bg);
  color: var(--region-label-active-text);
}

@keyframes region-pulse {
  from {
    box-shadow: 0 0 0 1px var(--region-halo), inset 0 0 0 1px var(--region-halo), 0 0 0 10px var(--region-fill-active);
  }
  to {
    box-shadow: 0 0 0 1px var(--region-halo), inset 0 0 0 1px var(--region-halo), 0 0 0 0 var(--region-fill-active);
  }
}

@media (prefers-reduced-motion: reduce) {
  .region-box,
  .wc-region {
    transition: none;
  }
  .region-box.is-active {
    animation: none;
  }
}

/* Phones: everything stacks, the button is a full-width 44px tap target */
@media (max-width: 680px) {
  .what-changed {
    padding: 18px 14px 20px;
  }
  .wc-region {
    padding: 12px;
  }
  .wc-region-head {
    align-items: flex-start;
  }
  .wc-region-title {
    flex: 1 1 0;
  }
  .wc-region-area {
    display: block;
    margin-left: 0;
  }
  .btn-show-region {
    width: 100%;
    margin-left: 0;
    font-size: 13px;
  }
  .wc-change .wc-prop-name {
    min-width: 0;
  }
  /* The diff image is scaled down a lot here: keep the numbers from hiding the boxes */
  .region-box-label {
    min-width: 14px;
    padding: 0 3px;
    font-size: 10px;
    line-height: 13px;
  }
}
