:root {
  --brand-900: #0f3d6d;
  --brand-800: #145a96;
  --brand-700: #1b74b5;
  --brand-200: #d7ebfa;
  --brand-100: #eef7ff;
  --ink-900: #0d2236;
  --ink-700: #365067;
  --ink-500: #6a8196;
  --line: rgba(15, 61, 109, 0.12);
  --surface: rgba(255, 255, 255, 0.9);
  --shadow: 0 20px 50px rgba(17, 66, 114, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--ink-900);
  background:
    radial-gradient(circle at top left, rgba(27, 116, 181, 0.18), transparent 32%),
    linear-gradient(180deg, #f7fbff 0%, #edf6fd 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(15, 61, 109, 0.08);
  font-size: 0.95em;
}

.page-shell {
  min-height: 100vh;
  padding: 24px;
}

.site-header {
  max-width: 1680px;
  margin: 0 auto 24px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__logo {
  display: inline-block;
  height: 40px;
  width: auto;
  object-fit: contain;
}

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand__text strong {
  font-size: 1rem;
}

.brand__text small {
  color: var(--ink-500);
}

.site-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.site-nav a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--ink-700);
  transition: 0.2s ease;
}

.site-nav a.is-active,
.site-nav a:hover {
  color: white;
  background: var(--brand-800);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  z-index: 1001;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.menu-toggle:hover {
  background-color: rgba(15, 61, 109, 0.06);
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--brand-900);
  margin: 4px auto;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Animation to 'X' */
.menu-toggle.is-active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.menu-toggle.is-active span:nth-child(2) {
  opacity: 0;
}
.menu-toggle.is-active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.site-nav__user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.site-nav__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.site-nav__avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.site-nav__username {
  display: none; /* Hide on desktop for clean menu */
}

.btn--logout {
  min-height: 36px !important;
  padding: 0 14px !important;
  font-weight: 600 !important;
  font-size: 0.9rem !important;
}

.content {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 24px;
  align-items: stretch;
}

.hero__content,
.hero__panel,
.panel,
.info-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero__content {
  padding: 32px;
}

.hero__panel,
.info-card,
.panel {
  padding: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--brand-800);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

h1,
h2 {
  margin-top: 0;
}

.hero h1 {
  margin-bottom: 16px;
  font-size: clamp(1.8rem, 2.5vw, 2.8rem);
  line-height: 1.12;
}

.hero__lead,
.page-intro p,
.panel p {
  color: var(--ink-700);
  line-height: 1.75;
}

.hero__actions {
  margin: 28px 0 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.btn--primary {
  color: white;
  background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
}

.btn--ghost {
  border: 1px solid var(--line);
  color: var(--brand-900);
  background: white;
}

.status-card {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--brand-100);
  color: var(--brand-900);
}

.status-card[data-tone="warning"] {
  background: #fff5d6;
  color: #7b5b00;
}

.status-card[data-tone="danger"] {
  background: #ffe7e7;
  color: #962d2d;
}

.status-card[data-tone="success"] {
  background: #e7f8ee;
  color: #14633b;
}

.json-card {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(9, 28, 45, 0.96);
  color: #d9e8f4;
}

.json-card__header {
  margin-bottom: 14px;
}

.json-card__header h2 {
  margin-bottom: 8px;
  color: white;
}

.json-card__header p {
  margin: 0;
  color: rgba(217, 232, 244, 0.76);
}

.json-viewer {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.7;
}

.flow-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-700);
  line-height: 1.8;
}

.page-intro {
  margin-bottom: 20px;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.data-list {
  margin: 0;
  display: grid;
  gap: 16px;
}

.data-list div {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.data-list dt {
  margin-bottom: 6px;
  color: var(--ink-500);
  font-size: 0.95rem;
}

.data-list dd {
  margin: 0;
  font-weight: 600;
}

.student-profile {
  width: 100%;
  min-height: calc(100vh - 160px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.student-profile__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.student-profile__identity {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.student-profile__avatar {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  border: 4px solid white;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand-100);
  box-shadow: 0 14px 30px rgba(17, 66, 114, 0.16);
}

.student-profile__avatar--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
  font-size: 2rem;
  font-weight: 800;
  width: 100%;
  height: 100%;
}

/* ============================================================
   AVATAR CAROUSEL SLIDER STYLES
   ============================================================ */
.avatar-slider-wrapper {
  position: relative;
  width: 104px;
  height: 104px;
  flex: 0 0 auto;
  user-select: none;
  cursor: pointer;
}

.avatar-slider-track {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(17, 66, 114, 0.2);
  border: 3px solid #ffffff;
  background: var(--brand-100, #e0f2fe);
}

.avatar-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-slide.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.avatar-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: none;

}

.avatar-slide-badge {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 10;
  letter-spacing: 0.2px;
}

.badge-moodle {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
}

.badge-selfie {
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
}

.avatar-slider-dots {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 12;
}

.avatar-slider-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cbd5e1;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-slider-dots .dot.active {
  background: #0284c7;
  width: 16px;
  border-radius: 8px;
}

.student-profile__heading h1 {
  margin-bottom: 10px;
  font-size: 2rem;
  line-height: 1.2;
}

.student-profile__heading p {
  margin: 0;
  color: var(--ink-700);
}

.student-profile__edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-top: 14px;
  padding: 0 14px;
  border-radius: 999px;
  color: white;
  background: var(--brand-800);
  font-weight: 700;
}

.student-profile__status {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  color: #14633b;
  background: #e7f8ee;
  font-weight: 700;
}

.student-profile__grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.student-profile__grid div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
}

.student-profile__grid dt {
  margin-bottom: 8px;
  color: var(--ink-500);
  font-size: 0.88rem;
}

.student-profile__grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
  line-height: 1.45;
}

