*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: light;
  --bg-page: #f3f2f1;
  --text-primary: #323130;
  --text-muted: #605e5c;
  --surface-1: #ffffff;
  --surface-2: #faf9f8;
  --surface-3: #f3f2f1;
  --border-1: #edebe9;
  --border-2: #8a8886;
  --hover-surface: #faf9f8;
  --focus-ring: rgba(0,120,212,.2);
  --link-accent: #0078d4;
  --stack-bg: #f3f2f1;
  --loading-bg: rgba(255,255,255,.82);
  --modal-overlay: rgba(0,0,0,.45);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-page: #121417;
  --text-primary: #e6e9ec;
  --text-muted: #a8b0b8;
  --surface-1: #1b2026;
  --surface-2: #232a33;
  --surface-3: #1d232b;
  --border-1: #35404b;
  --border-2: #5e6b77;
  --hover-surface: #2a333d;
  --focus-ring: rgba(77,163,255,.28);
  --link-accent: #67b0ff;
  --stack-bg: #171c22;
  --loading-bg: rgba(7,10,14,.75);
  --modal-overlay: rgba(0,0,0,.62);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background .2s ease, color .2s ease;
}

/* ─── Header ─── */
.site-header {
  background: #0078d4;
  color: #fff;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header h1 { font-size: 1.25rem; font-weight: 600; }
.site-header .meta { font-size: .75rem; opacity: .8; margin-bottom: 3px; }
.header-actions { display: flex; gap: 10px; align-items: center; }
#lastRefreshed { font-size: .78rem; opacity: .75; }

/* ─── Container ─── */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 32px; }

