/* =====================================================================
   INDUSTRIAL TRAINING PORTAL — DESIGN SYSTEM
   Palette grounded in industrial signage & compliance stamps:
   deep navy + safety amber, hairline "blueprint" borders, a
   stamped-manifest motif for progress. Type: Space Grotesk (display,
   technical character) / IBM Plex Sans (body) / IBM Plex Mono (data,
   codes) / IBM Plex Serif (certificate register).
   ===================================================================== */

:root {
  /* Palette */
  --ink:        #132A3A;
  --ink-2:      #1E3F54;
  --ink-3:      #0C1B26;
  --amber:      #D98E1E;
  --amber-dark: #B5730F;
  --amber-tint: #FBF0DC;
  --paper:      #F5F6F3;
  --white:      #FFFFFF;
  --success:    #2F8F5B;
  --success-tint: #E4F3EA;
  --danger:     #C1452E;
  --danger-tint:  #FBE9E5;

  --slate-50:  #F7F8F7;
  --slate-100: #EEF0EE;
  --slate-200: #DFE3E0;
  --slate-300: #C7CDC8;
  --slate-400: #9AA39D;
  --slate-500: #71797A;
  --slate-600: #545C5D;
  --slate-700: #3B4243;
  --slate-800: #262C2D;
  --slate-900: #171B1B;

  /* Type */
  --font-display: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, Segoe UI, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --font-serif: 'IBM Plex Serif', Georgia, serif;

  /* Scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(19, 42, 58, 0.06);
  --shadow-md: 0 4px 16px rgba(19, 42, 58, 0.08);
  --shadow-lg: 0 12px 32px rgba(19, 42, 58, 0.14);
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--slate-800);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 .5em;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--ink-2); }
code, .mono { font-family: var(--font-mono); }

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

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* =========================== LAYOUT SHELL =========================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow-md);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--white);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.brand-mark { color: var(--amber); font-size: 1.2rem; }
.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.role-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(217, 142, 30, 0.18);
  color: var(--amber);
  border: 1px solid rgba(217, 142, 30, 0.4);
}
.user-name { font-size: 0.88rem; color: var(--slate-200); display: none; }
.btn-logout {
  color: var(--white);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
}
.btn-logout:hover { background: rgba(255,255,255,0.08); }

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.hamburger span { display: block; width: 20px; height: 2px; background: var(--white); border-radius: 2px; }

.app-shell {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--slate-200);
  padding: 20px 12px;
}
.side-nav-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-400);
  margin: 18px 10px 6px;
}
.side-nav-label:first-child { margin-top: 4px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--slate-700);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 2px;
}
.side-link:hover { background: var(--slate-100); }
.side-link.active { background: var(--ink); color: var(--white); }
.side-icon { width: 18px; text-align: center; opacity: 0.8; }
.side-link-back { color: var(--slate-500); font-size: 0.85rem; margin-bottom: 10px; }

.sidebar-backdrop { display: none; }

.content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 60px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 { margin-bottom: 2px; }
.page-sub { color: var(--slate-500); margin: 0; font-size: 0.95rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* =========================== ALERTS / FLASH =========================== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-tint); color: #1E5C3B; border-color: #BFE3CE; }
.alert-danger  { background: var(--danger-tint); color: #7C2C1B; border-color: #F0C4B9; }
.alert-info    { background: var(--amber-tint); color: #7A5410; border-color: #F0D9AE; }

/* =========================== BUTTONS =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--white); }
.btn-primary:hover { background: var(--ink-2); }
.btn-accent { background: var(--amber); color: var(--ink-3); }
.btn-accent:hover { background: var(--amber-dark); color: var(--white); }
.btn-outline { background: var(--white); color: var(--ink); border-color: var(--slate-300); }
.btn-outline:hover { border-color: var(--ink); }
.btn-danger { background: var(--white); color: var(--danger); border-color: #EAC2B7; }
.btn-danger:hover { background: var(--danger-tint); }
.btn-ghost { background: transparent; color: var(--slate-600); border-color: transparent; }
.btn-ghost:hover { background: var(--slate-100); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* =========================== FORMS =========================== */

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label {
  display: block;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--slate-700);
  margin-bottom: 6px;
}
.form-hint { color: var(--slate-500); font-size: 0.8rem; margin-top: 5px; }
.form-control, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--slate-800);
  background: var(--white);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
}
.form-control:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px rgba(30, 63, 84, 0.12);
}
textarea { resize: vertical; min-height: 100px; font-family: var(--font-body); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; }
.checkbox-row label { margin: 0; font-weight: 500; }
fieldset { border: 1px solid var(--slate-200); border-radius: var(--radius-md); padding: 16px; margin: 0 0 16px; }
legend { font-family: var(--font-display); font-weight: 600; color: var(--ink); padding: 0 6px; }

