/* ==========================================================================
   CSS STYLESHEET - STUDENT ID CARD REVIEW & PRINT SYSTEM
   Exact Phôi Gốc: phoi-the.jpg (300 DPI)
   Fonts: Be Vietnam Pro from local /font/
   ========================================================================== */

/* 1. Local Font Setup: Be Vietnam Pro */
@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('font/BeVietnamPro-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('font/BeVietnamPro-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('font/BeVietnamPro-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('font/BeVietnamPro-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  src: url('font/BeVietnamPro-ExtraBold.ttf') format('truetype');
  font-weight: 800;
  font-style: normal;
}

:root {
  --primary: #255EAB;
  --primary-hover: #1d4b88;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 94, 171, 0.25);

  --accent-blue: #255EAB;
  --pill-bg: #005fa8;
  --text-dark: #27364B;

  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;

  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-base: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-main);
  color: #0f172a;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 24px 32px;
  min-height: 100vh;
}

.app-container {
  max-width: 1540px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  padding: 20px 28px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

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

.brand-logo {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #255EAB 0%, #1e40af 100%);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 94, 171, 0.3);
}

.badge-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: #dbeafe;
  color: #1e40af;
  margin-bottom: 4px;
}

.header-brand h1 {
  font-size: 23px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.3px;
}

.header-brand .subtitle {
  font-size: 13.5px;
  color: #64748b;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.header-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Scope Navigation Tabs (Danh Sách Chính vs Danh Sách Bổ Sung) */
.scope-nav-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  background: #ffffff;
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}

.scope-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-base);
  user-select: none;
}

.scope-nav-btn:hover {
  color: #1e293b;
  background: #f1f5f9;
}

.scope-nav-btn.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
}

.scope-nav-btn svg {
  flex-shrink: 0;
}

/* Buttons & Labels - All buttons and labels must be nowrap */
.btn, button, .view-btn, .filter-chip, .action-icon-btn, .modal-close-btn, .btn-nav-arrow, .modal-side-arrow, label, .badge-pill, .canva-tool-label, .canva-toggle-label {
  white-space: nowrap !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  font-family: var(--font-base);
  text-decoration: none;
  white-space: nowrap !important;
}

.btn svg {
  flex-shrink: 0;
}

/* Floating CTA Dock at Bottom Right */
.floating-cta-dock {
  position: fixed;
  bottom: 24px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 8px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 1050;
  transition: all 0.2s ease;
}

.floating-cta-dock:hover {
  box-shadow: 0 14px 28px -4px rgba(0, 0, 0, 0.2), 0 6px 10px -2px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.floating-cta-dock .btn {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-full);
}

