/* ============================================================
   comtobooks — Design System v2
   ระบบข้อสอบออนไลน์ | Sarabun · White · Indigo · Royal Blue
   ============================================================ */

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

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
  /* ── Palette ── */
  --ink-900: #0a1628;
  --ink-800: #0f1d3a;
  --ink-700: #1c2e5e;
  --ink-600: #263d7a;
  --ink-500: #2f4d96;

  /* ── Navy aliases (สำหรับ admin panel) ── */
  --navy-900: #050c1a;
  --navy-800: #0f1d3a;
  --navy-700: #1c2e5e;
  --navy-600: #263d7a;
  --navy-500: #2f4d96;
  --blue-700: #1044c4;
  --blue-600: #1a56db;
  --blue-500: #2563eb;
  --blue-400: #3b82f6;

  --royal-700: #1044c4;
  --royal-600: #1a56db;
  --royal-500: #2563eb;
  --royal-400: #3b82f6;
  --royal-300: #93c5fd;
  --royal-100: #dbeafe;
  --royal-50:  #eff6ff;

  --sky-400: #38bdf8;
  --sky-300: #7dd3fc;
  --sky-100: #e0f2fe;
  --sky-50:  #f0f9ff;

  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white:     #ffffff;

  /* ── Semantic ── */
  --success:       #059669;
  --success-bg:    #d1fae5;
  --success-text:  #064e3b;
  --warning:       #d97706;
  --warning-bg:    #fef3c7;
  --warning-text:  #78350f;
  --danger:        #dc2626;
  --danger-bg:     #fee2e2;
  --danger-text:   #7f1d1d;
  --info:          var(--royal-500);
  --info-bg:       var(--royal-50);
  --info-text:     var(--ink-700);

  /* ── Text ── */
  --text-primary:     #0a1628;
  --text-secondary:   #334155;
  --text-muted:       #64748b;
  --text-placeholder: #94a3b8;
  --text-inverse:     #ffffff;

  /* ── Border ── */
  --border-light:  #f1f5f9;
  --border:        #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus:  var(--royal-500);

  /* ── Elevation ──
     ทุก shadow ใช้ indigo undertone ไม่ใช่ black
     เพื่อให้รู้สึก premium ไม่ flat */
  --shadow-xs: 0 1px 2px rgba(15,29,58,.05);
  --shadow-sm: 0 1px 4px rgba(15,29,58,.07), 0 1px 2px rgba(15,29,58,.04);
  --shadow-md: 0 4px 12px rgba(15,29,58,.09), 0 2px 4px rgba(15,29,58,.05);
  --shadow-lg: 0 8px 24px rgba(15,29,58,.12), 0 3px 8px rgba(15,29,58,.06);
  --shadow-xl: 0 16px 40px rgba(15,29,58,.14), 0 6px 16px rgba(15,29,58,.08);

  /* glow effect สำหรับ focus / active button */
  --glow-royal: 0 0 0 3px rgba(26,86,219,.18);
  --glow-success: 0 0 0 3px rgba(5,150,105,.16);

  /* ── Radius ── */
  --r-xs:   3px;
  --r-sm:   6px;
  --r-md:   9px;
  --r-lg:   13px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* ── Typography ── */
  --font: 'Sarabun', system-ui, -apple-system, sans-serif;

  /* ── Layout ── */
  --sidebar-w:      232px;
  --navbar-h:        58px;
  --bottom-nav-h:    60px;

  /* ── Transition (ลดเป็น 3 ระดับ ชัดเจน) ── */
  --ease:    cubic-bezier(.25,.1,.25,1);
  --spring:  cubic-bezier(.34,1.4,.64,1);   /* bounce เล็กน้อยสำหรับ appear */
  --t-fast:  120ms;
  --t-base:  180ms;
  --t-slow:  280ms;

  /* ── Spacing ── */
  --sp-1:  4px;  --sp-2:  8px;  --sp-3: 12px;
  --sp-4: 16px;  --sp-5: 20px;  --sp-6: 24px;
  --sp-8: 32px;  --sp-10: 40px; --sp-12: 48px;
  --sp-16: 64px;
}

