/* SCG Training Portal — Data Analysis & Process Improvement */

:root {
  --scg-red: #D32F2F;
  --scg-red-dark: #9A0007;
  --scg-red-light: #FFCDD2;
  --accent: #F57C00;
  --success: #2E7D32;
  --info: #1565C0;
  --error: #C62828;
  --warning: #E65100;
  --gray-900: #212121;
  --gray-700: #616161;
  --gray-500: #9E9E9E;
  --gray-300: #E0E0E0;
  --gray-100: #F5F5F5;
  --white: #FFFFFF;
  --shadow-low: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-mid: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-high: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

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

body {
  font-family: "Noto Sans Thai", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== LOGIN PAGE ========== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--scg-red) 0%, var(--scg-red-dark) 100%);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-high);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.login-logo-mark {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: var(--scg-red);
  color: var(--white);
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px;
}
.login-logo h1 {
  font-size: 20px; font-weight: 600; color: var(--scg-red-dark);
}
.login-subtitle {
  color: var(--gray-700);
  font-size: 14px;
  margin-bottom: 32px;
}

.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: 16px;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.form-field input:focus {
  outline: none;
  border-color: var(--scg-red);
  box-shadow: 0 0 0 3px var(--scg-red-light);
}

.btn {
  width: 100%;
  padding: 12px 20px;
  background: var(--scg-red);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out, transform 150ms ease-out;
}
.btn:hover { background: var(--scg-red-dark); }
.btn:active { transform: scale(0.98); }

.login-error {
  background: #FFEBEE;
  color: var(--scg-red-dark);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

.login-hint {
  margin-top: 20px;
  padding: 12px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--gray-700);
  text-align: center;
}
.login-hint code {
  background: var(--white);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  color: var(--scg-red-dark);
}

/* ==========================================================================
   LAYOUT — both shells use the same left-sidebar grid (.app > .sidebar + .main):
     * /admin  navigates with .admin-nav-item rows
     * /app    navigates with .nav-section blocks of .nav-item rows
   Shared class names (.nav-item, .nav-num, .logout-btn, …) are therefore styled
   once here rather than being scoped per shell.
   ========================================================================== */

/* ========== APP LAYOUT ========== */
.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 250ms ease-out;
}
.app.collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--gray-300);
  padding: 16px 0 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  /* A grid item defaults to min-width:auto, which would let long nav labels and
     email addresses push the column wider than its track. Without this the
     sidebar overflows the viewport on narrow screens. */
  min-width: 0;
  transition: width 250ms ease-out;
}
/* Same reason, one level down: let the label ellipsis rather than set the width. */
.nav-item { min-width: 0; }
.nav-item > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar toggle button — lives at sidebar edge, tracks sidebar width so it never overlaps content */
.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: calc(280px - 14px);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: var(--white);
  color: var(--scg-red);
  border: 1px solid var(--gray-300);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-mid);
  z-index: 50;
  transition: left 250ms ease-out, background 150ms ease-out, color 150ms ease-out, box-shadow 150ms ease-out, border-color 150ms ease-out;
}
.sidebar-toggle:hover {
  background: var(--scg-red);
  color: var(--white);
  border-color: var(--scg-red);
  box-shadow: var(--shadow-high);
}
.sidebar-toggle:focus-visible {
  outline: 2px solid var(--scg-red);
  outline-offset: 2px;
}
.sidebar-toggle-icon {
  transition: transform 250ms ease-out;
}
.app.collapsed .sidebar-toggle { left: calc(72px - 14px); }
.app.collapsed .sidebar-toggle-icon { transform: rotate(180deg); }

/* Collapsed sidebar — hide text, center icons */
.app.collapsed .sidebar-logo h2,
.app.collapsed .sidebar-sub,
.app.collapsed .nav-label,
.app.collapsed .nav-item span:last-child,
.app.collapsed .logout-btn span.logout-text {
  display: none;
}
.app.collapsed .sidebar-logo {
  justify-content: center;
}
.app.collapsed .sidebar-header {
  padding: 0 12px 16px;
}
.app.collapsed .nav-item {
  justify-content: center;
  padding: 10px 12px;
  border-left: none;
  border-right: 3px solid transparent;
}
.app.collapsed .nav-item.active {
  border-right-color: var(--scg-red);
}
.app.collapsed .sidebar-footer {
  padding: 12px 8px;
}
.app.collapsed .logout-btn {
  padding: 10px 0;
  font-size: 16px;
}
.app.collapsed .logout-icon {
  display: inline-block !important;
}
.app.collapsed .nav-num {
  margin: 0;
}

/* Tooltip on hover when collapsed */
.app.collapsed .nav-item {
  position: relative;
}
.app.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--gray-900);
  color: var(--white);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms;
  z-index: 100;
  box-shadow: var(--shadow-mid);
}
.app.collapsed .nav-item:hover::after {
  opacity: 1;
}