.panel__heading {
  margin-bottom: 18px;
}

.table-wrap {
  overflow-x: auto;
}

.semester-list {
  display: grid;
  gap: 24px;
}

.semester-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.semester-section__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(15, 61, 109, 0.08), rgba(255, 255, 255, 0.68));
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.semester-section__heading::-webkit-details-marker {
  display: none;
}

.semester-section__heading::after {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: white;
  background: var(--brand-800);
  font-weight: 800;
}

.semester-section[open] .semester-section__heading::after {
  content: "-";
}

.semester-section__title {
  margin: 0;
  color: var(--brand-900);
  font-size: 1.12rem;
  font-weight: 800;
}

.semester-section__meta {
  margin: 0;
  color: var(--ink-700);
  font-weight: 700;
  margin-left: auto;
}

.curriculum-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
}

.curriculum-table th,
.curriculum-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.curriculum-table th {
  position: sticky;
  top: 0;
  color: var(--brand-900);
  background: #f5faff;
  font-size: 0.86rem;
  text-transform: uppercase;
}

.curriculum-table td {
  background: rgba(255, 255, 255, 0.82);
}

.curriculum-table tbody tr:nth-child(even) td {
  background: rgba(238, 247, 255, 0.42);
}

.curriculum-table tbody tr:hover td {
  background: rgba(215, 235, 250, 0.52);
}

.curriculum-table th:first-child,
.curriculum-table td:first-child {
  width: 132px;
  font-weight: 800;
}

.curriculum-table th:nth-child(3),
.curriculum-table td:nth-child(3),
.curriculum-table th:nth-child(4),
.curriculum-table td:nth-child(4),
.curriculum-table th:nth-child(5),
.curriculum-table td:nth-child(5) {
  width: 90px;
  text-align: center;
}

.table-link {
  color: var(--brand-800);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.course-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: white;
  background: var(--brand-800);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.course-link-button--disabled {
  color: var(--ink-500);
  background: rgba(15, 61, 109, 0.08);
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  background: var(--brand-100);
  color: var(--ink-700);
}

.lookup-panel {
  max-width: 860px;
}

.lookup-form {
  display: flex;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.lookup-form__field {
  flex: 1 1 320px;
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: var(--ink-700);
}

.lookup-form__field input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink-900);
  font: inherit;
}

.lookup-form__field input:focus {
  outline: 2px solid rgba(27, 116, 181, 0.18);
  border-color: var(--brand-700);
}

.lookup-result {
  margin-top: 24px;
}

.session-monitor {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 360px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  background: rgba(13, 34, 54, 0.92);
  color: white;
  box-shadow: var(--shadow);
}

.session-monitor[data-tone="warning"] {
  background: rgba(123, 91, 0, 0.94);
}

.session-monitor[data-tone="danger"] {
  background: rgba(150, 45, 45, 0.95);
}

.session-monitor[data-tone="success"] {
  background: rgba(20, 99, 59, 0.94);
}

.panel--error {
  max-width: 720px;
}

.panel--auth {
  max-width: 480px;
  margin: 60px auto;
  text-align: center;
  padding: 48px 32px;
}

.spinner {
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
  border: 4px solid var(--line);
  border-top-color: var(--brand-700);
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-loading h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: var(--brand-900);
}

