/* ==========================================================================
   © 2026 Hải Đăng VMU. Bản quyền mã nguồn và dữ liệu tổng hợp thuộc về dự án Hải Đăng VMU.
   Nghiêm cấm sao chép, phân phối lại hoặc sử dụng cho mục đích thương mại khi chưa có sự đồng ý.
   ========================================================================== */
@layer properties, theme, base, components, utilities;

/* ==========================================================================
   HẢI ĐĂNG VMU — MARITIME LIGHTHOUSE DESIGN SYSTEM (style.css)
   Trường Đại học Hàng hải Việt Nam • 484 Lạch Tray, Lê Chân, Hải Phòng
   60-30-10 Color Architecture • Light & Dark Mode • Zero Horizontal Overflow
   ========================================================================== */

:root {
  /* 60-30-10 Light Mode Palette */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --ink: #0F172A;
  --muted: #475569;
  --line: #E2E8F0;

  /* Brand & Semantic Accents */
  --navy: #0A2540;
  --navy-elevated: #103256;
  --ocean: #0284C7;
  --ocean-soft: #E0F2FE;
  --ocean-ink: #0369A1;
  --lamp: #F59E0B;
  --lamp-soft: #FEF3C7;
  --lamp-ink: #92400E;
  --good: #059669;
  --good-soft: #D1FAE5;
  --good-ink: #065F46;
  --bad: #DC2626;
  --bad-soft: #FEE2E2;
  --bad-ink: #991B1B;

  /* Button Text Contrast Tokens */
  --btn-ocean-fg: #FFFFFF;
  --btn-ocean-hover: #0369A1;
  --btn-lamp-fg: #1C1200;
  --btn-lamp-hover: #FBBF24;

  /* Typography */
  --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Be Vietnam Pro', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Layout Metrics */
  --sidebar-w: 268px;
  --sidebar-mini-w: 78px;
  --topbar-h: 72px;
  --bottom-nav-h: 66px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 18px -8px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 12px 26px -10px rgba(2, 132, 199, 0.18), 0 4px 12px -4px rgba(15, 23, 42, 0.08);
  --shadow-pop: 0 20px 42px -10px rgba(10, 37, 64, 0.24), 0 4px 14px -4px rgba(15, 23, 42, 0.1);

  color-scheme: light;
}

html.dark {
  /* 60-30-10 Dark Mode Palette */
  --bg: #0B1120;
  --surface: #1E293B;
  --surface-2: #0F172A;
  --ink: #F1F5F9;
  --muted: #94A3B8;
  --line: #334155;

  /* Brand & Semantic Accents (Dark Tuned for WCAG AA/AAA Contrast) */
  --navy: #070D19;
  --navy-elevated: #111C30;
  --ocean: #38BDF8;
  --ocean-soft: rgba(56, 189, 248, 0.15);
  --ocean-ink: #7DD3FC;
  --lamp: #F59E0B;
  --lamp-soft: rgba(245, 158, 11, 0.16);
  --lamp-ink: #FBBF24;
  --good: #34D399;
  --good-soft: rgba(16, 185, 129, 0.16);
  --good-ink: #6EE7B7;
  --bad: #F87171;
  --bad-soft: rgba(239, 68, 68, 0.16);
  --bad-ink: #FCA5A5;

  /* High-contrast text on bright Sky-400 button in dark mode */
  --btn-ocean-fg: #041322;
  --btn-ocean-hover: #7DD3FC;
  --btn-lamp-fg: #1C1200;
  --btn-lamp-hover: #FBBF24;

  --shadow-xs: 0 1px 2px rgba(2, 6, 23, 0.35);
  --shadow-card: 0 2px 6px rgba(2, 6, 23, 0.4), 0 10px 24px -10px rgba(2, 6, 23, 0.55);
  --shadow-hover: 0 14px 30px -10px rgba(2, 6, 23, 0.72), 0 0 0 1px rgba(56, 189, 248, 0.28);
  --shadow-pop: 0 24px 48px -12px rgba(2, 6, 23, 0.82);

  color-scheme: dark;
}

/* Unconditional Anti-Overflow & Hidden Attribute Guarantee */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden],
.hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

@layer components {
  /* ==========================================================================
     1. BASE TYPOGRAPHY & ACCESSIBILITY
     ========================================================================== */

  html,
  body {
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
  }

h1, h2, h3, h4, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  line-height: 1.28;
}

code, kbd, pre, .font-mono, .mono {
  font-family: var(--font-mono);
}

img, svg, video, canvas {
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Accessibility Skip Link */
.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: 999;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--lamp);
  color: #1C1200;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Visibility Helpers */
.only-mobile {
  display: none !important;
}

.only-desktop {
  display: inline-flex;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 58%, transparent);
}

/* ==========================================================================
   2. APP SHELL, SIDEBAR & NAVIGATION
   ========================================================================== */

.sidebar {
  /* Scoped dark-navy tokens so any nested cards/badges/text stay readable */
  --ink: #F8FAFC;
  --muted: #CBD5E1;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.13);
  --ocean-soft: rgba(56, 189, 248, 0.18);
  --ocean-ink: #7DD3FC;
  --lamp-soft: rgba(245, 158, 11, 0.2);
  --lamp-ink: #FCD34D;
  --good-soft: rgba(16, 185, 129, 0.2);
  --good-ink: #6EE7B7;

  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 60;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, color-mix(in srgb, var(--navy) 88%, #020617) 100%);
  color: #F8FAFC;
  border-right: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1), transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-x: hidden;
  overflow-y: auto;
}

.side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.1rem 1rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  min-width: 0;
}

.side-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  overflow: hidden;
  display: inline-flex;
}

.side-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.side-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.side-brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.06rem;
  letter-spacing: -0.02em;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-brand-sub {
  font-size: 0.74rem;
  font-weight: 500;
  color: #94A3B8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-close-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #F8FAFC !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
}

/* Sidebar Navigation Links */
.side-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 0.75rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-nav a,
.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.66rem 0.85rem;
  border-radius: 11px;
  color: #CBD5E1;
  font-size: 0.89rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  min-width: 0;
}

.side-nav a svg,
.side-nav a i,
.side-link svg,
.side-link i {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  opacity: 0.86;
  transition: color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.side-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-nav a:hover,
.side-link:hover {
  background: rgba(255, 255, 255, 0.075);
  color: #FFFFFF;
}

.side-nav a.is-active,
.side-nav a.active,
.side-nav a[aria-current="page"],
.side-link.is-active,
.side-link.active,
.side-link[aria-current="page"] {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.2) 0%, rgba(245, 158, 11, 0.12) 100%);
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.32);
}

.side-nav a.is-active::before,
.side-nav a.active::before,
.side-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3.5px;
  border-radius: 0 4px 4px 0;
  background: var(--lamp);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.8);
}

.side-nav a.is-active svg,
.side-nav a.active svg,
.side-nav a[aria-current="page"] svg {
  color: var(--lamp);
  opacity: 1;
}

/* Sidebar Footer & Major Quick Progress Box */
.side-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-shrink: 0;
}

.side-major-box {
  padding: 0.8rem 0.85rem;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #F8FAFC;
  font-size: 0.8rem;
  min-width: 0;
  overflow: hidden;
}

.side-major-box p,
.side-major-box div,
.side-major-box span {
  max-width: 100%;
}

.side-major-name {
  margin: 0.4rem 0 0.5rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: #F8FAFC;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-major-box .progress-track {
  background: rgba(255, 255, 255, 0.14);
  border-color: transparent;
  height: 7px;
}

.side-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #CBD5E1;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.side-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.side-collapse-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  transition: transform 0.22s ease;
}