.sidebar-header {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--gray-300);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.sidebar-logo-mark {
  width: 36px; height: 36px;
  background: var(--scg-red);
  color: var(--white);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.sidebar-logo h2 {
  font-size: 14px; font-weight: 600;
}
.sidebar-sub {
  font-size: 12px; color: var(--gray-500);
}

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  padding: 11px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px;
  color: var(--gray-700);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 150ms ease-out, color 150ms ease-out;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active {
  background: var(--scg-red-light);
  color: var(--scg-red-dark);
  border-left-color: var(--scg-red);
}
.nav-num {
  width: 22px; height: 22px;
  background: transparent;
  color: var(--gray-500);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 13px;
  line-height: 1;
  transition: color 150ms ease-out, background 150ms ease-out;
}
.nav-item:hover .nav-num { color: var(--gray-900); }
.nav-item.active .nav-num {
  background: var(--scg-red);
  color: var(--white);
}
.nav-num i.fa-solid { font-size: 14px; }

/* Sub-nav item — indented child of a parent module */
.nav-item.nav-sub {
  padding-left: 38px;
  font-size: 12.5px;
  color: var(--gray-500);
}
.nav-item.nav-sub .nav-num {
  width: 20px; height: 20px;
  background: transparent;
  color: var(--gray-500);
}
.nav-item.nav-sub .nav-num i.fa-solid { font-size: 12px; }
.nav-item.nav-sub:hover .nav-num { color: var(--scg-red); }
.nav-item.nav-sub.active .nav-num {
  background: var(--scg-red);
  color: var(--white);
}
.app.collapsed .nav-item.nav-sub { padding-left: 0; }
.app.collapsed .nav-item.nav-sub .nav-num { background: var(--gray-100); color: var(--gray-700); }

/* The portal's logo is a link back to Home; strip the default link styling so it
   matches the admin panel's plain <div> version. */
a.sidebar-logo,
a.sidebar-logo:hover {
  text-decoration: none;
  color: inherit;
}
a.sidebar-logo h2 { color: var(--gray-900); }
a.sidebar-logo:focus-visible {
  outline: 2px solid var(--scg-red);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Sidebar nav sections ──────────────────────────────────────────────────
   Each former top-bar dropdown is a titled, always-expanded section. The list
   scrolls inside the sidebar; the header, user card and footer stay put. */
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
}
.nav-section + .nav-section {
  margin-top: 2px;
  border-top: 1px solid var(--gray-100);
}
/* Pinned shortcuts lead the list, so they get a stronger divider beneath them
   to read as a separate band from the module sections. */
.nav-section-quick {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--gray-300);
}
.nav-section-quick + .nav-section { border-top: none; }
.nav-label i.fa-solid {
  width: 14px;
  margin-right: 7px;
  font-size: 11px;
  color: var(--gray-500);
}
/* The section owning the open module gets a tinted heading so the current
   area is obvious without expanding anything. */
.nav-section.has-active > .nav-label,
.nav-section.has-active > .nav-label i.fa-solid {
  color: var(--scg-red);
}

/* Pinned shortcut (Prompt Gallery) — a highlighted row, not a plain link. */
.nav-item-pinned {
  text-decoration: none;
  color: var(--scg-red-dark, #9A0007);
  font-weight: 600;
}
.nav-item-pinned .nav-num { color: var(--scg-red); }
.nav-item-pinned-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--scg-red);
  color: var(--white);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Collapsed rail: headings and badges disappear, icons stay centred. */
.app.collapsed .sidebar-nav { overflow-x: hidden; }
.app.collapsed .nav-label,
.app.collapsed .nav-item-pinned-badge { display: none; }
.app.collapsed .nav-section + .nav-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--gray-300);
}

/* Account block — pinned to the bottom of the sidebar, above Sign out.
   margin-top:auto keeps it there even when the nav list is short. */
.sidebar-user {
  margin-top: auto;
  padding: 10px 16px 0;
  flex-shrink: 0;
}
.sidebar-user:empty { display: none; }
.app.collapsed .sidebar-user { padding: 8px 8px 0; }
.app.collapsed .sidebar-user .sidebar-user-text,
.app.collapsed .sidebar-user .sidebar-admin-link { display: none; }
.app.collapsed .sidebar-user .sidebar-user-info {
  justify-content: center;
  padding: 6px;
  gap: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-300);
  background: var(--white);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
}

.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active {
  background: var(--scg-red-light, #ffebee);
  color: var(--scg-red);
  font-weight: 600;
}

/* A soft pulse on first paint draws the eye without being noisy */
@media (prefers-reduced-motion: no-preference) {

  @keyframes pinnedPulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(211, 47, 47, 0.32); }
    50%      { box-shadow: 0 2px 8px rgba(211, 47, 47, 0.32), 0 0 0 6px rgba(211, 47, 47, 0.12); }
  }
}