.auth-loading .status-text {
  color: var(--ink-700);
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .page-shell {
    padding: 12px;
  }

  .hero,
  .grid-two {
    grid-template-columns: 1fr;
  }

  .site-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    box-sizing: border-box;
    border-radius: 0;
    z-index: 1000;
  }

  .menu-toggle {
    display: block;
  }

  .site-nav {
    position: fixed;
    top: 0;
    left: -320px;
    width: 280px;
    height: 100dvh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    z-index: 1000;
    box-shadow: none;
    padding: 80px 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    flex-wrap: nowrap;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .site-nav.is-open {
    left: 0;
    box-shadow: var(--shadow);
  }

  .site-nav a {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 600;
    color: var(--ink-700);
  }

  .site-nav a.is-active,
  .site-nav a:hover {
    color: white;
    background: var(--brand-800);
  }

  .site-nav__user {
    margin-top: auto; /* Đẩy khối thông tin người dùng xuống đáy menu */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
  }

  .site-nav__avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  }

  .site-nav__avatar-fallback {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 24px;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  }

  .site-nav__username {
    display: block;
    font-weight: 700;
    color: var(--ink-900);
    font-size: 1rem;
    text-align: center;
  }

  .btn--logout {
    width: 100% !important;
    min-height: 44px !important;
    font-weight: 700 !important;
  }

  .nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(13, 34, 54, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .nav-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .hero__content,
  .hero__panel,
  .panel,
  .info-card,
  .json-card,
  .student-profile {
    padding: 16px;
  }

  .student-profile__heading {
    display: grid;
    gap: 14px;
  }

  .student-profile__identity {
    align-items: flex-start;
  }

  .student-profile__status {
    width: fit-content;
  }

  .semester-section__heading {
    display: grid;
    gap: 6px;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .curriculum-table {
    min-width: 0;
  }

  .curriculum-table thead {
    display: none;
  }

  .curriculum-table,
  .curriculum-table tbody {
    display: block;
  }

  .curriculum-table tbody tr {
    display: block;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
    box-shadow: 0 2px 8px rgba(17, 66, 114, 0.06);
  }

  .curriculum-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .curriculum-table tbody tr:hover td {
    background: transparent;
  }

  .curriculum-table td {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    background: transparent !important;
    width: auto !important;
    text-align: left !important;
    font-weight: 500;
  }

  .curriculum-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .curriculum-table td:first-child {
    padding-top: 0;
    font-weight: 800;
    color: var(--brand-900);
  }

  .curriculum-table td::before {
    content: attr(data-label);
    flex: 0 0 100px;
    color: var(--ink-500);
    font-size: 0.85rem;
    font-weight: 600;
  }

  .curriculum-table td:first-child::before {
    color: var(--brand-800);
  }
}

@media (max-width: 560px) {
  .student-profile__grid {
    grid-template-columns: 1fr;
  }

  .student-profile__heading h1 {
    font-size: 1.3rem;
  }

  .student-profile__identity {
    display: grid;
  }

  .student-profile__avatar {
    width: 64px;
    height: 64px;
  }

  .brand__logo {
    height: 32px;
  }

  .brand__text small {
    display: none;
  }

  .brand__text strong {
    font-size: 0.85rem;
    max-width: 200px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* ==========================================================================
   MODERN SIDEBAR & HEADER LAYOUT FOR DESKTOP
   ========================================================================== */

/* Tránh giật lag và set padding cơ bản */
body.desktop-sidebar-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-gradient, radial-gradient(circle at top left, rgba(27, 116, 181, 0.12), transparent 32%), linear-gradient(180deg, #f7fbff 0%, #edf6fd 100%));
  overflow-x: hidden;
}

/* Header mỏng hiện đại cố định ở đỉnh */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--header-bg, rgba(255, 255, 255, 0.85));
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin: 0;
  max-width: none;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Thân trang sau Header */
.layout-body {
  display: flex;
  flex: 1;
  margin-top: 64px;
  min-height: calc(100vh - 64px);
}

.sidebar-brand-header {
  display: none;
}

/* Thanh Sidebar dọc cố định bên trái */
.site-sidebar {
  width: 260px;
  background: var(--sidebar-bg, rgba(255, 255, 255, 0.72));
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 16px;
  position: fixed;
  top: 64px;
  bottom: 0;
  left: 0;
  z-index: 999;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* MUI Toolpad IconButton cho Main Portal Navigation Toggle
   — Đồng bộ hoàn toàn với .mui-queue-btn trong trang CCCD */
.mui-portal-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--line, #e2e8f0);
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  padding: 0;
  z-index: 10;
}

.mui-portal-toggle-btn:hover {
  background: #f1f5f9;
  color: #0284c7;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.mui-portal-toggle-btn:active {
  transform: translateY(0);
  background: #e2e8f0;
}

/* Dark mode */
.dark-mode .mui-portal-toggle-btn {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

.dark-mode .mui-portal-toggle-btn:hover {
  background: #334155;
  color: #38bdf8;
}

.mui-portal-toggle-svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  transition: transform 0.3s ease;
}


/* Khi Main Sidebar thu nhỏ (.collapsed), xoay icon 180 độ mượt mà */
/* Dùng class .sidebar-icon-rotated được gắn trực tiếp qua JS để tương thích đa trình duyệt */
.sidebar-icon-rotated {
  transform: rotate(180deg) !important;
}

/* Khi Sidebar thu nhỏ (Collapsed) */
.site-sidebar.collapsed {
  width: 80px;
}


.site-sidebar.collapsed .sidebar-link span,
.site-sidebar.collapsed .sidebar-user-info,
.site-sidebar.collapsed .btn--logout-vertical > span {
  display: none;
}

.site-sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 12px;
}

.site-sidebar.collapsed .btn--logout-vertical {
  justify-content: center;
  padding: 12px;
  width: 100%;
}

.site-sidebar.collapsed .sidebar-user {
  justify-content: center;
}

/* Menu điều hướng bên trong sidebar */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;           /* chiếm toàn bộ không gian còn lại trong sidebar */
  overflow-y: auto;  /* scroll khi items nhiều hơn viewport */
  min-height: 0;     /* BẮT BUỘC: flex item cần min-height:0 để overflow hoạt động */
  padding-right: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 500;
  color: var(--ink-700);
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

/* ── Sidebar Accordion Groups ────────────────────────────────────────── */
.sidebar-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px 4px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.sidebar-group-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-group-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-400, #94a3b8);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Chấm màu trước label — mỗi nhóm một màu riêng */
.sidebar-group-label::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Màu sắc riêng từng nhóm ── */
[data-group="student"] .sidebar-group-label {
  color: #2563eb;
}
[data-group="student"] .sidebar-group-label::before {
  background: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.18);
}
[data-group="student"].sidebar-group-header:hover {
  background: rgba(37, 99, 235, 0.06);
}