/* =========================== CARDS =========================== */

.card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card-title { font-family: var(--font-display); font-weight: 600; color: var(--ink); margin: 0 0 4px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.stat-card.accent { border-left-color: var(--amber); }
.stat-card.ok { border-left-color: var(--success); }
.stat-card.warn { border-left-color: var(--danger); }
.stat-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; color: var(--ink); }
.stat-label { color: var(--slate-500); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* =========================== BADGES =========================== */

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-success { background: var(--success-tint); color: #1E5C3B; }
.badge-amber   { background: var(--amber-tint); color: #8A5D0E; }
.badge-danger  { background: var(--danger-tint); color: #7C2C1B; }
.badge-slate   { background: var(--slate-100); color: var(--slate-600); }

/* =========================== TABLES =========================== */

.table-responsive { overflow-x: auto; border: 1px solid var(--slate-200); border-radius: var(--radius-md); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--slate-100); white-space: nowrap; }
th { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-500); background: var(--slate-50); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--slate-50); }
td.wrap, th.wrap { white-space: normal; }
.table-empty { padding: 32px; text-align: center; color: var(--slate-500); }

/* =========================== TABS =========================== */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--slate-200); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 10px 16px;
  text-decoration: none;
  color: var(--slate-500);
  font-weight: 600;
  font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--ink); border-bottom-color: var(--amber); }
.tab .count { font-family: var(--font-mono); font-size: 0.72rem; margin-left: 4px; color: var(--slate-400); }

/* =========================== AUTH PAGES =========================== */

.auth-page {
  background: var(--ink);
  background-image:
    linear-gradient(160deg, var(--ink) 0%, var(--ink-3) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; color: var(--white); margin-bottom: 22px; }
.auth-brand .brand-mark { color: var(--amber); font-size: 1.6rem; }
.auth-brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-title { margin-bottom: 6px; }
.auth-sub { color: var(--slate-500); font-size: 0.9rem; margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 0.85rem; color: rgba(255,255,255,0.65); }
.auth-foot a { color: var(--amber); text-decoration: none; }

.otp-boxes { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 6px; }
.otp-boxes input {
  width: 46px; height: 54px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
}
.otp-boxes input:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px rgba(30,63,84,0.12); }
.otp-resend { font-size: 0.85rem; color: var(--slate-500); margin-top: 14px; text-align: center; }
.otp-resend button { background: none; border: none; color: var(--ink-2); font-weight: 600; cursor: pointer; padding: 0; font-size: 0.85rem; }
.otp-resend button[disabled] { color: var(--slate-400); cursor: not-allowed; }
.debug-otp-box {
  margin-top: 14px; padding: 10px 14px; background: var(--amber-tint);
  border: 1px dashed var(--amber-dark); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.85rem; color: #7A5410;
}