.btn-view-portal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px;
  margin-bottom: 8px;
  background: var(--scg-red);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms;
}
.btn-view-portal:hover { background: var(--scg-red-dark, #b71c1c); color: var(--white); }
/* Admin sidebar footer — full-width button, as before. */
.logout-btn {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  color: var(--gray-700);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.logout-btn:hover {
  border-color: var(--scg-red);
  color: var(--scg-red);
}

/* ========== MAIN CONTENT ========== */
.main {
  padding: 40px 48px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  /* Grid items default to min-width:auto, so a wide child (code block, flow
     diagram) would stretch the column past the viewport instead of scrolling
     inside its own container. */
  min-width: 0;
}

.module { display: none; }
.module.active { display: block; animation: fadeIn 250ms ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== HERO ========== */
.hero {
  position: relative;
  height: 240px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: var(--shadow-mid);
}
.hero img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,0.75) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 32px;
  color: var(--white);
}
.hero-tag {
  display: inline-block;
  background: var(--scg-red);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
  width: fit-content;
}
.hero h1 {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 6px;
}
.hero p { font-size: 15px; opacity: 0.9; max-width: 600px; }

/* ========== SECTIONS ========== */
.section { margin-bottom: 40px; }
.section-title {
  display: flex; align-items: center; gap: 12px;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--gray-900);
}
.section-title-num {
  width: 28px; height: 28px;
  background: var(--scg-red);
  color: var(--white);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.section p {
  color: var(--gray-700);
  font-size: 15px;
  margin-bottom: 12px;
}

/* ========== FLOW DIAGRAM ========== */
.flow {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-low);
  margin-bottom: 24px;
  overflow-x: auto;
}
.flow-steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: fit-content;
}
.flow-step {
  flex: 1;
  min-width: 120px;
  text-align: center;
}
.flow-icon {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--scg-red-light), var(--white));
  border: 2px solid var(--scg-red);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 28px;
  color: var(--scg-red-dark);
  box-shadow: var(--shadow-low);
}
.flow-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.flow-desc {
  font-size: 11px;
  color: var(--gray-500);
  line-height: 1.4;
}
.flow-arrow {
  color: var(--scg-red);
  font-size: 24px;
  align-self: center;
  flex-shrink: 0;
  margin-top: -24px;
}

/* ========== CARD GRID ========== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-low);
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-mid);
}
.card-icon {
  width: 44px; height: 44px;
  background: var(--scg-red-light);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-size: 22px;
  margin-bottom: 12px;
}
.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.card p {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.5;
  margin: 0;
}

/* ========== EXAMPLE / CASE BOX ========== */
.example {
  background: linear-gradient(135deg, #FFF8E1 0%, #FFF 100%);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.example-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}
.example h4 {
  font-size: 16px; font-weight: 600; margin-bottom: 8px;
}
.example p { margin: 0; font-size: 14px; }

/* ========== PROMPT BLOCK (copyable) ========== */
.prompt-block {
  background: #1e2330;
  border-radius: var(--radius-md);
  margin: 16px 0;
  overflow: hidden;
  box-shadow: var(--shadow-low);
}
.prompt-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #161a24;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.prompt-block-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #cbd5e1;
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.14); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy-btn.copied {
  background: var(--success);
  border-color: var(--success);
  color: var(--white);
}
.prompt-block-body {
  margin: 0;
  padding: 16px 18px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.65;
  color: #e6edf3;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.prompt-block-body code {
  font-family: inherit;
  color: inherit;
  background: none;
  padding: 0;
}

/* ========== VIZ TABS (compact, wrapping pill tabs for the gallery) ========== */
.viz-tabs {
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--gray-300);
  padding-bottom: 10px;
  margin-bottom: 16px;
}
.viz-tabs .process-tab {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-700);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  margin-bottom: 0;
}
.viz-tabs .process-tab:hover {
  color: var(--scg-red-dark);
  border-color: var(--scg-red);
}
.viz-tabs .process-tab.active {
  color: var(--white);
  background: var(--scg-red);
  border-color: var(--scg-red);
}
.viz-panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--scg-red-dark);
  margin-bottom: 10px;
}

/* Size the branching flow diagrams to fill a Full HD screen, but never overflow it */
#vf-approval-flow .viz svg,
#vf-swimlane-flow .viz svg,
#vf-decision-tree .viz svg,
#vf-escalation-flow .viz svg {
  width: 100%;
  height: auto;
  max-height: 72vh;
  margin: 0 auto;
}
#vf-approval-flow .viz svg { max-width: 920px; }
#vf-swimlane-flow .viz svg { max-width: 960px; }
#vf-decision-tree .viz svg { max-width: 560px; }
#vf-escalation-flow .viz svg { max-width: 440px; }

