html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

:root {
  --app-bg: #f3f3f3;
  --app-panel: #ffffff;
  --app-border: #dfe3e8;
  --app-text: #1f2937;
  --app-muted: #6b7280;
  --app-accent: #0d6efd;
  --app-danger: #b91c1c;
  --app-danger-soft: #fdecea;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.app-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.app-header-inner {
  max-width: 1550px;
  margin: 0 auto;
  padding: 0.35rem 1rem;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  flex-shrink: 0;
  color: #1e293b !important;
}

.app-brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.08));
}

.app-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.app-brand-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e3a8a;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.app-brand-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
  white-space: nowrap;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff7b54, #d92d4d);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-nav .nav-item {
  white-space: nowrap;
}

.app-nav .nav-link {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  color: #475569 !important;
  font-size: 0.88rem !important;
  font-weight: 500 !important;
  padding: 0.45rem 0.8rem !important;
  border-radius: 8px !important;
  border: 1px solid transparent !important;
  background: transparent;
  white-space: nowrap !important;
  transition: all 0.18s ease-in-out;
  text-decoration: none;
  line-height: 1.4;
}

.app-nav .nav-link:hover {
  color: #0f172a !important;
  background: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
}

.app-nav .nav-link:hover .nav-icon {
  color: #2563eb;
  transform: scale(1.1);
}

.app-nav .nav-link.active {
  color: #1d4ed8 !important;
  font-weight: 600 !important;
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.06);
}

.app-nav .nav-link.active .nav-icon {
  color: #2563eb;
}

.nav-icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.1;
  color: #64748b;
  transition: transform 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
}

.app-user-block {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  padding-left: 0.85rem;
  border-left: 1px solid #e2e8f0;
}

.user-avatar-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  color: #1e293b;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
}

.user-avatar-badge svg {
  color: #2563eb;
  flex-shrink: 0;
}

.user-greeting {
  color: #1e293b;
  font-size: 0.86rem;
  font-weight: 600;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 8px;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-logout:hover {
  color: #ffffff;
  background: #dc2626;
  border-color: #dc2626;
}

.app-advance-year-item form { margin: 0; }
.app-advance-year-button {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

@media (max-width: 1199.98px) {
  .app-header-inner {
    flex-wrap: wrap;
  }

  .app-brand {
    gap: 0.55rem;
  }

  .app-brand-logo {
    width: 36px !important;
    height: 36px !important;
  }

  .app-brand-title {
    font-size: 0.88rem;
  }

  .app-brand-subtitle {
    font-size: 0.6rem;
  }

  .app-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.75rem 0 0.5rem;
  }

  .app-nav .nav-link {
    width: 100%;
    padding: 0.6rem 0.85rem !important;
  }

  .app-user-block {
    border-left: 0;
    border-top: 1px solid #e2e8f0;
    padding-top: 0.65rem;
    padding-left: 0;
    margin-top: 0.35rem;
    justify-content: space-between;
    width: 100%;
  }

  .navbar-toggler {
    border-color: var(--app-border);
    padding: 0.35rem 0.55rem;
  }

  .app-nav-collapse {
    border-top: 1px solid var(--app-border);
    flex-basis: 100%;
    margin-top: 0.45rem;
  }
    order: 4;
    padding-top: 0.4rem;
    width: 100%;
  }

  .app-nav {
    gap: 0.2rem;
    padding-bottom: 0.25rem;
  }

  .app-nav .nav-link {
    border-bottom: 0;
    border-left: 3px solid transparent;
    border-radius: 0.35rem;
    padding: 0.6rem 0.75rem;
  }

  .app-nav .nav-link:hover,
  .app-nav .nav-link.active {
    border-bottom-color: transparent;
    border-left-color: #d92d4d;
  }
}

.app-shell {
  max-width: 1320px;
  margin-top: 1.2rem;
  min-height: calc(100vh - 140px);
}

.card {
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
}

.table {
  margin-bottom: 0;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  table-layout: fixed;
}

.dashboard-table thead th {
  background: #f3f4f6;
  color: #2d3748;
  font-weight: 700;
  padding: 0.9rem 0.65rem;
  border: 1px solid var(--app-border);
  text-align: center;
  vertical-align: middle;
  line-height: 1.3;
}

