/* =====================================================================
   Oral Fluid Testing Portal — elegant theme with vertical sidebar
   ===================================================================== */

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

:root {
  /* Brand — deep midnight navy with a warm copper accent */
  --brand:        #1a3a5c;
  --brand-2:      #2c5680;
  --brand-dark:   #0d1e33;
  --brand-light:  #e6ecf2;
  --brand-tint:   #f5f7fa;

  --accent:       #c47a3a;
  --accent-2:     #a85f24;
  --accent-light: #fbf2e8;

  /* Neutrals */
  --ink:          #0f172a;
  --ink-2:        #1f2937;
  --muted:        #5e6b7a;
  --line:         #dde3ec;
  --line-soft:    #ebeef4;
  --bg:           #f3f5f9;
  --card:         #ffffff;

  /* Status */
  --danger:       #b91c1c;
  --danger-bg:    #fee2e2;
  --warn:         #b45309;
  --warn-bg:      #fef3c7;
  --ok:           #047857;
  --ok-bg:        #d1fae5;

  /* Layout */
  --sidebar-w:    260px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md:    0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg:    0 10px 24px -8px rgba(15, 23, 42, 0.18);
}

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }

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

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth overlays ---------- */
.overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(13, 30, 51, 0.96), rgba(26, 58, 92, 0.92));
  display: flex; align-items: center; justify-content: center;
  z-index: 150; padding: 1rem;
}
.auth-card {
  background: #fff;
  padding: 2.5rem;
  border-radius: 16px;
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg);
  max-height: 92vh; overflow-y: auto;
}
.auth-card.wide { max-width: 600px; }
.auth-card h2 {
  color: var(--ink);
  margin-bottom: 0.4rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-card .muted { margin-bottom: 1.25rem; }

.auth-brand {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.auth-brand-title {
  font-weight: 600; color: var(--ink);
  font-size: 0.95rem;
}
.auth-brand-sub {
  color: var(--muted);
  font-size: 0.78rem; letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Brand mark */
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 55%, var(--accent) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(13, 30, 51, 0.35);
}

/* ---------- Forms ---------- */
label {
  display: block;
  margin: 1rem 0 0.4rem;
  font-size: 0.875rem; font-weight: 500;
  color: var(--ink-2);
}
label.inline {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.9rem;
}
label.switch-row {
  padding: 0.75rem 1rem;
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

input[type=text], input[type=email], input[type=tel],
input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 5rem; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.16);
}
input[disabled] { background: var(--bg); color: var(--muted); }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  border: 1px solid transparent;
  transition: all 0.15s;
}
button.primary {
  background: var(--brand); color: #fff; border-color: var(--brand);
  margin-top: 0.5rem;
  box-shadow: 0 1px 2px rgba(13, 30, 51, 0.18);
}
/* When primary sits in a flex row alongside other buttons (modals, sticky
   headers, button groups), the default top-margin throws off vertical
   alignment vs neighbouring secondary buttons. Remove it in that context. */
.row button.primary { margin-top: 0; }
button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: #fff; color: var(--brand); border-color: var(--line);
}
button.secondary:hover { background: var(--brand-tint); border-color: var(--brand); }

button.danger {
  background: var(--danger-bg); color: var(--danger); border-color: rgba(185, 28, 28, 0.2);
}
button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

button.link {
  background: none; border: none; color: var(--brand);
  padding: 0.5rem 0; font-size: 0.875rem; text-decoration: underline;
}

.alert {
  margin-top: 1rem; padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm); font-size: 0.9rem;
}
.alert.info  { background: var(--brand-light); color: var(--brand); }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok    { background: var(--ok-bg); color: var(--ok); }
.alert.warn  { background: var(--warn-bg); color: var(--warn); }

/* Test-environment MFA code panel */
.test-code {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  background: linear-gradient(135deg, #fff7ed, #fef3c7);
  border: 1px dashed var(--warn);
  border-radius: var(--radius-sm);
  text-align: center;
}
.test-code-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warn);
  margin-bottom: 0.4rem;
}
.test-code-value {
  font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.4rem;
  color: var(--ink);
  user-select: all;
}
.test-code-hint {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--warn);
}