/* Compact flow diagrams inside the Graph & Flow Gallery only */
#mod-viz-reference .flow { padding: 18px 14px; margin-bottom: 8px; }
#mod-viz-reference .flow-icon { width: 44px; height: 44px; font-size: 19px; margin-bottom: 8px; border-width: 2px; }
#mod-viz-reference .flow-step { min-width: 80px; }
#mod-viz-reference .flow-label { font-size: 12px; }
#mod-viz-reference .flow-desc { font-size: 10px; }
#mod-viz-reference .flow-arrow { font-size: 18px; margin-top: -18px; }
#mod-viz-reference .process-panel > h3:first-child { margin-top: 4px !important; }

/* ========== DATA-VIZ EXAMPLES (graph & flow reference) ========== */
.viz {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-low);
  margin: 14px 0;
  overflow-x: auto;
}
.viz-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
}
.viz svg { max-width: 100%; height: auto; display: block; }
.viz-caption {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--gray-700);
  border-top: 1px solid var(--gray-100);
  padding-top: 10px;
}
.viz-caption strong { color: var(--scg-red-dark); }
.viz-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.3fr;
  gap: 18px;
  align-items: center;
}
.viz-grid .table { margin: 0; }
@media (max-width: 760px) { .viz-grid { grid-template-columns: 1fr; } }

/* KPI dashboard cards */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-low);
  padding: 14px 16px;
  border-left: 4px solid var(--scg-red);
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 4px;
}
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--error); }

/* ========== CHECKLIST ========== */
.checklist {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-low);
}
.checklist h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--scg-red-dark);
}
.checklist ul { list-style: none; }
.checklist li {
  padding: 8px 0 8px 28px;
  position: relative;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}
.checklist li:last-child { border-bottom: none; }
.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 8px;
  width: 20px; height: 20px;
  background: var(--success);
  color: var(--white);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
}

/* ========== HOME / DASHBOARD ========== */
.welcome {
  background: linear-gradient(135deg, var(--scg-red) 0%, var(--scg-red-dark) 100%);
  color: var(--white);
  border-radius: var(--radius-xl);
  padding: 40px;
  margin-bottom: 32px;
}
.welcome h1 { font-size: 28px; font-weight: 600; margin-bottom: 8px; }
.welcome p { font-size: 15px; opacity: 0.92; max-width: 600px; }

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.module-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-low);
  cursor: pointer;
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-high);
}
.module-card-img {
  height: 140px;
  background-size: cover;
  background-position: center;
  position: relative;
}
.module-card-img::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4) 100%);
}
.module-card-num {
  position: absolute;
  top: 12px; left: 12px;
  width: 32px; height: 32px;
  background: var(--white);
  color: var(--scg-red);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-low);
  z-index: 1;
}
.module-card-body { padding: 20px; }
.module-card-body h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.module-card-body p { font-size: 13px; color: var(--gray-700); margin: 0; }