.dashboard-table tbody td,
.dashboard-table tfoot td {
  padding: 0.75rem 0.65rem;
  border: 1px solid var(--app-border);
  vertical-align: middle;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.35;
}

.dashboard-table thead th.col-stt,
.dashboard-table tbody td.col-stt,
.dashboard-table tfoot td.col-stt {
  width: 50px;
  text-align: center;
}

.dashboard-table thead th:nth-child(2),
.dashboard-table tbody td:nth-child(2),
.dashboard-table tfoot td:nth-child(2) {
  width: 25%;
  text-align: left;
}

.dashboard-table thead th.col-stat-tier,
.dashboard-table tbody td.col-stat-tier,
.dashboard-table tfoot td.col-stat-tier {
  width: 14%;
  text-align: center;
}

.tier-full {
  display: inline;
}

.tier-short {
  display: none;
}

.dashboard-table thead th:nth-child(2),
.dashboard-table tbody td:nth-child(2),
.dashboard-table tfoot td:nth-child(2) {
  text-align: left;
}

.dashboard-table thead th:nth-child(n + 3),
.dashboard-table tbody td:nth-child(n + 3),
.dashboard-table tfoot td:nth-child(n + 3) {
  text-align: center;
}

.dashboard-table .statistics-number {
  text-align: center !important;
}

.statistics-table thead th,
.statistics-table tbody td,
.statistics-table tfoot td {
  text-align: center !important;
}

.statistics-table thead th:nth-child(2),
.statistics-table tbody td:nth-child(2),
.statistics-table tfoot td:nth-child(2) {
  text-align: left !important;
}

.statistics-table tbody td:last-child {
  color: #b71c1c !important;
  font-weight: 700 !important;
}

.dashboard-table tbody tr:hover {
  background: #f8fafc;
}

.dashboard-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.grand-total-row,
.grand-total-row td,
.grand-total-row th {
  background: #fff1f2 !important;
  color: #b71c1c !important;
  font-weight: 700 !important;
}

.grand-total-cell {
  font-weight: 700 !important;
  color: #b71c1c !important;
}

.page-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-muted);
  font-weight: 700;
}

.page-title {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-card {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  padding: 0;
  overflow: hidden;
}

.panel-card-header {
  padding: 1rem 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid var(--app-border);
}

.panel-card .table-wrap {
  border: none;
  border-radius: 0;
}

/* --- Filter Panel --- */
.filter-panel {
  background: #ffffff;
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  padding: 1.25rem 1.5rem;
}

.filter-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
  margin-bottom: 1rem;
}

.filter-header svg {
  color: #0284c7;
}

.filter-panel .form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}

.filter-panel .form-select,
.filter-panel .form-control {
  height: 42px;
  font-size: 0.92rem;
  border-color: #cbd5e1;
  background-color: #f8fafc;
  transition: all 0.2s ease;
}

.filter-panel .form-select:focus,
.filter-panel .form-control:focus {
  background-color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn-filter-submit {
  height: 42px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: none;
  color: #ffffff;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.btn-filter-submit:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  transform: translateY(-1px);
}

.btn-filter-reset {
  height: 42px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  padding: 0 0.85rem;
}

.btn-filter-reset:hover {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #94a3b8;
}

.btn-export-excel {
  height: 42px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  border: none;
  color: #ffffff !important;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
  text-decoration: none;
  padding: 0 1rem;
}

.btn-export-excel:hover {
  background: linear-gradient(135deg, #15803d, #166534);
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
  transform: translateY(-1px);
}

.verification-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  flex-shrink: 0;
  vertical-align: middle;
  transition: transform 0.15s ease;
}

.verification-icon:hover {
  transform: scale(1.25);
}

.verification-icon.text-danger svg {
  filter: drop-shadow(0 1px 2px rgba(220, 38, 38, 0.35));
}

.verification-icon.text-success svg {
  filter: drop-shadow(0 1px 2px rgba(22, 163, 74, 0.35));
}

.verification-icon.text-warning svg {
  filter: drop-shadow(0 1px 2px rgba(245, 158, 11, 0.35));
}

.verification-icon.text-muted svg {
  filter: drop-shadow(0 1px 2px rgba(100, 116, 139, 0.25));
}

/* --- Table Counter & Header --- */
.table-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid var(--app-border);
}