/* =========================== CATEGORY / DASHBOARD =========================== */

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.category-card {
  background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius-md);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.category-card.subscribed { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.category-card h3 { margin: 0; }
.category-card p { margin: 0; color: var(--slate-500); font-size: 0.86rem; flex: 1; }

.training-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.training-card {
  background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius-md);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.training-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.training-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.training-card h3 { margin: 0; font-size: 1.02rem; }
.training-cat-tag { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; color: var(--slate-500); letter-spacing: 0.05em; }
.progress-track { height: 7px; background: var(--slate-100); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--amber); border-radius: 20px; }
.training-card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--slate-500); }
.due-overdue { color: var(--danger); font-weight: 600; }

/* =========================== MODULE PLAYER (signature element) =========================== */

.player-shell { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

.manifest {
  background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius-lg);
  padding: 18px 16px; position: sticky; top: calc(var(--topbar-h) + 16px);
}
.manifest-head { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--slate-400); margin-bottom: 14px; }
.manifest-list { list-style: none; margin: 0; padding: 0; position: relative; }
.manifest-list::before {
  content: ''; position: absolute; left: 15px; top: 8px; bottom: 8px; width: 1px; background: var(--slate-200);
}
.manifest-item { position: relative; padding: 0 0 20px 40px; }
.manifest-item:last-child { padding-bottom: 0; }
.manifest-stamp {
  position: absolute; left: 0; top: -1px; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600;
  background: var(--white); border: 2px solid var(--slate-300); color: var(--slate-400);
}
.manifest-item.completed .manifest-stamp { border-color: var(--success); color: var(--success); background: var(--success-tint); }
.manifest-item.current .manifest-stamp { border-color: var(--amber); color: var(--amber-dark); background: var(--amber-tint); }
.manifest-item.locked .manifest-stamp { border-style: dashed; }
.manifest-link { text-decoration: none; color: var(--slate-700); font-size: 0.88rem; font-weight: 500; display: block; }
.manifest-item.current .manifest-link { color: var(--ink); font-weight: 700; }
.manifest-item.locked .manifest-link { color: var(--slate-400); pointer-events: none; }
.manifest-type { display: block; font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; color: var(--slate-400); margin-top: 2px; }

.player-main { background: var(--white); border: 1px solid var(--slate-200); border-radius: var(--radius-lg); overflow: hidden; }
.player-header { padding: 20px 24px; border-bottom: 1px solid var(--slate-100); }
.player-header h2 { margin-bottom: 4px; }
.player-body { padding: 0; }
.player-body.has-padding { padding: 24px; }
.doc-frame, .video-frame { width: 100%; height: 62vh; border: none; display: block; background: var(--slate-900); }
.text-reader { padding: 28px 32px; font-size: 1rem; line-height: 1.8; color: var(--slate-800); white-space: pre-wrap; max-height: 62vh; overflow-y: auto; }
.player-footer {
  padding: 16px 24px; border-top: 1px solid var(--slate-100);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--slate-50);
}
.gate-status { font-size: 0.85rem; color: var(--slate-500); display: flex; align-items: center; gap: 8px; }
.gate-countdown {
  font-family: var(--font-mono); font-size: 1rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--amber-dark); background: var(--amber-tint); padding: 3px 12px; border-radius: var(--radius-sm);
}
.gate-countdown.gate-countdown-ready { color: #1E5C3B; background: var(--success-tint); }
.watch-progress-row { flex-basis: 100%; }
.btn-accent[disabled] {
  background: var(--slate-200); color: var(--slate-500); opacity: 1; cursor: not-allowed;
}
@keyframes readyPulse {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 142, 30, 0.45); }
  60%  { transform: scale(1.045); box-shadow: 0 0 0 10px rgba(217, 142, 30, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(217, 142, 30, 0); }
}
.btn-ready-pulse { animation: readyPulse 0.7s ease-out; }
.gate-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.viewer-fallback { padding: 16px 24px; background: var(--amber-tint); font-size: 0.85rem; color: #7A5410; }

/* =========================== ASSESSMENT =========================== */

.quiz-question { padding: 20px 0; border-bottom: 1px solid var(--slate-100); }
.quiz-question:last-child { border-bottom: none; }
.quiz-question-title { font-weight: 600; color: var(--ink); margin-bottom: 12px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--slate-200); border-radius: var(--radius-sm); cursor: pointer; }
.quiz-option:hover { border-color: var(--ink-2); }
.quiz-option input { width: 16px; height: 16px; }
.quiz-option.correct { border-color: var(--success); background: var(--success-tint); }
.quiz-option.incorrect { border-color: var(--danger); background: var(--danger-tint); }
.score-ring { text-align: center; padding: 28px 0; }
.score-num { font-family: var(--font-display); font-size: 3rem; font-weight: 700; color: var(--ink); }