/* Desktop Collapsed Mini Sidebar (78px) */
@media (min-width: 901px) {
  body.sidebar-mini .sidebar {
    width: var(--sidebar-mini-w);
  }

  body.sidebar-mini .app-shell {
    margin-left: var(--sidebar-mini-w);
  }

  body.sidebar-mini .side-header {
    justify-content: center;
    padding-inline: 0.5rem;
  }

  body.sidebar-mini .side-brand-text,
  body.sidebar-mini .side-link-text,
  body.sidebar-mini .side-nav a span:not(.side-logo),
  body.sidebar-mini .side-major-box,
  body.sidebar-mini .side-collapse-text {
    display: none !important;
  }

  body.sidebar-mini .side-nav {
    padding-inline: 0.6rem;
  }

  body.sidebar-mini .side-nav a,
  body.sidebar-mini .side-link {
    justify-content: center;
    padding: 0.72rem 0;
  }

  body.sidebar-mini .side-collapse-btn svg {
    transform: rotate(180deg);
  }
}

/* Drawer Backdrop */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(7, 13, 25, 0.62);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

/* App Shell */
.app-shell {
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  transition: margin-left 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   3. STICKY TOPBAR & GLOBAL STUDOCU COURSE SEARCH
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-h);
  padding: 0.7rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-titles {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Global Search Bar */
.global-search-wrap {
  flex: 0 1 430px;
  width: 100%;
  max-width: 430px;
  min-width: 0;
  position: relative;
}

.global-search-wrap .search-icon {
  position: absolute;
  left: 0.82rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
  z-index: 2;
}

#globalCourseInput {
  width: 100%;
  height: 40px;
  padding: 0.45rem 0.85rem 0.45rem 2.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.85rem;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

#globalCourseInput::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

#globalCourseInput:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px var(--ocean-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

/* Main Content Area & Footer */
.app-view {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 2.2rem;
  min-width: 0;
}

.app-view:focus {
  outline: none;
}

.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 75%, var(--bg));
  padding: 1.15rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
}

.footer-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
}

.footer-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--lamp);
  box-shadow: 0 0 0 3px var(--lamp-soft);
}

.footer-sep {
  color: var(--muted);
}

.footer-note {
  margin: 0;
  font-size: 0.77rem;
  color: var(--muted);
}

/* Mobile Bottom Nav (Hidden on Desktop) */
.bottom-nav {
  display: none;
}

/* ==========================================================================
   4. CARDS, BENTO GRID & MARITIME HERO LIGHTHOUSE
   ========================================================================== */

.vmu-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
  max-width: 100%;
}

.vmu-card-hover {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.vmu-card-hover:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--ocean) 45%, var(--line));
  box-shadow: var(--shadow-hover);
}

/* Hero Lighthouse Night-Sea Banner */
.hero-lighthouse {
  --ink: #F8FAFC;
  --muted: #CBD5E1;
  --line: rgba(255, 255, 255, 0.16);
  --surface-2: rgba(255, 255, 255, 0.1);
  --ocean-soft: rgba(56, 189, 248, 0.2);
  --ocean-ink: #7DD3FC;
  --lamp-soft: rgba(245, 158, 11, 0.22);
  --lamp-ink: #FCD34D;
  --good-soft: rgba(16, 185, 129, 0.22);
  --good-ink: #6EE7B7;
  --bad-soft: rgba(239, 68, 68, 0.24);
  --bad-ink: #FCA5A5;

  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.6rem;
  background:
    radial-gradient(circle at 88% 18%, rgba(245, 158, 11, 0.22) 0%, transparent 42%),
    radial-gradient(circle at 12% 85%, rgba(2, 132, 199, 0.28) 0%, transparent 48%),
    linear-gradient(135deg, #0A2540 0%, #0D1F38 52%, #0F172A 100%);
  border: 1px solid rgba(56, 189, 248, 0.24);
  color: #F8FAFC;
  box-shadow: 0 18px 38px -14px rgba(7, 13, 25, 0.55);
  min-width: 0;
}

.hero-lighthouse > *:not(.lighthouse-beam) {
  position: relative;
  z-index: 1;
}

/* Sweeping Golden Lighthouse Beam */
.lighthouse-beam {
  position: absolute;
  top: -65%;
  right: -18%;
  width: 520px;
  height: 520px;
  pointer-events: none;
  z-index: 0;
  background: conic-gradient(
    from 200deg at 68% 35%,
    transparent 0deg,
    rgba(245, 158, 11, 0.03) 18deg,
    rgba(251, 191, 36, 0.24) 36deg,
    rgba(56, 189, 248, 0.12) 52deg,
    transparent 74deg
  );
  filter: blur(8px);
  transform-origin: 68% 35%;
  animation: lighthouseSweep 9s ease-in-out infinite alternate;
}

@keyframes lighthouseSweep {
  0% {
    transform: rotate(-12deg) scale(1);
    opacity: 0.78;
  }
  100% {
    transform: rotate(14deg) scale(1.05);
    opacity: 1;
  }
}

/* Bento & KPI Stat Cards */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  min-width: 0;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.45rem;
  min-width: 0;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ocean), var(--lamp));
  opacity: 0.85;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--ocean) 40%, var(--line));
  box-shadow: var(--shadow-hover);
}

/* ==========================================================================
   5. BUTTONS, CHIPS, SUBTABS, BADGES & FORM CONTROLS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.56rem 0.98rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  max-width: 100%;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.btn svg,
.btn i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--ocean) 45%, var(--line));
  background: var(--surface-2);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ocean-soft);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-ocean {
  background: var(--ocean);
  border-color: transparent;
  color: var(--btn-ocean-fg);
  font-weight: 700;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--ocean) 28%, transparent);
}

.btn-ocean:hover:not(:disabled) {
  background: var(--btn-ocean-hover);
  border-color: transparent;
  color: var(--btn-ocean-fg);
}

.btn-lamp {
  background: var(--lamp);
  border-color: transparent;
  color: var(--btn-lamp-fg);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.28);
}

.btn-lamp:hover:not(:disabled) {
  background: var(--btn-lamp-hover);
  border-color: transparent;
  color: var(--btn-lamp-fg);
}

.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ocean-soft) 65%, var(--surface));
  border-color: color-mix(in srgb, var(--ocean) 45%, var(--line));
  color: var(--ocean-ink);
}

.hero-lighthouse .btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.hero-lighthouse .btn-ghost:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ocean-soft) 65%, var(--surface));
  border-color: color-mix(in srgb, var(--ocean) 45%, var(--line));
  color: var(--ocean);
}

.btn-danger {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 28%, transparent);
  color: var(--bad-ink);
}

.btn-danger:hover:not(:disabled) {
  background: var(--bad);
  border-color: var(--bad);
  color: #FFFFFF;
}

.btn-on,
.btn[aria-pressed="true"] {
  background: var(--ocean-soft) !important;
  border-color: var(--ocean) !important;
  color: var(--ocean-ink) !important;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--ocean);
}

.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.8rem;
  border-radius: 8px;
  gap: 0.35rem;
}

.btn-sm svg,
.btn-sm i {
  width: 14px;
  height: 14px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  flex-shrink: 0;
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

/* Filter Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
  max-width: 100%;
  transition: all 0.15s ease;
}

.chip svg,
.chip i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.chip:hover {
  border-color: color-mix(in srgb, var(--ocean) 45%, var(--line));
  color: var(--ink);
  background: var(--surface-2);
}

.chip[aria-pressed="true"],
.chip.is-active,
.chip.active {
  background: var(--ocean);
  border-color: var(--ocean);
  color: var(--btn-ocean-fg);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--ocean) 28%, transparent);
}

/* Subtab Segmented Control */
.subtab-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  max-width: 100%;
}

.subtab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  padding: 0.48rem 0.92rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 100%;
}

.subtab-btn svg,
.subtab-btn i {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.subtab-btn:hover {
  color: var(--ink);
}

.subtab-btn[aria-selected="true"],
.subtab-btn.is-active,
.subtab-btn.active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.35;
  border: 1px solid transparent;
  max-width: 100%;
  overflow-wrap: break-word;
}