.result-count-badge {
  font-size: 0.88rem;
  color: #475569;
  font-weight: 500;
}

.result-count-badge strong {
  color: #0f172a;
  font-weight: 700;
}

/* --- Student Table --- */
.student-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.student-table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.7rem 0.65rem;
  border-bottom: 2px solid #e2e8f0;
  vertical-align: middle;
  white-space: nowrap;
}

.student-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.15s ease;
}

.student-table tbody tr:last-child {
  border-bottom: none;
}

.student-table tbody tr:hover {
  background-color: #f8fafc;
}

.student-table tbody td {
  padding: 0.65rem 0.65rem;
  vertical-align: middle;
  font-size: 0.9rem;
  color: #334155;
}

/* Specific Column Styling */
.student-table .col-name {
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
}

.student-table .col-he {
  color: #475569;
  white-space: nowrap;
  font-size: 0.85rem;
}

.student-table .col-nghe {
  color: #334155;
  font-size: 0.88rem;
}

.student-table .col-manghe {
  text-align: center;
  white-space: nowrap;
}

.student-table .col-nghecu {
  color: #475569;
  font-size: 0.85rem;
}

.student-table .col-mahoso {
  text-align: center;
  white-space: nowrap;
}

.student-table .col-actions {
  text-align: center;
  white-space: nowrap;
}

/* Badges */
.code-badge-nghe {
  font-family: SFMono-Regular, Consolas, Monaco, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.2rem 0.45rem;
  border-radius: 0.35rem;
  display: inline-block;
}

.code-badge-nghe-cu {
  font-family: SFMono-Regular, Consolas, Monaco, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #ffedd5;
  padding: 0.15rem 0.4rem;
  border-radius: 0.35rem;
  display: inline-block;
}

.code-badge-dossier {
  font-family: SFMono-Regular, Consolas, Monaco, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: #0284c7;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  display: inline-block;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.06);
}

/* Action Group & Buttons */
.action-btn-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* --- Permissions Table --- */
.permission-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.permission-table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.75rem 0.85rem;
  border-bottom: 2px solid #e2e8f0;
  vertical-align: middle;
  white-space: nowrap;
}

.permission-table tbody td {
  padding: 0.75rem 0.85rem;
  vertical-align: middle;
  font-size: 0.9rem;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
}

.permission-table tbody tr:hover {
  background-color: #f8fafc;
}

.permission-table .col-stt {
  width: 50px;
  text-align: center;
}

.permission-table .col-username {
  width: 15%;
  font-weight: 600;
  color: #0f172a;
}

.permission-table .col-fullname {
  width: 18%;
  color: #334155;
}

.permission-table .col-current-role {
  width: 14%;
  white-space: nowrap;
}

.permission-table .col-description {
  color: #64748b;
  font-size: 0.86rem;
  line-height: 1.35;
}

.permission-table .col-action {
  width: 230px;
  white-space: nowrap;
  text-align: left;
}

.permission-table .col-action .form-select-sm {
  width: 135px;
  font-size: 0.85rem;
}