/* ============================================================
   2. RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--slate-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, video, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }
button, input, select, textarea { font-family: var(--font); font-size: inherit; }

a {
  color: var(--royal-600);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--royal-700); }

/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -.2px;
}
h1 { font-size: 30px; } h2 { font-size: 24px; } h3 { font-size: 20px; }
h4 { font-size: 18px; } h5 { font-size: 16px; } h6 { font-size: 15px; }

.text-xs { font-size: 12px; } .text-sm  { font-size: 13px; }
.text-md { font-size: 16px; } .text-lg  { font-size: 18px; }
.text-xl { font-size: 20px; } .text-2xl { font-size: 24px; }
.text-3xl{ font-size: 30px; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.font-extrabold{ font-weight: 800; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-inverse   { color: var(--text-inverse); }
.text-blue      { color: var(--royal-600); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.text-danger    { color: var(--danger); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }

.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.label-section {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-muted);
}

/* ============================================================
   4. LAYOUT
   ============================================================ */
.app-shell { display: flex; flex-direction: column; min-height: 100dvh; }

.layout-main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
}
.layout-content {
  padding: var(--sp-6);
  background: var(--slate-50);
  overflow-y: auto;
}

.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: var(--sp-4); }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.flex-1  { flex: 1 1 0%; }
.min-w-0 { min-width: 0; }

/* ============================================================
   5. SPACING
   ============================================================ */
.mt-1{margin-top:var(--sp-1)} .mt-2{margin-top:var(--sp-2)} .mt-3{margin-top:var(--sp-3)}
.mt-4{margin-top:var(--sp-4)} .mt-5{margin-top:var(--sp-5)} .mt-6{margin-top:var(--sp-6)}
.mb-1{margin-bottom:var(--sp-1)} .mb-2{margin-bottom:var(--sp-2)} .mb-3{margin-bottom:var(--sp-3)}
.mb-4{margin-bottom:var(--sp-4)} .mb-5{margin-bottom:var(--sp-5)} .mb-6{margin-bottom:var(--sp-6)}
.mx-auto{margin-inline:auto} .ml-auto{margin-left:auto}
.p-4{padding:var(--sp-4)} .p-5{padding:var(--sp-5)} .p-6{padding:var(--sp-6)}
.px-4{padding-inline:var(--sp-4)} .py-3{padding-block:var(--sp-3)}

/* ============================================================
   6. NAVBAR
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: var(--ink-800);
  display: flex;
  align-items: center;
  padding-inline: var(--sp-6);
  gap: var(--sp-4);

  /* 1px accent line di bawah — tanda garis biru yang halus */
  border-bottom: 1px solid rgba(96,165,250,.15);
  box-shadow: 0 2px 16px rgba(10,22,40,.35);
}

.navbar-brand {
  display: flex; align-items: center;
  gap: var(--sp-3); flex-shrink: 0;
  text-decoration: none;
}
.navbar-logo {
  width: 36px; height: 36px;
  background: var(--royal-600);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
  box-shadow: 0 2px 8px rgba(26,86,219,.4);
  transition: transform var(--t-base) var(--spring);
}
.navbar-logo:hover { transform: scale(1.07); }
.navbar-brand-name {
  font-size: 16px; font-weight: 700;
  color: #fff; letter-spacing: .2px;
}

.navbar-menu {
  display: flex; align-items: center;
  gap: 2px; flex: 1; justify-content: center;
}

.nav-link {
  padding: 6px 15px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  color: rgba(255,255,255,.6);
  text-decoration: none; white-space: nowrap;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
  position: relative;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }

/* active — ขีดสีฟ้าด้านล่าง (ไม่ใช้ fill เต็ม) */
.nav-link.active {
  color: var(--sky-300);
  background: rgba(56,189,248,.09);
}
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 50%;
  transform: translateX(-50%);
  width: 60%; height: 2px;
  background: var(--sky-400);
  border-radius: var(--r-full);
}