.badge svg,
.badge i {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.badge-ocean {
  background: var(--ocean-soft);
  color: var(--ocean-ink);
  border-color: color-mix(in srgb, var(--ocean) 25%, transparent);
}

.badge-lamp {
  background: var(--lamp-soft);
  color: var(--lamp-ink);
  border-color: color-mix(in srgb, var(--lamp) 32%, transparent);
}

.badge-good {
  background: var(--good-soft);
  color: var(--good-ink);
  border-color: color-mix(in srgb, var(--good) 26%, transparent);
}

.badge-bad {
  background: var(--bad-soft);
  color: var(--bad-ink);
  border-color: color-mix(in srgb, var(--bad) 26%, transparent);
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

/* Form Inputs, Selects & Textareas (excluding specialized global search bar) */
.app-view input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.app-view select,
.app-view textarea,
.vmu-modal input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
.vmu-modal select,
.vmu-modal textarea,
.vmu-input,
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.54rem 0.78rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background-color: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.app-view input:focus:not([type="checkbox"]):not([type="radio"]),
.app-view select:focus,
.app-view textarea:focus,
.vmu-modal input:focus:not([type="checkbox"]):not([type="radio"]),
.vmu-modal select:focus,
.vmu-modal textarea:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px var(--ocean-soft);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--ocean);
  width: 1.05rem;
  height: 1.05rem;
  cursor: pointer;
}

label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
}

/* ==========================================================================
   6. AUTOCOMPLETE & STUDOCU COURSE HUB
   ========================================================================== */

.ac-wrap {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.ac-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 95;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0.35rem;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-pop);
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  width: 100%;
  padding: 0.56rem 0.7rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 0;
  transition: background-color 0.12s ease;
}

.ac-item:hover,
.ac-item.is-active,
.ac-item[aria-selected="true"] {
  background: var(--ocean-soft);
}

.ac-code {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.16rem 0.48rem;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ocean-ink);
  border: 1px solid color-mix(in srgb, var(--ocean) 24%, var(--line));
  flex-shrink: 0;
}

/* Shared Multi-Major Callout Banner */
.shared-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.88rem 1.05rem;
  border-radius: 13px;
  background: linear-gradient(95deg, var(--lamp-soft) 0%, var(--ocean-soft) 100%);
  border: 1px solid color-mix(in srgb, var(--lamp) 42%, var(--line));
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.5;
  min-width: 0;
  max-width: 100%;
}

.shared-banner svg,
.shared-banner i {
  width: 19px;
  height: 19px;
  color: var(--lamp-ink);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* Studocu Course Hub Header */
.course-hub-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.5rem;
  background:
    radial-gradient(circle at 92% 12%, var(--lamp-soft) 0%, transparent 44%),
    linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--ocean-soft) 72%, var(--surface)) 100%);
  border: 1px solid color-mix(in srgb, var(--ocean) 34%, var(--line));
  box-shadow: var(--shadow-card);
  min-width: 0;
}

/* 8-Semester Curriculum Grid */
.semester-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  min-width: 0;
}

.semester-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
  min-width: 0;
}

.course-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 0.75rem;
  padding: 0.7rem 0.82rem;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  min-width: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.course-row > * {
  min-width: 0;
}

.course-row:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--ocean) 42%, var(--line));
}

.course-row.is-passed {
  background: color-mix(in srgb, var(--good-soft) 52%, var(--surface));
  border-color: color-mix(in srgb, var(--good) 35%, var(--line));
}

.course-row.has-warn {
  background: color-mix(in srgb, var(--lamp-soft) 52%, var(--surface));
  border-color: color-mix(in srgb, var(--lamp) 42%, var(--line));
}

/* Studocu Document Cards */
.doc-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.72rem;
  min-width: 0;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--ocean) 42%, var(--line));
  box-shadow: var(--shadow-hover);
}

.doc-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  padding: 0.22rem 0.54rem;
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--ocean-soft);
  color: var(--ocean-ink);
  border: 1px solid color-mix(in srgb, var(--ocean) 24%, transparent);
  flex-shrink: 0;
}

/* Progress Track & Fill */
.progress-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ocean) 0%, var(--lamp) 100%);
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   7. COUNTDOWN, GPA TABLE (MOBILE CARD TRANSFORM), RULES & DIRECTORY
   ========================================================================== */

.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  min-width: 0;
}

/* Adaptive layout if .countdown-grid wraps full exam cards instead of 4 unit boxes */
.countdown-grid:has(h3),
.countdown-grid:has(h4),
.countdown-grid:has(.btn) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr));
  gap: 0.85rem;
}

.countdown-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.52rem 0.4rem;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 0;
}

.hero-lighthouse .countdown-box {
  background: rgba(255, 255, 255, 0.085);
  border-color: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  backdrop-filter: blur(6px);
}

/* GPA Calculator Table (QĐ 1409/QĐ-ĐHHHVN) */
.gpa-table {
  width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.gpa-table thead th {
  padding: 0.68rem 0.6rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.gpa-table thead th:first-child {
  border-left: 1px solid var(--line);
  border-top-left-radius: 11px;
  border-bottom-left-radius: 11px;
}

.gpa-table thead th:last-child {
  border-right: 1px solid var(--line);
  border-top-right-radius: 11px;
  border-bottom-right-radius: 11px;
}

.gpa-table tbody td {
  padding: 0.62rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  min-width: 0;
}

.gpa-table tbody tr:last-child td {
  border-bottom: none;
}

/* Mobile Card Transform for .gpa-table (< 680px — Zero Horizontal Scroll!) */
@media (max-width: 679.98px) {
  div:has(> .gpa-table) {
    overflow: visible !important;
  }

  .gpa-table,
  .gpa-table tbody {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  .gpa-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .gpa-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    padding: 0.9rem;
    margin-bottom: 0.8rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-xs);
  }

  .gpa-table tbody td {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0;
    border-bottom: none;
    min-width: 0;
  }

  /* Course name / autocomplete row spans full card width */
  .gpa-table tbody td:first-child {
    grid-column: 1 / -1;
  }

  /* Optional data-label support if populated by JS */
  .gpa-table tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 0.25rem;
  }
}

/* Regulation & Directory Cards */
.rule-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 1.05rem 1.2rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.rule-card:hover {
  border-color: color-mix(in srgb, var(--ocean) 38%, var(--line));
}

details.rule-card > summary {
  list-style: none;
  cursor: pointer;
}

details.rule-card > summary::-webkit-details-marker {
  display: none;
}

.rule-highlight {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0.56rem;
  border-radius: 7px;
  background: var(--lamp-soft);
  color: var(--lamp-ink);
  border: 1px solid color-mix(in srgb, var(--lamp) 34%, transparent);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.dir-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.65rem;
  min-width: 0;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.dir-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--ocean) 40%, var(--line));
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.6rem;
  padding: 2.4rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--line);
  background: color-mix(in srgb, var(--surface-2) 65%, var(--surface));
  color: var(--muted);
  min-width: 0;
}

.empty-state svg,
.empty-state i {
  width: 34px;
  height: 34px;
  color: var(--ocean);
  opacity: 0.85;
}

/* ==========================================================================
   8. MODAL DIALOG, TOAST SYSTEM, SKELETON & PAGE ANIMATIONS
   ========================================================================== */