.btn-action {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.28rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  line-height: 1;
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-action-edit-name {
  background-color: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

.btn-action-edit-name:hover {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-action-edit-code {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.btn-action-edit-code:hover {
  background-color: #059669;
  color: #ffffff;
  border-color: #059669;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.btn-action-delete {
  background-color: #fff1f2;
  color: #e11d48;
  border-color: #fecdd3;
}

.btn-action-delete:hover {
  background-color: #e11d48;
  color: #ffffff;
  border-color: #e11d48;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.25);
}

/* Empty state */
.empty-table-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: #64748b;
}

/* --- Group Header Row for Dashboard --- */
.group-header-row,
.group-header-cell {
  background-color: #a4c2f4 !important;
  color: #0f172a !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  padding: 0.75rem 1rem !important;
  border-top: 2px solid #85aee6 !important;
  border-bottom: 2px solid #85aee6 !important;
  text-align: left !important;
}

.empty-table-state svg {
  color: #94a3b8;
  margin-bottom: 0.75rem;
}

.empty-table-state h5 {
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.3rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--app-border);
  border-radius: 1rem;
}

.legacy-form-wrap {
  max-width: 900px;
  padding: 1.5rem;
}

.legacy-form .form-label {
  font-weight: 600;
  color: #2f2f2f;
  margin-bottom: 0.5rem;
}

.legacy-form .form-control,
.legacy-form .form-select {
  height: 42px;
  border: 1px solid #d9dfe5;
  background: #fff;
}

.mahoso-output-box {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid #d92d4d;
  background: #fff5f6;
  color: #b71c1c;
  font-weight: 700;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

/* --- Online Users Block & Live Animations --- */
.online-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #10b981;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-green {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.action-row {
  justify-content: flex-start;
}

.btn-primary-custom {
  background: #d92d4d;
  border-color: #d92d4d;
  color: #fff;
}

.btn-primary-custom:hover {
  background: #c52443;
  border-color: #c52443;
}

.btn-cancel-ma {
  background: #d92d4d;
  border: 1px solid #d92d4d;
  color: #fff;
  min-width: 120px;
  font-weight: 600;
  border-radius: 0.55rem;
  padding: 0.7rem 1.25rem;
  transition: all 0.2s ease;
}

.btn-cancel-ma:hover {
  background: #c52443;
  border-color: #c52443;
  color: #fff;
}

.btn-secondary-custom {
  border-color: #b6bcc6;
  color: #374151;
}

.table-wrap {
  overflow: auto;
}

.stat-card {
  background: linear-gradient(135deg, #ffffff, #f8faff);
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
  padding: 1.15rem 1rem;
  min-height: 120px;
}

.stat-label {
  color: var(--app-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-value {
  margin: 0.55rem 0 0;
  font-weight: 800;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

/* --- Modern Stat Cards & Icons --- */
.modern-stat-card {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 0.75rem;
  box-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.04), 0 2px 4px -1px rgba(15, 23, 42, 0.02);
  padding: 0.75rem 1rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.15rem;
  min-height: auto;
}

.modern-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -4px rgba(15, 23, 42, 0.08), 0 3px 8px -2px rgba(15, 23, 42, 0.03);
  border-color: #cbd5e1;
}

.modern-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}

.stat-card-blue::before { background: linear-gradient(180deg, #0284c7, #38bdf8); }
.stat-card-green::before { background: linear-gradient(180deg, #059669, #34d399); }
.stat-card-amber::before { background: linear-gradient(180deg, #d97706, #fbbf24); }
.stat-card-purple::before { background: linear-gradient(180deg, #7c3aed, #a78bfa); }
.stat-card-rose::before { background: linear-gradient(180deg, #e11d48, #fb7185); }

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.1rem;
}

.stat-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}

.stat-icon-wrapper {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.modern-stat-card:hover .stat-icon-wrapper {
  transform: scale(1.06);
}

.stat-icon-blue {
  background: #eff6ff;
  color: #0284c7;
  border: 1px solid #dbeafe;
}

.stat-icon-green {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #d1fae5;
}

.stat-icon-amber {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fef3c7;
}

.stat-icon-purple {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ede9fe;
}

.stat-icon-rose {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid #ffe4e6;
}

.stat-card-body {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 1.85rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 0.05rem;
}

.stat-role-text {
  font-size: 1.18rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.15;
  margin: 0 0 0.15rem;
}

.stat-subtitle {
  font-size: 0.76rem;
  color: #64748b;
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.35rem;
  margin-top: 0;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 9999px;
  width: fit-content;
}

.role-badge-admin { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.role-badge-bgh { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.role-badge-mod { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.role-badge-tuyensinh { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.role-badge-viewer { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.max-form {
  max-width: 820px;
  padding: 1.75rem 2rem;
}

.max-form .form-label {
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.max-form .form-control,
.max-form .form-select {
  height: 42px;
  font-size: 0.92rem;
  border-color: #cbd5e1;
  background-color: #f8fafc;
  transition: all 0.2s ease;
}

.max-form .form-control:focus,
.max-form .form-select:focus {
  background-color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.max-form .form-control[readonly] {
  background-color: #e2e8f0;
  color: #475569;
  border-color: #cbd5e1;
  cursor: not-allowed;
}

.app-footer {
  background: #ffffff;
  border-top: 1px solid var(--app-border);
  color: var(--app-muted);
  font-size: 0.85rem;
  padding: 1rem 0;
}

.form-control,
.form-select,
.btn {
  border-radius: 0.5rem;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.report-card {
  display: flex;
  flex-direction: column;
  padding: 1.4rem;
}

.report-title {
  color: #1e3a5f;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
}

.trend-periods { display: flex; gap: 0.35rem; }
.trend-department { font-size: 0.78rem; min-width: 145px; }
.trend-period {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 0.4rem;
  color: #475569;
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
}
.trend-period.active { background: #0f6ead; border-color: #0f6ead; color: #fff; }
.trend-chart { min-height: 250px; width: 100%; }
.trend-chart svg { display: block; height: 250px; overflow: visible; width: 100%; }
.trend-grid-line { stroke: #e2e8f0; stroke-width: 1; }
.trend-axis-label { fill: #64748b; font-size: 10px; }
.trend-point { cursor: pointer; stroke: #fff; stroke-width: 1.5; }
.trend-point:hover, .trend-point:focus { r: 7; stroke: #0f172a; stroke-width: 2; outline: none; }
.trend-loading { align-items: center; color: #64748b; display: flex; font-size: 0.9rem; height: 250px; justify-content: center; }
.trend-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 0.85rem; margin-top: 0.3rem; }
.trend-legend span { align-items: center; color: #475569; display: flex; font-size: 0.75rem; gap: 0.3rem; }
.trend-legend i { border-radius: 50%; display: inline-block; height: 8px; width: 8px; }
.legend-cao-dang { background: #1683c5; }
.legend-lien-thong { background: #28a475; }
.legend-trung-cap-15 { background: #e99a26; }
.legend-trung-cap-2 { background: #8b6cc7; }
.trend-detail { background: #f0f7ff; border: 1px solid #c5def2; border-radius: 0.45rem; color: #334155; font-size: 0.82rem; margin-top: auto; padding: 0.6rem 0.75rem; }
.trend-detail strong { color: #0f4f7d; }

.report-flow {
  align-items: center;
  display: flex;
  flex-direction: column;
}

.flow-node {
  background: #f0f7ff;
  border: 1px solid #b9d9f5;
  border-radius: 0.65rem;
  color: #254563;
  display: flex;
  flex-direction: column;
  min-width: 110px;
  padding: 0.65rem 0.8rem;
  text-align: center;
}

.flow-node span { font-size: 0.78rem; }
.flow-node strong { font-size: 1.2rem; }

.flow-node-total {
  background: #0f6ead;
  border-color: #0f6ead;
  color: #fff;
}

.flow-connector {
  border-left: 2px solid #8bbce0;
  height: 24px;
  position: relative;
}

.flow-connector::after {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #8bbce0;
  bottom: -1px;
  content: "";
  left: -6px;
  position: absolute;
}

.flow-targets {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
}

.bar-chart {
  align-items: end;
  border: 1px solid #cbd5e1;
  border-radius: 0.45rem;
  box-sizing: border-box;
  display: flex;
  flex: 1 1 auto;
  min-height: 250px;
  gap: 1rem;
  justify-content: space-around;
  margin-bottom: 0.6rem;
  overflow: hidden;
  padding: 0.75rem 0.75rem 0.5rem;
}

.bar-item {
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100%;
  justify-content: end;
  min-width: 55px;
}

.bar-value { color: #334155; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.35rem; }
.bar-column { align-items: end; border-bottom: 1px solid #94a3b8; display: flex; flex: 1; height: 100%; width: 100%; }
.bar-fill { border-radius: 0.45rem 0.45rem 0 0; height: var(--bar-height); max-height: 100%; min-height: 4px; transition: height 0.25s ease; width: 100%; }
.bar-cao-dang { background: #1683c5; }
.bar-lien-thong { background: #28a475; }
.bar-trung-cap-15 { background: #e99a26; }
.bar-trung-cap-2 { background: #8b6cc7; }
.bar-label { color: #64748b; font-size: 0.75rem; line-height: 1.15; margin-top: 0.5rem; text-align: center; }

.sims-panel-box {
  height: 520px;
}

.sims-panel-box .dashboard-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
}

.sims-panel-box .dashboard-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: #f8fafc;
}

.province-bar-item, .school-bar-item {
  cursor: pointer;
  user-select: none;
}

.province-bar-item:hover, .school-bar-item:hover {
  background-color: #f1f5f9 !important;
}

.province-expand-arrow, .school-expand-arrow {
  transition: transform 0.25s ease;
}

.arrow-rotated {
  transform: rotate(180deg) !important;
}

.province-districts-accordion, .school-detail-accordion {
  animation: fadeInAccordion 0.2s ease-in-out;
}

@keyframes fadeInAccordion {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 991.98px) {
  .sims-panel-box {
    height: auto !important;
    max-height: 550px !important;
  }
}

@media (max-width: 767.98px) {
  .col-stt,
  .dashboard-table thead th.col-stt,
  .dashboard-table tbody td.col-stt,
  .dashboard-table tfoot td.col-stt,
  .statistics-table thead th.col-stt,
  .statistics-table tbody td.col-stt,
  .student-table thead th.col-stt,
  .student-table tbody td.col-stt {
    display: none !important;
  }
  .dashboard-table-toolbar {
    padding: 0.5rem 0.6rem 0.2rem !important;
  }
  .dashboard-table {
    table-layout: fixed !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  .dashboard-table thead th {
    padding: 0.45rem 0.12rem !important;
    font-size: 0.72rem !important;
    line-height: 1.15 !important;
    text-align: center !important;
    vertical-align: middle !important;
    word-break: break-word !important;
  }
  .dashboard-table tbody td,
  .dashboard-table tfoot td {
    padding: 0.38rem 0.12rem !important;
    font-size: 0.75rem !important;
    line-height: 1.25 !important;
  }
  .dashboard-table thead th:nth-child(2),
  .dashboard-table tbody td:nth-child(2),
  .dashboard-table tfoot td:nth-child(2) {
    width: 37% !important;
    min-width: 0 !important;
    text-align: left !important;
    padding-left: 0.35rem !important;
    font-size: 0.74rem !important;
    word-break: break-word !important;
  }
  .dashboard-table thead th.col-stat-tier:nth-child(3),
  .dashboard-table tbody td.col-stat-tier:nth-child(3),
  .dashboard-table tfoot td.col-stat-tier:nth-child(3) {
    width: 12% !important;
    min-width: 0 !important;
    text-align: center !important;
  }
  .dashboard-table thead th.col-stat-tier:nth-child(4),
  .dashboard-table tbody td.col-stat-tier:nth-child(4),
  .dashboard-table tfoot td.col-stat-tier:nth-child(4) {
    width: 13% !important;
    min-width: 0 !important;
    text-align: center !important;
  }
  .dashboard-table thead th.col-stat-tier:nth-child(5),
  .dashboard-table tbody td.col-stat-tier:nth-child(5),
  .dashboard-table tfoot td.col-stat-tier:nth-child(5) {
    width: 13% !important;
    min-width: 0 !important;
    text-align: center !important;
  }
  .dashboard-table thead th.col-stat-tier:nth-child(6),
  .dashboard-table tbody td.col-stat-tier:nth-child(6),
  .dashboard-table tfoot td.col-stat-tier:nth-child(6) {
    width: 11% !important;
    min-width: 0 !important;
    text-align: center !important;
  }
  .dashboard-table thead th.col-stat-tier:nth-child(7),
  .dashboard-table tbody td.col-stat-tier:nth-child(7),
  .dashboard-table tfoot td.col-stat-tier:nth-child(7) {
    width: 14% !important;
    min-width: 0 !important;
    text-align: center !important;
  }
  .dashboard-table tbody td.group-header-cell {
    font-size: 0.76rem !important;
    padding: 0.35rem 0.35rem !important;
    letter-spacing: 0.01em !important;
  }
  .tier-full {
    display: none !important;
  }
  .tier-short {
    display: inline !important;
    font-weight: 700 !important;
  }
  #dashboardTableCaptureArea {
    padding: 0.25rem 0.35rem !important;
  }
  .student-table thead th {
    padding: 0.55rem 0.45rem !important;
    font-size: 0.72rem !important;
  }
  .student-table tbody td {
    padding: 0.48rem 0.45rem !important;
    font-size: 0.82rem !important;
  }
  .student-table .btn-action {
    padding: 0.22rem 0.4rem !important;
    font-size: 0.72rem !important;
  }
}

@media (max-width: 575.98px) {
  .dashboard-table thead th {
    padding: 0.4rem 0.08rem !important;
    font-size: 0.68rem !important;
  }
  .dashboard-table tbody td,
  .dashboard-table tfoot td {
    padding: 0.32rem 0.08rem !important;
    font-size: 0.72rem !important;
  }
  .dashboard-table thead th:nth-child(2),
  .dashboard-table tbody td:nth-child(2),
  .dashboard-table tfoot td:nth-child(2) {
    font-size: 0.72rem !important;
    padding-left: 0.25rem !important;
  }
  .bar-chart { gap: 0.45rem; }
  .flow-targets { grid-template-columns: 1fr; }
  .trend-department { width: 100%; }
}

/* =========================================================
   Export Table to Image Styles (html2canvas)
   ========================================================= */
.export-capture-mode {
  background: #ffffff !important;
  padding: 20px 24px !important;
  border-radius: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
}

.export-capture-mode .table-wrap {
  overflow: visible !important;
  border: 1px solid #d1d5db !important;
  border-radius: 4px !important;
  width: 100% !important;
}

.export-capture-mode .dashboard-table {
  border-collapse: collapse !important;
  width: 100% !important;
  min-width: 100% !important;
  table-layout: fixed !important;
  background-color: #ffffff !important;
}

.export-capture-mode .dashboard-table thead th {
  background-color: #f3f4f6 !important;
  color: #2d3748 !important;
  border: 1px solid #d1d5db !important;
  font-weight: 700 !important;
  padding: 0.75rem 0.85rem !important;
  font-size: 0.95rem !important;
  text-align: center !important;
  vertical-align: middle !important;
}

.export-capture-mode .dashboard-table thead th.col-stt,
.export-capture-mode .dashboard-table tbody td.col-stt,
.export-capture-mode .dashboard-table tfoot td.col-stt {
  display: table-cell !important;
  width: 50px !important;
  text-align: center !important;
}

.export-capture-mode .dashboard-table thead th:nth-child(2),
.export-capture-mode .dashboard-table tbody td:nth-child(2),
.export-capture-mode .dashboard-table tfoot td:nth-child(2) {
  width: 25% !important;
  text-align: left !important;
}

.export-capture-mode .dashboard-table thead th.col-stat-tier,
.export-capture-mode .dashboard-table tbody td.col-stat-tier,
.export-capture-mode .dashboard-table tfoot td.col-stat-tier {
  width: 14% !important;
  text-align: center !important;
}

.export-capture-mode .dashboard-table tbody td {
  border: 1px solid #d1d5db !important;
  padding: 0.7rem 0.85rem !important;
  color: #0f172a !important;
  font-size: 0.95rem !important;
  vertical-align: middle !important;
}

.export-capture-mode .dashboard-table tbody tr:nth-child(even) td:not(.group-header-cell) {
  background-color: #fafbfc !important;
}

.export-capture-mode .dashboard-table tbody tr:nth-child(odd) td:not(.group-header-cell) {
  background-color: #ffffff !important;
}

.export-capture-mode .dashboard-table tbody td.group-header-cell,
.export-capture-mode .group-header-row td,
.export-capture-mode .group-header-cell {
  background-color: #a4c2f4 !important;
  color: #0f172a !important;
  border-top: 2px solid #85aee6 !important;
  border-bottom: 2px solid #85aee6 !important;
  border-left: 1px solid #85aee6 !important;
  border-right: 1px solid #85aee6 !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  padding: 0.7rem 0.85rem !important;
  text-align: left !important;
}

.export-capture-mode .dashboard-table tfoot tr.grand-total-row td,
.export-capture-mode .grand-total-row td,
.export-capture-mode .grand-total-cell {
  background-color: #fff1f2 !important;
  color: #b71c1c !important;
  border: 1px solid #d1d5db !important;
  font-weight: 700 !important;
  font-size: 0.96rem !important;
}

.export-capture-mode .col-stt,
.export-capture-mode .dashboard-table thead th.col-stt,
.export-capture-mode .dashboard-table tbody td.col-stt,
.export-capture-mode .dashboard-table tfoot td.col-stt {
  display: table-cell !important;
  width: 60px !important;
  text-align: center !important;
}

.export-capture-mode .tier-full {
  display: inline !important;
}

.export-capture-mode .tier-short {
  display: none !important;
}
