@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   EDUCORE — Premium Design System
   Font: DM Sans (display) + Inter (body)
   Palette: Royal Blue + Slate + Warm accents
   ============================================================ */

:root {
  --bg-base:       #f7f8fa;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f0f1f5;
  --bg-card:       #ffffff;
  --bg-hover:      #f0f2f6;
  --border:        #e2e5ed;
  --border-light:  #cfd3de;
  --accent:        #2563eb;
  --accent-dim:    #1d4ed8;
  --accent-glow:   rgba(37, 99, 235, 0.14);
  --accent-subtle: rgba(37, 99, 235, 0.07);
  --accent-warm:   #f97316;
  --success:       #059669;
  --success-dim:   rgba(5, 150, 105, 0.09);
  --danger:        #dc2626;
  --danger-dim:    rgba(220, 38, 38, 0.08);
  --warning:       #d97706;
  --warning-dim:   rgba(217, 119, 6, 0.08);
  --info:          #0284c7;
  --info-dim:      rgba(2, 132, 199, 0.08);
  --text-primary:  #111827;
  --text-secondary:#4b5563;
  --text-muted:    #9ca3af;
  --text-inverse:  #ffffff;
  --font-display:  'DM Sans', sans-serif;
  --font-body:     'Inter', sans-serif;
  --sidebar-w:     256px;
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #94a3b8;
  --sidebar-active:#e2e8f0;
  --header-h:      60px;
  --radius-sm:     8px;
  --radius-md:     10px;
  --radius-lg:     12px;
  --radius-xl:     16px;
  --radius-full:   9999px;
  --bg-input:      var(--bg-surface);
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:     0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --glow-accent:   0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* DARK MODE */
html.dark {
  --bg-base:       #0b0f19;
  --bg-surface:    #111827;
  --bg-elevated:   #1e2536;
  --bg-card:       #151c2c;
  --bg-hover:      #1e293b;
  --border:        #1e293b;
  --border-light:  #334155;
  --accent:        #3b82f6;
  --accent-dim:    #2563eb;
  --accent-glow:   rgba(59, 130, 246, 0.20);
  --accent-subtle: rgba(59, 130, 246, 0.10);
  --success-dim:   rgba(5, 150, 105, 0.15);
  --danger-dim:    rgba(220, 38, 38, 0.15);
  --warning-dim:   rgba(217, 119, 6, 0.15);
  --info-dim:      rgba(2, 132, 199, 0.15);
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;
  --text-inverse:  #0b0f19;
  --sidebar-bg:    #060a13;
  --sidebar-text:  #64748b;
  --sidebar-active:#e2e8f0;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.6);
}
html.dark { color-scheme: dark; }
html.dark .topbar { background: rgba(17, 24, 39, 0.92); }
html.dark ::-webkit-scrollbar-track { background: var(--bg-base); }
html.dark ::-webkit-scrollbar-thumb { background: var(--border-light); }
html.dark .flash-success { background: #052e16; border-color: rgba(16,185,129,0.3); color: #4ade80; }
html.dark .flash-error   { background: #450a0a; border-color: rgba(239,68,68,0.3);  color: #f87171; }
html.dark .flash-warning { background: #422006; border-color: rgba(245,158,11,0.3); color: #fbbf24; }
html.dark .flash-info    { background: #0c2051; border-color: rgba(59,130,246,0.3); color: #60a5fa; }
html.dark .ec-toast { background: var(--bg-card); border-color: var(--border); color: var(--text-primary); }
html.dark .ec-toast-success .ec-toast-icon { background: rgba(16,185,129,0.15); color: #34d399; }
html.dark .ec-toast-error   .ec-toast-icon { background: rgba(239,68,68,0.15);  color: #f87171; }
html.dark .ec-toast-warning .ec-toast-icon { background: rgba(245,158,11,0.15); color: #fbbf24; }
html.dark .ec-toast-info    .ec-toast-icon { background: rgba(59,130,246,0.15); color: #60a5fa; }
html.dark .ec-toast-desc { color: var(--text-secondary); }
html.dark #ec-confirm-box { background: var(--bg-card); }
html.dark #ec-confirm-title { color: var(--text-primary); }
html.dark #ec-confirm-message { color: var(--text-secondary); }
html.dark #ec-confirm-cancel { background: var(--bg-elevated); border-color: var(--border); color: var(--text-secondary); }
html.dark #ec-confirm-cancel:hover { background: var(--bg-hover); }

/* DARK TOGGLE */
.dark-toggle {
  width: 40px; height: 40px; border: 1px solid var(--border);
  background: var(--bg-surface); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  transition: all 0.15s; position: relative; flex-shrink: 0;
}
.dark-toggle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.dark-toggle .icon-sun, .dark-toggle .icon-moon { position: absolute; transition: opacity 0.2s, transform 0.3s; }
.dark-toggle .icon-sun  { opacity: 1; transform: rotate(0deg) scale(1); }
.dark-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.7); }
html.dark .dark-toggle .icon-sun  { opacity: 0; transform: rotate(90deg) scale(0.7); }
html.dark .dark-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14.5px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--bg-base); color: var(--text-primary); min-height: 100vh; line-height: 1.6; letter-spacing: -0.011em; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.08); /* added border */
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 16px rgba(0,0,0,0.15); /* added depth */
}
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main-content { margin-left: 0; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(13,17,23,0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 99; opacity: 0; transition: opacity 0.25s ease; }
.sidebar-overlay.visible { opacity: 1; }
.sidebar-brand { height: var(--header-h); display: flex; align-items: center; padding: 0 24px; gap: 12px; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.06); transition: background 0.2s; }
.sidebar-brand:hover { background: rgba(255,255,255,0.03); }
.brand-icon { width: 34px; height: 34px; background: linear-gradient(135deg, var(--accent), #1d4ed8); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; box-shadow: 0 4px 12px rgba(37,99,235,0.3); border: 1px solid rgba(255,255,255,0.15); }
.brand-text { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: #fff; letter-spacing: -0.02em; line-height: 1.1; }
.brand-text span { color: var(--accent-light); }
.sidebar-nav { flex: 1; padding: 20px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.nav-section { margin-bottom: 22px; }
.nav-section-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,0.4); padding: 0 4px; margin-bottom: 8px; display: block; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-md); color: var(--sidebar-text); text-decoration: none; font-size: 0.88rem; font-weight: 500; transition: all 0.2s ease; position: relative; margin-bottom: 2px; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 15%; bottom: 15%; width: 3px; background: var(--accent-light); border-radius: 0 4px 4px 0; }
.nav-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: rgba(255,255,255,0.45); transition: color 0.2s ease; }
.nav-item:hover .nav-icon { color: #fff; }
.nav-item.active .nav-icon { color: var(--accent-light); }
.nav-badge { margin-left: auto; background: rgba(37,99,235,0.2); color: #60a5fa; font-size: 0.6rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.nav-item.active .nav-badge { background: rgba(37,99,235,0.25); color: #93bbfc; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius-md); cursor: pointer; transition: background 0.2s; border: 1px solid transparent; }
.user-card:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.08); }
.user-avatar { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 800; color: #fff; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); }
.user-name { font-size: 0.84rem; font-weight: 600; color: #fff; line-height: 1.2; font-family: var(--font-display); margin-bottom: 2px; }
.user-role { font-size: 0.70rem; color: rgba(255,255,255,0.45); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* MAIN */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1); }

/* TOPBAR */
.topbar { height: var(--header-h); background: rgba(255,255,255,0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.02); display: flex; align-items: center; padding: 0 28px; gap: 16px; position: sticky; top: 0; z-index: 50; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex-shrink: 0; }
.topbar-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn { width: 38px; height: 38px; border: 1px solid transparent; background: transparent; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); transition: all 0.2s; position: relative; }
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border); }
.notif-dot { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; background: var(--danger); border-radius: 50%; border: 2px solid var(--bg-surface); }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-secondary); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.35; }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }

/* SEARCH */
.topbar-search-wrap { flex: 1; max-width: 500px; position: relative; margin: 0 auto; box-shadow: 0 1px 4px rgba(0,0,0,0.02); border-radius: var(--radius-lg); }
.topbar-search-btn { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0 14px; height: 44px; cursor: pointer; transition: all 0.2s cubic-bezier(0.4,0,0.2,1); width: 100%; text-align: left; }
.topbar-search-btn:hover { background: var(--bg-surface); border-color: var(--border-light); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.topbar-search-placeholder { flex: 1; font-size: 0.9rem; color: var(--text-muted); font-family: var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* USER CHIP */
.topbar-user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 1px solid transparent; border-radius: 99px; cursor: pointer; background: transparent; transition: all 0.2s; position: relative; flex-shrink: 0; }
.topbar-user-chip:hover { background: var(--bg-elevated); }
.topbar-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.topbar-user-name { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* USER DROPDOWN */
.topbar-user-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 224px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 200; padding: 6px; animation: fadeDropIn 0.15s ease; }
@keyframes fadeDropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.tum-header { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; }
.tum-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 800; color: #fff; flex-shrink: 0; }
.tum-name { font-size: 0.84rem; font-weight: 700; color: var(--text-primary); font-family: var(--font-display); }
.tum-role { font-size: 0.68rem; color: var(--text-muted); text-transform: capitalize; }
.tum-divider { height: 1px; background: var(--border); margin: 4px 0; }
.tum-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); font-size: 0.84rem; font-weight: 500; color: var(--text-secondary); text-decoration: none; transition: background 0.12s, color 0.12s; cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.tum-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.tum-item-danger { color: var(--danger) !important; }
.tum-item-danger:hover { background: var(--danger-dim) !important; color: var(--danger) !important; }