/* ===================================================================
   App shell — vertical sidebar + main column
   =================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, #0a1a2e 0%, #14304f 100%);
  color: #e2e8f0;
  display: flex; flex-direction: column;
  padding: 1.5rem 0;
  position: sticky; top: 0;
  height: 100vh;
  box-shadow: 1px 0 0 rgba(255,255,255,0.04);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-mark {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: none;
}
.brand-text { line-height: 1.25; }
.brand-title {
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
}
.brand-sub {
  color: rgba(255,255,255,0.6);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.15rem;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: none; border: none;
  color: rgba(255,255,255,0.72);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  border-radius: 9px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.nav-item .nav-icon {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--accent);
  flex-shrink: 0;
  transition: all 0.18s ease;
}
.nav-item .nav-icon svg {
  width: 17px; height: 17px;
}
.nav-item:hover .nav-icon {
  background: rgba(196, 122, 58, 0.16);
  border-color: rgba(196, 122, 58, 0.32);
  color: #e8a572;
}
.nav-item.active .nav-icon {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--brand-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

/* Sidebar footer / user button */
.sidebar-footer {
  position: relative;
  padding: 0.75rem 0.75rem 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: auto;
}
.sidebar-user {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%;
  background: none; border: none;
  color: #fff;
  padding: 0.6rem 0.6rem;
  border-radius: 8px;
  text-align: left;
}
.sidebar-user:hover { background: rgba(255,255,255,0.08); }
.avatar-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.85rem;
  flex-shrink: 0;
}
.sidebar-user-text {
  display: flex; flex-direction: column;
  min-width: 0;
}
.sidebar-user-name {
  color: #fff; font-size: 0.88rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  color: rgba(255,255,255,0.6);
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.avatar-menu {
  position: absolute; bottom: calc(100% - 0.5rem); left: 0.75rem; right: 0.75rem;
  background: #fff; color: var(--ink);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  z-index: 50; overflow: hidden;
  border: 1px solid var(--line);
}
.avatar-menu-header {
  padding: 0.85rem 1rem;
  background: var(--brand-tint);
  border-bottom: 1px solid var(--line);
}
.avatar-menu-name { font-weight: 600; font-size: 0.92rem; }
.avatar-menu-email { color: var(--muted); font-size: 0.82rem; }
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; padding: 0.7rem 1rem;
  font-size: 0.9rem; color: var(--ink);
  border-radius: 0;
}
.menu-item:hover { background: var(--brand-tint); }