.btn-primary {
  background: linear-gradient(135deg, #255EAB, #1d4b88);
  color: #fff;
  box-shadow: 0 3px 8px rgba(37, 94, 171, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d4b88, #163866);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #fff;
  color: #334155;
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-pdf {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.25);
}
.btn-pdf:hover {
  background: #b91c1c;
}

.btn-add-student {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
}
.btn-add-student:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

.action-icon-btn.btn-delete-student {
  color: #ef4444;
}
.action-icon-btn.btn-delete-student:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}

.btn-excel {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
  box-shadow: 0 3px 8px rgba(22, 163, 74, 0.25);
}
.btn-excel:hover {
  background: #15803d;
  border-color: #15803d;
  transform: translateY(-1px);
}

.btn-outline-success {
  background: #fff;
  color: var(--success);
  border-color: #a7f3d0;
}
.btn-outline-success:hover {
  background: #ecfdf5;
  border-color: var(--success);
}

.btn-amber {
  background: #f59e0b;
  color: #fff;
}
.btn-amber:hover {
  background: #d97706;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 4px;
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card.stat-alert {
  border-color: #fcd34d;
  background: linear-gradient(to right, #fffbeb, #ffffff);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-blue { background: #eff6ff; color: #255EAB; }
.icon-green { background: #ecfdf5; color: #059669; }
.icon-amber { background: #fffbeb; color: #d97706; }
.icon-purple { background: #faf5ff; color: #7c3aed; }
.icon-teal { background: #f0fdfa; color: #0d9488; }

.stat-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 500;
  color: #64748b;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  margin: 2px 0;
}

.stat-sub {
  font-size: 11.5px;
  color: #64748b;
}

.text-success { color: #059669 !important; font-weight: 600; }
.text-warning { color: #d97706 !important; font-weight: 600; }
.text-danger { color: #dc2626 !important; font-weight: 600; }
.text-primary { color: #255EAB !important; font-weight: 600; }

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  margin-top: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  transition: width 0.3s ease;
}

/* Alert Banner */
.alert-banner {
  background: linear-gradient(90deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-left: 5px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}

.alert-icon {
  color: #d97706;
  flex-shrink: 0;
}

.alert-content {
  font-size: 13.5px;
  color: #92400e;
  flex: 1;
}

/* Toolbar */
.toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.toolbar-left, .toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: #94a3b8;
  pointer-events: none;
}

.search-box input {
  padding: 9px 36px 9px 38px;
  font-size: 13.5px;
  font-family: var(--font-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 320px;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.search-box input:focus {
  outline: none;
  background: #fff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  background: #f1f5f9;
  border: 1px solid transparent;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #475569;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-base);
}

.filter-chip:hover {
  background: #e2e8f0;
}

.filter-chip.active {
  background: #255EAB;
  color: #fff;
  font-weight: 600;
}

.view-switch {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #64748b;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-base);
}

.view-btn.active {
  background: #fff;
  color: #0f172a;
  box-shadow: var(--shadow-sm);
}

/* View Sections */
.view-section {
  display: none;
}
.view-section.active {
  display: block;
}

/* Table View */
.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.students-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.students-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.students-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.students-table tbody tr {
  transition: background-color 0.12s ease;
}

.students-table tbody tr:hover {
  background-color: #f8fafc;
}

.students-table tr.row-missing {
  background-color: #fffbeb !important;
}
.students-table tr.row-approved {
  background-color: #fcfdfc;
}

.text-center { text-align: center; }

/* Table avatar cell */
.table-avatar-cell {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.table-avatar {
  width: 48px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1.5pt solid #255EAB;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
  display: block;
  transition: transform 0.15s ease;
}

.table-avatar:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.table-avatar-missing {
  width: 48px;
  height: 60px;
  border-radius: 4px;
  border: 1.5px dashed #f59e0b;
  background: #fef3c7;
  color: #d97706;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  padding: 2px;
}

.student-name-bold {
  font-weight: 700;
  font-size: 14.5px;
  color: #0f172a;
}

.student-code-badge {
  font-family: var(--font-base);
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  color: #255EAB;
  font-size: 13px;
}

.qty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: #eff6ff;
  color: #255EAB;
  font-weight: 700;
  border-radius: var(--radius-full);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-gray    { background: #f1f5f9; color: #475569; }

.status-select {
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: var(--font-base);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  cursor: pointer;
  width: 100%;
}
.status-select.approved { border-color: #10b981; color: #065f46; font-weight: 600; }
.status-select.pending { border-color: #cbd5e1; color: #475569; }
.status-select.flagged { border-color: #f59e0b; color: #92400e; font-weight: 600; }

.note-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12.5px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  font-family: var(--font-base);
}
.note-input:hover { background: #f8fafc; border-color: #e2e8f0; }
.note-input:focus { background: #fff; border-color: var(--border-focus); outline: none; }

.actions-cell {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.action-icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: #fff;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
  transition: all 0.12s ease;
}
.action-icon-btn:hover { background: #f1f5f9; color: #0f172a; }
.action-icon-btn.btn-warn-upload { border-color: #f59e0b; color: #d97706; background: #fffbeb; }

/* ==========================================================================
   EXACT STUDENT ID CARD ACCORDING TO PHOI-THE.JPG SPECIFICATION
   ========================================================================== */

.cards-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 12px 18px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.cards-tip {
  font-size: 13.5px;
  color: #334155;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 28px;
  justify-items: center;
}

.student-card-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 440px;
}

/* Card Mockup: 1024 x 628 ratio (~ 440px x 269.8px) */
.id-card-exact {
  width: 440px;
  height: 269.8px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.15), 0 8px 10px -6px rgba(0,0,0,0.06);
  border: 1px solid #cbd5e1;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  background: #ffffff;
}

.id-card-exact:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 30px -6px rgba(0,0,0,0.22);
}

.id-card-exact img.card-full-img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* Dynamic card fallback */
.id-card-exact.card-dynamic-template {
  background-image: url('phoi-the.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center center;
}

.id-card-exact.card-dynamic-template-phoi2 {
  background-image: url('phoi2.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: center center;
}

.card-dynamic-template-phoi2 .card-exact-photo-wrap {
  border-color: #b91c1c;
}

.card-name-phoi2 {
  color: #b91c1c !important;
}

.card-exact-pill-phoi2 {
  background: #b91c1c !important;
  box-shadow: 0 2px 4px rgba(185, 28, 28, 0.25) !important;
}

.card-code-phoi2 {
  color: #b91c1c !important;
}

/* Photo Box: x=49..274, y=230..580 -> Left 4.78%, Top 36.62%, Width 21.97%, Height 55.73% */
.card-exact-photo-wrap {
  position: absolute;
  left: 4.78%;
  top: 36.62%;
  width: 21.97%;
  height: 55.73%;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5pt solid #255EAB; /* Viền 1.5pt màu #255EAB */
  background: #f8fafc;
}

.card-exact-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-exact-photo-missing {
  width: 100%;
  height: 100%;
  background: #fef3c7;
  color: #b45309;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  padding: 4px;
  cursor: pointer;
}

/* Right Content Column: Center X = 662.5 (64.7%) */
.card-exact-info-block {
  position: absolute;
  left: 31%;
  right: 1.5%;
  top: 40.28%; /* y=253 */
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* 1. Student Name: #314F85, Bold, Uppercase. Gap to Pill = 15.5px */
.card-exact-name {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  color: #314F85;
  line-height: 1.1;
  margin-bottom: 15.5px; /* 36px at 1024 scale */
  letter-spacing: -0.2px;
}

/* 2. Pill "THẺ HỌC SINH": Capsule w=175px, h=26.6px, #255EAB. Gap to Class = 9.5px */
.card-exact-pill {
  width: 175px;
  height: 26.6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #255EAB;
  color: #ffffff;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14.2px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 9999px;
  margin-bottom: 9.5px; /* 22px at 1024 scale */
  box-shadow: 0 2px 4px rgba(37, 94, 171, 0.25);
}

/* 3. Class / School Year: #373435, Bold. Gap to Code = 14px */
.card-exact-class {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16.5px;
  font-weight: 700;
  color: #373435;
  line-height: 1.1;
  margin-bottom: 14px; /* 33px at 1024 scale */
}

/* 4. Student Code (MSHS): #314F85, Bold */
.card-exact-code {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #314F85;
  line-height: 1.1;
}

.card-actions-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  padding: 0 4px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal.active { display: flex; }

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1001;
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #64748b;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover {
  color: #0f172a;
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

.modal-dialog.modal-image {
  max-width: 960px;
  width: 96%;
  max-height: 96vh;
  margin: auto;
  overflow: hidden !important; /* Bỏ vertical scroll bar */
  display: flex;
  flex-direction: column;
}

.modal-dialog.modal-image .modal-header {
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.modal-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-header-left h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
}

.modal-header-sub {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  line-height: 1.2;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modal Nav Record Arrows & Counter */
.modal-nav-arrows {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px 4px;
  gap: 2px;
}

.btn-nav-arrow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-nav-arrow svg {
  flex-shrink: 0;
}

.btn-nav-arrow:hover:not(:disabled) {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-nav-arrow:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-nav-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.modal-nav-counter {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  padding: 0 6px;
  min-width: 46px;
  text-align: center;
  user-select: none;
  letter-spacing: 0.3px;
}

/* Floating Side Navigation Arrows on Left & Right */
.modal-dialog.modal-image {
  position: relative;
  overflow: visible !important;
}

.modal-side-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.22);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1050;
}

.modal-side-arrow:hover:not(:disabled) {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  transform: translateY(-50%) scale(1.12);
  box-shadow: 0 8px 26px rgba(37, 99, 235, 0.42);
}

.modal-side-arrow:active:not(:disabled) {
  transform: translateY(-50%) scale(0.95);
}

.modal-side-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.modal-side-prev {
  left: -64px;
}

.modal-side-next {
  right: -64px;
}

@media (max-width: 1120px) {
  .modal-side-prev {
    left: -24px;
  }
  .modal-side-next {
    right: -24px;
  }
}

.modal-dialog.modal-image .modal-body {
  padding: 10px 18px;
  overflow: hidden !important; /* Bỏ vertical scroll bar */
}

.modal-compare-grid {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 20px;
  align-items: start;
  justify-content: center;
  margin-bottom: 0;
}

@media (max-width: 860px) {
  .modal-compare-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

.compare-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.compare-col-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
}

.compare-title {
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.2px;
}

/* AI Auto Align Button */
.btn-ai-auto {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  border: none;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
  transition: all 0.2s ease;
}
.btn-ai-auto:hover {
  background: linear-gradient(135deg, #4338ca, #6d28d9);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.45);
}
.btn-ai-auto:active {
  transform: translateY(0);
}
.btn-ai-auto .ai-sparkle {
  font-size: 13px;
  animation: sparkleGlow 1.5s infinite alternate;
}
@keyframes sparkleGlow {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.15); opacity: 1; }
}

/* Canva Quick Toolbar */
.canva-quick-toolbar {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.canva-tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.canva-tool-label {
  font-weight: 600;
  color: #475569;
  min-width: 58px;
  font-size: 11.5px;
}
.canva-slider {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  accent-color: #7c3aed;
}
.canva-val {
  min-width: 36px;
  text-align: right;
  font-weight: 700;
  color: #334155;
  font-size: 11px;
}
.btn-reset-crop {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.btn-reset-crop:hover {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #94a3b8;
}
.canva-tool-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 5px;
  border-top: 1px dashed #e2e8f0;
}
.btn-outline-info {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.btn-outline-info.active {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
  font-weight: 600;
}
.canva-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap !important;
  user-select: none;
  padding: 3px 8px;
  font-size: 11px;
}
.canva-toggle-label input[type="checkbox"] {
  width: 13px;
  height: 13px;
  cursor: pointer;
  accent-color: #255EAB;
  margin: 0;
}
.bg-sample-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  background: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}
.bg-sample-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.15);
  display: inline-block;
}

/* Canva Stage Wrap */
.canva-stage-wrap {
  width: 100%;
  max-width: 290px;
  aspect-ratio: 480 / 700;
  height: auto;
  position: relative;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.18);
  border: 1.5pt solid #255EAB;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  margin: 0 auto;
}
#canvaCropCanvas {
  width: 100%;
  height: 100%;
  aspect-ratio: 480 / 700;
  object-fit: contain;
  display: block;
  cursor: grab;
}
#canvaCropCanvas.dragging {
  cursor: grabbing;
}

/* Canva Loading Overlay */
.canva-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  gap: 14px;
  padding: 20px;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.canva-loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.canva-spinner-ring {
  width: 44px;
  height: 44px;
  border: 3.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #8b3dff;
  border-right-color: #38bdf8;
  border-radius: 50%;
  animation: canvaSpin 0.75s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}
@keyframes canvaSpin {
  to { transform: rotate(360deg); }
}
.canva-loading-text {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  text-align: center;
  max-width: 90%;
  line-height: 1.4;
}
.canva-hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 6px;
  text-align: center;
  line-height: 1.3;
}
.canva-save-bar {
  margin-top: 8px;
  width: 100%;
}
.btn-success {
  background: #10b981;
  color: #ffffff;
  border: none;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-success:hover {
  background: #059669;
}

/* Mô phỏng Cell 93 x 57 mm có viền trắng bao quanh thẻ đúng như file in */
.lightbox-card-cell,
.lightbox-card-wrap {
  width: 100%;
  max-width: 540px;
  aspect-ratio: 93 / 57;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1.5pt solid #255EAB;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  padding: 8px 12px;
  box-sizing: border-box;
}

.lightbox-card-inner {
  width: 100%;
  height: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  aspect-ratio: 1004 / 614;
}

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

.lightbox-info { font-size: 14px; color: #334155; line-height: 1.5; }

.drop-zone {
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-md);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.15s ease;
  margin: 16px 0;
}
.drop-zone:hover { border-color: #255EAB; background: #eff6ff; }
.drop-zone svg { color: #64748b; margin-bottom: 8px; }

.preview-uploaded { text-align: center; margin-top: 12px; }
.preview-uploaded img {
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5pt solid #255EAB;
  margin-top: 6px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--font-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.print-summary-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
}
.print-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13.5px;
}

/* ==========================================================================
   PRINT MEDIA - EXACT CARD SIZING ON A4
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-header,
  .stats-row,
  .alert-banner,
  .toolbar,
  .cards-toolbar,
  .card-actions-bar,
  .table-container,
  .floating-cta-dock,
  .modal {
    display: none !important;
  }

  .main-content { display: none !important; }

  .print-container {
    display: block !important;
  }

  .print-page {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    padding: 6mm 12mm;
    margin: 0 auto;
    page-break-after: always;
    break-after: page;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(2, 93mm);
    grid-template-rows: repeat(5, 57mm);
    grid-gap: 0;
    justify-content: center;
    align-content: center;
  }

  .print-card-box {
    width: 93mm;
    height: 57mm;
    box-sizing: border-box;
    page-break-inside: avoid;
    break-inside: avoid;
    position: relative;
    border: 0.5pt solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }

  .print-card-box .id-card-exact {
    width: 90mm !important;
    height: 55.161mm !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    margin: auto !important;
    flex-shrink: 0 !important;
  }
}

/* ==========================================================================
   Export PDF Progress Modal Styles
   ========================================================================== */
@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin-slow {
  animation: spinSlow 2.5s linear infinite;
}

@keyframes progressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.export-progress-container {
  width: 100%;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.export-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.export-progress-shimmer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.45) 50%,
    rgba(255,255,255,0) 100%
  );
  animation: progressShimmer 1.8s infinite;
}