/* NOTIF */
.topbar-notif-badge { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: 0.55rem; font-weight: 800; min-width: 16px; height: 16px; border-radius: 99px; display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1; border: 2px solid var(--bg-surface); }
.notif-panel { position: absolute; right: 0; top: calc(100% + 8px); width: 320px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden; }
.notif-panel-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-elevated); }
.notif-mark-read { font-size: 0.72rem; color: var(--accent); text-decoration: none; font-weight: 600; }
.notif-panel-body { max-height: 300px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background 0.1s; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item-title { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.notif-item-body  { font-size: 0.76rem; color: var(--text-secondary); }
.notif-item-time  { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 0.8rem; }
.notif-panel-foot { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg-elevated); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* PAGE */
.page-content { padding: 28px; flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.page-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.025em; line-height: 1.25; }
.page-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; font-weight: 400; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; transition: box-shadow 0.2s; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--stat-color, var(--accent)); border-radius: 0 2px 2px 0; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--stat-bg, var(--accent-subtle)); display: flex; align-items: center; justify-content: center; font-size: 1rem; margin-bottom: 12px; color: var(--stat-color, var(--accent)); }
.stat-value { font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; color: var(--text-primary); line-height: 1; letter-spacing: -0.03em; }
.stat-label { font-size: 0.76rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-change { display: inline-flex; align-items: center; gap: 3px; font-size: 0.68rem; font-weight: 600; margin-top: 8px; padding: 2px 8px; border-radius: 999px; }
.stat-change.up   { color: var(--success); background: var(--success-dim); }
.stat-change.down { color: var(--danger);  background: var(--danger-dim); }

/* CARDS */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; }
.card-body { padding: 20px; }
.card-body.no-padding { padding: 0; }

/* TABLES */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.855rem; }
.data-table th { background: var(--bg-elevated); padding: 10px 16px; text-align: left; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:nth-child(even) td { background: rgba(0,0,0,0.012); }
.data-table tbody tr:hover td { background: var(--bg-hover); }
.data-table .cell-primary { color: var(--text-primary); font-weight: 600; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger  { background: var(--danger-dim);  color: var(--danger);  }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-info    { background: var(--info-dim);    color: var(--info);    }
.badge-accent  { background: var(--accent-subtle); color: var(--accent); }
.badge-muted   { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 18px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 0.84rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all 0.15s ease; text-decoration: none; white-space: nowrap; line-height: 1; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dim); box-shadow: 0 2px 8px rgba(37,99,235,0.25); }
.btn-ghost { background: var(--bg-surface); color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-danger  { background: var(--danger-dim); color: var(--danger); border-color: transparent; }
.btn-danger:hover  { background: rgba(220,38,38,0.14); }
.btn-success { background: var(--success-dim); color: var(--success); border-color: transparent; }
.btn-success:hover { background: rgba(5,150,105,0.14); }
.btn-sm   { padding: 6px 13px; font-size: 0.76rem; }
.btn-lg   { padding: 12px 26px; font-size: 0.92rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* FORMS */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control { width: 100%; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 14px; font-family: var(--font-body); font-size: 0.875rem; color: var(--text-primary); transition: border-color 0.15s, box-shadow 0.15s; outline: none; appearance: none; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; background: var(--bg-elevated); }
select.form-control { 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.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }
.form-hint  { font-size: 0.74rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 0.74rem; color: var(--danger); margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.form-row   { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* MODAL */
.modal-backdrop { position: fixed; inset: 0; background: rgba(13,17,23,0.55); backdrop-filter: blur(5px); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; visibility: hidden; transition: all 0.2s; }
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-xl); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; transform: translateY(16px) scale(0.98); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
.modal-backdrop.open .modal { transform: translateY(0) scale(1); }
.modal-header { padding: 22px 24px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); transition: all 0.15s; }
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-elevated); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* FLASH */
.flash-container { position: fixed; top: 80px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.flash-msg { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-radius: var(--radius-md); font-size: 0.84rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; cursor: pointer; border: 1px solid; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.flash-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* AVATAR */
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; text-transform: uppercase; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.65rem; }
.avatar-md { width: 38px; height: 38px; font-size: 0.85rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.5rem; }

/* SEARCH BAR */
.search-bar { display: flex; align-items: center; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px; gap: 8px; height: 40px; transition: border-color 0.15s, box-shadow 0.15s; }
.search-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); background: var(--bg-surface); }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }
.search-bar input { background: none; border: none; outline: none; font-family: var(--font-body); font-size: 0.875rem; color: var(--text-primary); width: 200px; }
.search-bar input::placeholder { color: var(--text-muted); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-icon { font-size: 1.4rem; margin-bottom: 14px; width: 48px; height: 48px; border-radius: var(--radius-md); background: var(--bg-elevated); display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); border: 1px solid var(--border); }
.empty-icon::after { content: ''; display: block; width: 20px; height: 20px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E") center/contain no-repeat; }
.empty-icon svg { font-size: initial; }
.empty-title { font-family: var(--font-display); font-size: 0.92rem; color: var(--text-primary); font-weight: 600; margin-bottom: 4px; }
.empty-desc { font-size: 0.8rem; color: var(--text-muted); }

/* PAGINATION */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-muted); }
.page-btns { display: flex; gap: 4px; }
.page-btn { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--border); background: var(--bg-surface); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); font-size: 0.8rem; font-weight: 600; text-decoration: none; transition: all 0.15s; }
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ATTENDANCE CODE */
.attendance-code-display { text-align: center; padding: 40px 30px; }
.code-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 16px; }
.code-value { font-family: var(--font-display); font-size: 4.5rem; font-weight: 800; letter-spacing: 0.18em; color: var(--accent); line-height: 1; margin-bottom: 16px; }
.code-timer { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; padding: 6px 16px; font-size: 0.82rem; color: var(--text-secondary); }
.code-timer .timer-val { font-weight: 700; color: var(--warning); }