/* ---------- Main column ---------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 1.25rem 2.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.page-title {
  font-size: 1.4rem; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }

.content {
  padding: 2rem 2.5rem 3rem;
  max-width: 1140px;
  width: 100%;
}
.tab-content { display: block; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  color: var(--ink); margin-bottom: 1rem;
  font-size: 1.2rem; font-weight: 600;
  letter-spacing: -0.005em;
}
.card h3 { margin-bottom: 0.75rem; font-size: 1.05rem; font-weight: 600; }

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 0.75rem; }

.muted { color: var(--muted); font-size: 0.9rem; }

.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.75rem 0;
}

/* ---------- Home / Hero ---------- */
.hero {
  background:
    radial-gradient(circle at 100% 0%, rgba(196, 122, 58, 0.22) 0%, transparent 55%),
    linear-gradient(135deg, #0a1a2e 0%, #1a3a5c 100%);
  color: #fff;
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; right: -80px; top: -80px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(255,255,255,0.12), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-text { max-width: 720px; position: relative; }
.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f4d5b3;
  padding: 0.28rem 0.85rem;
  background: rgba(196, 122, 58, 0.22);
  border: 1px solid rgba(196, 122, 58, 0.4);
  border-radius: 999px;
  margin-bottom: 1rem;
}
.hero h2 {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin-bottom: 0.85rem;
}
.hero p { font-size: 1rem; line-height: 1.65; color: rgba(255,255,255,0.88); }
.hero-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hero-actions .primary {
  background: #fff; color: var(--brand-dark); border-color: #fff;
}
.hero-actions .primary:hover { background: var(--brand-tint); border-color: var(--brand-tint); }
.hero-actions .secondary {
  background: transparent; color: #fff; border-color: rgba(255,255,255,0.4);
}
.hero-actions .secondary:hover { background: rgba(255,255,255,0.1); border-color: #fff; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.info-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.info-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.info-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  background: var(--accent-light);
  border: 1px solid rgba(196, 122, 58, 0.22);
  color: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.85rem;
}
.info-icon svg { width: 22px; height: 22px; }
.info-card h3 { font-size: 1rem; margin-bottom: 0.35rem; color: var(--ink); }
.info-card p { font-size: 0.88rem; color: var(--muted); line-height: 1.55; }

/* ---------- Training content ---------- */
.training-hero {
  background: linear-gradient(135deg, var(--brand-tint), #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.75rem;
  display: flex; gap: 1.5rem; align-items: center;
}
.training-hero img {
  max-width: 140px; height: auto;
  border-radius: var(--radius-sm);
}
.training-hero-text h2 {
  color: var(--ink); margin-bottom: 0.5rem;
  font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em;
}
.training-hero-text p { color: var(--muted); line-height: 1.6; }

.training-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.training-section h3 {
  color: var(--brand);
  font-size: 1.15rem; font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 0.6rem;
}
.training-section .section-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}
.training-section h4 {
  color: var(--ink);
  font-size: 1rem; font-weight: 600;
  margin: 1.1rem 0 0.6rem;
}
.training-section p { margin-bottom: 0.7rem; line-height: 1.65; color: var(--ink-2); }
.training-section ul, .training-section ol {
  margin: 0.5rem 0 1rem 1.4rem;
  color: var(--ink-2);
}
.training-section li { margin-bottom: 0.35rem; line-height: 1.6; }
.training-section strong { color: var(--ink); font-weight: 600; }

.training-image-row {
  display: flex; gap: 0.85rem; flex-wrap: wrap;
  margin: 1rem 0;
}
.training-image-row figure {
  flex: 1 1 200px;
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
}
.training-image-row img {
  max-width: 100%; height: auto;
  max-height: 220px;
  border-radius: 6px;
  display: block;
  margin: 0 auto;
}
.training-image-row figcaption {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.training-image-block {
  margin: 1rem 0;
  text-align: center;
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.training-image-block img {
  max-width: 100%; height: auto; max-height: 360px;
  border-radius: 6px;
}
.training-image-block figcaption {
  margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted);
}

.training-callout {
  background: var(--warn-bg);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.85rem 1rem;
  margin: 0.85rem 0;
  font-size: 0.92rem;
  color: var(--warn);
}
.training-callout strong { color: var(--warn); }

.training-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.92rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.training-table th, .training-table td {
  text-align: left;
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid var(--line-soft);
}
.training-table th {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.training-table tr:last-child td { border-bottom: none; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
  background: #fff;
}
.result-card.ok      { border-top: 3px solid var(--ok); }
.result-card.warn    { border-top: 3px solid var(--warn); }
.result-card.danger  { border-top: 3px solid var(--danger); }
.result-card h4 { margin-bottom: 0.6rem; }
.result-card img {
  max-width: 100%; height: auto; max-height: 200px;
  margin: 0.5rem auto;
  display: block;
  border-radius: 6px;
}

/* ---------- Exam ---------- */
.status-banner {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  margin-bottom: 0.8rem;
  border: 1px solid transparent;
}
.status-banner.ok    { background: var(--ok-bg);     color: var(--ok);     border-color: rgba(4, 120, 87, 0.2); }
.status-banner.warn  { background: var(--warn-bg);   color: var(--warn);   border-color: rgba(180, 83, 9, 0.2); }
.status-banner.danger{ background: var(--danger-bg); color: var(--danger); border-color: rgba(185, 28, 28, 0.2); }

.exam-form .question {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.question-number {
  color: var(--brand); font-weight: 600;
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}
.question-text { font-size: 1.02rem; font-weight: 500; margin-bottom: 1rem; color: var(--ink); }
.options { display: flex; flex-direction: column; gap: 0.5rem; }
.option {
  display: flex; align-items: flex-start;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.option:hover { background: var(--brand-tint); border-color: var(--brand-2); }
.option input { margin: 0.25rem 0.75rem 0 0; accent-color: var(--brand); }
.option:has(input:checked) {
  background: var(--brand-light); border-color: var(--brand);
}

.exam-actions {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: sticky; bottom: 1rem;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th, .data-table td {
  text-align: left; padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}
.data-table thead th {
  background: var(--bg); font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  font-size: 0.72rem; letter-spacing: 0.08em;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--brand-tint); }

.status-pill {
  display: inline-block;
  padding: 0.18rem 0.65rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.status-pill.certified     { background: var(--ok-bg); color: var(--ok); }
.status-pill.expired       { background: var(--danger-bg); color: var(--danger); }
.status-pill.not_certified { background: var(--bg); color: var(--muted); }

/* ---------- Sub-nav (used by Completions) ---------- */
.subnav {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.35rem;
  display: inline-flex; gap: 0.2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.subnav .seg {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}
.subnav .seg.active { background: var(--brand); color: #fff; }

.view-header { margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem; }
.attempt-log-blurb { margin: -0.25rem 0 1rem; }
.filter-input {
  width: 280px;
  max-width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

/* Sortable table headers */
.sortable-table thead th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.3rem;
  transition: color 0.12s;
}
.sortable-table thead th[data-sort]:hover { color: var(--brand); }
.sortable-table thead th[data-sort]::after {
  content: '↕';
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  opacity: 0.4;
}
.sortable-table thead th[data-sort].sort-asc::after  { content: '▲'; opacity: 0.9; color: var(--brand); }
.sortable-table thead th[data-sort].sort-desc::after { content: '▼'; opacity: 0.9; color: var(--brand); }

.result-pill {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.result-pill.passed { background: var(--ok-bg); color: var(--ok); }
.result-pill.failed { background: var(--danger-bg); color: var(--danger); }
.result-pill.in_progress { background: var(--warn-bg); color: var(--warn); }

/* ---------- Settings ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.settings-sidebar {
  position: sticky;
  top: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  box-shadow: var(--shadow-sm);
}
.settings-group { display: flex; flex-direction: column; gap: 0.1rem; }
.settings-group-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0 0.7rem;
  margin-bottom: 0.25rem;
}
.settings-panes { min-width: 0; }

.seg {
  background: none; border: none;
  padding: 0.55rem 0.85rem; color: var(--ink-2);
  border-radius: 7px; font-weight: 500;
  font-size: 0.9rem;
}
.settings-sidebar .seg {
  text-align: left;
  width: 100%;
  position: relative;
}
.settings-sidebar .seg.active {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}
.seg:hover:not(.active) { background: var(--brand-tint); color: var(--brand); }

/* Sticky save bar — applies to any .settings-pane that opens with a
   .row.between header. The pane is a .card (1.75rem padding), so the
   negative margins make the header span the full card width. */
.settings-pane > .row.between:first-child {
  position: sticky;
  top: 0;
  background: #ffffff;
  margin: -1.75rem -1.75rem 1.25rem;
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 5;
  gap: 1rem;
  align-items: center;
}
.settings-pane > .row.between:first-child h3 {
  margin-bottom: 0;
  min-width: 0; /* allow the title to shrink before the buttons start wrapping */
}
.settings-pane > .row.between:first-child button {
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 38px;        /* lock heights so a wrapped label can't make one taller */
}
/* The buttons + status message group should hold together without breaking. */
.settings-pane > .row.between:first-child .row.gap {
  flex-shrink: 0;
  align-items: center;
  flex-wrap: nowrap;
}

/* Inline editor for tunables/auth (short panes) — sticky save bar at the top */
.pane-sticky-actions {
  position: sticky;
  top: 0;
  background: #ffffff;
  margin: -1.75rem -1.75rem 1.25rem;
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}

/* Chip list (domains) */
.chip-list {
  list-style: none; display: flex; flex-wrap: wrap;
  gap: 0.5rem; margin-top: 1rem; padding: 0;
}
.chip {
  background: var(--brand-light); color: var(--brand);
  padding: 0.35rem 0.6rem 0.35rem 0.85rem;
  border-radius: 999px; display: flex; align-items: center;
  font-size: 0.88rem; font-weight: 500;
}
.chip button {
  background: none; border: none; color: var(--brand);
  font-size: 1.1rem; margin-left: 0.3rem;
  padding: 0 0.3rem; line-height: 1;
}
.chip button:hover { color: var(--danger); }

/* Question list */
.q-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 1rem 1.25rem;
  margin-bottom: 0.6rem;
  background: #fff;
}
.q-card.inactive { opacity: 0.55; }
.q-card .q-text { font-weight: 500; margin-bottom: 0.3rem; }
.q-card .q-meta { font-size: 0.85rem; color: var(--muted); }
.q-card .q-actions { float: right; }
.q-card .q-actions button {
  background: none; border: none; color: var(--brand);
  padding: 0.2rem 0.5rem; font-size: 0.85rem;
}
.q-card .q-actions button:hover { text-decoration: underline; }

/* Role select inside table — opt out of the global input { width: 100% } so
   the dropdown is wide enough to show "Global Admin" without clipping. */
.data-table select {
  width: auto;
  min-width: 144px;
  padding: 0.35rem 0.6rem;
  font-size: 0.88rem;
}

/* User-row actions */
.user-actions {
  display: flex; gap: 0.35rem; flex-wrap: wrap;
}
.user-actions .tool-btn { font-size: 0.78rem; padding: 0.3rem 0.6rem; }
tr.row-disabled td { opacity: 0.6; }
tr.row-disabled td:last-child { opacity: 1; }
tr.row-disabled td:first-child::before {
  content: '';
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  margin-right: 0.5rem; vertical-align: middle;
}

/* ---------- Rich text editor (Quill) ---------- */
#trainingEditor {
  background: #fff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  min-height: 480px;
}
.ql-toolbar.ql-snow {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-color: var(--line);
  background: var(--brand-tint);
}
.ql-container.ql-snow {
  border-color: var(--line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
}
.ql-editor { min-height: 480px; line-height: 1.6; }
.ql-editor h2 { color: var(--ink); font-size: 1.35rem; margin-top: 1.2rem; }
.ql-editor h3 { color: var(--brand); font-size: 1.1rem; margin-top: 1rem; }
.ql-editor img { max-width: 100%; height: auto; border-radius: 6px; margin: 0.5rem 0; }
.editor-actions { margin-top: 1rem; }

/* Rendered training content (saved HTML) */
.training-html {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-sm);
  line-height: 1.65;
  color: var(--ink-2);
}
.training-html h1, .training-html h2 {
  color: var(--ink); margin: 0 0 0.6rem;
  font-weight: 600; letter-spacing: -0.01em;
}
.training-html h2 { font-size: 1.4rem; margin-top: 1.4rem; }
.training-html h3 {
  color: var(--brand); font-size: 1.1rem;
  margin: 1.2rem 0 0.5rem; font-weight: 600;
}
.training-html h4 { color: var(--ink); font-size: 1rem; margin: 1rem 0 0.4rem; }
.training-html p  { margin: 0 0 0.7rem; }
.training-html ul, .training-html ol { margin: 0.5rem 0 1rem 1.4rem; }
.training-html li { margin-bottom: 0.3rem; }
.training-html img {
  max-width: 100%; height: auto;
  border-radius: 8px;
  margin: 0.75rem 0;
  display: block;
}
.training-html blockquote {
  border-left: 3px solid var(--brand);
  background: var(--brand-tint);
  padding: 0.7rem 1rem;
  margin: 0.7rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-2);
}
.training-html table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.9rem 0;
}
.training-html th, .training-html td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.85rem;
  text-align: left;
}
.training-html th { background: var(--brand-tint); color: var(--brand); }

/* ---------- Training content editor ---------- */
#trainingEditorRoot { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }

.editor-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
}
.editor-section-card { background: linear-gradient(180deg, var(--brand-tint), #fff 30%); }

.editor-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.85rem;
}
.editor-card-tag {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
}
.editor-card-tools { display: flex; gap: 0.3rem; }

.editor-field { margin-bottom: 0.85rem; }
.editor-field > label { display: block; margin-bottom: 0.25rem; font-size: 0.85rem; font-weight: 500; color: var(--ink-2); }
.editor-field input[type=text],
.editor-field textarea,
.editor-field select { font-size: 0.92rem; }

.editor-checkbox { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; }
.editor-checkbox input { width: auto; margin: 0; }

.editor-block {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  margin-bottom: 0.7rem;
  background: #fff;
}
.editor-block-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.55rem;
}
.editor-block-tag {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 600;
}
.editor-block-tools { display: flex; gap: 0.25rem; }
.editor-block-body { display: flex; flex-direction: column; }

.editor-add-block { margin-top: 0.5rem; }
.editor-add-block select {
  background: var(--brand-tint);
  border: 1px dashed var(--brand-2);
  color: var(--brand);
  font-weight: 500;
  cursor: pointer;
}
.editor-add-btn {
  align-self: flex-start;
  border: 1px dashed var(--brand-2);
  background: var(--brand-tint);
  color: var(--brand);
}

.editor-mini-btn {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
}

.tool-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  padding: 0.2rem 0.55rem;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.1;
}
.tool-btn:hover { background: var(--brand-tint); border-color: var(--brand-2); color: var(--brand); }
.tool-btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

/* Image picker */
.image-picker-row {
  display: flex; gap: 0.6rem; align-items: center;
  flex-wrap: wrap;
}
.image-picker-row select { flex: 1; min-width: 200px; }
.image-preview {
  width: 110px; height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, var(--bg) 25%, transparent 25%, transparent 75%, var(--bg) 75%),
    linear-gradient(45deg, var(--bg) 25%, transparent 25%, transparent 75%, var(--bg) 75%),
    #ffffff;
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
}
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-preview .muted { font-size: 0.75rem; }

.image-picker-upload, .image-picker-edit {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 0.35rem;
  transition: all 0.15s;
}
.image-picker-upload {
  border: 1px dashed var(--accent);
  background: var(--accent-light);
  color: var(--accent-2);
}
.image-picker-upload:hover { background: var(--accent); color: #fff; border-style: solid; }
.image-picker-edit {
  border: 1px solid var(--brand-2);
  background: var(--brand-tint);
  color: var(--brand);
}
.image-picker-edit:hover:not(:disabled) {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.image-picker-edit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--bg);
  color: var(--muted);
  border-color: var(--line);
}

/* Upload + crop modal */
.upload-card { max-width: 720px !important; }
.upload-picker {
  margin: 0.6rem 0 1rem;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.upload-picker input[type=file] { flex: 1; }

.upload-stage {
  margin-bottom: 1rem;
}
.upload-canvas-wrap {
  background: #1a1d24;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 420px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.6rem;
}
.upload-canvas-wrap img { display: block; max-width: 100%; max-height: 420px; }

.upload-toolbar {
  display: flex; gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.upload-toolbar-group {
  display: flex; align-items: center; gap: 0.3rem;
}
.upload-toolbar-label {
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.25rem;
}
.upload-toolbar .seg {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  background: #fff;
}
.upload-toolbar .seg.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.upload-toolbar .seg:hover:not(.active) { background: var(--brand-tint); color: var(--brand); }

.upload-actions { margin-top: 0.75rem; align-items: center; }
.upload-actions .muted { font-size: 0.85rem; }

/* List items editor */
.list-items { display: flex; flex-direction: column; gap: 0.35rem; }
.list-item-row {
  display: flex; align-items: center; gap: 0.35rem;
}
.list-item-row input { flex: 1; }

/* Image row editor */
.image-row-entry {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  margin-bottom: 0.5rem;
  background: var(--brand-tint);
}

/* Result card editor */
.result-card-edit {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-bottom: 0.6rem;
  background: var(--brand-tint);
}

/* Table editor */
.table-edit-row {
  display: flex; gap: 0.3rem; margin-bottom: 0.3rem;
  align-items: center;
}
.table-edit-row input { flex: 1; min-width: 0; }
.table-edit-head input { background: var(--brand-tint); font-weight: 600; }

/* Training video embed */
.training-video {
  margin: 1rem 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.training-video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.training-video-frame iframe,
.training-video-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.training-video-placeholder {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 1rem;
  color: rgba(255,255,255,0.65);
}
.training-video figcaption {
  background: var(--brand-tint);
  padding: 0.6rem 0.95rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.editor-hint {
  font-size: 0.78rem !important;
  margin-top: 0.4rem !important;
  color: var(--muted);
  line-height: 1.45;
}

/* Hosted-video upload control */
.video-upload-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.video-upload-status { font-size: 0.82rem; }
.video-upload-status.video-upload-error { color: var(--danger); }
.video-upload-bar {
  margin-top: 0.5rem;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.video-upload-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s ease;
}

/* Callout kind hints in renderer */
.training-callout.callout-info {
  background: var(--brand-light); border-left-color: var(--brand-2); color: var(--ink-2);
}
.training-callout.callout-info strong { color: var(--brand); }
.training-callout.callout-danger {
  background: var(--danger-bg); border-left-color: var(--danger); color: var(--danger);
}
.training-callout.callout-danger strong { color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
  .topbar, .content { padding-left: 1.5rem; padding-right: 1.5rem; }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 240px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 120;
  }
  .sidebar.open { transform: translateX(0); }
  .hero h2 { font-size: 1.4rem; }
  .hero { padding: 1.75rem 1.5rem; }
}
