/*
 * TestFlow theme
 * Loaded after Metronic's style.bundle.css: re-points its Bootstrap tokens to the
 * TestFlow palette and styles the app shell (sidebar, top bar, project header).
 */

/* ---------- Tokens ---------- */
/* Brand palette: 1 lightest … 5 darkest. 4 is the logo's symbol colour; 5 carries text and buttons
   (white on 4 is too faint to read, so 4 is kept for graphics, never behind text). */
:root {
  --tf-palette-1: #d6e4f5;
  --tf-palette-2: #a4c7df;
  --tf-palette-3: #7bb7d1;
  --tf-palette-4: #4aa0c4;
  --tf-palette-5: #1d3a6d;
  --tf-brand-symbol: var(--tf-palette-4);
}

:root,
[data-bs-theme=light] {
  --tf-accent: var(--tf-palette-5);
  --tf-accent-hover: #142a50;
  --tf-accent-soft: var(--tf-palette-1);
  --tf-accent-ink: var(--tf-palette-5);
  --tf-on-accent: #FFFFFF;

  --tf-ink: #0F172A;
  --tf-text: #344054;
  --tf-muted: #5B6474;
  --tf-subtle: #98A2B3;

  --tf-bg: #F5F6F8;
  --tf-surface: #FFFFFF;
  --tf-surface-2: #FAFBFC;
  --tf-chip: #F2F4F7;
  --tf-border: #E4E7EC;
  --tf-border-strong: #D0D5DD;
  --tf-divider: #EEF0F3;

  --tf-success: #0E7C7B;
  --tf-success-soft: #E6F4F3;
  --tf-success-ink: #0B6463;
  --tf-warning: #B54708;
  --tf-warning-soft: #FEF6E7;
  --tf-warning-ink: #93370D;
  --tf-danger: #B42318;
  --tf-danger-soft: #FEF3F2;
  --tf-notice-soft: #FFF6EF;
  --tf-notice-border: #F5C9A9;
  --tf-notice-ink: #5C2A0B;

  --tf-radius: 0;
  --tf-radius-sm: 0;
  --tf-sidebar-w: 248px;
  --tf-font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --tf-font-display: "Inter Tight", Inter, system-ui, sans-serif;

  /* Metronic / Bootstrap tokens */
  --bs-font-sans-serif: var(--tf-font);
  --bs-page-bg: var(--tf-bg);
  --bs-body-color: var(--tf-text);
  --bs-border-color: var(--tf-border);
  --bs-link-color: var(--tf-accent);
  --bs-link-color-rgb: 29, 58, 109;
  --bs-link-hover-color: var(--tf-accent-hover);
  --bs-link-hover-color-rgb: 20, 42, 80;

  --bs-primary: #1d3a6d;
  --bs-primary-rgb: 29, 58, 109;
  --bs-primary-active: #142a50;
  --bs-primary-light: #d6e4f5;
  --bs-primary-inverse: #FFFFFF;
  --bs-primary-clarity: rgba(29, 58, 109, 0.2);
  --bs-primary-text-emphasis: #1d3a6d;
  --bs-primary-bg-subtle: #d6e4f5;
  --bs-primary-border-subtle: #a4c7df;

  --bs-success: #0E7C7B;
  --bs-success-rgb: 14, 124, 123;
  --bs-success-active: #0B6463;
  --bs-success-light: #E6F4F3;
  --bs-success-inverse: #FFFFFF;
  --bs-success-clarity: rgba(14, 124, 123, 0.2);

  --bs-warning: #B54708;
  --bs-warning-rgb: 181, 71, 8;
  --bs-warning-active: #93370D;
  --bs-warning-light: #FEF6E7;
  --bs-warning-inverse: #FFFFFF;
  --bs-warning-clarity: rgba(181, 71, 8, 0.2);

  --bs-danger: #B42318;
  --bs-danger-rgb: 180, 35, 24;
  --bs-danger-active: #912018;
  --bs-danger-light: #FEF3F2;
  --bs-danger-inverse: #FFFFFF;
  --bs-danger-clarity: rgba(180, 35, 24, 0.2);

  --bs-info: #6941C6;
  --bs-info-rgb: 105, 65, 198;
  --bs-info-active: #53389E;
  --bs-info-light: #F4F0FD;
  --bs-info-inverse: #FFFFFF;

  --bs-light: #F2F4F7;
  --bs-light-rgb: 242, 244, 247;
  --bs-light-active: #E4E7EC;
  --bs-light-inverse: #344054;
  --bs-secondary: #F2F4F7;
  --bs-secondary-active: #E4E7EC;
  --bs-secondary-inverse: #344054;
}

