:root {
  --navy: #1a3560;
  --navy-dark: #112244;
  --sky: #2e86c1;
  --amber: #e67e22;
  --bg: #f0f2f5;
  --surface: #ffffff;
  --text: #1e2b3c;
  --muted: #6b7a8d;
  --border: #d8dde6;
  --sidebar-width: 260px;
  --header-height: 56px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ── TOP HEADER ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.topbar-logo {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  white-space: nowrap;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
#menu-toggle:hover { background: rgba(255,255,255,0.1); }
#menu-toggle svg { display: block; }

/* ── LAYOUT ──────────────────────────────────────────────────── */
.layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-dark);
  color: #cdd6e4;
  flex-shrink: 0;
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 20px 16px 6px;
}

.nav-item {
  display: block;
  padding: 9px 16px 9px 20px;
  color: #b8c5d6;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}
.nav-item.active {
  background: rgba(46,134,193,0.2);
  border-left-color: var(--amber);
  color: #fff;
  font-weight: 600;
}

.nav-sub .nav-item {
  padding-left: 32px;
  font-size: 13px;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px 9px 20px;
  color: #b8c5d6;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-group-toggle:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-group-toggle.open { color: #fff; }

.nav-group-toggle .caret {
  transition: transform 0.2s;
  opacity: 0.5;
}
.nav-group-toggle.open .caret { transform: rotate(90deg); opacity: 1; }

.nav-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}
.nav-sub.open { max-height: 400px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */
.main {
  flex: 1;
  /* Flex items default to min-width:auto, which lets a wide table (the
     inspection chart, the torque tables) push the whole page wider than the
     viewport instead of scrolling inside its own .table-wrapper. */
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 32px 28px;
  max-width: 960px;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
}
.page-header .eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 4px;
}
.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}
.page-header .subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}
.divider {
  height: 3px;
  width: 48px;
  background: var(--amber);
  border-radius: 2px;
  margin-top: 10px;
}

/* ── CARDS ───────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 18px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card:hover {
  box-shadow: 0 4px 16px rgba(26,53,96,0.12);
  transform: translateY(-2px);
  border-color: var(--sky);
}
.card-icon {
  font-size: 28px;
  line-height: 1;
}
.card-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
}
.card-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

/* ── SECTION CONTENT ─────────────────────────────────────────── */
.content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
}
.content-section h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.content-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin: 16px 0 6px;
}
.content-section p {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

/* ── HOME PAGE HERO ──────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, #2a5298 100%);
  color: #fff;
  border-radius: 10px;
  padding: 36px 32px;
  margin-bottom: 28px;
}
.hero-badge {
  display: inline-block;
  background: var(--amber);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 3px;
  margin-bottom: 14px;
}
.hero h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 10px;
}
.hero p {
  font-size: 14.5px;
  color: rgba(255,255,255,0.75);
  max-width: 540px;
}

/* ── SAFETY NOTE ─────────────────────────────────────────────── */
.safety-note {
  background: #fff5f5;
  border: 1px solid #f5c2c7;
  border-left: 4px solid #dc3545;
  border-radius: 6px;
  padding: 14px 16px;
  margin: 20px 0;
  font-size: 13.5px;
  color: #3d0a0a;
}
.safety-note .safety-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #dc3545;
  margin-bottom: 5px;
}
.safety-note p { color: #4a1010; font-style: normal; font-size: 13.5px; }

/* ── COMPONENT LIST ──────────────────────────────────────────── */
.component-list { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.component-list li {
  padding: 10px 14px;
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.5;
}
.component-list li strong { color: var(--navy); }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  #menu-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.visible { display: block; }

  .main {
    margin-left: 0;
    padding: 20px 16px;
  }

  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 22px; }

  .page-header h1 { font-size: 20px; }

  .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 400px) {
  .card-grid { grid-template-columns: 1fr; }
}

/* ── ASSESSMENT (pre-test / post-test) ───────────────────────── */
.consent-note {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 13px;
  color: #1e3a5f;
  line-height: 1.6;
  margin-bottom: 20px;
}

.identity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 24px;
  margin-bottom: 22px;
}
.identity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.field label .req { color: #dc3545; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
.field input:focus {
  outline: 2px solid var(--sky);
  outline-offset: 1px;
  border-color: var(--sky);
}
.field input:disabled { background: #f1f3f7; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.part-heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--amber);
}
.part-heading:first-child { margin-top: 0; }

.queue-chip[hidden] { display: none; }
.queue-chip {
  display: inline-block;
  background: #fff3e0;
  border: 1px solid #ffcc80;
  color: #e65100;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

#test-result {
  display: none;
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid;
}
#test-result.ok    { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
#test-result.warn  { background: #fff3e0; border-color: #ffcc80; color: #e65100; }
#test-result.error { background: #ffebee; border-color: #ef5350; color: #b71c1c; }

/* ── QUIZ / TEST CARDS (shared by practice quiz and pre/post tests) ── */
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 24px;
  margin-bottom: 14px;
}
.quiz-card .q-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.quiz-card .q-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 14px;
  line-height: 1.4;
}
.option-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.option-list li label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.15s, border-color 0.15s;
}
.option-list li label:hover { background: #eef3fa; border-color: var(--sky); }
.option-list input[type=radio] { accent-color: var(--sky); flex-shrink: 0; }
.option-list li label:has(input:disabled) { cursor: default; opacity: 0.75; }

.quiz-controls { margin-top: 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.btn {
  padding: 10px 24px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary  { background: var(--navy);   color: #fff; }
.btn-secondary{ background: var(--border); color: var(--text); }