/* ========== VIETNAM REGION MAP (heat-style stack) ========== */
.vn-map {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  background: linear-gradient(180deg, #f0f7ff 0%, #f5f9fc 100%);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
}
.vn-region {
  position: relative;
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  color: var(--white);
  font-weight: 500;
  cursor: default;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}
.vn-region:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-mid);
}
.vn-region-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.vn-region-desc {
  font-size: 12px;
  opacity: 0.92;
}
.vn-region-share {
  font-size: 16px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
  padding: 4px 10px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
/* Heat intensities */
.vn-region.heat-high   { background: #b71c1c; }
.vn-region.heat-medhigh{ background: #e53935; }
.vn-region.heat-med    { background: #fb8c00; }
.vn-region.heat-low    { background: #fdd835; color: var(--gray-900); }
.vn-region.heat-low .vn-region-share { background: rgba(0,0,0,0.08); color: var(--gray-900); }
.vn-region.heat-verylow{ background: #a5d6a7; color: var(--gray-900); }
.vn-region.heat-verylow .vn-region-share { background: rgba(0,0,0,0.08); color: var(--gray-900); }

.vn-map-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px;
  background: var(--white);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--gray-700);
}
.vn-legend-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

/* ========== VIETNAM SVG MAP ========== */
.vn-svgmap {
  background: linear-gradient(180deg, #dbeaf4 0%, #eef5fa 50%, #f5f9fc 100%);
  border: 1px solid #c6d8e6;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 4px 16px rgba(70,110,150,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
}
.vn-svgmap-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.vn-svgmap-sub {
  font-size: 12px;
  color: var(--gray-700);
  margin-bottom: 14px;
  line-height: 1.55;
}
.vn-svgmap-canvas {
  background: radial-gradient(ellipse at 60% 40%, #eaf3fb 0%, #c9deee 70%, #a9c5dc 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 12px rgba(60,100,140,0.15);
}
.vn-svgmap svg {
  width: 100%;
  height: auto;
  max-height: 640px;
  display: block;
}
.vn-svgmap svg .land {
  filter: url(#vn-land-shadow);
}
.vn-svgmap svg .coastline {
  fill: none;
  stroke: #5f7a8a;
  stroke-width: 1.1;
  stroke-linejoin: round;
  opacity: 0.55;
}
.vn-svgmap svg .river {
  fill: none;
  stroke: #5fa3c7;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}
.vn-svgmap svg .river-mouth {
  fill: #5fa3c7;
  opacity: 0.6;
}
.vn-svgmap svg .sea-label {
  fill: #4a6c82;
  font-size: 11px;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.05em;
}
.vn-svgmap svg .country-label {
  fill: #6b7c67;
  font-size: 11px;
  font-weight: 500;
  font-family: Georgia, serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.vn-svgmap svg .region-tag {
  fill: #3d5a42;
  font-size: 9px;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  letter-spacing: 0.12em;
}
.vn-svgmap svg .city-dot {
  fill: #3a4a55;
  stroke: var(--white);
  stroke-width: 0.8;
}
.vn-svgmap svg .city-label {
  fill: #1a1a1a;
  font-size: 9px;
  font-weight: 600;
  font-family: "Inter", sans-serif;
  paint-order: stroke;
  stroke: rgba(255,255,255,0.9);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vn-svgmap svg .island {
  fill: #d5e4ca;
  stroke: #94a58a;
  stroke-width: 0.8;
  filter: url(#vn-land-shadow);
}
.vn-svgmap svg .volume-bubble {
  fill: url(#vn-bubble-grad);
  stroke: #8a0b0b;
  stroke-width: 1.2;
  stroke-opacity: 0.7;
  filter: url(#vn-bubble-glow);
}
.vn-svgmap svg .volume-bubble.pulse {
  animation: vn-bubble-pulse 2.4s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}
@keyframes vn-bubble-pulse {
  0%, 100% { transform: scale(1); filter: url(#vn-bubble-glow); }
  50%      { transform: scale(1.08); }
}
.vn-svgmap svg .volume-label {
  fill: var(--white);
  font-size: 9px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  font-family: "Inter", sans-serif;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.vn-svgmap svg .region-boundary {
  fill: none;
  stroke: #8ea8ba;
  stroke-width: 0.7;
  stroke-dasharray: 4 3;
  opacity: 0.5;
}
.vn-svgmap svg [class^="marker-"] {
  filter: url(#vn-marker-shadow);
  transition: transform 150ms ease-out;
  transform-origin: center;
  transform-box: fill-box;
}
.vn-svgmap svg [class^="marker-"]:hover {
  transform: scale(1.35);
}
.vn-svgmap svg .marker-scg     { fill: var(--scg-red); stroke: var(--white); stroke-width: 1.5; }
.vn-svgmap svg .marker-vicem   { fill: #1565C0; stroke: var(--white); stroke-width: 1.5; }
.vn-svgmap svg .marker-vissai  { fill: #EF6C00; stroke: var(--white); stroke-width: 1.5; }
.vn-svgmap svg .marker-nghison { fill: #6A1B9A; stroke: var(--white); stroke-width: 1.5; }
.vn-svgmap svg .marker-insee   { fill: #2E7D32; stroke: var(--white); stroke-width: 1.5; }
.vn-svgmap svg .marker-other   { fill: #616161; stroke: var(--white); stroke-width: 1.5; }

.vn-svgmap svg .compass {
  fill: #3a4a55;
  opacity: 0.75;
}
.vn-svgmap svg .compass-label {
  fill: #3a4a55;
  font-size: 10px;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  text-anchor: middle;
}
.vn-svgmap svg .scale-bar {
  stroke: #3a4a55;
  stroke-width: 1.5;
  fill: none;
}
.vn-svgmap svg .scale-text {
  fill: #3a4a55;
  font-size: 9px;
  font-family: "Inter", sans-serif;
}

.vn-svgmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 14px;
  margin-top: 14px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--gray-700);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.vn-svgmap-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.vn-svgmap-legend-swatch {
  width: 14px; height: 14px;
  display: inline-block;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.vn-svgmap-legend-swatch.circle { border-radius: 50%; }
.vn-svgmap-legend-swatch.square { border-radius: 2px; }

/* ========== HORIZONTAL BAR CHART ========== */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 80px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.bar-label {
  font-weight: 600;
  color: var(--gray-900);
  text-align: right;
}
.bar-track {
  position: relative;
  height: 22px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--scg-red) 0%, var(--scg-red-dark) 100%);
  border-radius: var(--radius-sm);
  transition: width 400ms ease-out;
}
.bar-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}
@media (max-width: 640px) {
  .bar-row { grid-template-columns: 110px 1fr 70px; font-size: 12px; }
  .vn-region { grid-template-columns: 1fr auto; }
  .vn-region-desc { grid-column: 1 / -1; }
}

/* ========== TWO-COLUMN ========== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* ── Sidebar shell — responsive (shared by /admin and /app) ── */
@media (max-width: 1024px) {
  .app { grid-template-columns: 240px minmax(0, 1fr); }
  .app.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar-toggle { left: calc(240px - 14px); }
  .app.collapsed .sidebar-toggle { left: calc(64px - 14px); }
}
@media (max-width: 768px) {
  /* Single column: the sidebar stacks above the content instead of beside it.
     minmax(0,…) rather than a bare 1fr so the track cannot be widened by
     min-content. */
  .app,
  .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    max-height: 60vh;
    border-right: none;
    border-bottom: 1px solid var(--gray-300);
  }
  /* Sidebar hidden when collapsed on mobile */
  .app.collapsed .sidebar { display: none; }
  /* Pin the toggle to the top-right so it's reachable whether or not the
     sidebar is showing */
  .sidebar-toggle,
  .app.collapsed .sidebar-toggle {
    top: 14px;
    right: 14px;
    left: auto;
  }
}

@media (max-width: 1024px) {

  .main { padding: 32px 24px; }
  .hero { height: 200px; }
  .hero h1 { font-size: 26px; }
}

/* Below ~1280px six dropdown groups plus the pinned button no longer fit on one
   line next to the user chrome, so the whole nav collapses behind the hamburger
   and opens as a sheet. */
@media (max-width: 1280px) {

  .nav-item { white-space: normal; }

}

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 20px 16px; }
  .hero { height: 180px; }
  .hero h1 { font-size: 22px; }
  .welcome { padding: 24px; }
  .welcome h1 { font-size: 22px; }
  .section-title { font-size: 17px; }
  .modules-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .step-head { padding: 14px 16px; }
  .step-body { padding: 14px 16px; }
}

/* Very small phones */
@media (max-width: 420px) {
  .hero-overlay { padding: 20px 16px; }
  .hero h1 { font-size: 20px; }
  .step-meta { grid-template-columns: 1fr; }
  .flow-steps { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); margin: 0; }
  .process-tabs { overflow-x: auto; }
}

/* ========== CODE BLOCK ========== */
.code {
  background: #1E1E1E;
  color: #D4D4D4;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  margin-bottom: 12px;
}
.code .kw { color: #569CD6; }
.code .str { color: #CE9178; }
.code .fn { color: #DCDCAA; }
.code .com { color: #6A9955; font-style: italic; }

/* ========== TABLE ========== */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-low);
  margin-bottom: 16px;
}
th, td {
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-300);
}
th {
  background: var(--gray-100);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-700);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-100); }

/* ========== CONCEPT BOX ========== */
.concept {
  background: linear-gradient(135deg, #E8F5E9 0%, #FFFFFF 100%);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.concept-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--success);
  margin-bottom: 8px;
}
.concept h4 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.concept p { margin-bottom: 8px; font-size: 14px; }
.concept p:last-child { margin-bottom: 0; }

/* ========== QUIZ ========== */
.quiz {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-low);
  margin-bottom: 16px;
}
.quiz-question {
  padding: 16px 0;
  border-bottom: 1px solid var(--gray-100);
}
.quiz-question:last-child { border-bottom: none; padding-bottom: 0; }
.quiz-question:first-child { padding-top: 0; }
.quiz-q {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-900);
}
.quiz-q-num {
  display: inline-block;
  width: 24px; height: 24px;
  background: var(--scg-red);
  color: var(--white);
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
}
.quiz-options {
  display: flex; flex-direction: column;
  gap: 8px;
}
.quiz-option {
  padding: 12px 16px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-700);
  transition: all 150ms ease-out;
  display: flex; align-items: center; gap: 10px;
}
.quiz-option:hover {
  border-color: var(--scg-red);
  background: #FFF8F8;
}
.quiz-option.correct {
  border-color: var(--success);
  background: #E8F5E9;
  color: var(--success);
  font-weight: 500;
}
.quiz-option.correct::after {
  content: "✓ Correct";
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
}
.quiz-option.wrong {
  border-color: #C62828;
  background: #FFEBEE;
  color: #C62828;
}
.quiz-option.wrong::after {
  content: "✗ Try again";
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
}
.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.6;
}
.quiz-score {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  display: none;
}
.quiz-score.show { display: block; }

/* ========== SOLUTION REVEAL ========== */
.solution-wrap {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-low);
  margin-bottom: 16px;
}
.solution-toggle {
  background: var(--info);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out;
}
.solution-toggle:hover { background: #0D47A1; }
.solution-body {
  margin-top: 16px;
  padding: 16px;
  background: #E3F2FD;
  border-left: 4px solid var(--info);
  border-radius: var(--radius-md);
  display: none;
  font-size: 14px;
}
.solution-body.show { display: block; animation: fadeIn 250ms ease-out; }
.solution-body h4 { color: var(--info); margin-bottom: 8px; }
.solution-body ul { margin-left: 20px; margin-top: 4px; }
.solution-body li { margin-bottom: 4px; font-size: 14px; }
.solution-body p { margin-bottom: 8px; }

/* ========== REFLECTION ========== */
.reflection {
  background: linear-gradient(135deg, #F3E5F5 0%, #FFFFFF 100%);
  border-left: 4px solid #8E24AA;
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.reflection-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8E24AA;
  margin-bottom: 8px;
}
.reflection h4 { font-size: 16px; margin-bottom: 12px; }
.reflection-prompt {
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 8px;
  padding-left: 16px;
  position: relative;
}
.reflection-prompt::before {
  content: "?";
  position: absolute;
  left: 0;
  color: #8E24AA;
  font-weight: 700;
}
.reflection-input {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-top: 12px;
  transition: border-color 150ms;
}
.reflection-input:focus {
  outline: none;
  border-color: #8E24AA;
  box-shadow: 0 0 0 3px #F3E5F5;
}
.reflection-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.reflection-save {
  background: #8E24AA;
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.reflection-save:hover { background: #6A1B9A; }
.reflection-saved-msg {
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
  display: none;
}
.reflection-saved-msg.show { display: inline-block; }

/* ========== PROCESS TIMELINE (SAP Step-by-Step) ========== */
.process-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-300);
}
.process-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  margin-bottom: -2px;
  transition: color 150ms, border-color 150ms;
}
.process-tab:hover { color: var(--gray-900); }
.process-tab.active {
  color: var(--scg-red-dark);
  border-bottom-color: var(--scg-red);
}
.process-panel { display: none; }
.process-panel.active { display: block; animation: fadeIn 250ms ease-out; }

.timeline {
  position: relative;
  padding-left: 40px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: linear-gradient(180deg, var(--scg-red) 0%, var(--scg-red-light) 100%);
  border-radius: 2px;
}

.step {
  position: relative;
  margin-bottom: 20px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-low);
  overflow: hidden;
  transition: transform 150ms, box-shadow 150ms;
}
.step:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-mid);
}
.step::before {
  content: attr(data-step);
  position: absolute;
  left: -38px;
  top: 16px;
  width: 36px;
  height: 36px;
  background: var(--scg-red);
  color: var(--white);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  border: 3px solid var(--white);
  box-shadow: var(--shadow-low);
  z-index: 1;
}

.step-head {
  padding: 16px 20px;
  background: linear-gradient(135deg, #FFF5F5 0%, #FFF 100%);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.step-icon {
  width: 40px; height: 40px;
  background: var(--white);
  border: 2px solid var(--scg-red);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.step-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  flex: 1;
  min-width: 180px;
}
.step-role {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--scg-red-light);
  color: var(--scg-red-dark);
  border-radius: var(--radius-full);
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.step-body {
  padding: 16px 20px;
}
.step-action {
  font-size: 14px;
  color: var(--gray-700);
  margin-bottom: 14px;
  line-height: 1.6;
}
.step-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.meta-item {
  padding: 10px 12px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--scg-red);
  font-size: 13px;
}
.meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 2px;
  display: block;
}
.meta-value { color: var(--gray-900); font-weight: 500; }
.meta-value code {
  background: var(--white);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 12px;
  color: var(--scg-red-dark);
  margin-right: 4px;
}

.step-journal {
  background: #FFF8E1;
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 12px;
  color: var(--gray-900);
  margin-bottom: 10px;
}
.step-journal .jrn-label {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
  font-family: "Noto Sans Thai", "Inter", sans-serif;
}
.step-journal .dr { color: var(--info); }
.step-journal .cr { color: #C62828; }

.step-warn {
  background: #FFEBEE;
  border-left: 3px solid #C62828;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #B71C1C;
}
.step-warn::before {
  content: "⚠️ ";
  margin-right: 4px;
}
.step-warn-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 6px;
}

/* ========== SUB-TOPIC CARDS (advanced modules) ========== */
.subtopic {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-low);
  margin-bottom: 16px;
  border-left: 4px solid var(--scg-red);
  transition: transform 150ms, box-shadow 150ms;
}
.subtopic:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-mid);
}
.subtopic-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-100);
}
.subtopic-icon {
  width: 40px; height: 40px;
  background: var(--scg-red-light);
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.subtopic-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
  flex: 1;
}
.subtopic-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.subtopic-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: start;
  padding: 6px 0;
  font-size: 14px;
}
.subtopic-row-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--scg-red-dark);
  padding-top: 2px;
}
.subtopic-row-value {
  color: var(--gray-700);
  line-height: 1.6;
}
.subtopic-row-value code {
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", "SF Mono", monospace;
  font-size: 12px;
  color: var(--scg-red-dark);
}
.subtopic-tip {
  margin-top: 10px;
  padding: 10px 14px;
  background: #FFF8E1;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--gray-900);
}
.subtopic-tip::before {
  content: "💡 ";
  font-size: 14px;
}