/* Override Tailwind Preflight margin:0 so native <dialog> centers properly */
.vmu-modal {
  margin: auto;
  inset: 0;
  width: min(620px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(88dvh, 840px);
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  overflow-x: hidden;
  overflow-y: auto;
}

.vmu-modal:not([open]) {
  display: none;
}

.vmu-modal[open] {
  animation: modalPop 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.vmu-modal::backdrop {
  background: rgba(7, 13, 25, 0.65);
  backdrop-filter: blur(4px);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Toast Notifications */
.toast-root {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.78rem 1rem;
  border-radius: 12px;
  background: #0A2540;
  color: #F8FAFC;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-left: 4px solid var(--lamp);
  box-shadow: var(--shadow-pop);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.4;
  animation: toastSlideIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow-wrap: anywhere;
}

html.dark .toast-item {
  background: #1E293B;
  border-color: rgba(56, 189, 248, 0.4);
  border-left-color: var(--lamp);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Page Enter Transition (ends at transform:none to preserve fixed descendants) */
.page-enter {
  animation: pageEnter 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Initial Boot Skeleton */
.boot-skeleton {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.boot-skel-title {
  margin: 0.65rem 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: #FFFFFF;
}

.boot-skel-sub {
  margin: 0;
  font-size: 0.88rem;
  color: #CBD5E1;
  max-width: 62ch;
}

.skel-line {
  height: 12px;
  border-radius: 999px;
  background: var(--surface-2);
}

.skel-lg {
  height: 24px;
  margin-top: 0.35rem;
}

.skel-w40 { width: 42%; }
.skel-w70 { width: 72%; }

.boot-pulse {
  animation: skelPulse 1.5s ease-in-out infinite;
}

@keyframes skelPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ==========================================================================
   9. RESPONSIVE BREAKPOINTS (1440px -> 1100px -> 900px -> 375px)
   ========================================================================== */

@media (max-width: 1120px) {
  .bento-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .semester-grid {
    grid-template-columns: 1fr;
  }
}

/* Tablet & Mobile Navigation Drawer + Bottom Nav (<= 900px) */
@media (max-width: 900px) {
  .only-mobile {
    display: inline-flex !important;
  }

  .only-desktop {
    display: none !important;
  }

  .sidebar {
    width: min(286px, 84vw);
    transform: translateX(-104%);
    box-shadow: none;
  }

  body.drawer-open {
    overflow: hidden;
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
    box-shadow: 20px 0 48px rgba(2, 6, 23, 0.55);
  }

  body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-shell {
    margin-left: 0 !important;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }

  /* Two-row compact sticky topbar on mobile so search input is 100% usable */
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.55rem 0.6rem;
    padding: 0.6rem 0.9rem;
    min-height: unset;
  }

  .topbar-left {
    grid-column: 1 / 2;
  }

  .topbar-actions {
    grid-column: 2 / 3;
  }

  .global-search-wrap {
    grid-column: 1 / -1;
    max-width: 100%;
    flex: none;
  }

  .page-title {
    font-size: 1.05rem;
  }

  .page-subtitle {
    display: none;
  }

  .app-view {
    padding: 1rem 0.9rem 1.6rem;
  }

  .app-footer {
    padding: 1rem 0.9rem 1.25rem;
  }

  /* Thumb-Friendly Mobile Bottom Navigation Bar */
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    min-height: var(--bottom-nav-h);
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
  }

  .bottom-nav-item,
  .bottom-nav a,
  .bottom-nav button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    padding: 0.35rem 0.15rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.15;
    text-decoration: none;
    cursor: pointer;
    min-width: 0;
    transition: color 0.15s ease, background-color 0.15s ease;
  }

  .bottom-nav-item span,
  .bottom-nav a span,
  .bottom-nav button span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bottom-nav-item svg,
  .bottom-nav a svg,
  .bottom-nav button svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .bottom-nav a.is-active,
  .bottom-nav a.active,
  .bottom-nav a[aria-current="page"],
  .bottom-nav button.is-active,
  .bottom-nav button.active {
    color: var(--ocean);
    font-weight: 700;
  }

  .bottom-nav a.is-active::before,
  .bottom-nav a.active::before,
  .bottom-nav a[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 0;
    width: 24px;
    height: 3px;
    border-radius: 999px;
    background: var(--lamp);
  }

  /* Keep toast above mobile bottom bar */
  .toast-root {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: calc(var(--bottom-nav-h) + 0.65rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Compact Mobile Screens (<= 520px, including 390px & 375px) */
@media (max-width: 520px) {
  .hide-xs {
    display: none !important;
  }

  .bento-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .hero-lighthouse,
  .course-hub-hero {
    padding: 1.15rem 1.05rem;
    border-radius: 16px;
  }

  .vmu-card,
  .semester-card,
  .doc-card,
  .rule-card,
  .dir-card {
    padding: 0.95rem 1rem;
  }

  .vmu-modal {
    padding: 1.05rem 1rem;
    border-radius: 16px;
  }

  .subtab-bar {
    display: flex;
    width: 100%;
  }

  .subtab-btn {
    flex: 1 1 auto;
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
  }
}

/* Respect Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .lighthouse-beam {
    animation: none !important;
  }
}

/* Additional General Table, Modal & Safe Word-Wrap Helpers */
.vmu-card,
.semester-card,
.doc-card,
.rule-card,
.dir-card {
  overflow-wrap: break-word;
}

.app-view table:not(.gpa-table) {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.app-view table:not(.gpa-table) th {
  padding: 0.6rem 0.7rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.app-view table:not(.gpa-table) td {
  padding: 0.58rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.modal-head,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-foot,
.modal-footer,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  padding-top: 0.95rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}

} /* end @layer components */



/* ==========================================================================
   9. TINH CHỈNH GIAO DIỆN — phẳng, bớt hiệu ứng, bố cục có nhịp
   ========================================================================== */
:root, html.dark {
  --radius-lg: 10px;
  --radius-xl: 12px;
  --shadow-card: none;
  --shadow-hover: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-pop: 0 8px 24px -8px rgba(15, 23, 42, 0.28);
}
.sidebar { background: var(--navy) !important; }
.side-nav a.is-active, .side-nav a.active, .side-nav a[aria-current="page"],
.side-link.is-active, .side-link.active, .side-link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}
.side-nav a.is-active::before, .side-nav a.active::before, .side-nav a[aria-current="page"]::before { box-shadow: none; }
.hero-lighthouse { background: #0F2A47 !important; box-shadow: none !important; border-radius: 10px !important; }
.lighthouse-beam { display: none !important; }
.stat-card::before { display: none; }
.stat-card, .vmu-card-hover, .doc-card { transition: border-color 0.12s ease; }
.stat-card:hover, .vmu-card-hover:hover, .doc-card:hover { transform: none; box-shadow: none; }
.progress-fill { background: var(--ocean); }
.shared-banner { background: var(--lamp-soft); border-radius: 8px; }
.course-hub-hero { background: var(--surface); border-radius: 10px; box-shadow: none; border: 1px solid var(--line); }
.topbar, .bottom-nav { backdrop-filter: none; -webkit-backdrop-filter: none; }
.vmu-card, .semester-card { border-radius: 10px; }
.page-subtitle { font-size: 0.82rem; }

/* Nhịp bố cục: thẻ đầu to hơn, hai cột lệch */
.bento-grid { grid-template-columns: 1.7fr 1fr 1fr 1fr !important; }
.bento-grid > :first-child { background: var(--surface-2); }
.bento-grid > :first-child > div:nth-child(2) { font-size: 2rem !important; }
.dash-split { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; min-width: 0; }
.semester-grid { grid-template-columns: 1.15fr 1fr; }
.semester-grid > :nth-child(4n+1), .semester-grid > :nth-child(4n+4) { background: var(--surface-2); }
@media (max-width: 1100px) {
  .bento-grid { grid-template-columns: 1fr 1fr !important; }
  .bento-grid > :first-child { grid-column: 1 / -1; }
  .dash-split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .semester-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .bento-grid { grid-template-columns: 1fr !important; }
}

/* ==========================================================================
   10. PHONG CÁCH CỔNG THÔNG TIN VMU + CHỐNG GIẬT KHI TÌM KIẾM + ĐÍNH KÈM FILE
   ========================================================================== */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

:root {
  --font-sans: 'Be Vietnam Pro', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Be Vietnam Pro', 'Inter', system-ui, sans-serif;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --navy: #1C1E2D;
  --navy-elevated: #25283B;
  --line: #E2E6EE;
  --radius-md: 10px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --shadow-card: 0 1px 2px rgba(28, 30, 45, 0.05);
}

html.dark {
  --font-sans: 'Be Vietnam Pro', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Be Vietnam Pro', 'Inter', system-ui, sans-serif;
  --navy: #141622;
  --navy-elevated: #1E2133;
}

body, h1, h2, h3, h4, button, input, select, textarea {
  font-family: var(--font-sans);
}

.sidebar {
  background: #1C1E2D !important;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}
html.dark .sidebar {
  background: #141622 !important;
}
.side-nav a,
.side-link {
  color: rgba(255, 255, 255, 0.72);
}
.side-nav a:hover,
.side-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #FFFFFF;
}
.side-nav a.is-active,
.side-nav a.active,
.side-nav a[aria-current="page"],
.side-link.is-active,
.side-link.active,
.side-link[aria-current="page"] {
  background: rgba(2, 132, 199, 0.28) !important;
  color: #FFFFFF !important;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}
.side-nav a.is-active::before,
.side-nav a.active::before,
.side-nav a[aria-current="page"]::before {
  background: #38BDF8;
  box-shadow: none;
}

.vmu-card,
.semester-card,
.stat-card,
.doc-card,
.rule-card,
.dir-card {
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}

.search-results-region {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.file-upload-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--surface-2);
}
.file-upload-box input[type="file"] {
  font-size: 0.82rem;
  color: var(--ink);
  width: 100%;
}
.file-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}

/* Sửa tương phản nút trên nền xanh navy đậm & bố cục 2 hàng cho danh sách môn học */
.hero-lighthouse .btn-ghost,
.course-hub-hero .btn-ghost {
  background: rgba(255, 255, 255, 0.14) !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
  color: #FFFFFF !important;
}
.hero-lighthouse .btn-ghost:hover:not(:disabled),
.course-hub-hero .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22) !important;
  border-color: rgba(255, 255, 255, 0.42) !important;
  color: #FFFFFF !important;
}
.course-hub-hero .btn-on {
  background: rgba(245, 158, 11, 0.22) !important;
  border-color: rgba(251, 191, 36, 0.55) !important;
  color: #FEF3C7 !important;
}

.ac-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 6px !important;
}
.ac-item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.ac-item-top .ac-code {
  flex-shrink: 0;
}
.ac-item-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--ink);
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}
.ac-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
}

