/* ============================================
   BBQ — National Azan Competition 2026
   Global Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- Design Tokens ---- */
:root {
  --primary:        #2563EB;
  --primary-hover:  #1D4ED8;
  --primary-light:  #EFF6FF;
  --primary-border: #BFDBFE;

  --success:        #059669;
  --success-light:  #ECFDF5;
  --success-border: #A7F3D0;

  --warning:        #D97706;
  --warning-light:  #FFFBEB;
  --warning-border: #FDE68A;

  --danger:         #DC2626;
  --danger-light:   #FEF2F2;
  --danger-border:  #FECACA;

  --gold:           #B45309;
  --gold-light:     #FFFBEB;

  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-disabled:  #CBD5E1;

  --bg:             #F8FAFC;
  --bg-white:       #FFFFFF;
  --bg-hover:       #F1F5F9;
  --bg-active:      #E2E8F0;

  --border:         #E2E8F0;
  --border-strong:  #CBD5E1;

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.07), 0 4px 6px -4px rgb(0 0 0 / 0.07);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl:20px;
  --radius-full:9999px;

  --sidebar-w: 256px;
  --topbar-h:  60px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Prevent any child from making page wider than viewport */
  overflow-x: hidden;
  max-width: 100%;
}
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
}
img, video, iframe, embed { display: block; max-width: 100%; }
svg { display: block; }
/* Flex children min-width fix — prevents content overflow in flex rows */
.portal-main, .page-content, .card, .card-body, .card-header,
.topbar, .sidebar-nav { min-width: 0; }