[data-bs-theme=dark] {
  --tf-accent: var(--tf-palette-3);
  --tf-accent-hover: var(--tf-palette-2);
  --tf-accent-soft: #16294a;
  --tf-accent-ink: var(--tf-palette-2);
  --tf-on-accent: #0B1020;

  --tf-ink: #F2F4F7;
  --tf-text: #CED4DE;
  --tf-muted: #98A2B3;
  --tf-subtle: #667085;

  --tf-bg: #0E1117;
  --tf-surface: #161B24;
  --tf-surface-2: #1B212C;
  --tf-chip: #222A37;
  --tf-border: #263041;
  --tf-border-strong: #344054;
  --tf-divider: #202836;

  --tf-success: #3CC2B6;
  --tf-success-soft: #10302E;
  --tf-success-ink: #8ADCD4;
  --tf-warning: #F2B54B;
  --tf-warning-soft: #33260F;
  --tf-warning-ink: #F5C77A;
  --tf-danger: #F97066;
  --tf-danger-soft: #3A1714;
  --tf-notice-soft: #2B1D12;
  --tf-notice-border: #5C3A1E;
  --tf-notice-ink: #F5C9A9;

  --bs-page-bg: var(--tf-bg);
  --bs-body-bg: var(--tf-surface);
  --bs-body-color: var(--tf-text);
  --bs-border-color: var(--tf-border);
  --bs-link-color: var(--tf-accent);
  --bs-link-color-rgb: 123, 183, 209;
  --bs-link-hover-color: var(--tf-accent-hover);

  --bs-primary: #7bb7d1;
  --bs-primary-rgb: 123, 183, 209;
  --bs-primary-active: #a4c7df;
  --bs-primary-light: #16294a;
  --bs-primary-inverse: #0B1020;
  --bs-primary-clarity: rgba(123, 183, 209, 0.2);
  --bs-primary-text-emphasis: #a4c7df;
  --bs-primary-border-subtle: #2c4f7a;

  --bs-success: #3CC2B6;
  --bs-success-rgb: 60, 194, 182;
  --bs-success-active: #8ADCD4;
  --bs-success-light: #10302E;
  --bs-success-inverse: #0B1020;

  --bs-warning: #F2B54B;
  --bs-warning-rgb: 242, 181, 75;
  --bs-warning-active: #F5C77A;
  --bs-warning-light: #33260F;
  --bs-warning-inverse: #0B1020;

  --bs-danger: #F97066;
  --bs-danger-rgb: 249, 112, 102;
  --bs-danger-active: #FDA29B;
  --bs-danger-light: #3A1714;
  --bs-danger-inverse: #0B1020;

  --bs-info: #B692F6;
  --bs-info-light: #2A1F45;
  --bs-info-inverse: #0B1020;

  --bs-light: #222A37;
  --bs-light-active: #2C3545;
  --bs-light-inverse: #CED4DE;
  --bs-secondary: #222A37;
  --bs-secondary-active: #2C3545;
  --bs-secondary-inverse: #CED4DE;
}

/* ---------- Square corners ---------- */
/* TestFlow has no rounded corners. The theme bundle hard-codes its radii, so they are switched off
   here for every element; true circles (radio buttons, avatars, step numbers, dots, spinners) stay round. */
:root {
  --bs-border-radius: 0;
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: 0;
  --bs-border-radius-xl: 0;
  --bs-border-radius-xxl: 0;
  --bs-border-radius-2xl: 0;
  --bs-border-radius-pill: 0;
}

*,
*::before,
*::after {
  border-radius: 0 !important;
}

