:root {
  --bg-body: #f5f7fa;
  --bg-card: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-hover: #f3f4f6;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;
  --border-color: #e5e7eb;
  --border-hover: #d1d5db;
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success-text: #059669;
  --success-bg: #d1fae5;
  --success-border: #6ee7b7;
  --danger-text: #dc2626;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;
  --warning-text: #d97706;
  --warning-bg: #fef3c7;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0a0e14;
    --bg-card: #151920;
    --bg-subtle: #1e2430;
    --bg-hover: #252c38;
    --text-main: #e6edf3;
    --text-muted: #8b949e;
    --text-subtle: #6e7681;
    --border-color: #2d3543;
    --border-hover: #3d4554;
    --primary-color: #58a6ff;
    --primary-hover: #79c0ff;
    --primary-light: #1f2d3d;
    --success-text: #3fb950;
    --success-bg: rgba(46, 160, 67, 0.15);
    --success-border: rgba(46, 160, 67, 0.4);
    --danger-text: #f85149;
    --danger-bg: rgba(248, 81, 73, 0.15);
    --danger-border: rgba(248, 81, 73, 0.4);
    --warning-text: #e3b341;
    --warning-bg: rgba(187, 128, 9, 0.15);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

body {
  margin: 0;
  padding: 20px 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  overflow-y: scroll;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.container {
  max-width: 980px;
  margin: 0 auto;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.header {
  padding: 28px 24px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(to bottom, var(--bg-card), var(--bg-subtle));
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Summary Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background-color: var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.summary-item {
  background-color: var(--bg-card);
  padding: 20px 16px;
  text-align: center;
  transition: var(--transition);
  position: relative;
}

.summary-item:hover {
  background-color: var(--bg-hover);
}

.summary-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.summary-value {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-value.success {
  color: var(--success-text);
}

.summary-value.danger {
  color: var(--danger-text);
}

/* Filter Controls */
.controls {
  padding: 14px 20px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.filter-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.filter-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

.search-box input {
  width: 100%;
  padding: 6px 14px 6px 36px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-family: inherit;
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box {
  position: relative;
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  opacity: 0.5;
}

/* Table Styles */
.table-wrapper {
  overflow-x: auto;
}

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

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 32px;
}

th.sortable:hover {
  background-color: var(--bg-hover);
}

th.sortable::after {
  content: '↕';
  position: absolute;
  right: 12px;
  opacity: 0.3;
  font-size: 0.875rem;
}

th.sortable.sorted-asc::after {
  content: '↑';
  opacity: 1;
  color: var(--primary-color);
}

th.sortable.sorted-desc::after {
  content: '↓';
  opacity: 1;
  color: var(--primary-color);
}

tbody tr {
  transition: var(--transition);
  border-bottom: 1px solid var(--border-color);
}

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

tbody tr.hidden {
  display: none;
}

td {
  padding: 12px 16px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* First Column: Test Suite Link */
td:first-child {
  color: var(--text-main);
  font-weight: 500;
}

td:first-child a {
  color: var(--primary-color);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  word-break: break-word;
  line-height: 1.5;
}

td:first-child a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Numeric Columns Alignment */
th:not(:first-child),
td:not(:first-child) {
  text-align: center;
}

/* Status Badge Styles */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  min-width: 42px;
}

.badge.success {
  color: var(--success-text);
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
}

.badge.danger {
  color: var(--danger-text);
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
}

/* Engine Error Icon */
.error-icon {
  color: var(--danger-text);
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
}

/* Progress Bar */
.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.progress-track {
  width: 80px;
  height: 6px;
  background-color: var(--border-color);
  border-radius: 99px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.progress-fill {
  height: 100%;
  background: var(--text-muted);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.progress-fill.success {
  background: linear-gradient(90deg, var(--success-text), #059669);
}

.progress-text {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
  color: var(--text-muted);
}

/* Footer Totals */
tfoot {
  background-color: var(--bg-subtle);
  font-weight: 700;
}

tfoot th {
  color: var(--text-main);
  font-size: 0.8125rem;
  border-top: 2px solid var(--border-color);
  border-bottom: none;
  font-weight: 700;
  padding: 14px 16px;
}

/* Footer Note */
.footer-note {
  padding: 16px 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-subtle);
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  line-height: 1.5;
}

.footer-note a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.footer-note a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Empty State */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 0.875rem;
  margin: 0;
}

/* Print Styles */
@media print {
  body {
    padding: 0;
    background: white;
  }

  .card {
    box-shadow: none;
    border: none;
  }

  .controls {
    display: none;
  }

  tbody tr:hover {
    background-color: transparent;
  }

  .summary-item:hover {
    background-color: var(--bg-card);
  }

  a {
    text-decoration: none;
    color: inherit;
  }

  thead {
    position: static;
  }
}

/* Responsive Mobile Styles */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .header {
    padding: 32px 20px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-value {
    font-size: 1.5rem;
  }

  .controls {
    padding: 16px;
  }

  .search-box {
    max-width: 100%;
    order: -1;
    flex: 1 1 100%;
  }

  /* Mobile Card Layout */
  .table-wrapper {
    margin-top: 20px;
    overflow-x: visible;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr,
  tfoot {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 16px;
    border-style: solid;
    border-color: var(--border-color);
    border-width: 1px 0;
    overflow: hidden;
  }

  tbody tr:last-child {
    margin-bottom: 0;
  }

  td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
  }

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

  /* Title Cell */
  td:first-child {
    background-color: var(--bg-subtle);
    text-align: left;
    display: block;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
  }

  td:first-child a {
    font-size: 0.9375rem;
    font-weight: 600;
  }

  /* Data Labels */
  td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }

  td:first-child::before {
    content: none;
  }

  td:nth-of-type(2)::before {
    content: 'Total';
  }

  td:nth-of-type(3)::before {
    content: 'Passed';
  }

  td:nth-of-type(4)::before {
    content: 'Failed';
  }

  td:nth-of-type(5)::before {
    content: 'Pass Rate';
  }

  td .progress-wrapper {
    justify-content: flex-end;
    flex: 1;
  }

  /* Footer Mobile */
  tfoot {
    margin-top: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
  }

  tfoot tr {
    display: flex;
    flex-direction: column;
  }

  tfoot th {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
  }

  tfoot th:last-child {
    border-bottom: none;
  }

  tfoot th:first-child {
    display: block;
    text-align: center;
    background-color: var(--bg-subtle);
    padding: 16px 20px;
  }

  tfoot th::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }

  tfoot th:nth-of-type(2)::before {
    content: 'Total';
  }

  tfoot th:nth-of-type(3)::before {
    content: 'Passed';
  }

  tfoot th:nth-of-type(4)::before {
    content: 'Failed';
  }

  tfoot th:nth-of-type(5)::before {
    content: 'Pass Rate';
  }

  tfoot .progress-wrapper {
    justify-content: flex-end;
    flex: 1;
  }
}

/* Tablet Adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@page {
  size: A4;
  margin: 20mm;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

tbody tr {
  animation: fadeIn 0.3s ease-out;
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}