/* PLAN BADGE */
.plan-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid; }
.plan-starter    { background: var(--bg-elevated); color: var(--text-muted);  border-color: var(--border); }
.plan-pro        { background: var(--info-dim);    color: var(--info);        border-color: rgba(59,130,246,0.2); }
.plan-enterprise { background: var(--accent-subtle); color: var(--accent);   border-color: rgba(79,70,229,0.2); }

/* PAGE FOOTER */
.page-footer { margin-top: auto; border-top: 1px solid var(--border); background: var(--bg-surface); padding: 32px 40px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.page-footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-footer-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-footer-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text-primary); font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; transition: color 0.2s; }
.page-footer-brand:hover { color: var(--accent); }
.page-footer-brand-icon { width: 28px; height: 28px; background: var(--accent); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.page-footer-brand-icon svg { width: 14px; height: 14px; stroke-width: 2.5; }
.page-footer-brand strong { color: var(--accent); }
.page-footer-sep { color: var(--border); font-size: 1.2rem; }
.page-footer-copy { font-size: 0.8rem; color: var(--text-muted); }
.page-footer-links { display: flex; align-items: center; gap: 12px; }
.page-footer-link { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); text-decoration: none; padding: 6px 12px; border-radius: var(--radius-sm); transition: all 0.2s; border: 1px solid transparent; }
.page-footer-link:hover { color: var(--text-primary); background: var(--bg-elevated); border-color: var(--border); box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.page-footer-link-muted:hover { color: var(--danger); background: var(--danger-dim); border-color: rgba(239, 68, 68, 0.2); }

/* SIDEBAR TOGGLE */
.topbar-menu-btn { position: relative; overflow: hidden; }
body.sidebar-collapsed .topbar-menu-btn { background: var(--accent-subtle); border-color: rgba(37,99,235,0.15); color: var(--accent); }
body.sidebar-collapsed .topbar-menu-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.topbar-menu-btn svg { transition: transform 0.2s ease; }
body.sidebar-collapsed .topbar-menu-btn svg { transform: rotate(180deg); }

/* DARK TRANSITION */
html.dark-transitioning body, html.dark-transitioning .sidebar, html.dark-transitioning .topbar, html.dark-transitioning .card, html.dark-transitioning .stat-card, html.dark-transitioning .modal, html.dark-transitioning .notif-panel, html.dark-transitioning .topbar-user-menu, html.dark-transitioning .page-footer, html.dark-transitioning .data-table th, html.dark-transitioning .data-table td, html.dark-transitioning .form-control, html.dark-transitioning .btn, html.dark-transitioning .badge { transition: background-color 0.22s ease, border-color 0.22s ease, color 0.18s ease; }

/* ONBOARDING */
#onboardBox { animation: onboardIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes onboardIn { from { transform: translateY(20px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* UTILITIES */
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; } .text-sm { font-size: 0.84rem; } .text-xs { font-size: 0.72rem; }
.text-muted { color: var(--text-muted); } .text-secondary { color: var(--text-secondary); } .text-accent { color: var(--accent); } .text-success { color: var(--success); } .text-danger { color: var(--danger); }
.font-bold { font-weight: 700; } .font-display { font-family: var(--font-display); } .rounded { border-radius: var(--radius-md); } .truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* FILTER BAR — unified toolbar for listing pages */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-bar .search-bar { flex: 1; min-width: 200px; background: var(--bg-surface); height: 38px; }
.filter-bar .search-bar input { width: 100%; }
.filter-bar .form-control { height: 38px; min-width: 120px; font-size: 0.82rem; padding: 0 12px; background: var(--bg-surface); }
.filter-count { margin-left: auto; font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; font-weight: 500; }
.filter-bar .filter-count { font-size: 0.72rem; }