[data-group="public"] .sidebar-group-label {
  color: #059669;
}
[data-group="public"] .sidebar-group-label::before {
  background: #059669;
  box-shadow: 0 0 0 2px rgba(5,150,105,0.18);
}
[data-group="public"].sidebar-group-header:hover {
  background: rgba(5, 150, 105, 0.06);
}

[data-group="cccd"] .sidebar-group-label {
  color: #d97706;
}
[data-group="cccd"] .sidebar-group-label::before {
  background: #d97706;
  box-shadow: 0 0 0 2px rgba(217,119,6,0.18);
}
[data-group="cccd"].sidebar-group-header:hover {
  background: rgba(217, 119, 6, 0.06);
}

[data-group="admin"] .sidebar-group-label {
  color: #dc2626;
}
[data-group="admin"] .sidebar-group-label::before {
  background: #dc2626;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.18);
}
[data-group="admin"].sidebar-group-header:hover {
  background: rgba(220, 38, 38, 0.06);
}

/* Chevron bắt màu theo nhóm */
[data-group="student"] .sidebar-group-chevron { color: #2563eb; }
[data-group="public"]  .sidebar-group-chevron { color: #059669; }
[data-group="cccd"]    .sidebar-group-chevron { color: #d97706; }
[data-group="admin"]   .sidebar-group-chevron { color: #dc2626; }

/* Dark mode — nhạt hơn một chút */
.dark-mode [data-group="student"] .sidebar-group-label { color: #60a5fa; }
.dark-mode [data-group="student"] .sidebar-group-label::before { background: #60a5fa; box-shadow: 0 0 0 2px rgba(96,165,250,0.2); }
.dark-mode [data-group="public"]  .sidebar-group-label { color: #34d399; }
.dark-mode [data-group="public"]  .sidebar-group-label::before { background: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,0.2); }
.dark-mode [data-group="cccd"]    .sidebar-group-label { color: #fbbf24; }
.dark-mode [data-group="cccd"]    .sidebar-group-label::before { background: #fbbf24; box-shadow: 0 0 0 2px rgba(251,191,36,0.2); }
.dark-mode [data-group="admin"]   .sidebar-group-label { color: #f87171; }
.dark-mode [data-group="admin"]   .sidebar-group-label::before { background: #f87171; box-shadow: 0 0 0 2px rgba(248,113,113,0.2); }

.sidebar-group-chevron {
  color: var(--ink-400, #94a3b8);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.sidebar-group-header[aria-expanded="false"] .sidebar-group-chevron {
  transform: rotate(-90deg);
}

.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity   0.2s ease,
              padding   0.2s ease;
  opacity: 1;
  padding: 0 0 2px 0;
}

.sidebar-group-items.is-collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding: 0;
}

.sidebar-group-divider {
  height: 1px;
  background: var(--line, #e2e8f0);
  margin: 4px 6px;
  flex-shrink: 0;
}

/* Dark mode */
.dark-mode .sidebar-group-header:hover {
  background: rgba(255, 255, 255, 0.05);
}
.dark-mode .sidebar-group-label {
  color: #475569;
}
.dark-mode .sidebar-group-divider {
  background: rgba(255, 255, 255, 0.08);
}

/* Collapsed sidebar (icon-only): ẩn toàn bộ group headers & dividers, luôn hiện items */
.site-sidebar.collapsed .sidebar-group-header,
.site-sidebar.collapsed .sidebar-group-divider {
  display: none;
}
.site-sidebar.collapsed .sidebar-group-items {
  max-height: 600px !important;
  opacity: 1 !important;
  padding: 0 !important;
}

/* Thin custom scrollbar cho sidebar-nav */
.sidebar-nav::-webkit-scrollbar {
  width: 3px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--line, #e2e8f0);
  border-radius: 99px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--ink-300, #cbd5e1);
}
.dark-mode .sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
}
.dark-mode .sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar-link svg {
  flex-shrink: 0;
  color: var(--ink-500);
  transition: color 0.2s ease;
}

.sidebar-link:hover {
  background: rgba(27, 116, 181, 0.08);
  color: var(--brand-700);
}

.sidebar-link:hover svg {
  color: var(--brand-700);
}

.sidebar-link.is-active {
  background: var(--brand-700);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(27, 116, 181, 0.3);
}

.sidebar-link.is-active svg {
  color: #fff;
}

/* Footer Sidebar chứa User + Đăng xuất */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--brand-700);
}

.sidebar-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-700);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
}

.sidebar-username {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.sidebar-userrole {
  color: var(--ink-500);
  font-size: 0.75rem;
  text-decoration: none;
  transition: color 0.2s, text-decoration 0.2s;
}

.sidebar-userrole:hover {
  color: var(--brand-700) !important;
  text-decoration: underline !important;
}

.btn--logout-vertical {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(220, 53, 69, 0.2);
  background: rgba(220, 53, 69, 0.05);
  color: #dc3545;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn--logout-vertical:hover {
  background: #dc3545;
  color: #fff;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

.btn--logout-vertical .logout-txt-desktop {
  display: inline !important;
}

.btn--logout-vertical .logout-txt-mobile {
  display: none !important;
}

/* Phần nội dung chính nằm bên phải */
.content-wrapper {
  flex: 1;
  margin-left: 260px;
  padding: 16px 20px;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: calc(100% - 260px);
}

/* Body-class approach: hoạt động ở mọi cấu trúc DOM lồng nhau */
body.sidebar-collapsed .content-wrapper {
  margin-left: 80px;
  width: calc(100% - 80px);
}

/* Trên mobile / tablet: content chiếm toàn bộ */
body.sidebar-hidden .content-wrapper {
  margin-left: 0;
  width: 100%;
}

/* Nút chuyển đổi Theme (Dark Mode) - Thiết kế Tinh tế & Cao cấp */
.theme-toggle {
  background: rgba(15, 61, 109, 0.03);
  border: 1px solid var(--line);
  color: var(--ink-700);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  box-sizing: border-box;
}

.theme-toggle svg {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s ease;
}

.theme-toggle:hover {
  background: rgba(15, 61, 109, 0.08);
  border-color: rgba(15, 61, 109, 0.15);
  color: var(--brand-700);
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(15, 61, 109, 0.08);
}

.theme-toggle:hover svg {
  transform: rotate(45deg);
}

.theme-toggle:active {
  transform: scale(0.92);
}

/* ==========================================================================
   DARK MODE VARIABLES
   ========================================================================== */
html.dark-mode {
  --brand-900: #eef7ff;
  --brand-800: #d7ebfa;
  --brand-700: #5ba3e0;
  --brand-200: #1b5387;
  --brand-100: #0d2c4f;
  --ink-900: #f7fbff;
  --ink-700: #c2d5e5;
  --ink-500: #88a1b5;
  --line: rgba(255, 255, 255, 0.12);
  --surface: rgba(18, 30, 49, 0.95);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  --bg-gradient: radial-gradient(circle at top left, rgba(27, 116, 181, 0.25), transparent 45%), linear-gradient(180deg, #091321 0%, #0d1a2f 100%);
  --header-bg: rgba(14, 26, 42, 0.85);
  --sidebar-bg: rgba(14, 26, 42, 0.72);
}

html.dark-mode .theme-toggle {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--brand-700);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Dark mode overrides for Tables and Grid components */
html.dark-mode .semester-section {
  background: rgba(13, 26, 42, 0.6) !important;
}

html.dark-mode .semester-section__heading {
  background: linear-gradient(135deg, rgba(27, 116, 181, 0.15), rgba(18, 30, 49, 0.8)) !important;
}

html.dark-mode .curriculum-table th {
  background: #122336 !important;
  color: var(--brand-700) !important;
}

html.dark-mode .curriculum-table td {
  background: rgba(18, 30, 49, 0.4) !important;
  color: var(--ink-700) !important;
}

html.dark-mode .curriculum-table tbody tr:nth-child(even) td {
  background: rgba(13, 26, 42, 0.6) !important;
}

html.dark-mode .curriculum-table tbody tr:hover td {
  background: rgba(27, 116, 181, 0.18) !important;
}

/* Dark mode overrides for Student Profile Grid */
html.dark-mode .student-profile__grid div {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Dark mode overrides for Info Footnotes & Badges */
html.dark-mode .scores-footnote {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--ink-700) !important;
}

html.dark-mode .badge--info {
  background-color: rgba(91, 163, 224, 0.2) !important;
  color: #7ebbf0 !important;
}

html.dark-mode .badge--secondary {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: var(--ink-500) !important;
}

/* Dark mode overrides for Course Link Buttons */
html.dark-mode .course-link-button {
  background: var(--brand-100) !important;
  color: var(--brand-900) !important;
  border: 1px solid var(--line) !important;
}

html.dark-mode .course-link-button:hover {
  background: var(--brand-200) !important;
  color: #fff !important;
}

html.dark-mode .course-link-button--disabled {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--ink-500) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

html.dark-mode .student-profile__edit {
  background: var(--brand-100) !important;
  color: var(--brand-900) !important;
  border: 1px solid var(--line) !important;
}

html.dark-mode .student-profile__edit:hover {
  background: var(--brand-200) !important;
  color: #fff !important;
}

/* ==========================================================================
   RESPONSIVE LAYOUT (MOBILE/TABLET)
   ========================================================================== */
@media (max-width: 991px) {
  .site-sidebar {
    transform: translateX(-100%);
    top: 0;
    height: 100dvh;
    width: 280px !important;
    background: var(--surface);
    box-shadow: 10px 0 30px rgba(0,0,0,0.15);
    z-index: 1050;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  }
  
  .sidebar-brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
  }
  
  .sidebar-close-btn {
    background: none;
    border: none;
    color: var(--ink-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
  }
  
  .sidebar-close-btn:hover {
    background: rgba(15, 61, 109, 0.08);
    color: var(--brand-700);
  }
  
  body.dark-mode .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--brand-700);
  }
  
  .site-sidebar.is-open {
    transform: translateX(0);
  }
  
  .site-sidebar .sidebar-link span,
  .site-sidebar .sidebar-user-info,
  .site-sidebar .btn--logout-vertical > span {
    display: block !important;
  }
  
  .site-sidebar .sidebar-link {
    justify-content: flex-start !important;
    padding: 12px 16px !important;
  }
  
  .site-sidebar .btn--logout-vertical {
    justify-content: flex-start !important;
    padding: 10px 16px !important;
  }
  
  .site-sidebar .sidebar-user {
    justify-content: flex-start !important;
  }

  /* Override accordion collapsed state trong mobile — luôn hiện group headers + labels */
  .site-sidebar.collapsed .sidebar-group-header,
  .site-sidebar .sidebar-group-header {
    display: flex !important;
    padding: 10px 14px 4px !important;
    justify-content: space-between !important;
  }
  .site-sidebar.collapsed .sidebar-group-label,
  .site-sidebar .sidebar-group-label {
    display: block !important;
  }
  .site-sidebar.collapsed .sidebar-group-chevron,
  .site-sidebar .sidebar-group-chevron {
    display: block !important;
  }
  .site-sidebar.collapsed .sidebar-group-divider,
  .site-sidebar .sidebar-group-divider {
    display: block !important;
    margin: 4px 6px !important;
  }
  .site-sidebar.collapsed .sidebar-group-items {
    /* Đừng force max-height trên mobile — để accordion JS tự quản lý */
    max-height: 600px;
    opacity: 1;
  }
  
  .content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 14px 16px;
  }
  
  .nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1040;
    display: none;
    transition: opacity 0.3s ease;
  }
  
  .nav-overlay.is-active {
    display: block;
  }

  .site-sidebar .btn--logout-vertical .logout-txt-desktop {
    display: none !important;
  }

  .site-sidebar .btn--logout-vertical .logout-txt-mobile {
    display: inline !important;
  }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS - Tối ưu không gian làm việc đa thiết bị
   ============================================================ */

/* ── Laptop nhỏ (992px – 1366px): Auto-collapse sidebar ── */
@media (min-width: 992px) and (max-width: 1366px) {
  /* Sidebar tự thu gọn về icon-only khi màn hình nhỏ */
  .site-sidebar {
    width: 80px;
  }

  .site-sidebar .sidebar-link span,
  .site-sidebar .sidebar-user-info,
  .site-sidebar .btn--logout-vertical > span {
    display: none;
  }

  .site-sidebar .sidebar-link {
    justify-content: center;
    padding: 12px;
  }

  .site-sidebar .btn--logout-vertical {
    justify-content: center;
    padding: 12px;
    width: 100%;
  }

  .site-sidebar .sidebar-user {
    justify-content: center;
  }

  /* Content wrapper tự mở rộng khi sidebar thu gọn */
  .content-wrapper {
    margin-left: 80px;
    width: calc(100% - 80px);
    padding: 14px 18px;
  }

  /* Khi user bấm nút mở rộng (body.sidebar-expanded): hiện text + thu hẹp content */
  body.sidebar-expanded .site-sidebar {
    width: 260px;
  }

  body.sidebar-expanded .site-sidebar .sidebar-link span,
  body.sidebar-expanded .site-sidebar .sidebar-user-info,
  body.sidebar-expanded .site-sidebar .btn--logout-vertical > span {
    display: block !important;
  }

  body.sidebar-expanded .site-sidebar .sidebar-link {
    justify-content: flex-start !important;
    padding: 12px 16px !important;
  }

  body.sidebar-expanded .site-sidebar .btn--logout-vertical {
    justify-content: flex-start !important;
    padding: 10px 16px !important;
    width: 100%;
  }

  body.sidebar-expanded .site-sidebar .sidebar-user {
    justify-content: flex-start !important;
  }

  body.sidebar-expanded .content-wrapper {
    margin-left: 260px;
    width: calc(100% - 260px);
  }
}

/* ── Tablet Landscape (768px – 1199px): Sidebar drawer + tối đa content ── */
@media (max-width: 1199px) and (min-width: 768px) {
  .site-sidebar {
    transform: translateX(-100%);
    top: 0;
    height: 100dvh;
    width: 280px !important;
    background: var(--surface);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.18);
    z-index: 1050;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  }

  .site-sidebar .sidebar-link span,
  .site-sidebar .sidebar-user-info,
  .site-sidebar .btn--logout-vertical > span {
    display: block !important;
  }

  .site-sidebar .sidebar-link {
    justify-content: flex-start !important;
    padding: 12px 16px !important;
  }

  .site-sidebar .btn--logout-vertical {
    justify-content: flex-start !important;
    padding: 10px 16px !important;
  }

  .site-sidebar .sidebar-user {
    justify-content: flex-start !important;
  }

  .site-sidebar.is-open {
    transform: translateX(0);
  }

  .content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 14px 16px;
  }

  .nav-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1040;
    display: none;
    transition: opacity 0.3s ease;
  }

  .nav-overlay.is-active {
    display: block;
  }

  .sidebar-brand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
  }
}

/* ── Mobile Portrait (< 768px): Full-width content, compact sidebar drawer ── */
@media (max-width: 767px) {
  .site-sidebar {
    transform: translateX(-100%);
    top: 0;
    height: 100dvh;
    width: min(300px, 85vw) !important;
    background: var(--surface);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.22);
    z-index: 1050;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  }

  .site-sidebar .sidebar-link span,
  .site-sidebar .sidebar-user-info,
  .site-sidebar .btn--logout-vertical > span {
    display: block !important;
  }

  .site-sidebar .sidebar-link {
    justify-content: flex-start !important;
    padding: 12px 16px !important;
  }

  .site-sidebar.is-open {
    transform: translateX(0);
  }

  .content-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 12px 14px !important;
  }

  .site-header {
    padding: 10px 14px;
  }

  .brand__text strong {
    font-size: 13px;
  }

  .brand__text small {
    display: none;
  }
}

