:root {
  --page-bg: #f4f6f3;
  --surface: #fffefa;
  --soft-bg: #edf3ef;
  --table-stripe: #fafbf8;
  --text-strong: #18221f;
  --text-muted: #52615b;
  --text-soft: #718078;
  --border: #d9e2dc;
  --border-strong: #b8c7bf;
  --accent: #13786e;
  --accent-strong: #0b5f58;
  --accent-soft: #dff0eb;
  --success: #23764f;
  --danger: #bb3b37;
  --warning: #9a6a14;
  --info: #1f5fb0;
  --info-soft: #eaf1fb;
  --status-passed-bg: #e9f7ee;
  --status-passed-fg: #1a6b37;
  --status-passed-border: #c4e8d0;
  --status-failed-bg: #fef0f0;
  --status-failed-fg: #a93030;
  --status-failed-border: #fecaca;
  --status-pending-bg: #fef8ec;
  --status-pending-fg: #8a5a00;
  --status-pending-border: #fde68a;
  --status-skipped-bg: #f1f2f5;
  --status-skipped-fg: #4d5570;
  --status-skipped-border: #d1d5db;
  --status-blocker-bg: #fbe3e3;
  --status-blocker-fg: #7f1d1d;
  --status-blocker-border: #e7a3a3;
  --status-reported-bg: #fff7ed;
  --status-reported-fg: #9a3412;
  --status-reported-border: #fed7aa;
  --status-clarification-bg: #eff6ff;
  --status-clarification-fg: #1d4ed8;
  --status-clarification-border: #bfdbfe;
  --status-inprogress-bg: #fffbeb;
  --status-inprogress-fg: #92400e;
  --status-inprogress-border: #fef3c7;
  --status-hold-bg: #f3f4f6;
  --status-hold-fg: #374151;
  --status-hold-border: #d1d5db;

  /* Priority chip palette (High/Medium/Low) — single source of truth */
  --priority-high-bg: #fff5f5;
  --priority-high-fg: var(--danger);
  --priority-high-border: #fecaca;
  --priority-med-bg: #fff8e6;
  --priority-med-fg: var(--warning);
  --priority-med-border: #fde68a;
  --priority-low-bg: #f0fdf4;
  --priority-low-fg: var(--success);
  --priority-low-border: #bbf7d0;
  --shadow-sm: 0 1px 2px rgba(24, 34, 31, 0.04);
  --shadow-md: 0 8px 22px rgba(24, 34, 31, 0.07);
  --shadow-lg: 0 18px 42px rgba(24, 34, 31, 0.12);

  /* Radius scale — 8px is the system default; 12px reserved for surfaces */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  /* Humanist UI + editorial display pairing: warm, legible, and offline-safe. */
  --sans: 'Trebuchet MS', 'Segoe UI', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  --display: Georgia, 'Times New Roman', serif;
  --mono: 'Cascadia Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --border-soft: #e7ede9;

  /* Derived tokens */
  --focus-ring: 0 0 0 3px rgba(19, 120, 110, 0.35);
  --accent-glow-sm: none;
  --accent-glow-md: none;
}

/* Prefer the perceptually-mixed ring when the engine supports color-mix;
   the rgba() value above is the fallback so the focus ring never disappears. */
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  :root {
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  }
}

:root {
  color-scheme: light;
  color: var(--text-muted);
  background: var(--page-bg);
  font-family: var(--sans);
  font-variation-settings: normal;
  font-size: 16px;
  font-synthesis: none;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

html {
  background: var(--page-bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  scrollbar-gutter: stable;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
  font: inherit;
}

/* ── Brand selection colour ─────────────────────────────── */
::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text-strong);
}

/* ── Custom scrollbar ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-soft);
}

/* ── Spacing utility classes ─────────────────────────────── */
.mb-0   { margin-bottom: 0; }
.mb-xs  { margin-bottom: 4px; }
.mb-sm  { margin-bottom: 8px; }
.mb-md  { margin-bottom: 16px; }
.mb-lg  { margin-bottom: 24px; }
.mb-xl  { margin-bottom: 32px; }
.mt-0   { margin-top: 0; }
.mt-xs  { margin-top: 4px; }
.mt-sm  { margin-top: 8px; }
.mt-md  { margin-top: 16px; }
.mt-lg  { margin-top: 24px; }
.mt-xl  { margin-top: 32px; }
.pt-0   { padding-top: 0; }
.pt-sm  { padding-top: 8px; }
.pt-md  { padding-top: 16px; }
.pb-0   { padding-bottom: 0; }
.pb-sm  { padding-bottom: 8px; }
.pb-md  { padding-bottom: 16px; }
.p-sm   { padding: 8px; }
.p-md   { padding: 16px; }
.px-md  { padding-left: 16px; padding-right: 16px; }
.py-md  { padding-top: 16px; padding-bottom: 16px; }
.ml-xs  { margin-left: 4px; }
.ml-sm  { margin-left: 8px; }
.ml-md  { margin-left: 16px; }
.mr-xs  { margin-right: 4px; }
.mr-sm  { margin-right: 8px; }
.mr-md  { margin-right: 16px; }

/* ── Keyframes ──────────────────────────────────────────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to   { opacity: 1; transform: none; }
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Premium High-End Visual Design & Micro-interactions (taste-guided) ── */

/* Double-Bezel nested container */
.double-bezel-outer {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 20px;
  margin-bottom: 24px;
}

.double-bezel-inner {
  background: var(--surface) !important;
  border: 1px solid rgba(0, 0, 0, 0.04) !important;
  border-radius: calc(20px - 6px) !important;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), var(--shadow-sm) !important;
}

/* Premium smooth transitions & micro-actions */
.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.link-btn {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled),
.danger-button:active:not(:disabled) {
  transform: scale(0.98) translateY(0) !important;
}

/* Button-in-Button Trailing Icon pattern for Start Run */
.start-run-btn {
  position: relative;
  overflow: hidden;
  padding-right: 14px !important;
}

.start-run-btn .btn-icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  margin-left: 8px;
  font-size: 8px;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease;
  vertical-align: middle;
}

.start-run-btn:hover .btn-icon-circle {
  transform: translateX(2px) scale(1.08);
  background: rgba(255, 255, 255, 0.3);
}

/* Checkbox micro-interactions */
.row-checkbox {
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.2) !important;
}
.row-checkbox:hover {
  transform: scale(1.08);
}
.row-checkbox:active {
  transform: scale(0.88);
}

/* Entrance reveal animations */
.page-entrance {
  animation: fade-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Table rows styling & status pills hover tension */
.rpt-table tbody tr {
  transition: background-color 0.2s ease;
}
.rpt-table tbody tr:hover {
  background-color: var(--table-stripe);
}

.status-pill {
  transition: transform 0.15s ease, filter 0.15s ease;
}
.status-pill:hover {
  transform: translateY(-1px);
  filter: brightness(0.97);
}

/* Typography polish (tracking tension) */
h1, h2, h3 {
  letter-spacing: -0.02em;
}

/* Reduced Motion overrides */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0s !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
    transform: none !important;
  }
}