.navbar-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

.navbar-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: var(--sp-2); border-radius: var(--r-sm);
  color: rgba(255,255,255,.75); font-size: 20px;
  transition: background var(--t-fast) var(--ease);
}
.navbar-toggle:hover { background: rgba(255,255,255,.1); }

/* ── Mobile Drawer ── */
.mobile-drawer { display: none; position: fixed; inset: 0; z-index: 200; }
.mobile-drawer.open { display: block; }
.drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(10,22,40,.55);
  backdrop-filter: blur(3px);
}
.drawer-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 80%; max-width: 300px;
  background: var(--ink-800);
  padding: var(--sp-6) var(--sp-4);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--t-slow) var(--ease);
  box-shadow: 4px 0 24px rgba(0,0,0,.3);
}
.mobile-drawer.open .drawer-panel { transform: translateX(0); }
.drawer-nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--r-md);
  font-size: 16px; font-weight: 500;
  color: rgba(255,255,255,.7);
  text-decoration: none; margin-bottom: 2px;
  transition: all var(--t-fast) var(--ease);
}
.drawer-nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.drawer-nav-link.active { background: var(--royal-600); color: #fff; }

/* ── Bottom Nav ── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(10,22,40,.08);
}
.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  height: 100%;
}
.bottom-nav-item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-muted); font-size: 10px;
  font-weight: 600; text-decoration: none;
  text-transform: uppercase; letter-spacing: .3px;
  transition: color var(--t-fast) var(--ease);
  position: relative;
}
.bottom-nav-item .nav-icon { font-size: 18px; line-height: 1; }
.bottom-nav-item.active { color: var(--royal-600); }
.bottom-nav-item.active::before {
  content: ''; position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--royal-600);
  border-radius: 0 0 var(--r-xs) var(--r-xs);
}

/* ============================================================
   7. SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--navbar-h);
  height: calc(100dvh - var(--navbar-h));
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
  scrollbar-width: thin;
  scrollbar-color: var(--slate-200) transparent;
}

.sidebar-section { margin-bottom: var(--sp-5); }
.sidebar-section-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px;
  color: var(--text-muted);
  padding: 0 var(--sp-2);
  margin-bottom: var(--sp-2);
}
.sidebar-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px var(--sp-3);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none; cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  margin-bottom: 1px;
}
.sidebar-item:hover { background: var(--slate-50); color: var(--ink-800); }
.sidebar-item.active {
  background: var(--royal-50);
  color: var(--royal-700);
  font-weight: 600;

  /* ขีดซ้าย */
  box-shadow: inset 3px 0 0 var(--royal-600);
}
.sidebar-item-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-item-count {
  margin-left: auto;
  background: var(--royal-100);
  color: var(--royal-700);
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-full);
}
.sidebar-item.active .sidebar-item-count {
  background: var(--royal-600); color: #fff;
}
.sidebar-divider { height: 1px; background: var(--border-light); margin: var(--sp-3) 0; }

/* ============================================================
   8. CARD
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  /* transition ยืดหยุ่นสำหรับ hover lift */
  transition: box-shadow var(--t-base) var(--ease),
              transform var(--t-base) var(--ease);
}
.card-sm   { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); }
.card-lg   { padding: var(--sp-8); border-radius: var(--r-xl); }

/* ── Stat Card ──
   ใช้ top accent bar แทน left bar
   เพราะมันอ่าน hierarchy ได้ชัดกว่าบน grid layout */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-base) var(--ease),
              transform var(--t-base) var(--ease);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.stat-card.blue::before   { background: var(--royal-500); }
.stat-card.green::before  { background: var(--success); }
.stat-card.amber::before  { background: var(--warning); }
.stat-card.red::before    { background: var(--danger); }
.stat-card.navy::before   { background: var(--ink-700); }