/* =========================== CERTIFICATE =========================== */

.certificate-page { background: var(--slate-200); padding: 40px 16px; min-height: 100vh; }
.certificate-toolbar { max-width: 900px; margin: 0 auto 18px; display: flex; justify-content: space-between; align-items: center; }
.certificate {
  max-width: 900px; margin: 0 auto; background: var(--white);
  border: 10px solid var(--ink); position: relative; padding: 56px 60px; text-align: center;
}
.certificate::before {
  content: ''; position: absolute; inset: 10px; border: 1px solid var(--amber);
}
.cert-eyebrow { font-family: var(--font-mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--amber-dark); font-size: 0.78rem; }
.cert-title { font-family: var(--font-serif); font-size: 2.3rem; color: var(--ink); margin: 10px 0 20px; }
.cert-name { font-family: var(--font-serif); font-size: 1.9rem; color: var(--ink); margin: 14px 0; font-weight: 700; }
.cert-body-text { color: var(--slate-600); max-width: 560px; margin: 0 auto; }
.cert-training { font-weight: 700; color: var(--ink); }
.cert-meta { display: flex; justify-content: center; gap: 48px; margin-top: 36px; flex-wrap: wrap; }
.cert-meta-item { text-align: center; }
.cert-meta-label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; color: var(--slate-400); letter-spacing: 0.06em; }
.cert-meta-value { font-family: var(--font-mono); font-weight: 500; color: var(--ink); margin-top: 4px; }
.cert-seal {
  width: 88px; height: 88px; border-radius: 50%; border: 3px solid var(--amber);
  display: flex; align-items: center; justify-content: center; margin: 24px auto 0;
  font-family: var(--font-mono); font-size: 0.62rem; color: var(--amber-dark); text-align: center;
  line-height: 1.3; transform: rotate(-6deg);
}
@media print {
  .no-print { display: none !important; }
  .certificate-page { background: var(--white); padding: 0; }
  .certificate { border-width: 8px; box-shadow: none; }
}

/* =========================== MISC UI =========================== */