.form-check-input[type=radio],
.rounded-circle,
.spinner-border,
.spinner-grow,
.badge.badge-circle,
.btn.btn-icon.btn-circle,
.symbol.symbol-circle,
.symbol.symbol-circle .symbol-label,
.symbol.symbol-circle > img,
.image-input.image-input-circle,
.image-input.image-input-circle .image-input-wrapper,
.pagination.pagination-circle .page-link,
.timeline .timeline-icon,
.tf-avatar,
.tf-auth-status,
.tf-pending-icon,
.tf-next-step-label::before,
.tfs-step-badge,
.tfs-timer-btn,
.tfq-done-icon,
.tfq-card-icon,
.tfh-pin,
.tfh-note b,
.tfh-step-num {
  border-radius: 50% !important;
}

/* ---------- Language menu (layouts/_language_select.php) ---------- */
.tf-lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--tf-muted);
}

.tf-lang select {
  height: 40px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--tf-border-strong);
  background-color: var(--tf-surface);
  color: var(--tf-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tf-lang select:focus-visible { outline: 2px solid var(--tf-accent); outline-offset: 2px; }

/* ---------- Base ---------- */
html,
body {
  font-size: 14px !important;
  font-family: var(--tf-font);
}

body {
  background-color: var(--tf-bg) !important;
  background-image: none !important;
  color: var(--tf-text);
  line-height: 1.5;
}

h1, h2, h3, .h1, .h2, .h3 {
  font-family: var(--tf-font-display);
  letter-spacing: -0.01em;
  color: var(--tf-ink);
}

:focus-visible {
  outline: 2px solid var(--tf-accent);
  outline-offset: 2px;
}

.text-muted { color: var(--tf-muted) !important; }

/* ---------- Components ---------- */
.card {
  --bs-card-bg: var(--tf-surface);
  --bs-card-border-color: var(--tf-border);
  --bs-card-border-radius: 0;
  --bs-card-box-shadow: none;
  border: 1px solid var(--tf-border);
  border-radius: 0;
  box-shadow: none;
}

.card > .card-header {
  border-bottom: 1px solid var(--tf-divider);
}

.card .card-title,
.card .card-header .card-title {
  font-family: var(--tf-font);
  font-weight: 600;
  color: var(--tf-ink);
}

.btn {
  border-radius: 0;
  font-weight: 600;
}

/* Metronic zeroes .btn borders with a high-specificity rule, so outline with an inset shadow */
.btn.btn-light,
.btn.btn-secondary {
  background-color: var(--tf-surface);
  box-shadow: inset 0 0 0 1px var(--tf-border-strong) !important;
  color: var(--tf-text);
}

.btn.btn-light:hover:not(.btn-active),
.btn.btn-secondary:hover:not(.btn-active) {
  background-color: var(--tf-chip) !important;
  color: var(--tf-ink) !important;
}

.btn.btn-light-primary {
  background-color: var(--tf-accent-soft);
  color: var(--tf-accent-ink);
}

.badge {
  border-radius: 0;
  font-weight: 600;
}

.form-control,
.form-select {
  border-color: var(--tf-border-strong);
  border-radius: 0;
  color: var(--tf-ink);
  background-color: var(--tf-surface);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--tf-accent);
  box-shadow: 0 0 0 3px var(--bs-primary-clarity);
}

.form-label {
  font-weight: 600;
  color: var(--tf-text);
}

.table > :not(caption) > * > * {
  border-bottom-color: var(--tf-divider);
}

.table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--tf-muted);
}

.nav-line-tabs .nav-item .nav-link.active,
.nav-line-tabs .nav-item.show .nav-link,
.nav-line-tabs .nav-item .nav-link:hover:not(.disabled) {
  border-bottom-color: var(--tf-accent);
  color: var(--tf-ink);
}

.menu-sub-dropdown {
  border: 1px solid var(--tf-border);
  border-radius: 0;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.12);
}

.modal-content {
  border-radius: 0;
  border: 1px solid var(--tf-border);
}

.separator {
  border-bottom-color: var(--tf-divider) !important;
}