/* ─── Buttons ─── */
.btn {
  padding: 8px 18px;
  border-radius: 4px;
  border: none;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #0078d4; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #106ebe; }
.btn-secondary { background: #f3f2f1; color: #323130; border: 1px solid #8a8886; }
.btn-secondary:hover:not(:disabled) { background: #edebe9; }
.btn-ghost { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.25); }

.btn-theme {
  min-width: 108px;
  text-align: center;
}

/* ─── Config Panel ─── */
.config-panel { background: #fff; border: 1px solid #edebe9; border-radius: 8px; margin-bottom: 24px; overflow: hidden; }
.config-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; cursor: pointer; user-select: none;
  background: #faf9f8; border-bottom: 1px solid #edebe9;
}
.config-header:hover { background: #f3f2f1; }
.config-header h2 { font-size: .92rem; font-weight: 600; }
.config-header .toggle-icon { font-size: .7rem; color: #605e5c; transition: transform .2s; }
.config-header .toggle-icon.rotated { transform: rotate(180deg); }
.config-body { padding: 20px; display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.config-body.hidden { display: none; }

.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 220px; }
.form-group label { font-size: .75rem; font-weight: 600; color: #605e5c; text-transform: uppercase; letter-spacing: .05em; }
.form-group input, .form-group select {
  padding: 7px 11px; border: 1px solid #8a8886; border-radius: 4px;
  font-size: .88rem; color: #323130; background: #fff; transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: #0078d4; box-shadow: 0 0 0 2px rgba(0,120,212,.2);
}
.config-actions { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 1px; }

/* ─── Auth Status ─── */
.auth-status-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 6px; font-size: .88rem; font-weight: 600;
}
.auth-ok  { background: #dff6dd; color: #107c10; border: 1px solid #a9d1a9; }
.auth-pat { background: #fff4ce; color: #7a6400; border: 1px solid #e8d76a; }

/* ─── Error Banner ─── */
.error-banner {
  background: #fde7e9; border: 1px solid #f1707b; border-radius: 8px;
  padding: 13px 18px; margin-bottom: 22px; font-size: .875rem; color: #a4262c; display: none;
}
.error-banner.visible { display: block; }

/* ─── Run Info Bar ─── */
.run-info {
  background: #fff; border: 1px solid #edebe9; border-radius: 8px;
  padding: 15px 20px; margin-bottom: 22px;
  display: none; flex-wrap: wrap; gap: 20px; align-items: center;
}
.run-info.visible { display: flex; }
.run-info-item { display: flex; flex-direction: column; gap: 2px; }
.run-info-item .lbl { font-size: .72rem; color: #605e5c; text-transform: uppercase; letter-spacing: .05em; }
.run-info-item .val { font-size: .92rem; font-weight: 600; }
.run-picker-group { display: flex; flex-direction: column; gap: 5px; }
.run-picker-group label { font-size: .72rem; color: #605e5c; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
#runPickerSelect {
  padding: 6px 10px; border: 1px solid #8a8886; border-radius: 4px;
  font-size: .84rem; color: #323130; background: #fff; min-width: 260px; cursor: pointer;
}
#runPickerSelect:focus { outline: none; border-color: #0078d4; box-shadow: 0 0 0 2px rgba(0,120,212,.2); }
.run-status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 100px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.rs-succeeded { background: #dff6dd; color: #107c10; }
.rs-failed    { background: #fde7e9; color: #a4262c; }
.rs-running   { background: #fff4ce; color: #7a6400; }
.rs-unknown   { background: #edebe9; color: #605e5c; }

/* ─── Summary Grid ─── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 16px;
  margin-bottom: 22px;
  display: none;
}
.summary-grid.visible { display: grid; }
@media (max-width: 900px) { .summary-grid.visible { grid-template-columns: 1fr 1fr; } }

.summary-card {
  background: #fff; border: 1px solid #edebe9; border-radius: 8px;
  padding: 18px 16px; text-align: center;
}
.summary-card .card-val { font-size: 2.4rem; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.summary-card .card-lbl { font-size: .8rem; color: #605e5c; text-transform: uppercase; letter-spacing: .05em; }
.card-total  .card-val { color: #0078d4; }
.card-passed .card-val { color: #107c10; }
.card-failed .card-val { color: #d83b01; }

.chart-card {
  background: #fff; border: 1px solid #edebe9; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 12px;
}

/* ─── Generic Section ─── */
.section {
  background: #fff; border: 1px solid #edebe9; border-radius: 8px;
  overflow: hidden; margin-bottom: 22px; display: none;
}
.section.visible { display: block; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; cursor: pointer; user-select: none; border-bottom: 1px solid #edebe9;
}
.section-header:hover { background: #faf9f8; }
.section-header h2 { font-size: .97rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.section-header .sh-chevron { font-size: .7rem; color: #605e5c; transition: transform .2s; }
.section-header .sh-chevron.open { transform: rotate(180deg); }
.section-body.collapsed { display: none; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #d83b01; color: #fff; font-size: .72rem; font-weight: 700;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 100px;
}
.badge-blue { background: #0078d4; }

/* ─── Accordion (failed tests) ─── */
.acc-item { border-bottom: 1px solid #edebe9; }
.acc-item:last-child { border-bottom: none; }
.acc-trigger {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 20px; cursor: pointer; transition: background .1s;
}
.acc-trigger:hover { background: #faf9f8; }
.acc-trigger .acc-icon { flex-shrink: 0; margin-top: 1px; }
.acc-trigger .acc-title { font-size: .88rem; font-weight: 600; color: #d83b01; flex: 1; word-break: break-word; }
.acc-trigger .acc-chevron { font-size: .68rem; color: #605e5c; flex-shrink: 0; transition: transform .2s; margin-top: 4px; }
.acc-trigger.open .acc-chevron { transform: rotate(180deg); }
.acc-body { padding: 0 20px 16px 44px; display: none; }
.acc-body.open { display: block; }

.error-msg {
  background: #fde7e9; border-left: 3px solid #d83b01;
  padding: 9px 13px; border-radius: 0 4px 4px 0;
  margin-bottom: 10px; font-size: .83rem; white-space: pre-wrap; word-break: break-word;
}
.stack-toggle { font-size: .78rem; color: #0078d4; cursor: pointer; display: inline-block; margin-bottom: 8px; }
.stack-trace {
  background: #f3f2f1; border-radius: 4px; padding: 9px 13px;
  font-family: 'Cascadia Code', Consolas, monospace; font-size: .76rem; color: #605e5c;
  white-space: pre-wrap; word-break: break-all; overflow-x: auto;
  display: none; margin-bottom: 10px;
}
.stack-trace.open { display: block; }

.screenshot-area { margin-top: 10px; }
.screenshot-area .ss-label { font-size: .78rem; color: #605e5c; margin-bottom: 6px; }
.screenshot-area img {
  max-width: 100%; max-height: 380px; border-radius: 4px;
  border: 1px solid #edebe9; cursor: zoom-in; display: block;
}
.screenshot-link { font-size: .83rem; color: #0078d4; text-decoration: none; }
.screenshot-link:hover { text-decoration: underline; }

.testim-link {
  flex-shrink: 0; display: inline-flex; align-items: center;
  font-size: .73rem; font-weight: 700; color: #5b2b82;
  background: #f3eef9; border: 1px solid #c9b4e8;
  padding: 2px 10px; border-radius: 100px; text-decoration: none;
  white-space: nowrap; transition: background .1s;
}
.testim-link:hover { background: #e6d9f5; }
.testim-run-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .83rem; font-weight: 600; color: #5b2b82; text-decoration: none;
}
.testim-run-link:hover { text-decoration: underline; }

/* ─── Rerun Buttons ─── */
.btn-rerun {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 4px; font-size: .78rem; font-weight: 600;
  background: #0078d4; color: #fff; border: none; cursor: pointer;
  transition: background .15s; white-space: nowrap;
}
.btn-rerun:hover:not(:disabled) { background: #106ebe; }
.btn-rerun:disabled { opacity: .5; cursor: not-allowed; }
.btn-rerun.loading { pointer-events: none; }
.btn-rerun .spinner-small {
  width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite;
}

.rerun-test-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px;
  font-size: .73rem; font-weight: 700; color: #fff;
  background: #0078d4; border: 1px solid #005a9e;
  padding: 2px 10px; border-radius: 100px; text-decoration: none;
  white-space: nowrap; transition: background .1s; cursor: pointer;
}
.rerun-test-btn:hover:not(:disabled) { background: #106ebe; }
.rerun-test-btn:disabled { opacity: .5; cursor: not-allowed; }
.rerun-test-btn.loading { pointer-events: none; }
.rerun-test-btn .spinner-small {
  width: 10px; height: 10px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite;
}

/* ─── Confirmation Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.visible { display: flex; }
.modal-box {
  background: #fff; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.25);
  max-width: 440px; width: 90%; padding: 24px; text-align: center;
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 12px; color: #323130; }
.modal-message { font-size: .9rem; color: #605e5c; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ─── Success Toast ─── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 1100;
  background: #107c10; color: #fff; padding: 14px 20px;
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  display: none; font-size: .88rem; max-width: 400px;
}
.toast.visible { display: block; animation: slideIn .25s ease-out; }
.toast.error { background: #a4262c; }
.toast a { color: #fff; text-decoration: underline; }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── All Tests Table ─── */
.table-filters {
  padding: 12px 20px; border-bottom: 1px solid #edebe9;
  display: flex; gap: 10px; align-items: center; flex-wrap: nowrap;
}
.table-filters input {
  padding: 6px 11px; border: 1px solid #8a8886; border-radius: 4px;
  font-size: .83rem; width: 220px; min-width: 150px;
}
.table-filters input:focus { outline: none; border-color: #0078d4; }

.results-table { width: 100%; border-collapse: collapse; }
.results-table th {
  text-align: left; padding: 9px 20px;
  font-size: .75rem; font-weight: 600; color: #605e5c;
  text-transform: uppercase; letter-spacing: .05em;
  background: #faf9f8; border-bottom: 1px solid #edebe9;
}
.results-table td { padding: 9px 20px; font-size: .86rem; border-bottom: 1px solid #edebe9; vertical-align: middle; }
.results-table tr:last-child td { border-bottom: none; }
.results-table tbody tr:hover td { background: #faf9f8; }
.tag-summary-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.outcome-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 100px; font-size: .73rem; font-weight: 700; white-space: nowrap;
}
.op-passed { background: #dff6dd; color: #107c10; }
.op-failed { background: #fde7e9; color: #a4262c; }
.op-other  { background: #edebe9; color: #605e5c; }

/* ─── Loading Overlay ─── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.82);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  z-index: 500; gap: 14px;
}
.loading-overlay.visible { display: flex; }
.spinner {
  width: 38px; height: 38px; border: 3px solid #edebe9;
  border-top-color: #0078d4; border-radius: 50%;
  animation: spin .75s linear infinite;
}
.loading-label { font-size: .88rem; color: #605e5c; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Lightbox ─── */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px; cursor: zoom-out;
}
.lightbox.visible { display: flex; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 4px; object-fit: contain; }
.lightbox-close {
  position: absolute; top: 18px; right: 22px;
  color: #fff; font-size: 1.4rem; cursor: pointer; background: none; border: none; opacity: .8;
  line-height: 1;
}
.lightbox-close:hover { opacity: 1; }

/* ─── Misc ─── */
.all-passed { padding: 28px; text-align: center; color: #107c10; font-size: .97rem; font-weight: 600; }
.no-rows td { text-align: center; color: #605e5c; padding: 28px 20px !important; }
.group-header-row td {
  background: #f3f2f1; font-size: .75rem; font-weight: 700;
  color: #323130; text-transform: uppercase; letter-spacing: .06em;
  padding: 7px 20px; border-bottom: 1px solid #edebe9;
  border-top: 2px solid #c8c6c4;
}
.group-header-row:first-child td { border-top: none; }
.group-by-controls { display: flex; align-items: center; gap: 7px; margin-left: auto; flex-wrap: nowrap; }
.group-by-controls label { font-size: .78rem; color: #605e5c; font-weight: 600; white-space: nowrap; }
.group-by-controls select {
  padding: 5px 10px; border: 1px solid #8a8886; border-radius: 4px;
  font-size: .82rem; background: #fff; cursor: pointer;
  max-width: 140px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.group-by-controls select:focus { outline: none; border-color: #0078d4; }
a.ado-link { color: #fff; font-size: .8rem; font-weight: 600; padding: 6px 14px; border-radius: 4px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); text-decoration: none; transition: background .15s; }
a.ado-link:hover { background: rgba(255,255,255,.28); }

/* ─── Dark Theme Overrides ─── */
html[data-theme="dark"] .config-panel,
html[data-theme="dark"] .run-info,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .section,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .toast,
html[data-theme="dark"] #runPickerSelect,
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .table-filters input,
html[data-theme="dark"] .group-by-controls select {
  background: var(--surface-1);
  border-color: var(--border-1);
  color: var(--text-primary);
}

html[data-theme="dark"] .config-header,
html[data-theme="dark"] .section-header:hover,
html[data-theme="dark"] .acc-trigger:hover,
html[data-theme="dark"] .results-table tbody tr:hover td,
html[data-theme="dark"] .results-table th,
html[data-theme="dark"] .group-header-row td,
html[data-theme="dark"] .table-filters,
html[data-theme="dark"] .site-header {
  background: var(--surface-2);
}

html[data-theme="dark"] .site-header {
  box-shadow: 0 2px 10px rgba(0,0,0,.45);
}

html[data-theme="dark"] .section-header,
html[data-theme="dark"] .results-table th,
html[data-theme="dark"] .results-table td,
html[data-theme="dark"] .table-filters,
html[data-theme="dark"] .acc-item,
html[data-theme="dark"] .config-header,
html[data-theme="dark"] .run-info,
html[data-theme="dark"] .group-header-row td,
html[data-theme="dark"] .error-msg,
html[data-theme="dark"] .screenshot-area img {
  border-color: var(--border-1);
}

html[data-theme="dark"] .form-group label,
html[data-theme="dark"] .run-info-item .lbl,
html[data-theme="dark"] .run-picker-group label,
html[data-theme="dark"] .summary-card .card-lbl,
html[data-theme="dark"] .section-header .sh-chevron,
html[data-theme="dark"] .config-header .toggle-icon,
html[data-theme="dark"] .stack-trace,
html[data-theme="dark"] .loading-label,
html[data-theme="dark"] .no-rows td,
html[data-theme="dark"] .group-by-controls label,
html[data-theme="dark"] .screenshot-area .ss-label,
html[data-theme="dark"] .modal-message,
html[data-theme="dark"] .results-table th,
html[data-theme="dark"] .results-table td[style*="color:#605e5c"],
html[data-theme="dark"] .run-info-item .val,
html[data-theme="dark"] #lastRefreshed {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] .btn-secondary {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: var(--border-2);
}

html[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: var(--hover-surface);
}

html[data-theme="dark"] .form-group input:focus,
html[data-theme="dark"] .form-group select:focus,
html[data-theme="dark"] #runPickerSelect:focus,
html[data-theme="dark"] .table-filters input:focus,
html[data-theme="dark"] .group-by-controls select:focus {
  border-color: var(--link-accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

html[data-theme="dark"] .stack-trace {
  background: var(--stack-bg);
  color: #b7c0ca;
}

html[data-theme="dark"] .loading-overlay {
  background: var(--loading-bg);
}

html[data-theme="dark"] .modal-overlay {
  background: var(--modal-overlay);
}

html[data-theme="dark"] .group-header-row td {
  color: var(--text-primary);
  border-top-color: #4b5763;
}

html[data-theme="dark"] .error-banner {
  background: #3d1c21;
  border-color: #b14652;
  color: #ffb3bb;
}

html[data-theme="dark"] .error-msg {
  background: #3a1e24;
  color: #ffb5bc;
}

html[data-theme="dark"] .stack-toggle,
html[data-theme="dark"] .screenshot-link,
html[data-theme="dark"] .testim-run-link {
  color: var(--link-accent);
}

html[data-theme="dark"] .toast {
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
}

html[data-theme="dark"] .auth-ok {
  background: #193823;
  color: #8be091;
  border-color: #2c6540;
}

html[data-theme="dark"] .auth-pat,
html[data-theme="dark"] .rs-running {
  background: #3b3315;
  color: #f0d985;
  border-color: #6c5a20;
}

html[data-theme="dark"] .rs-succeeded,
html[data-theme="dark"] .op-passed {
  background: #1d3d26;
  color: #8be091;
}

html[data-theme="dark"] .rs-failed,
html[data-theme="dark"] .op-failed {
  background: #4a2027;
  color: #ffadb7;
}

html[data-theme="dark"] .rs-unknown,
html[data-theme="dark"] .op-other {
  background: #2b333c;
  color: #c4ccd4;
}

html[data-theme="dark"] .loading-overlay .spinner {
  border-color: #3a4652;
  border-top-color: #67b0ff;
}

/* ─── Views ─── */
.view[hidden] { display: none; }

/* ─── Analytics check (#diagnostics) ─── */
.diag-panel {
  background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 8px;
  padding: 20px; margin-bottom: 22px;
}
.diag-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.diag-head h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.diag-intro { font-size: .85rem; color: var(--text-muted); max-width: 620px; line-height: 1.5; }
.diag-actions { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.diag-actions a.btn { text-decoration: none; }
.diag-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.diag-table th, .diag-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-1); vertical-align: top; }
.diag-table th { color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
.diag-details { line-height: 1.5; word-break: break-word; }
.diag-empty { color: var(--text-muted); font-style: italic; }
.diag-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: .72rem; font-weight: 700; color: #fff; }
.diag-pass { background: #107c10; }
.diag-warn { background: #b35c00; }
.diag-fail { background: #c50f1f; }
.diag-info { background: #0078d4; }
.diag-skip { background: #8a8886; }
.config-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
@media (max-width: 640px) {
  .diag-table th:nth-child(2), .diag-table td:nth-child(2) { width: auto; }
  .diag-table th:first-child { width: auto !important; }
}

/* ─── Test history (failed tests) ─── */
:root {
  --hist-pass: #107c10; --hist-fail: #c50f1f; --hist-other: #a19f9d;
  --hist-new-bg: #fde7e9;   --hist-new-fg: #a4262c;
  --hist-flaky-bg: #fff4ce; --hist-flaky-fg: #7a5a00;
  --hist-ongoing-bg: #edebe9; --hist-ongoing-fg: #323130;
  --hist-none-bg: #deecf9;  --hist-none-fg: #004578;
}
html[data-theme="dark"] {
  --hist-pass: #54b054; --hist-fail: #f1707b; --hist-other: #6b7580;
  --hist-new-bg: #4a1f24;   --hist-new-fg: #ffb3b8;
  --hist-flaky-bg: #463a12; --hist-flaky-fg: #ffd966;
  --hist-ongoing-bg: #2f3842; --hist-ongoing-fg: #d5dbe1;
  --hist-none-bg: #1d3550;  --hist-none-fg: #a9d1f7;
}
.acc-trigger .hist { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; margin-top: 1px; }
.hist-strip { display: inline-flex; gap: 3px; }
.hist-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.hist-dot:hover, .hist-dot:focus-visible { outline: 2px solid var(--link-accent); outline-offset: 1px; }
.hist-pass  { background: var(--hist-pass); }
.hist-fail  { background: var(--hist-fail); }
.hist-other { background: var(--hist-other); }
.hist-label { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.hist-label.hist-new     { background: var(--hist-new-bg);     color: var(--hist-new-fg); }
.hist-label.hist-flaky   { background: var(--hist-flaky-bg);   color: var(--hist-flaky-fg); }
.hist-label.hist-ongoing { background: var(--hist-ongoing-bg); color: var(--hist-ongoing-fg); }
.hist-label.hist-none    { background: var(--hist-none-bg);    color: var(--hist-none-fg); }
.hist-loading, .hist-detail-muted { font-size: .78rem; color: var(--text-muted); font-style: italic; }
.hist-detail { margin-bottom: 12px; }
.hist-stats { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: .82rem; color: var(--text-muted); margin-bottom: 8px; }
.hist-stats strong { color: var(--text-primary); }
.hist-errors-btn { font-size: .78rem; padding: 4px 10px; }
.hist-errors { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.hist-error-head { display: flex; gap: 12px; font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; }
.hist-error-head a { color: var(--link-accent); }
@media (max-width: 640px) {
  .acc-trigger { flex-wrap: wrap; }
  .acc-trigger .hist { order: 3; width: 100%; padding-left: 28px; }
}

/* ─── View navigation ─── */
.view-nav { display: inline-flex; gap: 2px; background: rgba(255,255,255,.12); border-radius: 6px; padding: 3px; margin-right: 6px; }
.view-nav a {
  color: #fff; text-decoration: none; font-size: .82rem; font-weight: 600;
  padding: 5px 12px; border-radius: 4px; opacity: .85;
}
.view-nav a:hover { opacity: 1; background: rgba(255,255,255,.12); }
.view-nav a.active { opacity: 1; background: #fff; color: #0078d4; }
html[data-theme="dark"] .view-nav { background: var(--surface-3); }
html[data-theme="dark"] .view-nav a { color: var(--text-primary); }
html[data-theme="dark"] .view-nav a.active { background: var(--link-accent); color: #0b1220; }
@media (max-width: 760px) {
  .site-header { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .header-actions { flex-wrap: wrap; width: 100%; }
  .container { padding: 20px 16px; }
}

/* ─── Trends ─── */
.trends-controls { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; margin-bottom: 18px; }
.trends-control { flex: 0 1 240px; min-width: 180px; }
.trends-note { font-size: .8rem; color: var(--text-muted); line-height: 1.5; margin: 0 0 14px; max-width: 640px; }
.trends-controls .trends-note { margin: 0; flex: 1 1 260px; }
.trends-empty {
  background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 8px;
  padding: 32px; text-align: center; color: var(--text-muted); margin-bottom: 22px;
}
.trends-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1000px) { .trends-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .trends-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.trend-kpi { background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 8px; padding: 14px 16px; }
.trend-kpi-lbl { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.trend-kpi-val { font-size: 1.7rem; font-weight: 700; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.trend-kpi-note { font-size: .76rem; color: var(--text-muted); min-height: 1em; }
.trend-kpi-note.trend-up   { color: var(--hist-pass); }
.trend-kpi-note.trend-down { color: var(--hist-fail); }
.trends-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
.trend-card-wide { grid-column: 1 / -1; }
@media (max-width: 800px) { .trends-charts { grid-template-columns: 1fr; } }
.trend-card { background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.trend-card h3 { font-size: .9rem; font-weight: 600; margin-bottom: 10px; }
.trend-card-sub { font-size: .76rem; color: var(--text-muted); margin: -6px 0 8px; }
.trend-chart { position: relative; height: 240px; }
.trends-tables { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
@media (max-width: 1100px) { .trends-tables { grid-template-columns: 1fr; } }
.trend-table { width: 100%; border-collapse: collapse; font-size: .8rem; table-layout: fixed; }
.trend-table th { text-align: left; font-weight: 600; color: var(--text-muted); padding: 6px 6px; border-bottom: 1px solid var(--border-1); }
.trend-table td { padding: 6px; border-bottom: 1px solid var(--border-1); }
.trend-table th:first-child, .trend-table td:first-child { width: 55%; }
.trend-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend-table tr:last-child td { border-bottom: none; }
.trend-test { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend-muted { color: var(--text-muted); font-style: italic; text-align: center; padding: 14px; }

/* ─── Test library ─── */
.lib-controls .lib-search { flex: 1 1 260px; }
.lib-controls input[type="search"] {
  padding: 8px 10px; border: 1px solid var(--border-2); border-radius: 4px; font-size: .9rem;
  background: var(--surface-1); color: var(--text-primary);
}
.lib-toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.lib-summary { font-size: .85rem; color: var(--text-muted); line-height: 1.6; }
.lib-summary strong { color: var(--text-primary); }
.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-btn { font-size: .82rem; padding: 6px 12px; }
.lib-btn:disabled { opacity: .5; cursor: not-allowed; }
.lib-table-wrap { background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 8px; overflow-x: auto; margin-bottom: 10px; }
.lib-table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 860px; }
.lib-table th {
  text-align: left; font-weight: 600; color: var(--text-muted); background: var(--surface-2);
  padding: 8px 10px; border-bottom: 1px solid var(--border-1); white-space: nowrap; position: sticky; top: 0;
}
.lib-table th button {
  all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center;
}
.lib-table th button:focus-visible { outline: 2px solid var(--link-accent); outline-offset: 2px; }
.lib-table th.num button { justify-content: flex-end; }
.lib-sort-ind { font-size: .65rem; }
.lib-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-1); vertical-align: middle; }
.lib-table tr:last-child td { border-bottom: none; }
.lib-table tbody tr:hover { background: var(--hover-surface); }
.lib-table tr.lib-selected { background: var(--focus-ring); }
.lib-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lib-check { width: 34px; }
.lib-name { max-width: 380px; }
.lib-test { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-sub { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 3px; }
.lib-class { font-size: .74rem; color: var(--text-muted); }
.lib-cat { font-size: .68rem; padding: 1px 6px; border-radius: 8px; background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border-1); }
.lib-last { white-space: nowrap; }
.lib-outcome { font-weight: 600; margin-right: 6px; }
.lib-out-passed { color: var(--hist-pass); }
.lib-out-failed { color: var(--hist-fail); }
.lib-out-none, .lib-out-notexecuted, .lib-out-inconclusive { color: var(--text-muted); }
.lib-muted { color: var(--text-muted); font-size: .76rem; }

/* Library layouts */
.lib-layout { display: inline-flex; border: 1px solid var(--border-2); border-radius: 4px; overflow: hidden; }
.lib-layout-btn {
  font: inherit; font-size: .82rem; padding: 6px 12px; border: 0; cursor: pointer;
  background: var(--surface-1); color: var(--text-primary);
}
.lib-layout-btn + .lib-layout-btn { border-left: 1px solid var(--border-2); }
.lib-layout-btn.active { background: var(--link-accent); color: #fff; font-weight: 600; }
html[data-theme="dark"] .lib-layout-btn.active { color: #0b1220; }
.lib-layout-btn:focus-visible { outline: 2px solid var(--link-accent); outline-offset: 2px; }
.lib-group { margin-bottom: 14px; }
.lib-group > summary {
  display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none;
  padding: 10px 14px; background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 8px;
}
.lib-group > summary::-webkit-details-marker { display: none; }
.lib-group > summary::before { content: '▸'; font-size: .8rem; color: var(--text-muted); transition: transform .15s; }
.lib-group[open] > summary::before { transform: rotate(90deg); }
.lib-group[open] > summary { border-radius: 8px 8px 0 0; border-bottom: none; }
.lib-group[open] > .lib-table-wrap { border-radius: 0 0 8px 8px; }
.lib-group-title { font-weight: 600; font-size: .95rem; }
.lib-group-count { font-size: .8rem; color: var(--text-muted); }
.lib-group-failing { font-size: .76rem; font-weight: 600; color: var(--hist-fail); }
/* Same column widths in every library table so grouped tables line up */
.lib-table { table-layout: fixed; }
.lib-table th:nth-child(1) { width: 40px; }
.lib-table th:nth-child(2) { width: 34%; }
.lib-table th:nth-child(3) { width: 150px; }
.lib-table th:nth-child(4) { width: 150px; }
.lib-table th:nth-child(5) { width: 70px; }
.lib-table th:nth-child(6) { width: 90px; }
.lib-table th:nth-child(7) { width: 110px; }
.lib-table .lib-name { max-width: none; overflow: hidden; }

/* ─── Multi-select dropdown ─── */
.ms { position: relative; }
.ms-dd { position: relative; }
.ms-btn {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 11px; border: 1px solid #8a8886; border-radius: 4px;
  font-size: .88rem; color: #323130; background: #fff; user-select: none;
}
.ms-btn::-webkit-details-marker { display: none; }
.ms-btn::after { content: '▾'; font-size: .75rem; opacity: .7; }
.ms-btn:focus-visible, .ms-dd[open] > .ms-btn { outline: none; border-color: #0078d4; box-shadow: 0 0 0 2px rgba(0,120,212,.2); }
.ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-panel {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; min-width: 100%; max-width: 340px;
  max-height: 320px; overflow-y: auto; padding: 6px 0;
  background: var(--surface-1); border: 1px solid var(--border-1); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.ms-tools { display: flex; gap: 6px; padding: 2px 10px 6px; border-bottom: 1px solid var(--border-1); margin-bottom: 4px; }
.ms-tools button {
  font: inherit; font-size: .76rem; background: none; border: 0; padding: 2px 4px; cursor: pointer; color: var(--link-accent);
}
.ms-tools button:hover { text-decoration: underline; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 5px 12px; cursor: pointer; font-size: .85rem; color: var(--text-primary); }
.ms-opt:hover { background: var(--hover-surface); }
.ms-opt-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-count { font-size: .75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .ms-btn { background: var(--surface-1); border-color: var(--border-1); color: var(--text-primary); }
html[data-theme="dark"] .ms-dd[open] > .ms-btn { border-color: var(--link-accent); box-shadow: 0 0 0 2px var(--focus-ring); }

/* Failed tests: fixed-width label then strip, so the dots form a column */
.acc-trigger .hist-label { display: inline-block; width: 140px; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.acc-trigger .hist-strip { width: 127px; }  /* 10 dots of 10px with 3px gaps */
.acc-trigger .hist-loading { display: inline-block; width: 275px; }
/* Options are <label>s inside .form-group: undo the uppercase field-label style */
.form-group .ms-opt { text-transform: none; letter-spacing: normal; font-weight: 400; font-size: .85rem; color: var(--text-primary); }
.lib-cat.lib-run { border-style: dashed; }

/* Fixed-width slot for the Testim link at the right end of failed-test rows */
.testim-slot { flex-shrink: 0; width: 86px; display: inline-flex; justify-content: flex-end; }

/* Low-key link to the Analytics check, inside the Configuration panel */
.config-link { font-size: .8rem; color: var(--link-accent); text-decoration: none; }
.config-link:hover { text-decoration: underline; }

/* ─── Run tests (#run) ─── */
body[data-view="run"] #pipelinePanel { display: none !important; }
.run-panel a { color: var(--link-accent); }
.run-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.run-row .form-group { max-width: 300px; }
.run-fieldset { border: 1px solid var(--border-1); border-radius: 6px; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.run-fieldset legend { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.run-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-2); border-radius: 4px; overflow: hidden; width: fit-content; max-width: 100%; }
.run-seg label { display: flex; align-items: center; gap: 6px; padding: 7px 14px; font-size: .86rem; cursor: pointer; background: var(--surface-1); color: var(--text-primary); border-right: 1px solid var(--border-2); }
.run-seg label:last-child { border-right: none; }
.run-seg input { position: absolute; opacity: 0; pointer-events: none; }
.run-seg label:has(input:checked) { background: #0078d4; color: #fff; font-weight: 600; }
.run-seg label:has(input:focus-visible) { outline: 2px solid var(--link-accent); outline-offset: -3px; }
.run-seg-sm label { padding: 5px 12px; font-size: .82rem; }
.run-mode-note { margin: 0; }
.run-options { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.run-opt-label { font-size: .82rem; color: var(--text-muted); min-width: 110px; }
#runCategorySection, #runNamesSection { display: flex; flex-direction: column; gap: 12px; }
#runCategorySection[hidden], #runNamesSection[hidden], .run-options[hidden] { display: none; }
.run-cat-toolbar, .run-cat-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.run-cat-toolbar input, .run-cat-add input, .run-names textarea {
  padding: 6px 10px; border: 1px solid var(--border-2); border-radius: 4px; font-size: .86rem;
  background: var(--surface-1); color: var(--text-primary); font-family: inherit;
}
.run-cat-toolbar input { flex: 0 1 240px; }
.run-cat-add input { flex: 1 1 280px; max-width: 420px; }
.run-names textarea { resize: vertical; font-family: Consolas, 'Cascadia Mono', monospace; font-size: .84rem; }
.run-names label { text-transform: none; letter-spacing: 0; font-size: .82rem; }
.run-btn-sm { padding: 5px 12px; font-size: .8rem; }
html[data-theme="dark"] .btn-secondary { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-2); }
.run-count { font-size: .78rem; color: var(--text-muted); font-weight: 400; }
.run-cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px;
  max-height: 320px; overflow-y: auto; padding: 8px; border: 1px solid var(--border-1); border-radius: 4px; background: var(--surface-2);
}
.run-cat { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 3px; font-size: .86rem; cursor: pointer; min-width: 0; }
.run-cat:hover { background: var(--hover-surface); }
.run-cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-source { margin: 0; }
.run-hint { font-size: .76rem; color: var(--text-muted); }
.run-check { display: flex; align-items: center; gap: 8px; font-size: .86rem; cursor: pointer; width: fit-content; }
.run-warn { font-size: .8rem; color: #b35c00; margin: 0; }
.run-spinner { display: inline-block; vertical-align: -2px; margin-right: 6px; width: 12px; height: 12px; border: 2px solid var(--border-1); border-top-color: #0078d4; border-radius: 50%; animation: spin 1s linear infinite; }
.run-footer { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.run-summary { flex: 1 1 320px; font-size: .9rem; line-height: 1.5; }
.run-problem { font-size: .82rem; color: #c50f1f; }
.run-recent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.run-recent-head h2 { font-size: 1.05rem; font-weight: 600; }
.run-recent-list { list-style: none; display: flex; flex-direction: column; }
.run-recent-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--border-1); font-size: .86rem; }
.run-recent-list li:last-child { border-bottom: none; }
.run-recent-list a { color: var(--link-accent); font-weight: 600; }
.run-recent-meta { flex: 1 1 260px; overflow-wrap: anywhere; }
.run-recent-by { color: var(--text-muted); font-size: .8rem; }
.run-state { display: inline-block; min-width: 92px; text-align: center; padding: 2px 8px; border-radius: 10px; font-size: .72rem; font-weight: 700; color: #fff; background: #8a8886; text-transform: capitalize; }
.run-state-succeeded { background: #107c10; }
.run-state-failed { background: #c50f1f; }
.run-state-partiallysucceeded { background: #b35c00; }
.run-state-inprogress, .run-state-notstarted { background: #0078d4; }
@media (max-width: 640px) {
  .run-row .form-group { max-width: none; }
  .run-seg { width: 100%; }
  .run-seg label { flex: 1 1 auto; justify-content: center; }
}