.stat-num {
  font-size: 28px; font-weight: 800;
  color: var(--ink-800); line-height: 1;
  margin-bottom: 4px; letter-spacing: -.5px;
}
.stat-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted);
}
.stat-sub  { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.stat-icon {
  position: absolute; right: var(--sp-4); top: var(--sp-5);
  font-size: 28px; opacity: .1;
}

/* ============================================================
   9. BADGE
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 700; line-height: 1.6;
  white-space: nowrap;
}
.badge-blue  { background: var(--royal-100); color: var(--ink-700); }
.badge-navy  { background: var(--ink-800); color: #fff; }
.badge-green { background: var(--success-bg); color: var(--success-text); }
.badge-amber { background: var(--warning-bg); color: var(--warning-text); }
.badge-red   { background: var(--danger-bg);  color: var(--danger-text); }
.badge-gray  { background: var(--slate-100);  color: var(--text-muted); }
.badge-sky   { background: var(--sky-100);    color: #0c4a6e; }

/* ============================================================
   10. BUTTON
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: 9px 20px;
  border-radius: var(--r-md);
  font-family: var(--font); font-size: 14px; font-weight: 600; line-height: 1;
  white-space: nowrap; cursor: pointer; border: none; outline: none;
  text-decoration: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:active  { transform: scale(.97); }
.btn:disabled{ opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: var(--glow-royal); }

.btn-primary {
  background: var(--royal-600); color: #fff;
  box-shadow: 0 2px 6px rgba(26,86,219,.3);
}
.btn-primary:hover {
  background: var(--royal-700); color: #fff;
  box-shadow: 0 4px 14px rgba(26,86,219,.38);
}

.btn-navy {
  background: var(--ink-800); color: #fff;
  box-shadow: 0 2px 6px rgba(10,22,40,.25);
}
.btn-navy:hover {
  background: var(--ink-700); color: #fff;
  box-shadow: 0 4px 12px rgba(10,22,40,.3);
}

.btn-success {
  background: var(--success); color: #fff;
}
.btn-success:hover { background: #047857; }

.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-outline {
  background: transparent;
  color: var(--royal-600);
  border: 1.5px solid var(--royal-400);
}
.btn-outline:hover { background: var(--royal-50); color: var(--royal-700); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
}
.btn-ghost:hover { background: var(--slate-50); color: var(--ink-800); }

.btn-white {
  background: var(--white); color: var(--ink-800);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-white:hover { background: var(--slate-50); }

/* Sizes */
.btn-xs   { padding: 4px 10px;  font-size: 12px; border-radius: var(--r-sm); }
.btn-sm   { padding: 6px 14px;  font-size: 13px; }
.btn-lg   { padding: 12px 28px; font-size: 15px; }
.btn-full { width: 100%; }

.btn-fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--royal-600); color: #fff; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: var(--shadow-lg);
  transition: all var(--t-base) var(--spring);
}
.btn-fab:hover {
  background: var(--royal-700);
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(26,86,219,.4);
}

/* ============================================================
   11. FORM
   ============================================================ */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: var(--sp-2);
}
.form-label.required::after { content: ' *'; color: var(--danger); }

.form-control {
  display: block; width: 100%;
  padding: 9px 13px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font); font-size: 15px;
  color: var(--text-primary); line-height: 1.5;
  outline: none;
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.form-control::placeholder { color: var(--text-placeholder); }
.form-control:hover:not(:focus) { border-color: var(--border-medium); }
.form-control:focus {
  border-color: var(--royal-500);
  box-shadow: var(--glow-royal);
}
.form-control:disabled {
  background: var(--slate-50); color: var(--text-muted); cursor: not-allowed;
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2394a3b8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 36px; cursor: pointer;
}