/* CONTENT CARD — listing pages with integrated toolbar */
.content-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.content-toolbar .search-bar { flex: 1; min-width: 180px; height: 36px; background: var(--bg-surface); border-color: transparent; }
.content-toolbar .search-bar:focus-within { border-color: var(--accent); background: var(--bg-surface); }
.content-toolbar .form-control { height: 36px; font-size: 0.8rem; border-color: transparent; background: var(--bg-elevated); }
.content-toolbar .filter-count { font-size: 0.72rem; }

/* ═══════════════════ RESPONSIVE ═══════════════════════════ */
html, body { max-width: 100%; }
@media (max-width: 1024px) { html, body { overflow-x: hidden; } }
img, video { max-width: 100%; height: auto; }
iframe { max-width: 100%; }

/* Sidebar off-canvas */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); position: fixed; top: 0; left: 0; bottom: 0; z-index: 300; width: var(--sidebar-w); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1), box-shadow 0.28s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,0.25); }
  .main-content { margin-left: 0 !important; }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(13,17,23,0.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 299; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }
}
@media (min-width: 1025px) { .topbar-menu-btn { display: none !important; } }
@media (max-width: 1024px) { .topbar-menu-btn { display: inline-flex !important; align-items: center; justify-content: center; } }

/* Tablet topbar */
@media (max-width: 1024px) { .topbar { padding: 0 16px; gap: 10px; } .topbar-search-wrap { max-width: 260px; } .topbar-search-kbd { display: none; } }