/* Advanced Track sidebar label color differentiation */
.nav-label.advanced {
  color: var(--accent);
}

@media (max-width: 640px) {
  .subtopic-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ========== USER INFO ==========
   app.js injects .sidebar-user-info / .sidebar-admin-link into the portal's
   #sidebarUser; /admin renders the same class names inside its own sidebar. */
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  margin-bottom: 8px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  min-width: 0;
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--scg-red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}
.sidebar-user-text {
  min-width: 0;
  flex: 1;
}
.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.sidebar-admin-link {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--scg-red);
  text-decoration: none;
  border-radius: var(--radius-md);
  background: rgba(211, 47, 47, 0.07);
  border: 1px solid rgba(211, 47, 47, 0.18);
  transition: background 0.15s, color 0.15s;
}
.sidebar-admin-link:hover {
  background: rgba(211, 47, 47, 0.14);
  color: var(--scg-red-dark, #b71c1c);
}

/* ── My Classes page ──────────────────────────────────────────────────── */
.my-classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.my-class-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s;
}
.my-class-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); }
.my-class-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.my-class-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--scg-red-light);
  color: var(--scg-red);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.my-class-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}
.my-class-desc {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.5;
  flex: 1;
}
.my-class-modules-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.my-class-modules-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.my-class-module-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-decoration: none;
}
.my-class-module-chip:hover {
  background: var(--scg-red-light);
  color: var(--scg-red);
  border-color: #ffcdd2;
}
.my-class-module-chip i { font-size: 11px; }
.my-classes-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-500);
}
.my-classes-empty i {
  font-size: 48px;
  color: var(--gray-300);
  display: block;
  margin-bottom: 16px;
}