.input-group {
  display: flex; align-items: stretch;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input-group:focus-within { border-color: var(--royal-500); box-shadow: var(--glow-royal); }
.input-group .form-control { border: none; border-radius: 0; box-shadow: none; flex: 1; }
.input-group .form-control:focus { box-shadow: none; }
.input-group-text {
  padding: 0 var(--sp-3);
  background: var(--slate-50); color: var(--text-muted);
  font-size: 13px; display: flex; align-items: center;
  border-right: 1.5px solid var(--border); white-space: nowrap;
}
.form-hint  { font-size: 13px; color: var(--text-muted); margin-top: var(--sp-1); }
.form-error { font-size: 13px; color: var(--danger); margin-top: var(--sp-1); }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid   { border-color: var(--success); }

/* ============================================================
   12. PROGRESS
   ============================================================ */
.progress {
  width: 100%; height: 6px;
  background: var(--slate-100);
  border-radius: var(--r-full); overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--royal-500);
  border-radius: var(--r-full);
  transition: width .5s cubic-bezier(.34,1.2,.64,1);
}

/* ============================================================
   13. TIMER
   ============================================================ */
.timer-pill {
  display: flex; align-items: center; gap: var(--sp-2);
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-full); padding: 6px 14px;
}
.timer-dot {
  width: 7px; height: 7px;
  background: var(--sky-400); border-radius: 50%;
  animation: pulse-dot .9s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity:1; transform:scale(1); }
  50%     { opacity:.4; transform:scale(.7); }
}
.timer-text {
  font-size: 15px; font-weight: 700; color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.timer-text.urgent {
  color: #fca5a5;
  animation: urgent-blink .7s ease-in-out infinite;
}
@keyframes urgent-blink { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ============================================================
   14. EXAM — QUESTION CARDS
   ============================================================ */
.q-dot {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--white); color: var(--text-muted);
  transition: all var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.q-dot:hover   { border-color: var(--royal-400); color: var(--royal-600); }
.q-dot.current { background: var(--royal-600); color: #fff; border-color: var(--royal-600); }
.q-dot.correct { background: var(--success); color: #fff; border-color: var(--success); }
.q-dot.wrong   { background: var(--danger); color: #fff; border-color: var(--danger); }

.question-text {
  font-size: 16px; font-weight: 500;
  color: var(--text-primary); line-height: 1.8;
}

.choice-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: 12px 16px;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; background: var(--white);
  transition: all var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.choice-item:hover {
  border-color: var(--royal-400);
  background: var(--royal-50);
  transform: translateX(2px);
}
.choice-item.selected { border-color: var(--royal-600); background: var(--royal-50); }
.choice-item.correct  { border-color: var(--success); background: var(--success-bg); pointer-events: none; }
.choice-item.wrong    { border-color: var(--danger); background: var(--danger-bg); pointer-events: none; }
.choice-item.skip-dim { opacity: .45; pointer-events: none; }

.choice-letter {
  width: 32px; height: 32px; min-width: 32px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--slate-50); color: var(--text-secondary);
  border: 1.5px solid var(--slate-200); margin-top: 1px;
  transition: all var(--t-fast) var(--ease);
}
.choice-item.selected .choice-letter { background: var(--royal-600); color: #fff; border-color: var(--royal-600); }
.choice-item.correct  .choice-letter { background: var(--success); color: #fff; border-color: var(--success); }
.choice-item.wrong    .choice-letter { background: var(--danger); color: #fff; border-color: var(--danger); }
.choice-text { font-size: 15px; color: var(--text-primary); line-height: 1.65; flex: 1; padding-top: 5px; }

/* ============================================================
   15. TABLE
   ============================================================ */
.table-wrap {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 500px; }
thead tr { background: var(--slate-50); border-bottom: 1px solid var(--border); }
thead th {
  padding: 10px var(--sp-4); text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .5px; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-light); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--royal-50); }
tbody td { padding: 10px var(--sp-4); color: var(--text-primary); vertical-align: middle; }

/* ============================================================
   16. TIMELINE
   ============================================================ */
.timeline { position: relative; }
.timeline-item { display: flex; gap: var(--sp-3); padding-bottom: var(--sp-5); position: relative; }
.timeline-item::before {
  content: ''; position: absolute;
  left: 17px; top: 36px; bottom: 0;
  width: 1.5px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 16px; z-index: 1; flex-shrink: 0;
}
.timeline-dot.blue  { background: var(--royal-100); color: var(--royal-600); }
.timeline-dot.green { background: var(--success-bg); color: var(--success); }
.timeline-dot.red   { background: var(--danger-bg); color: var(--danger); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-xs);
}
.timeline-meta { font-size: 12px; color: var(--text-muted); margin-top: var(--sp-2); }

/* ============================================================
   17. ALERT / TOAST
   ============================================================ */
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: 13px; margin-bottom: var(--sp-4);
}
.alert-icon { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-blue   { background: var(--royal-50);  color: var(--ink-700); border-left: 3px solid var(--royal-500); }
.alert-green  { background: var(--success-bg);color: var(--success-text); border-left: 3px solid var(--success); }
.alert-amber  { background: var(--warning-bg);color: var(--warning-text); border-left: 3px solid var(--warning); }
.alert-red    { background: var(--danger-bg); color: var(--danger-text); border-left: 3px solid var(--danger); }

.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--sp-4));
  right: var(--sp-4); z-index: 500;
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  background: var(--ink-800); color: #fff;
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex; align-items: center; gap: var(--sp-2);
  max-width: 320px;
  border-left: 3px solid var(--sky-400);
}
.toast-show {
  animation: toast-in .22s var(--spring) both;
}
.toast-hide {
  animation: toast-out .22s var(--ease) both;
}
.toast-close {
  background: none; border: none; color: rgba(255,255,255,.5);
  cursor: pointer; margin-left: auto; font-size: 14px;
  transition: color var(--t-fast) var(--ease);
}
.toast-close:hover { color: #fff; }
@keyframes toast-in  { from{opacity:0;transform:translateX(16px)} to{opacity:1;transform:none} }
@keyframes toast-out { from{opacity:1;transform:none} to{opacity:0;transform:translateX(16px)} }

/* ============================================================
   18. DROPDOWN
   ============================================================ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 200px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-2);
  box-shadow: var(--shadow-lg); z-index: 300;
  opacity: 0; visibility: hidden;
  transform: translateY(-6px) scale(.97);
  transform-origin: top right;
  transition: all var(--t-base) var(--ease);
}
.dropdown-menu.open {
  opacity: 1; visibility: visible;
  transform: translateY(0) scale(1);
}
.dropdown-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px var(--sp-3); border-radius: var(--r-sm);
  font-size: 14px; color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
  transition: background var(--t-fast) var(--ease);
}
.dropdown-item:hover { background: var(--slate-50); color: var(--ink-800); }
.dropdown-item.danger:hover { background: var(--danger-bg); color: var(--danger-text); }
.dropdown-divider { height: 1px; background: var(--border-light); margin: var(--sp-2) 0; }

/* ============================================================
   19. MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,22,40,.5);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  opacity: 0; visibility: hidden;
  transition: all var(--t-slow) var(--ease);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--r-xl); padding: var(--sp-8);
  width: 100%; max-width: 480px; max-height: 90dvh;
  overflow-y: auto; box-shadow: var(--shadow-xl);
  transform: scale(.95) translateY(12px);
  transition: transform var(--t-slow) cubic-bezier(.34,1.2,.64,1);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-5);
}
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--slate-100); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 16px;
  transition: all var(--t-fast) var(--ease);
}
.modal-close:hover { background: var(--slate-200); color: var(--ink-800); }

/* ============================================================
   20. AVATAR
   ============================================================ */
.avatar {
  border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0; overflow: hidden;
  background: var(--royal-100); color: var(--royal-700);
}
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.avatar-md { width: 44px; height: 44px; font-size: 16px; }
.avatar-lg { width: 60px; height: 60px; font-size: 22px; }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-navy { background: var(--ink-800); color: #fff; }

/* Notification button */
.notif-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.1);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.7); font-size: 16px; position: relative;
  transition: all var(--t-fast) var(--ease);
}
.notif-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; background: var(--danger);
  border-radius: 50%; border: 1.5px solid var(--ink-800);
}