/* ==========================================================================
   11. SIDEBAR XÁM THAN PHẲNG (#1F2328) + NỘI DUNG SÁNG TƯƠNG PHẢN CAO
   ========================================================================== */
:root {
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --ink: #0F172A;
  --muted: #475569;
  --line: #E2E8F0;
  --navy: #1F2328;
  --navy-elevated: #2B3137;
  --ocean: #00529B;
  --ocean-soft: #EFF6FF;
  --ocean-ink: #00529B;
  --btn-ocean-fg: #FFFFFF;
  --btn-ocean-hover: #003D73;
  --shadow-xs: none;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 1px 3px rgba(15, 23, 42, 0.07);
}

/* 1. Sidebar phẳng màu Xám than (#1F2328) — bỏ hoàn toàn gradient & glow */
.sidebar {
  background: #1F2328 !important;
  color: #B1BAC4 !important;
  border-right: 1px solid #30363D !important;
  box-shadow: none !important;
}
.sidebar .side-brand,
.sidebar .side-title {
  color: #FFFFFF !important;
  font-weight: 800;
}
.sidebar .side-sub {
  color: #B1BAC4 !important;
}
.sidebar .side-logo {
  box-shadow: none !important;
}
.side-nav a,
.side-link {
  color: #B1BAC4 !important;
}
.side-nav a:hover,
.side-link:hover {
  background: #2B3137 !important;
  color: #FFFFFF !important;
}
.side-nav a.is-active,
.side-nav a.active,
.side-nav a[aria-current="page"],
.side-link.is-active,
.side-link.active,
.side-link[aria-current="page"] {
  background: #2F363D !important;
  color: #FFFFFF !important;
  box-shadow: none !important;
}
.side-nav a.is-active::before,
.side-nav a.active::before,
.side-nav a[aria-current="page"]::before {
  width: 3px !important;
  background: #2563EB !important;
  box-shadow: none !important;
}
.side-nav a.is-active svg,
.side-nav a[aria-current="page"] svg {
  color: #FFFFFF !important;
}
.side-major-box,
.side-collapse-btn {
  background: #2B3137 !important;
  border: 1px solid #3B424A !important;
  color: #F0F6FC !important;
  box-shadow: none !important;
}
.side-major-box .side-major-label,
.side-major-box .side-major-meta {
  color: #B1BAC4 !important;
}
.side-major-box .side-major-name,
.side-major-box strong {
  color: #FFFFFF !important;
}

/* 2. Header Trang Học Phần (.course-hub-hero) nền Xám than phẳng (#1F2328) */
.course-hub-hero {
  background: #1F2328 !important;
  color: #F0F6FC !important;
  border: 1px solid #30363D !important;
  border-radius: 10px !important;
  box-shadow: none !important;
}
.course-hub-hero h2 {
  color: #FFFFFF !important;
}
.course-hub-hero .btn-ghost,
.course-hub-hero .btn-on {
  background: #2B3137 !important;
  border: 1px solid #444C56 !important;
  color: #F0F6FC !important;
}
.course-hub-hero .btn-ghost:hover:not(:disabled),
.course-hub-hero .btn-on:hover:not(:disabled) {
  background: #373E47 !important;
  border-color: #6E7681 !important;
  color: #FFFFFF !important;
}

/* 3. Khung Hero trang Tổng quan (nền trắng phẳng ở Light Mode, tương phản rõ) */
html:not(.dark) .hero-lighthouse {
  --ink: #0F172A;
  --muted: #475569;
  --line: #E2E8F0;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --ocean-soft: #EFF6FF;
  --ocean-ink: #00529B;
  background: #FFFFFF !important;
  color: #0F172A !important;
  border: 1px solid #E2E8F0 !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-card) !important;
}
html:not(.dark) .hero-exam-panel {
  background: #F8FAFC !important;
  border: 1px solid #E2E8F0 !important;
  border-radius: 10px;
  padding: 16px;
  color: #0F172A;
}
html:not(.dark) .hero-exam-title {
  color: #0F172A !important;
  font-weight: 700;
}
html:not(.dark) .hero-exam-sub {
  color: #475569 !important;
}
html.dark .hero-exam-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  color: #F1F5F9;
}
html.dark .hero-exam-title {
  color: #F8FAFC;
  font-weight: 700;
}
html.dark .hero-exam-sub {
  color: #CBD5E1;
}
html:not(.dark) .hero-lighthouse h2 {
  color: #0F172A !important;
}
html:not(.dark) .hero-lighthouse p {
  color: #475569 !important;
}
html:not(.dark) .hero-lighthouse .btn-ghost {
  background: #F8FAFC !important;
  border: 1px solid #CBD5E1 !important;
  color: #1E293B !important;
}
html:not(.dark) .hero-lighthouse .btn-ghost:hover:not(:disabled) {
  background: #EFF6FF !important;
  border-color: #93C5FD !important;
  color: #0F172A !important;
}

/* Dark Mode độc lập cho nội dung khi html.dark được bật */
html.dark .hero-lighthouse {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}
html.dark .hero-lighthouse .btn-ghost {
  background: var(--surface-2) !important;
  border: 1px solid var(--line) !important;
  color: var(--ink) !important;
}

/* 4. Nút & thành phần phẳng, bỏ toàn bộ glow box-shadow */
.btn,
.btn-ocean,
.btn-lamp,
.chip,
.badge {
  box-shadow: none !important;
}
.btn-ocean {
  background: var(--ocean) !important;
  border-color: var(--ocean) !important;
  color: var(--btn-ocean-fg) !important;
}
.btn-ocean:hover:not(:disabled) {
  background: var(--btn-ocean-hover) !important;
  border-color: var(--btn-ocean-hover) !important;
}
.progress-fill {
  background: var(--ocean) !important;
}

/* ==========================================================================
   12. REVIEW GIẢNG VIÊN THẬT — THẺ PHẲNG ĐỀU CHIỀU CAO & MODAL ĐÁNH GIÁ NHANH
   ========================================================================== */
.lec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

.lec-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  height: 100%;
  min-width: 0;
  box-shadow: var(--shadow-card);
}

.lec-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.lec-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--ocean-soft);
  color: var(--ocean-ink);
  border: 1px solid color-mix(in srgb, var(--ocean) 20%, var(--line));
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lec-info {
  min-width: 0;
  flex: 1;
}

.lec-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: normal;
}

.lec-sub {
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: normal;
}

.lec-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.lec-star-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  font-family: var(--font-mono);
}
.lec-star-good { background: var(--good-soft); color: var(--good-ink); }
.lec-star-mid  { background: var(--lamp-soft); color: var(--lamp-ink); }
.lec-star-low  { background: var(--bad-soft);  color: var(--bad-ink); }