/* ---------- App shell ---------- */
.tf-root {
  min-height: 100vh;
}

.tf-page {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.tf-sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--tf-sidebar-w);
  width: var(--tf-sidebar-w);
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 14px;
  overflow-y: auto;
  background: var(--tf-surface);
  border-right: 1px solid var(--tf-border);
  z-index: 105;
}

.tf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--tf-ink);
  text-decoration: none;
}

.tf-brand:hover { color: var(--tf-ink); }

.tf-brand-mark,
.tf-logo { flex-shrink: 0; display: block; max-width: 100%; height: auto; }

.tf-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tf-nav-label {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tf-muted);
}

.tf-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 0;
  color: var(--tf-text);
  font-weight: 500;
  text-decoration: none;
}

.tf-nav-link:hover {
  background: var(--tf-surface-2);
  color: var(--tf-ink);
}

.tf-nav-link[aria-current="page"] {
  background: var(--tf-accent-soft);
  color: var(--tf-accent-ink);
  font-weight: 600;
}

.tf-nav-link .tf-grow { flex-grow: 1; }

.tf-nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 0;
  background: #FEF0E6;
  color: #9A3B0B;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tf-create-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 0;
  background: var(--tf-accent);
  color: var(--tf-on-accent);
  font-weight: 600;
  text-decoration: none;
}

.tf-create-btn:hover {
  background: var(--tf-accent-hover);
  color: var(--tf-on-accent);
}

.tf-sidebar-spacer { flex-grow: 1; }

.tf-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--tf-border);
  border-radius: 0;
}

.tf-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tf-accent-soft);
  color: var(--tf-accent-ink);
  font-weight: 600;
  font-size: 13px;
}

.tf-user-name {
  display: block;
  font-weight: 600;
  color: var(--tf-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tf-user-meta {
  display: block;
  font-size: 12px;
  color: var(--tf-muted);
}

.tf-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tf-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 32px;
  margin-bottom: 28px;
  background: var(--tf-surface);
  border-bottom: 1px solid var(--tf-border);
}

.tf-topbar-heading {
  flex: 1 1 280px;
  min-width: 0;
}

.tf-content-title {
  margin: 0;
  font-family: var(--tf-font-display);
  font-size: 30px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tf-ink);
}

.tf-page-title {
  margin: 0;
  font-family: var(--tf-font-display);
  font-size: 20px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--tf-ink);
}

.tf-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 2px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--tf-muted);
}

.tf-breadcrumb a {
  color: var(--tf-text);
  text-decoration: none;
}

.tf-breadcrumb a:hover { color: var(--tf-accent); }

.tf-breadcrumb li + li::before {
  content: "/";
  margin-right: 6px;
  color: var(--tf-subtle);
}

.tf-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tf-segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 0;
  background: var(--tf-chip);
}

.tf-segmented a {
  min-width: 44px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  color: var(--tf-text);
  font-weight: 500;
  text-decoration: none;
}

.tf-segmented a[aria-current="true"] {
  background: var(--tf-surface);
  color: var(--tf-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.tf-icon-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--tf-border-strong);
  border-radius: 0;
  background: var(--tf-surface);
  color: var(--tf-text);
  text-decoration: none;
}

.tf-icon-btn:hover {
  background: var(--tf-chip);
  color: var(--tf-ink);
}

.tf-icon-btn.tf-plain { border-color: transparent; }

.tf-icon-btn.tf-icon-btn-primary { border-color: var(--tf-accent); background: var(--tf-accent); color: var(--tf-on-accent); }
.tf-icon-btn.tf-icon-btn-primary:hover { background: var(--tf-accent-hover); color: var(--tf-on-accent); }

.tf-menu-toggle { display: none; }

/* Small-screen app chrome: logo bar and bottom tab bar (hidden on large screens) */
.tf-topbar-mobile,
.tf-tabbar { display: none; }

.tf-theme-dark-icon { display: none; }
[data-bs-theme=dark] .tf-theme-dark-icon { display: inline; }
[data-bs-theme=dark] .tf-theme-light-icon { display: none; }