/* ============================================================
   21. BREADCRUMB / TABS
   ============================================================ */
.breadcrumb {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 13px; color: var(--text-muted);
  flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--royal-600); }
.breadcrumb-sep { opacity: .4; font-size: 11px; }
.breadcrumb-current { color: var(--ink-800); font-weight: 600; }

.page-tabs {
  display: flex; border-bottom: 1.5px solid var(--border);
  gap: 0; overflow-x: auto; scrollbar-width: none;
}
.page-tab {
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
  margin-bottom: -1.5px; text-decoration: none; flex-shrink: 0;
}
.page-tab:hover { color: var(--ink-800); }
.page-tab.active { color: var(--royal-600); border-bottom-color: var(--royal-600); font-weight: 600; }

/* ============================================================
   22. IMPORT ZONE
   ============================================================ */
.import-zone {
  border: 2px dashed var(--slate-200);
  border-radius: var(--r-lg); background: var(--white);
  padding: var(--sp-8) var(--sp-6);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-2); cursor: pointer; text-align: center;
  transition: all var(--t-base) var(--ease);
}
.import-zone:hover { border-color: var(--royal-400); background: var(--royal-50); }
.import-zone.drag-over { border-color: var(--royal-600); background: var(--royal-50); transform: scale(1.01); }
.import-icon { font-size: 36px; opacity: .35; }