.lec-courses-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  min-height: 26px;
}

.lec-course-pill {
  display: inline-block;
  max-width: 145px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lec-course-more {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--ocean-soft);
  color: var(--ocean-ink);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.lec-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

/* Modal Đánh giá nhanh 5 giây */
.star-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.star-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.star-btn.is-active,
.star-btn.is-hover {
  background: var(--lamp-soft);
  border-color: var(--lamp);
  color: #F59E0B;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.pill-btn:hover {
  border-color: var(--ocean);
}

.pill-btn.is-selected {
  background: var(--ocean);
  border-color: var(--ocean);
  color: var(--btn-ocean-fg);
}

/* Thanh So sánh giảng viên */
.compare-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ocean-soft);
  border: 1px solid color-mix(in srgb, var(--ocean) 30%, var(--line));
  color: var(--ink);
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.compare-table th,
.compare-table td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: normal;
}

.compare-table th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--muted);
  width: 150px;
}

/* ==========================================================================
   13. XẾP THỜI KHÓA BIỂU NHÁP ĐKHP & SAO LƯU HỒ SƠ JSON
   ========================================================================== */

.tkb-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr) minmax(0, 0.7fr) minmax(0, 1fr);
  gap: 10px;
}

@media (max-width: 900px) {
  .tkb-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .tkb-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tkb-session-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.tkb-session-row select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.tkb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1120px) {
  .tkb-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tkb-conflict-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bad-soft);
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line));
  color: var(--bad);
  font-size: 0.84rem;
  line-height: 1.45;
}

.tkb-conflict-banner strong {
  color: var(--bad);
}

.tkb-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.tkb-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8rem;
}

.tkb-table th,
.tkb-table td {
  border: 1px solid var(--line);
  vertical-align: top;
  padding: 4px;
}

.tkb-table thead th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  padding: 9px 6px;
  font-size: 0.82rem;
}

.tkb-table thead th:first-child {
  width: 82px;
}

.tkb-period-cell {
  background: var(--surface-2);
  text-align: center;
  vertical-align: middle !important;
  padding: 6px 4px !important;
  height: 48px;
  font-weight: 700;
  color: var(--ink);
}

.tkb-period-sub {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}

.tkb-group-row td {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
}

.tkb-empty-cell {
  height: 48px;
  background: var(--surface);
}

/* Ô gộp nhiều tiết (rowspan): đặt relative & cho thẻ môn học lấp đầy toàn bộ chiều cao */
.tkb-span-cell {
  position: relative;
  padding: 0 !important;
  height: 1px;
  vertical-align: stretch !important;
}

.tkb-span-cell > .tkb-block {
  position: absolute;
  inset: 4px;
  height: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: visible;
}

.tkb-cell-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tkb-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  line-height: 1.4;
  height: 100%;
  min-height: 38px;
  overflow: visible;
  overflow-wrap: break-word;
  word-break: break-word;
}

.tkb-block-title {
  display: block;
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.38;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: visible;
}

.tkb-block-meta {
  display: block;
  font-size: 0.71rem;
  line-height: 1.35;
  opacity: 0.9;
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
}

.tkb-block-code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.71rem;
  line-height: 1.35;
  font-weight: 700;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
}