.tf-main > .container-xxl,
.tf-main .container-xxl {
  max-width: 1280px;
  padding-left: 32px;
  padding-right: 32px;
}

.tf-footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 20px 32px;
  font-size: 13px;
  color: var(--tf-muted);
}

.tf-footer a {
  color: var(--tf-text);
  text-decoration: none;
}

.tf-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tf-scrim { display: none; }

/* Participant-facing minimal layout */
.tf-minimal-header {
  display: flex;
  justify-content: center;
  padding: 20px 16px;
}

/* ---------- Project header ---------- */
.tf-project-header {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: 0;
  margin-bottom: 24px;
}

.tf-project-header-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.tf-project-identity {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
  flex: 1 1 420px;
}

.tf-project-thumb {
  width: 64px;
  height: 64px;
  border-radius: 0;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tf-accent-soft);
  color: var(--tf-accent-ink);
}

.tf-project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tf-project-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tf-project-title h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

.tf-project-meta {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--tf-muted);
}

.tf-project-desc {
  margin: 4px 0 0;
  color: var(--tf-muted);
  max-width: 72ch;
}

.tf-project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tf-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px 24px 4px;
}

.tf-stat {
  padding: 12px 14px;
  border: 1px solid var(--tf-divider);
  border-radius: 0;
  background: var(--tf-surface-2);
}

.tf-stat-label {
  font-size: 13px;
  color: var(--tf-muted);
}

.tf-stat-value {
  font-family: var(--tf-font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--tf-ink);
}

.tf-stat-note {
  font-size: 12px;
  color: var(--tf-muted);
}

.tf-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 0;
  padding: 0 12px;
  list-style: none;
  overflow-x: auto;
  border-top: 1px solid var(--tf-divider);
}

.tf-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 12px;
  border-bottom: 2px solid transparent;
  color: var(--tf-text);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tf-tabs a:hover { color: var(--tf-ink); }

.tf-tabs a[aria-current="page"] {
  border-bottom-color: var(--tf-accent);
  color: var(--tf-ink);
  font-weight: 600;
}

/* Small-screen project bar (hidden on large screens) */
.tf-project-mobilebar { display: none; }

/* Inside a project the project header replaces the top bar (as in the design) */
.tf-topbar-project { display: none; }

/* A live session takes the whole screen */
body.tf-focus .tf-sidebar,
body.tf-focus .tf-scrim,
body.tf-focus .tf-footer,
body.tf-focus .tf-tabbar { display: none !important; }
body.tf-focus .tf-main { padding-top: 24px; }

@media (min-width: 992px) {
  /* Project header: a white band across the page with the path, the project, its actions and the tabs */
  .tf-project-header {
    margin: 0 0 24px;
    border: 0;
    box-shadow: 0 0 0 100vmax var(--tf-surface), 0 1px 0 100vmax var(--tf-border);
    clip-path: inset(0 -100vmax -1px);
  }
  .tf-project-crumbs { padding-top: 16px; }
  .tf-project-header-body { padding: 12px 0 0; }
  .tf-project-desc { display: none; }
  .tf-project-header .tf-tabs { margin-top: 16px; padding: 0; border-top: 0; }
  .tf-project-header .tf-tabs a { padding: 0 14px; }
  .tf-project-header .tf-tabs li:first-child a { padding-left: 0; }
  .tf-project-stats { padding: 0; margin-bottom: 24px; }
  .tf-project-stats .tf-stat { background: var(--tf-surface); border-color: var(--tf-border); }
  /* Other sections: the name and status only */
  .tf-project-header-compact .tf-project-meta,
  .tf-project-header-compact .tf-project-actions { display: none; }
  .tf-project-header-compact .tf-project-thumb { width: 48px; height: 48px; }
}

.tf-more { position: relative; }
.tf-more > summary { list-style: none; cursor: pointer; }
.tf-more > summary::-webkit-details-marker { display: none; }
.tf-more > ul {
  position: absolute;
  right: 4px;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 220px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14);
}
.tf-more > ul a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  color: var(--tf-text);
  font-weight: 500;
  text-decoration: none;
}
.tf-more > ul a:hover { background: var(--tf-chip); color: var(--tf-ink); }