/* ── Coworker Eligibility Exam ─────────────────────────────────────────── */
.cwexam { display: flex; flex-direction: column; gap: 20px; }
.cwexam-question {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-low);
  transition: border-color .15s ease;
}
.cwexam-question:hover { border-color: var(--scg-red-light); }
.cwexam-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.cwexam-num {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--scg-red);
  color: var(--white);
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.cwexam-head h3 { color: var(--scg-red-dark); font-size: 17px; margin-bottom: 4px; }
.cwexam-task { font-size: 14px; color: var(--gray-900); margin-bottom: 4px; }
.cwexam-purpose { font-size: 13px; color: var(--gray-700); }
.cwexam-criteria { display: flex; flex-direction: column; gap: 8px; }
.cwexam-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  font-size: 14px;
}
.cwexam-label { color: var(--gray-900); font-weight: 500; flex: 1; }
.cwexam-rate { display: inline-flex; gap: 4px; flex-shrink: 0; }
.cwexam-star {
  width: 28px; height: 28px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all .12s ease;
}
.cwexam-star:hover { border-color: var(--scg-red); color: var(--scg-red); }
.cwexam-star.selected {
  background: var(--scg-red);
  border-color: var(--scg-red);
  color: var(--white);
}
.cwexam-submit-wrap { margin-top: 8px; padding-top: 16px; border-top: 2px dashed var(--gray-300); }
.cwexam-submit { font-size: 15px; }
.cwexam-result {
  margin-top: 16px;
  padding: 18px 20px;
  background: var(--gray-100);
  border-left: 4px solid var(--gray-500);
  border-radius: var(--radius-md);
  display: none;
}
.cwexam-result.show { display: block; }
.cwexam-result.tier-strong  { border-left-color: var(--success); background: #E8F5E9; }
.cwexam-result.tier-pilot   { border-left-color: var(--accent);  background: #FFF3E0; }
.cwexam-result.tier-train   { border-left-color: var(--info);    background: #E3F2FD; }
.cwexam-result.tier-notready{ border-left-color: var(--scg-red); background: var(--scg-red-light); }
.cwexam-result h4 { font-size: 18px; margin-bottom: 8px; color: var(--gray-900); }
.cwexam-result .cwexam-verdict { font-size: 22px; font-weight: 700; margin: 8px 0; }
.cwexam-result .cwexam-breakdown { font-size: 14px; color: var(--gray-700); line-height: 1.8; }
.cwexam-result .cwexam-pct { font-size: 32px; font-weight: 700; color: var(--scg-red-dark); }