/* ==========================================================================
   QR CODE BATCH GENERATOR STYLES & PRINT MEDIA RULES
   ========================================================================== */

.qr-admin-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 4px 40px 4px;
}

.page-header-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.page-title-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink-900);
  margin: 0 0 4px 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--ink-600);
  margin: 0;
}

.badge-role {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* 2-Column Responsive Workspace Grid */
.qr-workspace-grid {
  display: grid;
  grid-template-columns: 440px minmax(0, 1fr);
  gap: 24px;
  width: 100%;
}

.qr-config-column,
.qr-output-column {
  min-width: 0;
  width: 100%;
}

@media (max-width: 1280px) {
  .qr-workspace-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 0;
}

.card-header-bar {
  padding: 14px 20px;
  background: rgba(241, 245, 249, 0.6);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--brand-800);
  flex-wrap: wrap;
}

.dark-mode .card-header-bar {
  background: rgba(30, 41, 59, 0.6);
  color: #38bdf8;
}

.card-header-bar h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.card-body {
  padding: 20px;
}

.form-row-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.form-row-2col > * {
  min-width: 0;
}

@media (max-width: 540px) {
  .form-row-2col {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.form-group label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--ink-700);
}

.form-select, .form-input, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-900);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-select:focus, .form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.highlight-select {
  border-color: #2563eb;
  font-weight: 700;
  color: #1e40af;
}