.tf-count {
  color: var(--tf-muted);
  font-weight: 500;
}

/* ---------- Shared bits for rebuilt screens ---------- */
.tf-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--tf-chip);
  color: var(--tf-text);
}

.tf-pill-accent { background: var(--tf-accent-soft); color: var(--tf-accent-ink); }
.tf-pill-success { background: var(--tf-success-soft); color: var(--tf-success-ink); }
.tf-pill-warning { background: var(--tf-warning-soft); color: var(--tf-warning-ink); }
.tf-pill-danger { background: var(--tf-danger-soft); color: var(--tf-danger); }

.tf-panel {
  background: var(--tf-surface);
  border: 1px solid var(--tf-border);
  border-radius: 0;
}

.tf-panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--tf-divider);
}

.tf-panel-title {
  margin: 0;
  font-family: var(--tf-font);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--tf-ink);
}

.tf-panel-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--tf-muted);
}

.tf-progress {
  height: 6px;
  border-radius: 0;
  background: var(--tf-divider);
  overflow: hidden;
}

.tf-progress > span {
  display: block;
  height: 100%;
  background: var(--tf-accent);
}

.tf-progress > span.is-done { background: var(--tf-success); }

.tf-btn-danger-quiet { color: var(--tf-danger) !important; }

.tf-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--tf-notice-border);
  background: var(--tf-notice-soft);
  color: var(--tf-notice-ink);
  border-radius: 0;
}

.tf-visually-hidden {
  position: absolute !important;
  /* pinned to the containing block so it never sits past the page edge and adds sideways scroll */
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Shared building blocks (used by several screens; define them only here) ---------- */
.tf-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tf-list {
  margin: 0;
  padding: 6px 0;
  list-style: none;
}

.tf-list-title {
  display: block;
  font-weight: 600;
  color: var(--tf-ink);
  overflow-wrap: anywhere;
}

.tf-row-actions {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  justify-content: flex-end;
}

.tf-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 300px;
}

.tf-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tf-muted);
  pointer-events: none;
}

.tf-search .form-control {
  min-height: 44px;
  padding-left: 38px;
}

/* Search across projects, tests and participants, in the topbar */
.tf-global-search {
  flex: 0 1 360px;
  max-width: 360px;
}

.tf-global-search .form-control {
  min-height: 40px;
}