.empty-state { text-align: center; padding: 60px 20px; color: var(--slate-500); }
.empty-state h3 { color: var(--slate-600); }
.divider { border: none; border-top: 1px solid var(--slate-200); margin: 22px 0; }
.text-muted { color: var(--slate-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.small { font-size: 0.82rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip-list { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-checkbox { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--slate-300); border-radius: 20px; padding: 6px 12px; font-size: 0.82rem; cursor: pointer; }
.timeline-note { background: var(--amber-tint); border: 1px solid #F0D9AE; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.85rem; color: #7A5410; }

/* =========================== RESPONSIVE =========================== */

@media (min-width: 640px) {
  .user-name { display: inline; }
}

@media (max-width: 991px) {
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform 0.2s ease; overflow-y: auto;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(12,27,38,0.4); z-index: 45;
  }
  .sidebar-backdrop.open { display: block; }
  .content { padding: 20px 16px 50px; }
  .player-shell { grid-template-columns: 1fr; }
  .manifest { position: static; }
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .certificate { padding: 32px 20px; }
  .cert-title { font-size: 1.6rem; }
  .cert-name { font-size: 1.4rem; }
  .cert-meta { gap: 24px; }
  h1 { font-size: 1.5rem; }
  .otp-boxes input { width: 40px; height: 48px; font-size: 1.2rem; }
}

/* ---------- Certificate: SOP-wise marks table + QR (v2) ---------- */
.cert-sop-table {
  width: 100%; border-collapse: collapse; margin: 22px 0 6px;
  font-family: var(--font-body); font-size: 0.82rem;
}
.cert-sop-table th {
  text-align: left; font-family: var(--font-mono); font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-500);
  border-bottom: 1px solid var(--slate-200); padding: 6px 8px; font-weight: 600;
}
.cert-sop-table td { padding: 6px 8px; border-bottom: 1px solid var(--slate-100); color: var(--ink); }
.cert-sop-table tr.cert-final-row td { font-weight: 600; border-top: 1.5px solid var(--slate-300); }
.cert-footer-row {
  display: flex; align-items: center; justify-content: center; gap: 40px;
  margin-top: 18px; flex-wrap: wrap;
}
.cert-qr { text-align: center; }
.cert-qr img, .cert-qr canvas { display: block; margin: 0 auto; }
.cert-qr-label {
  font-family: var(--font-mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--slate-500); margin-top: 5px;
}
@media print {
  .cert-sop-table { font-size: 0.76rem; }
  .cert-footer-row { gap: 28px; }
}

/* ---------- Learning assistant (v2) ---------- */
.assistant-toggle {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  background: var(--navy); color: #fff; border: none; cursor: pointer;
  border-radius: 30px; padding: 12px 20px; font-family: var(--font-body);
  font-size: 0.88rem; font-weight: 600; box-shadow: 0 4px 16px rgba(19,42,58,0.28);
  display: flex; align-items: center; gap: 8px;
}
.assistant-toggle:hover { background: var(--navy-light, #1C3A4F); }
.assistant-panel {
  position: fixed; right: 22px; bottom: 78px; z-index: 61;
  width: 360px; max-width: calc(100vw - 32px); height: 460px; max-height: calc(100vh - 130px);
  background: #fff; border: 1px solid var(--slate-200); border-radius: 12px;
  box-shadow: 0 10px 40px rgba(19,42,58,0.22);
  display: none; flex-direction: column; overflow: hidden;
}
.assistant-panel.open { display: flex; }
.assistant-head {
  background: var(--navy); color: #fff; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.assistant-head strong { font-family: var(--font-display); font-size: 0.95rem; }
.assistant-head button { background: none; border: none; color: #C9D3D8; font-size: 1.2rem; cursor: pointer; line-height: 1; }
.assistant-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.assistant-msg { padding: 9px 12px; border-radius: 10px; font-size: 0.87rem; line-height: 1.5; white-space: pre-wrap; max-width: 88%; }
.assistant-msg-user { background: var(--navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.assistant-msg-bot { background: var(--slate-100); color: var(--ink); align-self: flex-start; border-bottom-left-radius: 3px; }
.assistant-msg-error { background: var(--danger-tint); color: var(--danger); }
.assistant-foot { border-top: 1px solid var(--slate-100); padding: 10px; display: flex; gap: 8px; }
.assistant-foot textarea {
  flex: 1; resize: none; height: 38px; padding: 9px 10px; font-size: 0.87rem;
  border: 1px solid var(--slate-200); border-radius: 8px; font-family: var(--font-body);
}
.assistant-note { padding: 0 14px 10px; font-size: 0.72rem; color: var(--slate-500); }
@media (max-width: 640px) {
  .assistant-panel { right: 12px; left: 12px; width: auto; bottom: 70px; }
  .assistant-toggle { right: 14px; bottom: 14px; }
}
@media print { .assistant-toggle, .assistant-panel { display: none !important; } }
.side-badge {
  margin-left: auto; background: var(--amber); color: #fff; font-size: 0.68rem;
  font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