/* ── Global text overflow protection — all dynamic/user-generated content ── */
body {
  overflow-wrap: break-word;
  word-break: break-word;
}
/* Ensure text containers clip overflow */
.card, .card-body, .modal-body, .alert-body,
.form-group, .upload-zone, td, th, .filter-bar {
  overflow-wrap: break-word;
  word-break: break-word;
}
/* Force ellipsis for single-line text that's constrained */
.topbar-title, .card-title, .badge, .stat-label,
.tab-item, .filter-chip, .step-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
} 
/* But allow multi-line in these */
.card-body, .modal-body, .alert-body, .upload-zone, .form-textarea, textarea {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}
/* Dynamic text: filename, codes, user content — force break on very long words */
#sub-filename, #selected-filename, #sub-filesize,
#admin-comment-text, #reupload-reason, #welcome-code,
.name-display, .candidate-code-display {
  overflow-wrap: break-word;
  word-break: break-all;
  max-width: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, select, textarea { font-family: var(--font); }
ul, ol { list-style: none; }
hr { border: none; border-top: 1px solid var(--border); }

/* ---- Typography ---- */
h1 { font-size: 2rem;   font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3;  letter-spacing: -0.015em; }
h3 { font-size: 1.2rem; font-weight: 600; line-height: 1.4;  letter-spacing: -0.01em; }
h4 { font-size: 1rem;   font-weight: 600; line-height: 1.5; }
h5 { font-size: .875rem;font-weight: 600; line-height: 1.5; }
p  { color: var(--text-secondary); line-height: 1.7; }

.text-xs   { font-size: .75rem; }
.text-sm   { font-size: .875rem; }
.text-base { font-size: 1rem; }
.text-lg   { font-size: 1.125rem; }
.text-xl   { font-size: 1.25rem; }
.text-2xl  { font-size: 1.5rem; }
.text-3xl  { font-size: 1.875rem; }
.text-4xl  { font-size: 2.25rem; }
.text-5xl  { font-size: 3rem; }
.font-normal  { font-weight: 400; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.text-muted   { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.truncate     { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---- Layout Utilities ---- */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: 4px; }  .gap-2 { gap: 8px; }  .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.flex-1 { flex: 1; } .flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.w-full { width: 100%; }
.max-w-xs { max-width: 320px; }
.max-w-sm { max-width: 480px; }
.max-w-md { max-width: 640px; }
.max-w-lg { max-width: 800px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.hidden { display: none !important; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }

/* ---- Spacing ---- */
.p-1 { padding: 4px; }  .p-2 { padding: 8px; }  .p-3 { padding: 12px; }
.p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; }
.px-2 { padding-left: 8px;  padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-6 { padding-left: 24px; padding-right: 24px; }
.py-2 { padding-top: 8px;  padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.mt-1{margin-top:4px} .mt-2{margin-top:8px} .mt-3{margin-top:12px}
.mt-4{margin-top:16px} .mt-6{margin-top:24px} .mt-8{margin-top:32px}
.mb-1{margin-bottom:4px} .mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px}
.mb-4{margin-bottom:16px} .mb-6{margin-bottom:24px} .mb-8{margin-bottom:32px}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 9px 16px; font-size: 14px; font-weight: 500;
  border-radius: var(--radius); line-height: 1;
  transition: all .15s var(--ease); white-space: nowrap;
  border: 1px solid transparent; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); text-decoration: none; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; text-decoration: none; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #047857; text-decoration: none; }
.btn-ghost     { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.btn-link      { color: var(--primary); padding: 0; }
.btn-link:hover{ text-decoration: underline; }
.btn-xs  { padding: 5px 10px; font-size: 12px; }
.btn-sm  { padding: 7px 12px; font-size: 13px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; }
.btn-xl  { padding: 14px 28px; font-size: 16px; font-weight: 600; }
.btn-full{ width: 100%; }
.btn-icon{ padding: 8px; }
.btn-loading::after {
  content: ''; width: 14px; height: 14px; border: 2px solid currentColor;
  border-top-color: transparent; border-radius: 50%;
  animation: spin .6s linear infinite; margin-left: 6px;
}

/* ---- Form Elements ---- */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--text-primary);
  background: #fff; transition: border-color .15s, box-shadow .15s; outline: none;
  font-family: var(--font);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgb(37 99 235 / .1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input.error, .form-select.error { border-color: var(--danger); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
.form-help  { font-size: 12px; color: var(--text-muted); }
.form-error { font-size: 12px; color: var(--danger); }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.input-group { display: flex; }
.input-group .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ---- Cards ---- */
.card {
  background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.card-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-p { padding: 24px; }

/* ---- Stat Cards ---- */
.stat-card {
  background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-xs); padding: 20px 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; line-height: 1; }
.stat-desc  { font-size: 12px; color: var(--text-muted); }
.stat-icon  { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 20px; height: 20px; }

/* ---- Tables ---- */
.table-wrap { border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; background: #fff; }
.table-scroll { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 11px 16px; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
  background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td {
  padding: 13px 16px; font-size: 14px; color: var(--text-primary);
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--bg-hover); cursor: pointer; }
.table.no-hover tbody tr:hover { background: transparent; cursor: default; }
.table-empty { padding: 48px; text-align: center; color: var(--text-muted); }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text-primary); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; font-size: 12px; font-weight: 500; border-radius: var(--radius-full);
  border: 1px solid transparent; white-space: nowrap;
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-default { background: var(--bg-active); color: var(--text-secondary); border-color: var(--border); }
.badge-primary { background: var(--primary-light); color: var(--primary); border-color: var(--primary-border); }
.badge-success { background: var(--success-light); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning-border); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  border-color: var(--danger-border); }
.badge-gold    { background: #FEF3C7; color: var(--gold); border-color: #FDE68A; }

/* ---- Portal Layout ---- */
.portal-body { background: var(--bg); }
.portal-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); height: 100vh; background: #fff;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: transform .25s var(--ease);
}
.sidebar-header {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-mark {
  width: 36px; height: 36px; border-radius: var(--radius);
  overflow: hidden; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.sidebar-logo .logo-mark img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.sidebar-logo .logo-sub  { font-size: 11px; color: var(--text-muted); }
.sidebar-nav { padding: 12px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar-section { padding: 8px 10px 4px; font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .1em; }
.sidebar-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  color: var(--text-secondary); transition: all .15s; cursor: pointer;
  text-decoration: none !important;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active { background: var(--primary-light); color: var(--primary); }
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item .badge { margin-left: auto; }
.sidebar-divider { border-top: 1px solid var(--border); margin: 8px 0; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.sidebar-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.sidebar-user .user-info .name  { font-size: 13px; font-weight: 600; }
.sidebar-user .user-info .email { font-size: 11px; color: var(--text-muted); }

.portal-main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.page-content { padding: 24px; flex: 1; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; }
.page-header p  { margin-top: 4px; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgb(0 0 0 / .5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; backdrop-filter: blur(4px);
  animation: fadeIn .15s var(--ease);
}
.modal {
  background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  animation: slideUp .2s var(--ease);
}
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-header { padding: 20px 24px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all .15s; cursor: pointer; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Toasts ---- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--text-primary); color: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  animation: slideInRight .25s var(--ease); min-width: 280px; max-width: 400px;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info    { background: var(--primary); }
.toast-exit    { animation: slideOutRight .25s var(--ease) forwards; }

/* ---- Loading States ---- */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: skeleton 1.2s infinite;
  border-radius: var(--radius-sm);
}
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
.spinner-lg { width: 36px; height: 36px; border-width: 3px; }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 48px; gap: 12px; color: var(--text-muted); }

/* ---- Empty States ---- */
.empty-state { padding: 48px 24px; text-align: center; }
.empty-state-icon { width: 56px; height: 56px; background: var(--bg); border-radius: var(--radius-xl); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.empty-state-icon svg { width: 28px; height: 28px; color: var(--text-muted); }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }

/* ---- Tabs ---- */
.tabs { border-bottom: 1px solid var(--border); display: flex; gap: 0; }
.tab-item { padding: 11px 18px; font-size: 14px; font-weight: 500; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: all .15s; white-space: nowrap; }
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Filters Bar ---- */
.filters-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-chip {
  padding: 6px 12px; border-radius: var(--radius-full); font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); background: #fff; cursor: pointer; transition: all .15s;
  color: var(--text-secondary);
}
.filter-chip:hover, .filter-chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ---- Progress Bar ---- */
.progress { height: 6px; background: var(--bg-active); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: var(--radius-full); transition: width .5s var(--ease); }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }

/* ---- Alerts ---- */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid transparent; font-size: 14px; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--primary-light); border-color: var(--primary-border); color: var(--primary); }
.alert-success { background: var(--success-light); border-color: var(--success-border); color: var(--success); }
.alert-warning { background: var(--warning-light); border-color: var(--warning-border); color: var(--warning); }
.alert-danger  { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger); }
.alert-body { color: var(--text-primary); }
.alert-title { font-weight: 600; margin-bottom: 2px; }

/* ---- Leaderboard ---- */
.leaderboard-row { transition: all .5s var(--ease); }
.leaderboard-row.updated { animation: rowPulse .8s ease; }
.rank-badge {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.rank-1 { background: #FEF3C7; color: #92400E; }
.rank-2 { background: #F1F5F9; color: #475569; }
.rank-3 { background: #FEF3C7; color: #78350F; }
.rank-other { background: var(--bg); color: var(--text-muted); }
.name-display { display: flex; align-items: center; gap: 6px; }
.name-letters { font-weight: 600; }
.name-blur { filter: blur(4px); user-select: none; -webkit-user-select: none; pointer-events: none; font-weight: 600; letter-spacing: 2px; }
.score-pill {
  display: inline-flex; align-items: center; padding: 4px 10px;
  background: var(--primary-light); color: var(--primary);
  border-radius: var(--radius-full); font-size: 13px; font-weight: 600;
}

/* ---- Step Indicator ---- */
.steps { display: flex; align-items: center; gap: 0; margin-bottom: 32px; }
.step { display: flex; align-items: center; flex: 1; }
.step-circle {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  background: #fff; flex-shrink: 0; transition: all .25s; z-index: 1;
}
.step.active .step-circle   { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.step.done .step-circle     { border-color: var(--success); background: var(--success); color: #fff; }
.step-line { flex: 1; height: 2px; background: var(--border); transition: background .25s; }
.step.done + .step .step-line, .step.done .step-line { background: var(--success); }
.step-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-align: center; }
.step.active .step-label { color: var(--primary); font-weight: 500; }
.step.done .step-label { color: var(--success); }
.steps-container { display: flex; flex-direction: column; }
.step-content { display: none; }
.step-content.active { display: block; }

/* ---- Dropdown ---- */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); min-width: 180px; z-index: 500;
  padding: 4px; animation: fadeIn .15s var(--ease);
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  font-size: 14px; color: var(--text-primary); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .1s;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Video Player ---- */
.video-container { position: relative; background: #000; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 16/9; }
.video-container video { width: 100%; height: 100%; object-fit: contain; }

/* ---- Score Criteria ---- */
.criteria-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.criteria-row:last-child { border-bottom: none; }
.criteria-name { flex: 1; font-size: 14px; font-weight: 500; }
.criteria-score { display: flex; gap: 4px; align-items: center; }
.score-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .1s;
  display: flex; align-items: center; justify-content: center; background: #fff;
  color: var(--text-secondary);
}
.score-btn:hover { border-color: var(--primary); color: var(--primary); }
.score-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.criteria-max { font-size: 12px; color: var(--text-muted); width: 36px; text-align: center; }

/* ---- Certificate Preview ---- */
.cert-preview {
  background: linear-gradient(135deg, #fff9f0 0%, #fffdf7 100%);
  border: 3px solid #D97706; border-radius: var(--radius-xl);
  padding: 48px; text-align: center; font-family: 'Georgia', serif;
}
.cert-title   { font-size: 28px; color: #92400E; font-weight: 700; margin-bottom: 4px; }
.cert-sub     { font-size: 14px; color: var(--text-muted); margin-bottom: 32px; }
.cert-name    { font-size: 32px; color: var(--text-primary); font-weight: 700; margin: 16px 0; border-bottom: 2px solid #D97706; display: inline-block; padding-bottom: 4px; }
.cert-code    { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; font-family: monospace; }
.cert-body    { font-size: 16px; color: var(--text-secondary); line-height: 1.8; }
.cert-footer  { margin-top: 48px; display: flex; justify-content: space-between; align-items: flex-end; }
.cert-sig     { text-align: center; }
.cert-sig-line{ border-top: 1px solid var(--text-primary); width: 120px; margin: 0 auto 4px; padding-top: 8px; }

/* ---- Toggle Switch ---- */
.toggle { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  width: 40px; height: 22px; background: var(--border-strong); border-radius: var(--radius-full);
  transition: background .2s; flex-shrink: 0; position: relative;
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform .2s; box-shadow: var(--shadow-xs);
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.toggle-label { font-size: 14px; font-weight: 500; }

/* ---- Animations ---- */
@keyframes spin        { to { transform: rotate(360deg); } }
@keyframes skeleton    { 0%,100% { background-position: 200% 0; } 50% { background-position: -200% 0; } }
@keyframes fadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp     { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight{ from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideOutRight{to  { opacity: 0; transform: translateX(20px); } }
@keyframes rowPulse    { 0%,100% { background: transparent; } 40% { background: #FEF3C7; } }
@keyframes countUp     { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Mobile Hamburger Button ---- */
.sidebar-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: #fff; cursor: pointer; color: var(--text-secondary);
  transition: background .15s;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-toggle svg { width: 18px; height: 18px; }

/* ---- Sidebar Backdrop Overlay ---- */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgb(0 0 0 / .45); z-index: 98;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ---- Responsive: Tablet (≤ 900px) ---- */
/* ================================================================
   TABLET — 769–900 px
   Covers iPad mini, portrait tablets, narrow desktop windows.
   Sidebar stays visible but content grids stack to avoid overflow.
   ================================================================ */
@media (max-width: 900px) and (min-width: 769px) {

  /* ── Lock viewport ── */
  html, body, .portal-layout, .portal-main, .page-content {
    max-width: 100vw; overflow-x: hidden;
  }
  * { min-width: 0; }

  /* ── Typography ── */
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-label { font-size: 11px; }

  /* ── Page padding ── */
  .page-content { padding: 14px 14px !important; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .topbar-actions { gap: 4px; }

  /* ── Grids ── */
  .grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-3 { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── Inline grid overrides (must be !important to beat page <style> blocks) ── */
  [style*="repeat(5,"]   { grid-template-columns: repeat(3,1fr) !important; }
  [style*="repeat(5, "]  { grid-template-columns: repeat(3,1fr) !important; }
  [style*="repeat(4,"]   { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(4, "]  { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(3,"]   { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(3, "]  { grid-template-columns: repeat(2,1fr) !important; }
  [style*="1fr 380px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 340px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 320px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 260px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 240px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 1fr"]     { grid-template-columns: 1fr !important; }

  /* ── Forms ── */
  .form-row { grid-template-columns: 1fr !important; }

  /* ── Cards ── */
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }
  .card-body   { padding: 12px 14px; }
  .stat-card   { padding: 12px 14px; }

  /* ── Tables — compact but not card-layout ── */
  .table-wrap { border-radius: 8px; overflow-x: auto; }
  .table th, .table td { padding: 7px 9px; font-size: 11px; white-space: nowrap; }

  /* ── Inline width overrides ── */
  [style*="width:180px"], [style*="width: 180px"],
  [style*="width:200px"], [style*="width: 200px"],
  [style*="width:220px"], [style*="width: 220px"],
  [style*="width:130px"], [style*="width: 130px"],
  [style*="width:160px"], [style*="width: 160px"],
  [style*="width:140px"], [style*="width: 140px"],
  [style*="width:150px"], [style*="width: 150px"] { width: 100% !important; max-width: 100% !important; }

  /* ── Inline max-width overrides ── */
  [style*="max-width:720px"], [style*="max-width: 720px"],
  [style*="max-width:640px"], [style*="max-width: 640px"],
  [style*="max-width:800px"], [style*="max-width: 800px"],
  [style*="max-width:960px"], [style*="max-width: 960px"],
  [style*="max-width:820px"], [style*="max-width: 820px"],
  [style*="max-width:680px"], [style*="max-width: 680px"],
  [style*="max-width:760px"], [style*="max-width: 760px"],
  [style*="max-width:560px"], [style*="max-width: 560px"],
  [style*="max-width:520px"], [style*="max-width: 520px"] { max-width: 100% !important; padding-left: 0 !important; padding-right: 0 !important; }

  /* ── Setting rows ── */
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 0; }
  .setting-row .toggle { align-self: flex-start; }
  .setting-row input[type="date"],
  .setting-row .form-input { width: 100% !important; max-width: 100%; }

  /* ── Filter bars ── */
  .filter-bar { padding: 12px !important; flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
  .filter-bar .form-input,
  .filter-bar .form-select { width: 100% !important; max-width: 100% !important; }

  /* ── Dash grid ── */
  .dash-grid { grid-template-columns: 1fr !important; }

  /* ── Score layout (judge) ── */
  .score-layout { flex-direction: column !important; height: auto !important; }
  .score-list-panel { width: 100% !important; height: 260px; border-right: none !important; border-bottom: 1px solid var(--border); }
  .score-panel-main { height: auto !important; overflow-y: visible !important; padding: 14px !important; }

  /* ── Welcome cards ── */
  [style*="padding:28px 32px"] { padding: 16px 16px !important; }

  /* ── Criteria bars ── */
  .criteria-bar-row { flex-wrap: wrap; gap: 6px; }
  .criteria-bar-name { width: 100% !important; flex: none !important; }
  .criteria-bar-wrap { flex: none !important; width: 100%; }
  .criteria-bar-val  { width: auto !important; text-align: left !important; }

  /* ── Lock banner ── */
  #lock-banner .card-body { flex-direction: column !important; gap: 12px !important; }

  /* ── Card header inputs ── */
  .card-header .form-input,
  .card-header .form-select { width: 100% !important; max-width: 100% !important; }

  /* ── Announcements ── */
  #ann-grid .card .card-body > div:first-child { flex-direction: column !important; }
  #ann-grid .card .card-body > div:first-child > div:last-child { margin-top: 8px; }

  /* ── Modal ── */
  .modal-xl { max-width: min(96vw, 900px); }

  /* ── Buttons ── */
  .btn { min-height: 36px; }
  .btn-sm { min-height: 32px; }

  /* ── Safety net: ensure no card or container overflows ── */
  .card, .stat-card, .welcome-card, [class*="welcome"],
  [style*="max-width"] { max-width: 100% !important; }
  .card, .stat-card, .welcome-card { width: 100%; }
  /* Any element with inline style containing large px values should auto-fit */
  [style*="1fr 320px"], [style*="1fr 340px"], [style*="1fr 1fr"] {
    width: 100% !important;
  }
}

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .modal-xl { max-width: min(96vw, 900px); }
}

/* ================================================================
   COMPREHENSIVE MOBILE OVERRIDES  (≤ 768 px)
   Covers inline-style grids, page-specific layouts, typography,
   touch targets, and anything the utility classes above can't reach.
   ================================================================ */

/* ---- New animation for bottom-sheet modal ---- */
@keyframes slideUpSheet {
  from { opacity: 0; transform: translateY(60px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =================================================================
   TABLET + MOBILE OVERRIDES  (≤ 768 px)
   ================================================================= */

@media (max-width: 768px) {

  /* ── 1. Lock the viewport — nothing may exceed screen width ── */
  html, body, .portal-layout, .portal-main, .page-content {
    max-width: 100vw;
    overflow-x: hidden;
  }
  * { min-width: 0; } /* flex/grid children never force overflow */

  /* ── 2. Typography — scale up slightly so nothing is unreadably small ── */
  body  { font-size: 15px; }
  h1    { font-size: 1.5rem; }
  h2    { font-size: 1.25rem; }
  h3    { font-size: 1.1rem; }
  .card-title        { font-size: 15px; }
  .topbar-title      { font-size: 15px; }
  .stat-value        { font-size: 1.7rem; }
  .stat-label        { font-size: 12px; }
  .badge             { font-size: 12px; }
  .table td          { font-size: 14px; }
  .table th          { font-size: 12px; }

  /* ── 3. Touch targets — minimum 44 px tall ── */
  .btn               { min-height: 40px; }
  .btn-sm            { min-height: 36px; }
  .btn-xs            { min-height: 32px; }
  /* font-size:16px !important prevents iOS from zooming in on input focus
     — must beat inline style="font-size:13px" on every input/select in the app */
  .form-input,
  .form-select,
  .form-textarea     { font-size: 16px !important; }
  .sidebar-item      { min-height: 44px; padding: 10px 14px; font-size: 15px; }
  .sidebar-item svg  { width: 20px; height: 20px; }
  .tab-item          { min-height: 44px; }
  .filter-chip       { min-height: 36px; padding: 8px 14px; font-size: 14px; }

  /* ── 4. Sidebar drawer ── */
  .sidebar {
    transform: translateX(-100%);
    width: min(280px, 85vw);
    box-shadow: var(--shadow-xl);
    z-index: 200;
  }
  .sidebar.open      { transform: translateX(0); }
  .sidebar-toggle    { display: flex; }
  .portal-main       { margin-left: 0; }

  /* ── 5. Topbar ── */
  .topbar            { padding: 0 12px; gap: 10px; height: 56px; }
  .topbar-title      { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions    { display: flex; align-items: center; gap: 6px; overflow-x: auto; flex-shrink: 0; }
  .topbar-actions::-webkit-scrollbar { display: none; }
  /* Shrink search inputs in topbar so they don't push other items off */
  .topbar-actions .form-input { width: 120px; font-size: 14px; }
  .topbar-actions select { max-width: 110px; font-size: 14px; }

  /* ── 6. Page padding ── */
  .page-content      { padding: 16px 14px !important; }

  /* ── 7. Cards ── */
  .card-header       { padding: 14px 16px; flex-wrap: wrap; gap: 8px; }
  .card-body         { padding: 14px 16px; }
  .card-footer       { padding: 12px 16px; }
  .stat-card         { padding: 14px 16px; }

  /* ── 8. Grids (utility classes) ── */
  .grid-2            { grid-template-columns: repeat(2, 1fr); }
  .grid-3            { grid-template-columns: repeat(2, 1fr); }
  .grid-4            { grid-template-columns: repeat(2, 1fr); }

  /* ── 9. Inline-style grid overrides (admin dashboards, review modals) ── */
  [style*="repeat(5,"]   { grid-template-columns: repeat(3,1fr) !important; }
  [style*="repeat(5, "]  { grid-template-columns: repeat(3,1fr) !important; }
  [style*="repeat(4,"]   { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(4, "]  { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(3,"]   { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(3, "]  { grid-template-columns: repeat(2,1fr) !important; }
  [style*="1fr 380px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 340px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 320px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 260px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 240px"]   { grid-template-columns: 1fr !important; }
  [style*="1fr 1fr"]     { grid-template-columns: 1fr !important; }

  /* ── 10. Forms ── */
  .form-row { grid-template-columns: 1fr !important; }

  /* ── 11. Tables — compact, scrollable, keep as proper tables ── */
  .table-wrap        { border-radius: 8px; margin: 0; width: 100%; }
  .table th, .table td { padding: 8px 10px; font-size: 12px; white-space: nowrap; }
  /* Hide optional columns on ≤768px */
  .table .th-opt,
  .table .td-opt     { display: none; }

  /* ── 12. Filters/tabs — horizontal scroll row ── */
  .filters-bar       { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .filters-bar::-webkit-scrollbar { display: none; }
  .tabs              { overflow-x: auto; flex-wrap: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }

  /* ── 13. Modals → bottom sheet ── */
  .modal-overlay     { align-items: flex-end; padding: 0; }
  .modal,
  .modal-lg,
  .modal-xl          { max-width: 100% !important; width: 100% !important;
                       max-height: 90dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
                       animation: slideUpSheet .25s var(--ease); }
  .modal-header      { padding: 16px 20px 14px; position: sticky; top: 0; background: #fff; z-index: 1; }
  .modal-body        { padding: 16px 20px; }
  .modal-footer      { padding: 12px 20px; flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* ── 14. Toasts ── */
  #toast-container   { left: 12px; right: 12px; bottom: 16px; }
  .toast             { min-width: unset; max-width: 100%; font-size: 14px; }

  /* ── 15. Judge split-panel ── */
  .score-layout      { flex-direction: column !important; height: auto !important; overflow: visible !important; }
  .score-list-panel  { width: 100% !important; height: 260px; min-height: 200px;
                       border-right: none !important; border-bottom: 1px solid var(--border); flex-shrink: 0 !important; }
  .score-panel-main  { height: auto !important; min-height: 50vh;
                       overflow-y: visible !important; padding: 14px !important; }

  /* ── 16. Score criteria — page handles this (judge/score.html style block) ── */

  /* ── 17. Alerts ── */
  .alert             { font-size: 14px; }
  .alert-body        { word-break: break-word; }

  /* ── 18. Inline max-width overrides ── */
  [style*="max-width:720px"], [style*="max-width: 720px"],
  [style*="max-width:640px"], [style*="max-width: 640px"],
  [style*="max-width:800px"], [style*="max-width: 800px"],
  [style*="max-width:960px"], [style*="max-width: 960px"],
  [style*="max-width:820px"], [style*="max-width: 820px"],
  [style*="max-width:680px"], [style*="max-width: 680px"],
  [style*="max-width:760px"], [style*="max-width: 760px"],
  [style*="max-width:560px"], [style*="max-width: 560px"],
  [style*="max-width:520px"], [style*="max-width: 520px"] { max-width: 100% !important; padding-left: 0 !important; padding-right: 0 !important; }

  /* ── 18b. Inline width overrides (form inputs, selects, search boxes) ── */
  [style*="width:180px"], [style*="width: 180px"],
  [style*="width:200px"], [style*="width: 200px"],
  [style*="width:220px"], [style*="width: 220px"],
  [style*="width:130px"], [style*="width: 130px"],
  [style*="width:160px"], [style*="width: 160px"],
  [style*="width:140px"], [style*="width: 140px"],
  [style*="width:150px"], [style*="width: 150px"] { width: 100% !important; max-width: 100% !important; }

  /* ── 18c. Setting rows — wrap on mobile ── */
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 0; }
  .setting-row .toggle { align-self: flex-start; }
  .setting-row input[type="date"],
  .setting-row .form-input { width: 100% !important; max-width: 100%; }

  /* ── 18d. Reports filter/log header — wrap search and select ── */
  .card-header .form-input,
  .card-header .form-select { width: 100% !important; max-width: 100% !important; }
  .card-header { flex-wrap: wrap !important; gap: 8px !important; }

  /* ── 18e. Criteria bar (results page) — stack bars on mobile ── */
  .criteria-bar-row { flex-wrap: wrap; gap: 8px; padding: 8px 0; }
  .criteria-bar-name { width: 100% !important; flex: none !important; }
  .criteria-bar-wrap { flex: none !important; width: 100%; }
  .criteria-bar-val  { width: auto !important; text-align: left !important; }

  /* ── 18f. Welcome banner cards (candidate & judge dashboards) ── */
  [style*="padding:28px 32px"] { padding: 18px 16px !important; }

  /* ── 18g. Filter bar (judge completed page) — stack filters vertically ── */
  .filter-bar { padding: 12px !important; flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
  .filter-bar .form-input,
  .filter-bar .form-select { width: 100% !important; max-width: 100% !important; }

  /* ── 18h. Lock banner — wrap action buttons ── */
  #lock-banner .card-body { flex-direction: column !important; gap: 12px !important; }

  /* ── 18i. Candidate dashboard: right column card scaling ── */
  .dash-grid { grid-template-columns: 1fr !important; }

  /* ── 18j. Announcements card actions wrap ── */
  #ann-grid .card .card-body > div:first-child { flex-direction: column !important; }
  #ann-grid .card .card-body > div:first-child > div:last-child { margin-top: 8px; }

  /* ── 19. Registration form ── */
  .reg-body          { padding: 20px 16px !important; }
  .reg-header        { padding: 20px 16px 16px !important; }
  .step-bar-label    { font-size: 11px; }
  .steps-bar         { gap: 4px; }

  /* ── 20. Certificate ── */
  .cert-preview      { padding: 20px 14px; }
  .cert-title        { font-size: 18px; }
  .cert-name         { font-size: 22px; }
  .cert-footer       { flex-direction: column; align-items: center; gap: 20px; }

  /* ── 21. Empty / loading states ── */
  .empty-state       { padding: 32px 16px; }
  .loading-center    { padding: 32px 16px; }
}

/* ── Small phones ≤ 430 px ── */
@media (max-width: 430px) {
  .grid-2            { grid-template-columns: 1fr; }
  .grid-3            { grid-template-columns: 1fr; }
  .grid-4            { grid-template-columns: 1fr; }
  [style*="repeat(5,"]   { grid-template-columns: repeat(2,1fr) !important; }
  [style*="repeat(5, "]  { grid-template-columns: repeat(2,1fr) !important; }
  .topbar            { height: 52px; padding: 0 10px; }
  .topbar-title      { font-size: 13px; }
  .topbar-actions    { gap: 4px; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  body               { font-size: 14px; }
  h1                 { font-size: 1.25rem; }
  h2                 { font-size: 1.1rem; }
  .btn               { font-size: 13px; padding: 8px 12px; min-height: 38px; }
  .btn-lg            { padding: 10px 16px; font-size: 14px; }
  .btn-xl            { padding: 11px 18px; font-size: 14px; }
  .btn-sm            { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  .btn-xs            { padding: 5px 8px; font-size: 11px; min-height: 28px; }
  .card-header       { padding: 12px 12px; }
  .card-body         { padding: 12px 12px; }
  .card-footer       { padding: 10px 12px; }
  .stat-card         { padding: 12px 12px; }
  .page-content      { padding: 12px 10px !important; }
  .stat-value        { font-size: 1.4rem; }
  .stat-label        { font-size: 11px; }
  /* === Mobile table — compact, scrollable, clean === */
  .table-wrap {
    border: 1px solid var(--border); border-radius: 8px;
    margin: 0; width: 100%; background: #fff;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  table.table {
    display: table; min-width: max-content; width: 100%;
    border-collapse: collapse;
  }
  .table thead { display: table-header-group; }
  .table tbody { display: table-row-group; }
  .table tr {
    display: table-row; background: none; border: none;
    border-radius: 0; margin: 0; padding: 0;
  }
  .table tbody tr:hover { background: var(--bg); }
  .table th {
    display: table-cell; padding: 7px 8px; font-size: 10px;
    letter-spacing: .04em; white-space: nowrap;
    background: var(--bg); position: sticky; top: 0;
  }
  .table td {
    display: table-cell; padding: 8px 8px; font-size: 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap; text-align: left;
  }
  .table td:first-child { font-weight: 500; }
  /* Remove all ::before ::after pseudo-elements — no card labels */
  .table td::before,
  .table td::after { display: none !important; content: none !important; }
  /* Action buttons stay inline */
  .table td:last-child { white-space: nowrap; }
  /* Modal tighter padding */
  .modal-header      { padding: 14px 16px 12px; }
  .modal-body        { padding: 14px 16px; }
  .modal-footer      { padding: 10px 16px; }
  .modal-footer .btn { flex: 1; }
  /* Score layout smaller list panel */
  .score-list-panel  { height: 220px; min-height: 180px; }
  .score-panel-main  { padding: 10px !important; }
  /* Certificate */
  .cert-preview      { padding: 16px 10px; }
  .cert-title        { font-size: 16px; }
  .cert-name         { font-size: 20px; }
  .cert-page         { padding: 24px 16px !important; }
  /* Empty/loading */
  .empty-state       { padding: 24px 12px; }
  .loading-center    { padding: 24px 12px; }
  /* Welcome banner */
  [style*="padding:28px 32px"] { padding: 14px 12px !important; }
  /* Hide less important topbar elements */
  .topbar-actions .btn-ghost { display: none; }
  .topbar-actions .btn-link { padding: 6px 8px; font-size: 12px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Print ---- */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .portal-main { margin-left: 0 !important; }
}