/* ============================================================
   23. UTILITIES
   ============================================================ */
.hidden    { display: none !important; }
.sr-only   { position: absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border-width:0; }
.w-full    { width: 100%; }
.rounded-md{ border-radius: var(--r-md); }
.rounded-lg{ border-radius: var(--r-lg); }
.rounded-xl{ border-radius: var(--r-xl); }
.rounded-full{ border-radius: var(--r-full); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.divider   { height: 1px; background: var(--border); margin-block: var(--sp-5); }
.opacity-50{ opacity: .5; }

/* ── Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-50) 50%, var(--slate-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from{background-position:200% 0} to{background-position:-200% 0} }

/* ── Animations ── */
.fade-in { animation: fade-in .25s var(--ease) both; }
@keyframes fade-in { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }

/* ── Pagination ── */
.pagination { display:flex; gap:5px; justify-content:center; flex-wrap:wrap; }
.page-btn {
  min-width: 34px; height: 34px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; text-decoration: none;
  border: 1px solid var(--border); color: var(--text-secondary);
  background: var(--white); cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.page-btn:hover { border-color: var(--royal-400); color: var(--royal-600); }
.page-btn.active{ background: var(--ink-800); color: #fff; border-color: var(--ink-800); }
.page-btn.disabled{ opacity: .4; pointer-events: none; }

/* ============================================================
   24. RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 991px) {
  :root { --navbar-h: 54px; }
  .sidebar { display: none; }
  .layout-main { grid-template-columns: 1fr; }
  .layout-content { padding: var(--sp-4); }
  .navbar-menu { display: none; }
  .navbar-toggle { display: flex; }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
}

/* ============================================================
   25. RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 575px) {
  :root { --navbar-h: 52px; }
  .layout-content {
    padding: var(--sp-3);
    padding-bottom: calc(var(--bottom-nav-h) + var(--sp-3));
  }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid-4 { grid-template-columns: repeat(2,1fr) !important; }
  .bottom-nav { display: flex; }
  .navbar-brand-name { display: none; }
  .navbar { padding-inline: var(--sp-3); }
  .card { padding: var(--sp-4); }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-xl) var(--r-xl) 0 0; max-width: 100%; max-height: 92dvh; padding: var(--sp-6) var(--sp-5); }
  .toast-container { bottom: calc(var(--bottom-nav-h) + var(--sp-3)); left: var(--sp-3); right: var(--sp-3); }
  .toast { max-width: 100%; }
  .choice-item:hover { transform: none; }
}

/* ============================================================
   26. PRINT
   ============================================================ */
@media print {
  .navbar, .sidebar, .bottom-nav, .btn { display: none !important; }
  .layout-main { grid-template-columns: 1fr; }
  .layout-content { padding: 0; }
  body { background: white; font-size: 12pt; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