.dark-mode .highlight-select {
  color: #60a5fa;
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-input {
  width: 40px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: transparent;
}

.color-text {
  font-family: monospace;
  font-weight: 600;
}

.input-hint {
  font-size: 0.8rem;
  color: var(--ink-600);
  margin-top: 0;
  margin-bottom: 12px;
  line-height: 1.5;
}

.input-hint code {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.775rem;
}

.input-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.btn-secondary-sm,
.file-upload-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  height: 34px;
  margin: 0;
  box-sizing: border-box;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid var(--line);
  color: var(--ink-700);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  user-select: none;
}

.header-left-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.btn-secondary-sm:hover {
  background: #e2e8f0;
  color: var(--ink-900);
}

.dark-mode .btn-secondary-sm {
  background: #1e293b;
  color: #cbd5e1;
}

.dark-mode .btn-secondary-sm:hover {
  background: #334155;
}

.file-upload-label {
  cursor: pointer;
}

.generate-btn-wrapper {
  margin-top: 16px;
}

.btn-primary-lg {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary-lg:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
}

/* Output Panel Styles */
.output-header {
  justify-content: space-between;
}

.header-left-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-toggle {
  display: flex;
  background: var(--line);
  border-radius: 8px;
  padding: 2px;
}

.btn-toggle {
  padding: 5px 12px;
  font-size: 0.775rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink-600);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-toggle.active {
  background: var(--surface);
  color: #2563eb;
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.output-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-print {
  background: #059669;
  color: #fff;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.25);
  transition: background 0.2s;
}
.btn-print:hover:not(:disabled) { background: #047857; }

.btn-export-html {
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
  transition: background 0.2s;
}
.btn-export-html:hover:not(:disabled) { background: #1d4ed8; }

.btn-export-csv {
  background: #475569;
  color: #fff;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}
.btn-export-csv:hover:not(:disabled) { background: #334155; }

.output-toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.empty-state-box {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-600);
}

.empty-state-box p {
  margin-top: 16px;
  font-size: 0.95rem;
}

/* Printable QR Grid */
.qr-print-grid {
  display: grid;
  gap: 16px;
  margin-top: 10px;
}

.qr-print-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.qr-print-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.qr-print-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.qr-print-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.qr-print-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.qr-print-grid.cols-8 { grid-template-columns: repeat(8, 1fr); }
.qr-print-grid.cols-10 { grid-template-columns: repeat(10, 1fr); }

@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.qr-skeleton-card {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s infinite linear;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  min-height: 220px;
  pointer-events: none;
}

@media (max-width: 640px) {
  .qr-print-grid.cols-3,
  .qr-print-grid.cols-4,
  .qr-print-grid.cols-5,
  .qr-print-grid.cols-6,
  .qr-print-grid.cols-8,
  .qr-print-grid.cols-10 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.qr-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  page-break-inside: avoid;
  break-inside: avoid;
}

.qr-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.qr-card-img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.qr-card-label {
  font-weight: 600;
  color: #1e293b;
  text-align: center;
  word-break: break-word;
  line-height: 1.35;
}

.qr-card.pos-bottom .qr-card-label { margin-top: 8px; }
.qr-card.pos-top .qr-card-label { margin-bottom: 8px; }

/* QR Data Table */
.qr-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.qr-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.qr-data-table th, .qr-data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.qr-data-table th {
  background: rgba(241, 245, 249, 0.8);
  font-weight: 700;
  color: var(--ink-800);
}

.dark-mode .qr-data-table th {
  background: #1e293b;
  color: #e2e8f0;
}

.code-content-cell code {
  background: rgba(148, 163, 184, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: monospace;
}

.btn-download-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  transition: background 0.2s;
}

.btn-download-icon:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Cable Tag Flap & 1D Barcode Extension Styles */
.cable-tag-config-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(241, 245, 249, 0.6);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.dark-mode .cable-tag-config-box {
  background: rgba(30, 41, 59, 0.5);
}

.form-group-checkbox {
  display: flex;
  align-items: center;
}

.checkbox-label {
  cursor: pointer;
  user-select: none;
  font-size: 0.875rem;
  color: var(--ink-800);
}

.cable-flap-strip {
  width: 100%;
  padding: 6px;
  box-sizing: border-box;
  background: rgba(248, 250, 252, 0.95);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  border: 1.5px dashed #cbd5e1;
  overflow: hidden;
}

.qr-card.flap-bottom .cable-flap-strip,
.cable-flap-strip.flap-pos-bottom {
  margin-bottom: 0;
  margin-top: 10px;
}

.fold-line-dash {
  font-size: 0.675rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 4px 0;
  text-align: center;
  width: 100%;
  border-top: 1px dashed #94a3b8;
  padding-top: 3px;
}

.cable-flap-strip.flap-pos-top .fold-line-dash {
  border-top: 1px dashed #94a3b8;
  border-bottom: none;
  margin-top: 6px;
}

.cable-flap-strip.flap-pos-bottom .fold-line-dash {
  border-bottom: 1px dashed #94a3b8;
  border-top: none;
  margin-bottom: 6px;
}

.flap-barcode-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.flap-barcode-container.orient-vertical {
  transform: rotate(-90deg);
  transform-origin: center center;
  padding: 8px 0;
  margin: 4px 0;
}

.flap-barcode-text {
  font-family: monospace;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 2px;
  text-align: center;
}

/* PRINT MEDIA RULES FOR A4 IMPRESSION */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .site-header, .site-sidebar, .page-header-card, .qr-config-column, .output-toolbar, .view-mode-toggle, .qr-table-wrapper {
    display: none !important;
  }

  .layout-body, .content-wrapper, .qr-admin-container, .qr-workspace-grid, .output-panel, .output-body {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }

  .card-header-bar { display: none !important; }

  #qrGridPreview {
    display: grid !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .qr-card {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .cable-flap-strip {
    background: #ffffff !important;
    border-color: #64748b !important;
  }
}