.tf-nav-dot {
  width: 8px;
  height: 8px;
  margin: 0 5px;
  flex-shrink: 0;
  background: var(--tf-palette-4, #4aa0c4);
}

.tf-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--tf-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .tf-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  body.tf-sidebar-open .tf-sidebar { transform: none; box-shadow: 0 0 40px rgba(16, 24, 40, 0.2); }

  body.tf-sidebar-open .tf-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 104;
    background: rgba(15, 23, 42, 0.4);
  }

  /* Top bar: logo, search and new project, then the page title; no breadcrumbs, language or theme
     (those are in the Account menu) */
  .tf-topbar {
    position: static;
    gap: 12px;
    padding: 8px 8px 16px 16px;
    margin-bottom: 16px;
  }
  .tf-topbar-mobile {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 100%;
  }
  .tf-topbar-logo { display: flex; margin-right: auto; color: var(--tf-ink); }
  .tf-topbar-logo svg { height: 24px; width: auto; }
  .tf-topbar .tf-breadcrumb,
  .tf-topbar-actions > .tf-lang,
  .tf-topbar-actions > [data-tf-theme-toggle] { display: none; }
  .tf-topbar-heading { flex-basis: 100%; padding-right: 8px; }
  .tf-page-title { font-size: 24px; line-height: 1.2; }
  .tf-topbar-actions:empty { display: none; }

  /* Inside a project the project header is the top of the page */
  .tf-topbar-mobile-hidden { display: none; }

  .tf-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Bottom tab bar */
  .tf-main { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .tf-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 103;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--tf-surface);
    border-top: 1px solid var(--tf-border);
  }
  .tf-tabbar > a,
  .tf-tabbar > button {
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--tf-text);
    text-decoration: none;
  }
  .tf-tabbar > [aria-current="page"],
  .tf-tabbar > [aria-expanded="true"] {
    color: var(--tf-accent);
    font-weight: 600;
    box-shadow: inset 0 2px 0 var(--tf-accent);
  }
  .tf-tabbar-icon { position: relative; display: flex; }
  .tf-tabbar-badge {
    position: absolute;
    top: -6px;
    right: -12px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FEF0E6;
    color: #9A3B0B;
    font-size: 11px;
    font-weight: 700;
  }
  .tf-tabbar-avatar {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tf-accent-soft);
    color: var(--tf-accent-ink);
    font-size: 10px;
    font-weight: 700;
  }
  .toast-container { bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important; }

  /* The Account menu (the sidebar as a drawer) also holds language and theme */
  .tf-sidebar { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .tf-sidebar-prefs { display: flex; align-items: center; gap: 8px; }
  .tf-sidebar-prefs .tf-lang { flex-grow: 1; }
  .tf-sidebar-prefs .tf-lang select { width: 100%; }

  .tf-main > .container-xxl,
  .tf-main .container-xxl {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Project header: full-width bar and tabs, then status, actions and figures on the page background */
  .tf-project-header {
    display: flex;
    flex-direction: column;
    margin: 0 -16px 16px;
    background: transparent;
    border: 0;
  }
  .tf-project-mobilebar {
    order: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 4px 0;
    background: var(--tf-surface);
  }
  .tf-project-mobilebar-title { flex-grow: 1; min-width: 0; }
  .tf-project-mobilebar-title > div { font-size: 12px; color: var(--tf-muted); }
  .tf-project-mobilebar-title h1 {
    margin: 0;
    font-family: var(--tf-font-display);
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--tf-ink);
  }
  .tf-project-header > nav {
    order: 1;
    background: var(--tf-surface);
    border-bottom: 1px solid var(--tf-border);
  }
  .tf-project-header .tf-tabs { margin: 0; padding: 0 8px; border-top: 0; gap: 2px; scrollbar-width: none; }
  .tf-project-header .tf-tabs a { padding: 0 10px; }
  .tf-project-header-body { order: 2; padding: 16px 16px 0; gap: 12px; }
  .tf-project-stats { grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; margin: -4px 0 16px; }
  .tf-project-stats .tf-stat { background: var(--tf-surface); border-color: var(--tf-border); }
  .tf-project-stats .tf-stat-value { font-size: 22px; }
  .tf-project-crumbs { display: none; }

  /* The name is in the bar; status and dates stay; thumbnail and description go */
  .tf-project-thumb,
  .tf-project-title h2,
  .tf-project-desc { display: none; }
  .tf-project-identity { flex-basis: 100%; }
  .tf-project-title { display: inline-flex; margin-right: 8px; }
  .tf-project-meta { display: inline; }
  .tf-project-actions {
    flex-basis: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr 48px;
    gap: 8px;
  }
  .tf-project-actions > .btn { justify-content: center; min-height: 48px; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
  .tf-project-actions > .btn-primary { order: -2; }
  .tf-project-actions > .btn-light { order: -1; }
  .tf-project-actions > .tf-icon-btn { width: 48px; height: 48px; }

  /* Other sections: just the bar and the tabs */
  .tf-project-header-compact .tf-project-header-body { display: none; }

  .tf-stats { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tf-sidebar { transition: none; }
}

@media print {
  .tf-sidebar,
  .tf-tabbar,
  .tf-topbar,
  .tf-footer,
  .tf-tabs { display: none !important; }
}

/* ---------- Search results ---------- */
.tf-search-page {
  padding: 20px 24px;
}

.tf-search-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--tf-accent-soft);
  color: var(--tf-accent-ink);
}

/* Role choice when inviting someone to a project */
.tf-role-choice {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.tf-role-choice label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--tf-border);
  cursor: pointer;
}

.tf-role-choice label:has(input:checked) {
  border-color: var(--tf-accent);
  background: var(--tf-accent-soft);
}

.tf-role-choice input {
  margin-top: 4px;
  accent-color: var(--tf-accent);
}