/* Phone topbar */
@media (max-width: 768px) {
  :root { --header-h: 58px; }
  .topbar { height: 58px; padding: 0 14px; gap: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
  .topbar-search-wrap { display: none !important; }
  .plan-badge { display: none !important; }
  .topbar-user-name { display: none !important; }
  .topbar-user-chip { padding: 0; width: 38px; height: 38px; border-radius: 50%; justify-content: center; border: 2px solid var(--border); }
  .topbar-user-chip > svg:last-child { display: none; }
  .topbar-btn, .dark-toggle { width: 38px; height: 38px; border-radius: 50%; }
  .topbar-actions > a.topbar-btn { display: none; }
  .notif-panel { position: fixed; top: 66px; right: 8px; left: 8px; width: auto; max-height: 72vh; overflow-y: auto; z-index: 400; }
  .topbar-user-menu { position: fixed; top: 66px; right: 8px; left: 8px; width: auto; z-index: 400; }
  .breadcrumb { max-width: 160px; overflow: hidden; }
  .breadcrumb a, .breadcrumb .current { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
}
@media (max-width: 480px) { .topbar { padding: 0 10px; gap: 5px; } .topbar-title { font-size: 0.88rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* Content padding */
@media (max-width: 1024px) { .page-content { padding: 22px 18px; } }
@media (max-width: 768px) { .page-content { padding: 14px; padding-bottom: calc(76px + env(safe-area-inset-bottom, 8px)); } }
@media (max-width: 480px) { .page-content { padding: 10px; padding-bottom: calc(76px + env(safe-area-inset-bottom, 8px)); } }

/* Page header */
@media (max-width: 640px) {
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 14px; }
  .page-header .btn { width: 100%; justify-content: center; }
  .page-header > div:last-child { width: 100%; display: flex; flex-direction: column; gap: 8px; }
  .page-title { font-size: 1.3rem; }
  .page-subtitle { font-size: 0.78rem; }
}

/* Stats grid */
@media (max-width: 768px) { .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; margin-bottom: 14px; } .stat-card { padding: 14px; border-radius: var(--radius-md); } .stat-value { font-size: 1.65rem; } .stat-icon { width: 36px; height: 36px; font-size: 1rem; margin-bottom: 10px; } .stat-label { font-size: 0.74rem; } }
@media (max-width: 380px) { .stats-grid { grid-template-columns: 1fr !important; } }

/* Cards */
@media (max-width: 768px) { .card { border-radius: var(--radius-md); } .card-header { padding: 12px 14px; } .card-body { padding: 14px; } }
@media (max-width: 480px) { .card-header { padding: 10px 12px; } .card-body { padding: 12px; } }

/* Grid layouts — including dashboard 2-col */
@media (max-width: 900px) {
  div[style*="grid-template-columns:1fr 340px"], div[style*="grid-template-columns: 1fr 340px"], div[style*="grid-template-columns:1fr 320px"], div[style*="grid-template-columns: 1fr 320px"], div[style*="grid-template-columns:1fr 300px"], div[style*="grid-template-columns: 1fr 300px"], div[style*="grid-template-columns:1fr 280px"], div[style*="grid-template-columns: 1fr 280px"], div[style*="grid-template-columns:2fr 1fr"], div[style*="grid-template-columns: 2fr 1fr"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 768px) {
  div[style*="grid-template-columns:repeat(3"], div[style*="grid-template-columns: repeat(3"] { grid-template-columns: repeat(2, 1fr) !important; }
  div[style*="grid-template-columns:repeat(4"], div[style*="grid-template-columns: repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; }
  div[style*="grid-template-columns:repeat(5"], div[style*="grid-template-columns: repeat(5"] { grid-template-columns: repeat(2, 1fr) !important; }
  div[style*="grid-template-columns:repeat(6"], div[style*="grid-template-columns: repeat(6"] { grid-template-columns: repeat(3, 1fr) !important; }
  /* Dashboard 2-col grid */
  div[style*="grid-template-columns: 1fr 1fr"], div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  /* Grading grid — question + score side by side */
  div[style*="grid-template-columns:1fr 130px"], div[style*="grid-template-columns: 1fr 130px"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
  div[style*="grid-template-columns:repeat(2"], div[style*="grid-template-columns: repeat(2"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:repeat(3"], div[style*="grid-template-columns: repeat(3"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:repeat(4"], div[style*="grid-template-columns: repeat(4"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:repeat(5"], div[style*="grid-template-columns: repeat(5"] { grid-template-columns: 1fr !important; }
  div[style*="grid-template-columns:repeat(6"], div[style*="grid-template-columns: repeat(6"] { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Forms */
@media (max-width: 640px) { .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr !important; } }
@media (max-width: 768px) { input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], input[type="search"], input[type="date"], input[type="time"], input[type="url"], textarea, select { font-size: 16px !important; } }

/* ═══════════════════ FILTER BAR (responsive) ═════════════ */
@media (max-width: 640px) {
  .filter-bar { gap: 8px; }
  .filter-bar .search-bar { flex: 1 1 100%; min-width: 0; order: -1; }
  .filter-bar .search-bar input { width: 100%; }
  .filter-bar .form-control { flex: 1 1 calc(50% - 4px); min-width: 0; width: auto; }
  .filter-bar select.form-control { max-width: 100%; }
  .filter-bar .filter-count { flex: 1 1 100%; text-align: center; margin-left: 0; padding-top: 4px; }
  .filter-bar .btn { flex: 1 1 calc(50% - 4px); }
  .filter-bar input[type="date"] { flex: 1 1 calc(50% - 4px); min-width: 0; }
}

/* ═══════════════════ MOBILE CARD TABLE ═══════════════════ */
/* On phones, data-tables convert to stacked card layout    */
@media (max-width: 768px) {
  /* Default table behavior — horizontal scroll unless card mode */
  .card-body:has(.data-table), .card-body:has(table) { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0; }
  .data-table { min-width: 520px; }
  .data-table th { font-size: 0.64rem; padding: 10px 12px; }
  .data-table td { padding: 10px 12px; font-size: 0.82rem; }

  /* Card mode — table transforms into stacked cards */
  .data-table.mobile-cards { display: block; min-width: 0; border: none; }
  .data-table.mobile-cards thead { display: none; }
  .data-table.mobile-cards tbody { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
  .data-table.mobile-cards tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
    padding: 14px 16px; border-radius: var(--radius-md);
    border: 1px solid var(--border); background: var(--bg-card);
    transition: box-shadow 0.15s, border-color 0.15s;
    position: relative;
  }
  .data-table.mobile-cards tr:active { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
  .data-table.mobile-cards td { border: none; padding: 0; display: inline-flex; align-items: center; }
  .data-table.mobile-cards td:empty { display: none; }

  /* Primary cell stretches full width */
  .data-table.mobile-cards td.mc-primary {
    flex: 1 1 100%; font-size: 0.92rem; font-weight: 600; color: var(--text-primary);
    margin-bottom: 4px;
  }
  /* Secondary info row */
  .data-table.mobile-cards td.mc-info {
    font-size: 0.78rem; color: var(--text-secondary);
  }
  /* Muted / label data */
  .data-table.mobile-cards td.mc-muted {
    font-size: 0.74rem; color: var(--text-muted);
  }
  /* Actions stick to bottom-right */
  .data-table.mobile-cards td.mc-actions {
    flex: 1 1 100%; display: flex; justify-content: flex-end; gap: 6px;
    margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border);
  }
  /* Badge cells */
  .data-table.mobile-cards td.mc-badge { order: 10; }

  /* Labeled values — shows label before data */
  .data-table.mobile-cards td[data-label]::before {
    content: attr(data-label);
    font-size: 0.64rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); margin-right: 6px;
    flex-shrink: 0;
  }
  /* Hide label in primary/actions cells */
  .data-table.mobile-cards td.mc-primary[data-label]::before,
  .data-table.mobile-cards td.mc-actions[data-label]::before { display: none; }

  /* Card-mode parent container shouldn't scroll */
  .card-body:has(.data-table.mobile-cards) { overflow-x: visible; overflow: visible; padding: 0; }
}

/* ═══════════════════ MOBILE CARD LIST ════════════════════ */
/* Native mobile list — alternate to table, use directly    */
.mobile-list { display: none; }
@media (max-width: 768px) {
  .mobile-list { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
  .mobile-list + .table-wrap { display: none; }
  .mobile-list-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 14px 16px; border-radius: var(--radius-md);
    border: 1px solid var(--border); background: var(--bg-card);
    text-decoration: none; color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .mobile-list-item:active { border-color: var(--accent); box-shadow: var(--glow-accent); }
  .ml-header { flex: 1 1 100%; display: flex; align-items: center; gap: 10px; }
  .ml-name { font-weight: 600; font-size: 0.92rem; color: var(--text-primary); flex: 1; }
  .ml-row { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 4px; }
  .ml-field { font-size: 0.78rem; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
  .ml-field-label { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
  .ml-actions { flex: 1 1 100%; display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
}

/* Modal → bottom sheet */
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: 100% !important; width: 100% !important; border-radius: 22px 22px 0 0 !important; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch; transform: translateY(30px) scale(1); }
  .modal-backdrop.open .modal { transform: translateY(0) scale(1); }
  .modal-header { padding-top: 24px; position: relative; }
  .modal-header::before { content: ''; position: absolute; top: 9px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; background: var(--border-light); border-radius: 2px; }
  .modal-body   { padding: 0 18px 20px; }
  .modal-footer { padding: 14px 18px; flex-direction: column; gap: 8px; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

/* Bottom nav */
#mobileBottomNav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.95);
  border-top: 1px solid var(--border); z-index: 250;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
html.dark #mobileBottomNav { background: rgba(24,27,38,0.95); }
@media (max-width: 768px)  { #mobileBottomNav { display: flex !important; } }
@media (min-width: 769px)  { #mobileBottomNav { display: none !important; } }

.mbn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text-muted); text-decoration: none; font-size: 0.59rem; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
  padding: 9px 4px 11px; min-height: 62px; border: none; background: none; cursor: pointer;
  position: relative; -webkit-tap-highlight-color: transparent; transition: color 0.15s;
}
.mbn-item svg { transition: transform 0.15s; width: 22px; height: 22px; }
.mbn-item:active svg { transform: scale(0.85); }
.mbn-active { color: var(--accent) !important; }
.mbn-active svg { stroke: var(--accent); transform: scale(1.12); }
.mbn-active::after { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--accent); border-radius: 0 0 4px 4px; }

/* Pagination */
@media (max-width: 640px) { .pagination { flex-wrap: wrap; gap: 6px; padding: 12px 14px; font-size: 0.76rem; } .page-btns { flex-wrap: wrap; } .page-btn { min-width: 36px; height: 36px; } }

/* Footer */
@media (max-width: 768px) { .page-footer { display: none !important; } }
@media (max-width: 640px) { .page-footer { padding: 16px; } .page-footer-inner { flex-direction: column; align-items: flex-start; gap: 12px; } .page-footer-links { flex-wrap: wrap; } .topbar-search-wrap { display: none; } }

/* Auth pages */
@media (max-width: 768px) { .auth-wrapper { display: block !important; grid-template-columns: 1fr !important; } .auth-panel { display: none !important; } .auth-form-panel { padding: 36px 24px !important; min-height: 100vh; } }
@media (max-width: 480px) { .auth-form-panel { padding: 28px 16px !important; } }

/* Settings subnav */
@media (max-width: 768px) {
  div[style*="border-bottom:1px solid var(--border)"][style*="display:flex"],
  div[style*="display:flex;gap:4px;margin-bottom:24px;border-bottom"] { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; }
  div[style*="display:flex;gap:4px;margin-bottom:24px;border-bottom"]::-webkit-scrollbar { display: none; }
  div[style*="display:flex;gap:4px;margin-bottom:24px;border-bottom"] a { white-space: nowrap; flex-shrink: 0; }
}

/* Admin */
@media (max-width: 768px) {
  .sa-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .sa-tabs::-webkit-scrollbar { display: none; }
  .sa-tab { white-space: nowrap; flex-shrink: 0; }
  .act-btns { display: flex; flex-wrap: wrap; gap: 4px; }
  .act-btns .btn-sm { font-size: 0.7rem; padding: 4px 8px; }
}

/* Exam */
@media (max-width: 768px) {
  .exam-header-inner { padding: 0 14px !important; gap: 8px !important; }
  #timerDisplay { font-size: 1.1rem !important; }
  .timer-label  { display: none !important; }
  .exam-main    { padding: 0 12px !important; max-width: 100% !important; }
  .exam-q-body  { padding: 16px !important; }
  .opt-label    { padding: 12px 14px !important; font-size: 0.85rem !important; min-height: 48px; border-radius: var(--radius-sm) !important; }
  #navPanel { position: fixed !important; bottom: 0; left: 0; right: 0; top: auto !important; width: 100% !important; height: auto !important; max-height: 58vh; border-left: none !important; border-top: 1px solid var(--border) !important; border-radius: 22px 22px 0 0; z-index: 450; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 22px !important; transform: translateY(100%) !important; transition: transform 0.3s cubic-bezier(0.4,0,0.2,1) !important; }
  #navPanel::before { content: ''; display: block; width: 40px; height: 4px; background: var(--border-light); border-radius: 2px; margin: 0 auto 16px; }
  #navPanel.nav-visible { transform: translateY(0) !important; }
  #navGrid { grid-template-columns: repeat(7, 1fr) !important; gap: 4px !important; }
}
@media (max-width: 480px) { .exam-main { padding: 0 8px !important; } .exam-q-body { padding: 12px !important; } #navGrid { grid-template-columns: repeat(6, 1fr) !important; } }

/* Videos */
@media (min-width: 481px) and (max-width: 768px) { .video-grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (max-width: 480px) { .video-grid { grid-template-columns: 1fr !important; } }

/* Attendance code */
@media (max-width: 480px) { .attendance-code-display { padding: 24px 16px; } .code-value { font-size: 3rem; letter-spacing: 0.12em; } }

/* Flash */
@media (max-width: 640px) { .flash-container { top: 70px; left: 10px; right: 10px; max-width: none; } .flash-msg { font-size: 0.82rem; } }

/* Empty state */
@media (max-width: 640px) { .empty-state { padding: 40px 16px; } .empty-icon { font-size: 2.5rem; } }

/* Touch targets */
@media (max-width: 1024px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .nav-item { min-height: 46px; }
  .mbn-item { min-height: 62px; }
  a, button, [role="button"] { -webkit-tap-highlight-color: transparent; }
  .modal-close { width: 40px; height: 40px; }
}

/* Scroll */
@media (max-width: 768px) { .sidebar-nav, .modal-body, .notif-panel-body, #navPanel { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; } }

/* Visibility */
@media (max-width: 768px)  { .hide-mobile  { display: none !important; } .show-mobile { display: block !important; } .show-mobile-flex { display: flex !important; } .show-mobile-inline { display: inline-flex !important; } }
@media (min-width: 769px)  { .hide-desktop { display: none !important; } .show-mobile { display: none !important; } .show-mobile-flex { display: none !important; } .show-mobile-inline { display: none !important; } }
@media (min-width: 769px) and (max-width: 1024px) { .hide-tablet { display: none !important; } }

/* Enhanced mobile sidebar */
@media (max-width: 768px) {
  .sidebar { width: 280px; }
  .sidebar-brand { padding: 0 18px; }
  .nav-item { padding: 12px 12px; font-size: 0.9rem; min-height: 50px; }
  .nav-section-label { font-size: 0.62rem; padding: 10px 12px 4px; }
  .sidebar-footer { padding: 14px 12px; }
  .user-card { padding: 12px; }
  .user-name { font-size: 0.88rem; }
}

/* Mobile buttons and inputs */
@media (max-width: 768px) {
  .btn { min-height: 48px; padding: 10px 20px; border-radius: 12px; font-size: 0.9rem; }
  .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.82rem; border-radius: 10px; }
  .btn-lg { min-height: 54px; padding: 14px 28px; font-size: 1rem; }
  .btn-icon { min-height: 44px; width: 44px; height: 44px; padding: 0; }
  .form-control { padding: 12px 14px; border-radius: 12px; min-height: 50px; }
  .form-label { font-size: 0.82rem; margin-bottom: 8px; }
  .card { border-radius: 16px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .page-title { font-size: 1.3rem; }
}

/* ═══════════════════ GROUP CARD GRID ═════════════════════ */
@media (max-width: 768px) {
  div[style*="grid-template-columns:repeat(auto-fill,minmax(320px"],
  div[style*="grid-template-columns: repeat(auto-fill, minmax(320px"],
  div[style*="grid-template-columns:repeat(auto-fill,minmax(300px"],
  div[style*="grid-template-columns: repeat(auto-fill, minmax(300px"] {
    grid-template-columns: 1fr !important;
  }
}

/* ═══════════════════ MOBILE ACTIVE BUTTON PRESS ═════════ */
@media (max-width: 768px) {
  .btn:active { transform: scale(0.97); transition: transform 0.1s; }
  .btn-primary:active { box-shadow: 0 2px 8px rgba(37,99,235,0.25); }
  .card:active { transform: scale(0.995); }
  .nav-item:active { transform: scale(0.97); }
}

/* ═══════════════════ SAFE AREA (iPhone X+) ═══════════════ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #mobileBottomNav { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* ═══════════════════ INLINE STYLE OVERRIDES ═════════════ */
/* Override inline width on form controls inside filter bars */
@media (max-width: 640px) {
  .filter-bar [style*="width:"] { width: auto !important; flex: 1 1 calc(50% - 4px); min-width: 0 !important; }
  .filter-bar .search-bar[style*="width:"] { flex: 1 1 100%; }
  .filter-bar input[style*="width:"] { width: 100% !important; }
  /* Fix inline display:flex gaps on page headers */
  .page-header > div[style*="display:flex"][style*="gap:"] { width: 100% !important; flex-direction: column !important; }
}

/* ═══════════════════ PULSE ANIMATION ════════════════════ */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