/* 6 tông pastel phẳng rõ nét (Light Mode) */
.tkb-c0 { background: #EBF5FF; border-color: #93C5FD; color: #0F2942; }
.tkb-c1 { background: #ECFDF5; border-color: #6EE7B7; color: #064E3B; }
.tkb-c2 { background: #FEF3C7; border-color: #FCD34D; color: #78350F; }
.tkb-c3 { background: #F3E8FF; border-color: #D8B4FE; color: #4C1D95; }
.tkb-c4 { background: #E0F2FE; border-color: #7DD3FC; color: #0C4A6E; }
.tkb-c5 { background: #FCE7F3; border-color: #F9A8D4; color: #831843; }

/* Dark Mode cho các khối TKB */
html.dark .tkb-c0 { background: #162B45; border-color: #2E5A8F; color: #DBEAFE; }
html.dark .tkb-c1 { background: #0E3328; border-color: #1F6B54; color: #D1FAE5; }
html.dark .tkb-c2 { background: #3B2B0E; border-color: #855D18; color: #FEF3C7; }
html.dark .tkb-c3 { background: #2D1B4E; border-color: #6B3FA0; color: #F3E8FF; }
html.dark .tkb-c4 { background: #0E3147; border-color: #216691; color: #E0F2FE; }
html.dark .tkb-c5 { background: #421931; border-color: #8F3369; color: #FCE7F3; }

/* Ô bị trùng tiết */
.tkb-block.tkb-conflict {
  background: var(--bad-soft) !important;
  border: 1.5px solid var(--bad) !important;
  color: var(--bad) !important;
}

.tkb-copy-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tkb-copy-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.tkb-copy-item.is-conflict {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.tkb-copy-code {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}

.tkb-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.2);
}

/* Khu vực Sao lưu & Khôi phục JSON trong Modal Hồ sơ */
.profile-backup-box {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   14. ĐĂNG NHẬP GOOGLE & TRẠNG THÁI ĐỒNG BỘ ĐÁM MÂY (FIREBASE)
   ========================================================================== */

.auth-header-slot {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.auth-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}

.auth-google-btn:hover {
  border-color: var(--ocean);
  color: var(--ocean);
  background: var(--ocean-soft);
}

.auth-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  max-width: 390px;
}

.auth-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.auth-avatar-fallback {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--ocean);
  color: var(--btn-ocean-fg);
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.15;
}

.auth-user-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.auth-user-sub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  line-height: 1;
}

.auth-user-sub .role-badge,
.auth-user-sub .super-admin-badge,
.auth-user-sub .admin-role-badge,
.auth-user-sub .user-role-badge {
  height: 18px;
  padding: 0 7px;
  font-size: 0.6rem;
  line-height: 1;
}

.auth-sync-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}

.auth-sync-badge.is-synced {
  color: var(--good);
}

.auth-sync-badge.is-saving,
.auth-sync-badge.is-syncing {
  color: var(--ocean);
}

.auth-sync-badge.is-error {
  color: var(--bad);
}

.auth-signout-btn {
  padding: 4px 8px !important;
  font-size: 0.74rem !important;
  border-radius: 999px !important;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .auth-user-meta {
    display: none;
  }
  .auth-user-pill {
    padding: 3px 5px;
    gap: 5px;
  }
}

.profile-cloud-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-cloud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Modal Tài khoản (Đăng nhập / Đăng ký / Liên kết Khách) */
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.auth-tab-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.auth-tab-btn.is-active {
  background: var(--surface);
  color: var(--ocean);
  border: 1px solid var(--line);
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-wrap input {
  width: 100%;
  padding: 9px 40px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.86rem;
}

.auth-eye-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.auth-eye-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  margin: 2px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-guest-warn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #FEF9E7;
  border: 1px solid #F3D17A;
  color: #7C5200;
  font-size: 0.78rem;
  line-height: 1.45;
}

html.dark .auth-guest-warn {
  background: #33270E;
  border-color: #7A5C18;
  color: #FDE68A;
}

.auth-msg-box {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.81rem;
  line-height: 1.4;
  font-weight: 600;
}

.auth-msg-box.is-error {
  background: var(--bad-soft);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line));
  color: var(--bad);
}

.auth-msg-box.is-good {
  background: var(--good-soft);
  border: 1px solid color-mix(in srgb, var(--good) 40%, var(--line));
  color: var(--good);
}

.auth-avatar-fallback.is-guest {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.auth-link-btn {
  padding: 4px 9px !important;
  font-size: 0.74rem !important;
  border-radius: 999px !important;
  flex-shrink: 0;
}

/* Tuyên bố miễn trừ trách nhiệm (Footer & Modal) */
.footer-disclaimer {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.footer-copyright {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 600;
}

.modal-disclaimer {
  margin: 4px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

/* ==========================================================================
   15. SƠ ĐỒ TRƯỜNG & TRA CỨU TÒA NHÀ VMU + LIGHTBOX PHÓNG TO
   ========================================================================== */

.vmu-map-figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
  transition: border-color 0.14s ease;
}

.vmu-map-figure:hover {
  border-color: var(--ocean);
}

.vmu-map-img {
  display: block;
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  background: var(--surface-2);
}

.vmu-map-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.building-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.building-group-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.building-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
}

.building-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.building-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.building-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
}

.building-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.48;
  color: var(--muted);
}

/* Lightbox toàn màn hình xem sơ đồ */
.map-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.92);
  display: flex;
  flex-direction: column;
}

.map-lightbox[hidden] {
  display: none !important;
}

.map-lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  flex-shrink: 0;
}

.map-lightbox-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.map-lightbox-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-zoom-pct {
  min-width: 46px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.map-lightbox-stage {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.map-lightbox-img {
  display: block;
  width: 100%;
  max-width: 1200px;
  height: auto;
  border-radius: 8px;
  background: #ffffff;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

/* ==========================================================================
   16. TỐI ƯU DI ĐỘNG (360px – 430px) & PWA SAFE-AREA (iOS / ANDROID)
   ========================================================================== */

/* Chống tràn ngang toàn trang & cuộn ngang mượt cho mọi khung bảng */
body,
.app-shell,
.app-view {
  max-width: 100%;
  overflow-x: hidden;
}

.table-wrap,
.gpa-table-wrap,
.tkb-scroll,
.compare-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Hỗ trợ Safe-Area tai thỏ / thanh vuốt cho PWA */
.sidebar {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.map-lightbox {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 900px) {
  .topbar {
    padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }

  .app-shell {
    padding-bottom: calc(var(--bottom-nav-h) + 18px + env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav {
    min-height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding: 4px max(4px, env(safe-area-inset-left, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-right, 0px));
  }
}

@media (max-width: 767.98px) {
  /* 1. Ngăn iOS Safari tự phóng to khi bấm nhập liệu */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: 16px !important;
  }

  /* 2. Thu gọn khoảng đệm trên màn hình điện thoại để tăng diện tích nội dung */
  .app-view {
    padding: 12px 10px 24px;
  }

  .app-view > .page-enter {
    gap: 14px !important;
  }

  .app-footer {
    padding: 14px 12px 18px;
  }

  .vmu-card,
  .semester-card,
  .doc-card,
  .rule-card,
  .dir-card,
  .lec-card {
    padding: 12px !important;
  }

  /* 3. Vùng chạm tối thiểu 44x44px thân thiện ngón cái */
  .btn,
  .btn-icon,
  .bottom-nav-item,
  .bottom-nav a,
  .bottom-nav button,
  .subtab-btn,
  .chip,
  .pill-btn,
  .side-link,
  .auth-tab-btn,
  .auth-eye-btn {
    min-height: 44px;
  }

  .btn-icon,
  .auth-eye-btn,
  .bottom-nav-item,
  .bottom-nav a,
  .bottom-nav button {
    min-width: 44px;
  }

  /* Thanh subtab cuộn ngang mượt 1 tay thay vì rớt quá nhiều dòng */
  .subtab-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .subtab-bar::-webkit-scrollbar {
    display: none;
  }

  .subtab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* 4. Bảng GPA & CTĐT cuộn ngang mượt, không bóp chữ */
  .gpa-table {
    min-width: 640px;
  }

  .compare-table {
    min-width: 540px;
  }

  .tkb-session-row {
    gap: 6px;
  }

  .tkb-session-row select {
    flex: 1 1 110px;
    min-height: 44px;
  }

  /* 5. Modal Đăng nhập, Hồ sơ & Hộp thoại vừa khít mobile, cuộn mượt khi bật bàn phím ảo */
  .vmu-modal {
    width: 94vw !important;
    max-width: 94vw !important;
    max-height: 90vh !important;
    max-height: 90dvh !important;
    margin: auto;
    padding: 0 !important;
    border-radius: 12px;
  }

  .vmu-modal .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    max-height: 90dvh !important;
  }

  .vmu-modal .modal-body {
    padding: 14px !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .vmu-modal .modal-footer {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Lightbox sơ đồ trường gọn gàng trên mobile */
  .map-lightbox-bar {
    padding: 8px 10px;
    gap: 6px;
  }

  .map-lightbox-title {
    font-size: 0.82rem;
    flex: 1 1 100%;
  }

  .map-lightbox-tools {
    width: 100%;
    justify-content: flex-end;
  }

  .map-lightbox-stage {
    padding: 10px;
  }
}

/* Màn hình điện thoại nhỏ 360px – 430px */
@media (max-width: 430px) {
  .topbar {
    gap: 8px 6px;
    padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 10px 0.55rem;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-actions .btn {
    padding-left: 8px;
    padding-right: 8px;
  }

  .auth-user-pill {
    max-width: 190px;
    gap: 4px;
    padding: 2px 4px;
  }

  .auth-link-btn,
  .auth-signout-btn {
    padding: 0 7px !important;
    font-size: 0.72rem !important;
  }

  .page-title {
    font-size: 0.98rem;
  }

  .vmu-map-img {
    max-height: 280px;
  }
}

/* ==========================================================================
   17. TỐI ƯU HIỆU NĂNG CUỘN, CHẠM & RENDER (PERFORMANCE)
   ========================================================================== */

/* Bỏ độ trễ 300ms khi chạm trên điện thoại */
a,
button,
input,
select,
textarea,
summary,
[role="button"],
.chip,
.pill-btn,
.subtab-btn {
  touch-action: manipulation;
}

/* Bỏ qua layout/paint cho các thẻ danh sách dài ngoài vùng nhìn thấy */
.lec-card,
.rule-card,
.dir-card,
.doc-card,
.building-card,
.semester-card,
.tutor-card,
.living-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 180px;
}

/* Chỉ dùng transform/opacity cho hiệu ứng chuyển động mượt GPU */
.skip-link,
.sidebar {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

.app-shell {
  transition: opacity 0.16s ease;
}

/* ==========================================================================
   18. PHÒNG HỌC TRỰC TUYẾN (#classroom-modal — JITSI MEET)
   ========================================================================== */

.classroom-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 10050;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.classroom-modal[hidden] {
  display: none !important;
}

.classroom-bar {
  height: 48px;
  min-height: 48px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.classroom-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.classroom-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--good);
  flex-shrink: 0;
}

.classroom-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.classroom-server-select {
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.classroom-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.classroom-bar-actions .btn {
  min-height: 34px !important;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.classroom-frame-host {
  flex: 1;
  width: 100%;
  min-height: 0;
  background: #111827;
  position: relative;
}

.classroom-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 640px) {
  .classroom-bar {
    height: auto;
    min-height: 48px;
    padding: 6px 8px;
    gap: 6px;
  }

  .classroom-server-select {
    display: none;
  }

  .classroom-title {
    font-size: 0.82rem;
  }
}

/* ==========================================================================
   19. DIỄN ĐÀN SINH VIÊN VMU (#forum — FIRESTORE)
   ========================================================================== */

.forum-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forum-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 170px;
}

.forum-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.forum-author-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.forum-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--ocean-soft);
  color: var(--ocean);
  border: 1px solid color-mix(in srgb, var(--ocean) 25%, var(--line));
  font-size: 0.82rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.forum-avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.74rem;
}

.forum-author-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.forum-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.forum-body-btn {
  all: unset;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.forum-body-btn:hover .forum-title {
  color: var(--ocean);
}

.forum-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.38;
  overflow-wrap: anywhere;
  transition: color 0.12s ease;
}

.forum-excerpt {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.forum-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.forum-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.forum-like-btn.is-liked {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 40%, var(--line));
  color: var(--bad);
}

.forum-detail-content {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.forum-comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.forum-comment-item {
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.forum-comment-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Giao diện phân quyền Admin trên Diễn đàn & Header */
/* Hệ thống phân cấp 3 cấp bậc vai trò đồng nhất (Super Admin -> Admin -> Người dùng) */
.role-badge,
.super-admin-badge,
.admin-role-badge,
.user-role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Cấp 1: Super Admin (Cam nổi bật) */
.super-admin-badge {
  background: #EA580C;
  color: #FFFFFF;
}

/* Cấp 2: Admin (Xanh dương) */
.admin-role-badge {
  background: #2563EB;
  color: #FFFFFF;
}

/* Cấp 3: Người dùng (Xám trung tính) */
.user-role-badge {
  background: #E2E8F0;
  color: #475569;
}

html.dark .super-admin-badge {
  background: #EA580C;
  color: #FFFFFF;
}

html.dark .admin-role-badge {
  background: #2563EB;
  color: #FFFFFF;
}

html.dark .user-role-badge {
  background: #334155;
  color: #CBD5E1;
}

.forum-admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ocean-soft);
  border: 1px solid color-mix(in srgb, var(--ocean) 30%, var(--line));
  font-size: 0.82rem;
  color: var(--ink);
}

.forum-card.is-pinned {
  border-color: color-mix(in srgb, var(--ocean) 45%, var(--line));
}

.forum-card.is-hidden-post {
  opacity: 0.72;
  border-style: dashed;
  border-color: var(--bad);
}

.forum-mod-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.admin-user-uid {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

/* ==========================================================================
   20. SKELETON LOADING SHIMMER (.skeleton, .skeleton-card, .skeleton-line, .skeleton-avatar)
   ========================================================================== */

@keyframes vmuShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
  background-size: 200% 100%;
  animation: vmuShimmer 1.4s ease-in-out infinite;
}

html.dark .skeleton {
  background: linear-gradient(90deg, #252C37 25%, #323C4A 50%, #252C37 75%);
  background-size: 200% 100%;
}

.vmu-skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 12px;
}

.vmu-skel-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-card,
.vmu-skel-card {
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vmu-skel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skeleton-avatar,
.vmu-skel-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  flex-shrink: 0;
}

.skeleton-line,
.vmu-skel-line {
  height: 12px;
  border-radius: 6px;
}

.skeleton-line.is-title,
.vmu-skel-line.is-title {
  height: 16px;
  width: 72%;
}

.skeleton-line.is-short,
.vmu-skel-line.is-short {
  width: 38%;
}

.skeleton-line.is-mid,
.vmu-skel-line.is-mid {
  width: 58%;
}

.skeleton-line.is-full,
.vmu-skel-line.is-full {
  width: 100%;
}

.vmu-skel-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.vmu-skel-pill {
  height: 26px;
  width: 74px;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--line);
    opacity: 0.72;
  }
}

/* Bảo đảm mọi bảng Điểm rèn luyện, CTĐT, GPA, TKB cuộn mượt trên mobile (< 768px) */
.profile-form-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 10px;
}

.review-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 10px;
}

@media (max-width: 767.98px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  /* Xếp 1 cột thoáng mắt cho thẻ thống kê, form hồ sơ, bộ lọc & lưới thẻ trên mobile */
  .profile-form-row,
  .review-filter-grid,
  .bento-grid,
  .dash-split,
  .lec-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .drl-table-wrap,
  .curriculum-table-wrap,
  .app-view .overflow-x-auto {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .drl-table {
    min-width: 520px;
  }

  .course-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .course-row > a.btn {
    width: 100%;
    justify-content: center;
  }
}

/* Logo mới (logo-web.webp) khung tròn khít, căng đầy sắc nét */
.side-logo {
  width: 40px;
  height: 40px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.side-logo-img,
.side-logo img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
  transform: scale(1.08);
  display: block;
  flex-shrink: 0;
}

/* Tên trường 2 dòng IN HOA gọn gàng trên Sidebar */
.side-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.side-brand-uni {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  color: #E2E8F0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.25;
  white-space: nowrap;
}

.side-brand-en {
  display: block;
  font-size: 0.56rem;
  font-weight: 500;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.25;
  white-space: nowrap;
}

/* ==========================================================================
   21. TINH CHỈNH UX & ACCESSIBILITY (THEO CHUẨN UI-UX-PRO-MAX)
   ========================================================================== */

/* Tránh thanh sticky topbar che mất phần tử đang nhận keyboard focus */
html {
  scroll-padding-top: 88px;
}

/* Vòng focus bàn phím sắc nét, đồng bộ Light & Dark Mode */
:is(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--ocean);
  outline-offset: 2px;
}

/* Phản hồi chạm tức thì (80–120ms) không làm rung/lệch bố cục */
.btn:active:not(:disabled),
.chip:active:not(:disabled),
.pill-btn:active:not(:disabled),
.subtab-btn:active:not(:disabled),
.bottom-nav-item:active,
.side-link:active {
  opacity: 0.84;
  transition: opacity 0.1s ease, background-color 0.1s ease;
}

/* Trạng thái disabled rõ ràng, không gây nhầm là bấm được */
.btn:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Độ mờ nền (scrim) tách bạch hộp thoại & ngăn kéo trên cả Light/Dark Mode */
.vmu-modal::backdrop {
  background: rgba(15, 23, 42, 0.58);
}

html.dark .vmu-modal::backdrop {
  background: rgba(2, 6, 23, 0.74);
}

/* Độ dài dòng đọc tối ưu cho nội dung dài trên màn hình lớn */
.forum-detail-content,
.forum-comment-text {
  max-width: 72ch;
}

/* ==========================================================================
   22. TINH CHỈNH TỔNG QUAN (DASHBOARD) — VISUAL HIERARCHY & CARD UI
   ========================================================================== */

/* Căn độ rộng tối đa hài hòa & nhịp khoảng cách 8px đồng bộ */
.app-view > .page-enter,
.boot-skeleton {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.boot-skeleton {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero Tổng quan gọn gàng, thoáng mắt, cân đối 2 cột */
.hero-lighthouse {
  padding: 24px !important;
  border-radius: 12px !important;
  border: 1px solid var(--line) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hero-lighthouse > div {
  gap: 24px !important;
}

.hero-lighthouse h2 {
  letter-spacing: -0.015em;
}

.hero-lighthouse p {
  max-width: 60ch;
}

/* Lưới 4 thẻ chỉ số đồng đều chiều cao, thẳng hàng icon & số liệu */
.bento-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 16px !important;
  align-items: stretch;
}

.stat-card {
  height: 100%;
  padding: 18px !important;
  border-radius: 12px !important;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  justify-content: space-between;
  gap: 10px !important;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}

.stat-card:hover {
  border-color: color-mix(in srgb, var(--ocean) 42%, var(--line));
}

.stat-card > div:first-child .badge {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Khối chia đôi Lịch thi & Tin học vụ cân đối, giảm rối viền lồng nhau */
.dash-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.dash-split > .vmu-card {
  padding: 20px !important;
  border-radius: 12px !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dash-split > .vmu-card > div:last-child > div {
  border-radius: 10px !important;
  padding: 12px 14px !important;
  border-color: color-mix(in srgb, var(--line) 72%, transparent) !important;
  line-height: 1.5;
}

html.dark .hero-lighthouse,
html.dark .stat-card,
html.dark .dash-split > .vmu-card {
  box-shadow: none;
}

/* Tablet (768px – 1023px): Lưới 2x2 gọn gàng */
@media (max-width: 1023.98px) {
  .bento-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  .dash-split {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
}

/* Mobile (< 768px): Xếp dọc 1 cột thoáng mắt, không tràn ngang */
@media (max-width: 767.98px) {
  .hero-lighthouse {
    padding: 16px !important;
  }

  .hero-lighthouse > div {
    gap: 16px !important;
  }

  .bento-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .stat-card {
    padding: 14px !important;
  }

  .dash-split > .vmu-card {
    padding: 14px !important;
  }
}

/* Đứng yên tuyệt đối khi tích/bỏ tích môn học trong CTĐT (không rung, không scale, không animation) */
.course-row,
.course-row.is-passed,
.course-row.has-warn,
.course-row [data-act="togglePassCourse"],
.course-row [data-act="togglePassCourse"]:hover,
.course-row [data-act="togglePassCourse"]:active {
  animation: none !important;
  transform: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease !important;
}

.course-row [data-act="togglePassCourse"]:active {
  opacity: 1 !important;
}
