/* assets/css/style.css - Modern P.P.5 Webapp Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Prompt:wght@300;400;500;600;700&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-dark: #1e40af;
  --accent: #6366f1;
  --accent-light: #eef2ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #06b6d4;
  --info-light: #ecfeff;
  --purple: #8b5cf6;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-topbar: #ffffff;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  --font-sans: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-doc: 'TH SarabunPSK', 'THSarabunPSK', 'TH Sarabun New', 'THSarabunNew', 'Sarabun', sans-serif;
  --font-mono: 'Inter', monospace;
  
  --sidebar-width: 260px;
  --topbar-height: 70px;
}

[data-theme="dark"] {
  --bg-main: #090d16;
  --bg-card: #131b2e;
  --bg-sidebar: #0b1120;
  --bg-topbar: #131b2e;
  --border-color: #1e293b;
  --border-light: #182235;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --primary-light: rgba(37, 99, 235, 0.15);
  --success-light: rgba(16, 185, 129, 0.15);
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger-light: rgba(239, 68, 68, 0.15);
  --accent-light: rgba(99, 102, 241, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

/* Global Scrollbar Styles - Keep outer body slim while ensuring all data tables have visible, easy-to-use scrollbars */
html, body {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* General Scrollable Containers */
::-webkit-scrollbar {
  width: 8px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  overflow-x: hidden;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.app-sidebar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Sidebar Collapsed State */
body.sidebar-collapsed {
  --sidebar-width: 72px;
}

body.sidebar-collapsed .sidebar-title-wrap,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .sidebar-footer > div {
  display: none !important;
}

body.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 8px;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 12px 6px;
  margin: 4px 6px;
}

body.sidebar-collapsed .nav-item i {
  font-size: 1.25rem;
  width: auto;
  margin: 0;
}

body.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 12px 6px;
}

.sidebar-header {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  padding: 3px;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-title-wrap h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sidebar-title-wrap p {
  font-size: 0.72rem;
  color: #94a3b8;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.sidebar-nav::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.nav-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 8px 10px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #94a3b8;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 3px;
  user-select: none;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.nav-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Main Content Area */
.app-main {
  flex: 1 1 0%;
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Topbar */
.app-topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  width: 100%;
  box-sizing: border-box;
  gap: 12px;
}

.sidebar-toggle-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.course-selector-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  max-width: 460px;
  min-width: 0;
  flex: 1;
}

.course-select {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.live-time-chip {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(124, 58, 237, 0.1));
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Page Body */
.page-body {
  padding: 28px;
  flex: 1;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.academic-hub-box {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.academic-hub-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.15);
  border-color: var(--primary) !important;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Hero Course Banner */
.hero-banner {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #6366f1 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 30px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
}

.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.hero-badge-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hero-badge {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
}

.hero-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.hero-meta {
  font-size: 0.95rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

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

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

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

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1.1;
}

.stat-info .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.4;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: var(--bg-main);
  border-color: var(--border-color);
  color: var(--text-main);
}

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

.timetable-view-btn {
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
}

.timetable-view-btn.active {
  background: var(--primary, #2563eb) !important;
  border-color: var(--primary, #2563eb) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
}

.timetable-view-btn:not(.active) {
  background: var(--bg-main, #ffffff) !important;
  border-color: var(--border-color, #e2e8f0) !important;
  color: var(--text-main, #1e293b) !important;
}

.timetable-view-btn:not(.active):hover {
  background: var(--border-light, #f1f5f9) !important;
  border-color: #cbd5e1 !important;
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

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

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-purple {
  background: var(--purple);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-xs.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-sm.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.badge-present { background: #d1fae5; color: #065f46; }
.badge-late { background: #fef3c7; color: #92400e; }
.badge-sick { background: #e0e7ff; color: #3730a3; }
.badge-leave { background: #e0f2fe; color: #075985; }
.badge-absent { background: #fee2e2; color: #991b1b; }
.badge-activity { background: #f3e8ff; color: #6b21a8; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Sub Tabs Navigation */
.sub-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
}

.sub-tab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.sub-tab-btn:hover {
  color: var(--primary);
}

.sub-tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.sub-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

/* Tables & Horizontally Scrollable Responsive Containers */
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  scrollbar-width: thin !important;
  scrollbar-color: #64748b #f1f5f9 !important;
  position: relative;
}

/* Prominent, easily grabbable horizontal scrollbars for all .table-responsive */
.table-responsive::-webkit-scrollbar,
.matrix-top-scroll::-webkit-scrollbar {
  display: block !important;
  width: 12px !important;
  height: 14px !important;
}

.table-responsive::-webkit-scrollbar-track,
.matrix-top-scroll::-webkit-scrollbar-track {
  display: block !important;
  background: #f1f5f9 !important;
  border-radius: 8px !important;
  border: 1px solid #e2e8f0 !important;
}

.table-responsive::-webkit-scrollbar-thumb,
.matrix-top-scroll::-webkit-scrollbar-thumb {
  display: block !important;
  background: #94a3b8 !important;
  border-radius: 8px !important;
  border: 2px solid #f1f5f9 !important;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.matrix-top-scroll::-webkit-scrollbar-thumb:hover {
  background: #475569 !important;
}

.table-responsive::-webkit-scrollbar-thumb:active,
.matrix-top-scroll::-webkit-scrollbar-thumb:active {
  background: #2563eb !important;
}

/* For P.P.5 Matrices: Set max-height so the bottom horizontal scrollbar stays pinned within viewport */
.matrix-table-responsive,
#subview-matrix .table-responsive,
#tab-scores .table-responsive,
#tab-evaluations .table-responsive {
  max-height: calc(100vh - 290px);
  min-height: 440px;
  overflow-y: auto !important;
  overflow-x: auto !important;
}

/* Sticky thead for matrix tables */
.matrix-table-responsive thead,
#subview-matrix .table-responsive thead,
#tab-scores .table-responsive thead,
#tab-evaluations .table-responsive thead {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 25 !important;
}

.matrix-table-responsive thead th,
#subview-matrix .table-responsive thead th,
#tab-scores .table-responsive thead th,
#tab-evaluations .table-responsive thead th {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 25 !important;
  background-color: #f8fafc !important;
  border-top: 1px solid var(--border-color);
}

/* Top-Left Corner intersection cells: Sticky BOTH top & left */
.matrix-table-responsive thead th.col-sticky-no,
.matrix-table-responsive thead th.col-sticky-code,
.matrix-table-responsive thead th.col-sticky-name,
#subview-matrix .table-responsive thead th.col-sticky-no,
#subview-matrix .table-responsive thead th.col-sticky-code,
#subview-matrix .table-responsive thead th.col-sticky-name,
#tab-scores .table-responsive thead th.col-sticky-no,
#tab-scores .table-responsive thead th.col-sticky-code,
#tab-scores .table-responsive thead th.col-sticky-name,
#tab-evaluations .table-responsive thead th.col-sticky-no,
#tab-evaluations .table-responsive thead th.col-sticky-code,
#tab-evaluations .table-responsive thead th.col-sticky-name {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 45 !important;
  background-color: #f1f5f9 !important;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th {
  background: var(--bg-main);
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.table tr:hover td {
  background: rgba(37, 99, 235, 0.02);
}

/* Compact Table (Space-saving to fit cards without horizontal scrolling) */
.table-compact th {
  padding: 8px 10px;
  font-size: 0.83rem;
  vertical-align: middle;
}

.table-compact td {
  padding: 8px 10px;
  font-size: 0.85rem;
  vertical-align: middle;
}

/* ========================================================================= */
/* Table Matrix & Sticky Student Columns (Freezes No, Code, Name on scroll)  */
/* ========================================================================= */
.table-matrix,
.table-sticky-students {
  border-collapse: separate !important;
  border-spacing: 0;
}

.table-matrix th, 
.table-matrix td {
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid rgba(226, 232, 240, 0.7);
  box-sizing: border-box;
}

.table-matrix thead th,
.table-sticky-students thead th {
  border-top: 1px solid var(--border-color);
  background-color: #f8fafc;
}

/* Sticky Column 1: ที่ (No) */
.col-sticky-no {
  position: -webkit-sticky !important;
  position: sticky !important;
  left: 0 !important;
  width: 45px !important;
  min-width: 45px !important;
  max-width: 45px !important;
  text-align: center !important;
  box-sizing: border-box !important;
}

/* Sticky Column 2: รหัส (Student Code) */
.col-sticky-code {
  position: -webkit-sticky !important;
  position: sticky !important;
  left: 45px !important;
  width: 75px !important;
  min-width: 75px !important;
  max-width: 75px !important;
  text-align: center !important;
  box-sizing: border-box !important;
}

/* Sticky Column 3: ชื่อ - นามสกุล (Student Fullname) */
.col-sticky-name {
  position: -webkit-sticky !important;
  position: sticky !important;
  left: 120px !important;
  min-width: 180px !important;
  text-align: left !important;
  border-right: 2px solid #cbd5e1 !important;
  box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.14) !important;
  box-sizing: border-box !important;
}

/* Sticky Header Cells: High z-index & Opaque Background */
thead th.col-sticky-no,
thead th.col-sticky-code,
thead th.col-sticky-name,
.table-matrix thead th.col-sticky-no,
.table-matrix thead th.col-sticky-code,
.table-matrix thead th.col-sticky-name,
.table-sticky-students thead th.col-sticky-no,
.table-sticky-students thead th.col-sticky-code,
.table-sticky-students thead th.col-sticky-name {
  z-index: 30 !important;
  background-color: #f1f5f9 !important;
  color: var(--text-main) !important;
  font-weight: 600 !important;
}

/* Sticky Body Cells: Solid opaque background so scrolled cells don't bleed through */
tbody td.col-sticky-no,
tbody td.col-sticky-code,
tbody td.col-sticky-name,
.table-matrix tbody td.col-sticky-no,
.table-matrix tbody td.col-sticky-code,
.table-matrix tbody td.col-sticky-name,
.table-sticky-students tbody td.col-sticky-no,
.table-sticky-students tbody td.col-sticky-code,
.table-sticky-students tbody td.col-sticky-name {
  z-index: 15 !important;
  background-color: #ffffff !important;
}

/* Long absent student row sticky cells */
tbody tr.row-long-absent td.col-sticky-no,
tbody tr.row-long-absent td.col-sticky-code,
tbody tr.row-long-absent td.col-sticky-name,
.table-matrix tbody tr.row-long-absent td.col-sticky-no,
.table-matrix tbody tr.row-long-absent td.col-sticky-code,
.table-matrix tbody tr.row-long-absent td.col-sticky-name {
  background-color: #fffbeb !important;
}

/* Hover effects for sticky cells */
tbody tr:hover td.col-sticky-no,
tbody tr:hover td.col-sticky-code,
tbody tr:hover td.col-sticky-name,
.table-matrix tbody tr:hover td.col-sticky-no,
.table-matrix tbody tr:hover td.col-sticky-code,
.table-matrix tbody tr:hover td.col-sticky-name {
  background-color: #f1f5f9 !important;
}
tbody tr.row-long-absent:hover td.col-sticky-no,
tbody tr.row-long-absent:hover td.col-sticky-code,
tbody tr.row-long-absent:hover td.col-sticky-name,
.table-matrix tbody tr.row-long-absent:hover td.col-sticky-no,
.table-matrix tbody tr.row-long-absent:hover td.col-sticky-code,
.table-matrix tbody tr.row-long-absent:hover td.col-sticky-name {
  background-color: #fef3c7 !important;
}

/* Dark mode compatibility */
[data-theme="dark"] thead th.col-sticky-no,
[data-theme="dark"] thead th.col-sticky-code,
[data-theme="dark"] thead th.col-sticky-name {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}
[data-theme="dark"] tbody td.col-sticky-no,
[data-theme="dark"] tbody td.col-sticky-code,
[data-theme="dark"] tbody td.col-sticky-name {
  background-color: #0f172a !important;
}
[data-theme="dark"] tbody tr.row-long-absent td.col-sticky-no,
[data-theme="dark"] tbody tr.row-long-absent td.col-sticky-code,
[data-theme="dark"] tbody tr.row-long-absent td.col-sticky-name {
  background-color: #3b280c !important;
}
[data-theme="dark"] tbody tr:hover td.col-sticky-no,
[data-theme="dark"] tbody tr:hover td.col-sticky-code,
[data-theme="dark"] tbody tr:hover td.col-sticky-name {
  background-color: #1e293b !important;
}
[data-theme="dark"] .col-sticky-name {
  border-right: 2px solid #334155 !important;
  box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.4) !important;
}

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Real-time Kiosk Mode Styles */
.kiosk-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.kiosk-clock-panel {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: 32px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.4);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.kiosk-digital-clock {
  font-family: var(--font-mono);
  font-size: 3.8rem;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: 2px;
  line-height: 1;
  margin: 12px 0;
  text-shadow: 0 0 20px rgba(96, 165, 250, 0.5);
}

.kiosk-date-text {
  font-size: 1.1rem;
  color: #cbd5e1;
}

.kiosk-scan-input-wrap {
  position: relative;
  max-width: 500px;
  margin: 20px auto 0;
}

.kiosk-scan-input {
  width: 100%;
  padding: 16px 20px 16px 50px;
  font-size: 1.25rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
  backdrop-filter: blur(8px);
  text-align: center;
  transition: all 0.3s;
}

.kiosk-scan-input:focus {
  border-color: #60a5fa;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 25px rgba(96, 165, 250, 0.4);
}

.kiosk-scan-input::placeholder {
  color: #94a3b8;
  font-size: 1rem;
  font-weight: 400;
}

.scan-icon-inside {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: #60a5fa;
}

/* Student Quick Cards Grid */
.student-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  max-height: 520px;
  overflow-y: auto;
  padding: 6px;
}

.student-card-item {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
}

.student-card-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.student-card-item.status-present {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.04);
}

.student-card-item.status-late {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.04);
}

.student-card-item.status-absent {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.04);
}

.student-card-item.status-sick {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.04);
}

.st-card-no {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.st-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.st-card-code {
  font-size: 0.78rem;
  color: var(--text-light);
  font-family: var(--font-mono);
}

.st-card-time {
  font-size: 0.76rem;
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: 600;
  margin-top: 6px;
}

/* Recent Live Feed */
.live-feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  height: fit-content;
}

.feed-list {
  list-style: none;
  max-height: 520px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
  animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Score Sheet Inputs */
.score-input {
  width: 65px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  background: #fff;
  transition: all 0.2s;
}

.score-input:focus {
  border-color: var(--primary);
  outline: none;
  background: #f0f7ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.score-input.invalid {
  border-color: var(--danger);
  background: #fff5f5;
}

.score-total-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
}

.grade-badge-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Modal Popup */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-dialog.modal-xl {
  max-width: 1050px;
}

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

.modal-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-card);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
  min-width: 280px;
  animation: toastSlide 0.3s ease;
}

.toast.toast-success { border-left: 4px solid #10b981; }
.toast.toast-danger { border-left: 4px solid #ef4444; }
.toast.toast-warning { border-left: 4px solid #f59e0b; }

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Print Reports Catalog Cards */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.report-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.report-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.report-icon-box {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(124, 58, 237, 0.1));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 16px;
}

.report-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.report-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

/* Responsive Layout Adaptations */
@media (max-width: 1200px) {
  .hero-content { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 1024px) {
  :root { --sidebar-width: 72px; }
  .sidebar-title-wrap, .nav-section-title, .nav-item span, .sidebar-footer > div { display: none !important; }
  .sidebar-header { justify-content: center; padding: 16px 8px; }
  .nav-item { justify-content: center; padding: 12px 6px; margin: 4px 6px; }
  .nav-item i { font-size: 1.25rem; width: auto; margin: 0; }
  .sidebar-footer { justify-content: center; padding: 12px 6px; }
  .app-main { width: calc(100vw - 72px); max-width: calc(100vw - 72px); margin-left: 72px; }
  .kiosk-container { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  html, body {
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
  }

  /* Mobile Sidebar & Drawer Overlay */
  .app-sidebar { 
    transform: translateX(-100%);
    width: 250px !important;
    max-width: 250px !important;
    z-index: 50 !important;
  }
  body.sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 45;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    cursor: pointer;
  }
  body:not(.sidebar-open)::after {
    display: none !important;
    pointer-events: none !important;
  }
  body.sidebar-open .sidebar-title-wrap,
  body.sidebar-open .nav-section-title,
  body.sidebar-open .nav-item span,
  body.sidebar-open .sidebar-footer > div {
    display: block !important;
  }
  body.sidebar-open .nav-item {
    justify-content: flex-start;
    padding: 10px 12px;
  }

  .app-main { 
    margin-left: 0 !important; 
    width: 100vw !important; 
    max-width: 100vw !important; 
    box-sizing: border-box !important;
  }

  /* Responsive Topbar on Mobile */
  .app-topbar {
    height: auto !important;
    min-height: 56px;
    padding: 8px 12px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .topbar-left {
    display: contents !important;
  }
  .sidebar-toggle-btn {
    order: 1 !important;
    flex-shrink: 0 !important;
    width: 34px !important;
    height: 34px !important;
  }
  .topbar-term-badge {
    order: 2 !important;
    font-size: 0.72rem !important;
    padding: 3px 8px !important;
    max-width: 155px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  .topbar-right {
    order: 3 !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
  }
  .topbar-right .live-time-chip {
    display: none !important;
  }
  #themeToggleBtn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    font-size: 0.85rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }
  .topbar-user-widget {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 2px 4px !important;
  }
  .topbar-user-avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.75rem !important;
    flex-shrink: 0 !important;
  }
  .topbar-user-info {
    display: none !important;
  }
  .btn-logout-chip {
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
    flex-shrink: 0 !important;
  }
  .btn-logout-chip span {
    display: none !important;
  }

  /* Full-width Course Selector on Row 2 of Topbar */
  .course-selector-box,
  #topbarCourseSelectorBox {
    order: 10 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    margin: 2px 0 0 0 !important;
    padding: 6px 12px !important;
    box-sizing: border-box !important;
    border-radius: var(--radius-md) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .course-select,
  #activeCourseSelect {
    width: 100% !important;
    font-size: 0.85rem !important;
    min-width: 0 !important;
  }

  .page-body { 
    padding: 10px 12px !important; 
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Sub Tabs Horizontal Scroll */
  .sub-tabs {
    display: flex !important;
    gap: 6px !important;
    margin-bottom: 14px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-bottom: 2px !important;
  }
  .sub-tabs::-webkit-scrollbar {
    display: none !important;
  }
  .sub-tab-btn {
    flex-shrink: 0 !important;
    padding: 8px 12px !important;
    font-size: 0.82rem !important;
    white-space: nowrap !important;
  }

  /* PP5 Course Selector Bar (Attendance) */
  .pp5-course-selector-bar {
    margin-bottom: 14px !important;
  }
  .pp5-course-selector-bar > div {
    padding: 10px 12px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .pp5-course-selector-bar > div > div:first-child {
    min-width: 0 !important;
    width: 100% !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }
  .pp5-course-selector-bar .pp5-assigned-course-select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 0.82rem !important;
  }
  .pp5-course-selector-bar .pp5-assigned-count-badge {
    font-size: 0.75rem !important;
    padding: 4px 8px !important;
    align-self: flex-start !important;
  }

  /* Kiosk Clock Panel & Scanner */
  .kiosk-clock-panel {
    padding: 18px 12px !important;
    border-radius: var(--radius-lg) !important;
    margin-bottom: 14px !important;
  }
  .kiosk-date-text {
    font-size: 0.85rem !important;
  }
  .kiosk-digital-clock {
    font-size: 2.2rem !important;
    letter-spacing: 1px !important;
    margin: 6px 0 !important;
  }
  .kiosk-clock-panel p {
    font-size: 0.75rem !important;
  }
  .kiosk-scan-input-wrap {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 10px !important;
  }
  .kiosk-scan-input {
    font-size: 0.88rem !important;
    padding: 10px 12px 10px 38px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .scan-icon-inside {
    left: 12px !important;
    font-size: 1rem !important;
  }

  /* Kiosk Container & Student Cards Grid */
  .kiosk-container { 
    grid-template-columns: 1fr !important; 
    gap: 14px !important;
  }
  .student-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .student-card {
    padding: 8px 6px !important;
  }
  .student-card-name {
    font-size: 0.8rem !important;
  }
  .student-card-code {
    font-size: 0.7rem !important;
  }

  /* Hero Banner */
  .hero-banner {
    padding: 16px 14px !important;
    border-radius: var(--radius-lg) !important;
    margin-bottom: 14px !important;
  }
  .hero-title {
    font-size: 1.25rem !important;
  }
  .hero-badge-group {
    gap: 4px !important;
    flex-wrap: wrap !important;
  }
  .hero-badge {
    font-size: 0.7rem !important;
    padding: 3px 6px !important;
  }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* Tables & Responsive P.P.5 Matrices */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    margin-bottom: 12px !important;
  }
  .table th, .table td {
    padding: 8px 6px !important;
    font-size: 0.8rem !important;
  }
  .matrix-guide-toolbar {
    padding: 8px 10px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .matrix-legend-pills {
    gap: 4px !important;
    font-size: 0.75rem !important;
    flex-wrap: wrap !important;
  }
  .matrix-legend-pill {
    padding: 2px 6px !important;
    font-size: 0.72rem !important;
  }

  /* Modals */
  .modal-backdrop {
    padding: 8px !important;
  }
  .modal-dialog {
    max-height: 94vh !important;
    border-radius: var(--radius-lg) !important;
    width: 100% !important;
  }
  .modal-header {
    padding: 12px 14px !important;
  }
  .modal-title {
    font-size: 1.05rem !important;
  }
  .modal-body {
    padding: 14px !important;
  }
  .modal-footer {
    padding: 10px 14px !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .student-cards-grid { grid-template-columns: 1fr !important; }
}

/* CSV Dropzone & Import Styling */
.csv-dropzone {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.csv-dropzone:hover,
.csv-dropzone.dragover {
  border-color: var(--primary) !important;
  background: var(--primary-light) !important;
  transform: translateY(-1px);
}
[data-theme="dark"] .csv-dropzone:hover,
[data-theme="dark"] .csv-dropzone.dragover {
  background: rgba(37, 99, 235, 0.12) !important;
}

/* ========================================================================= */
/* Academic Settings & Roles Styling */
/* ========================================================================= */
.settings-sub-tab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.settings-sub-tab-btn:hover {
  color: var(--primary);
}

.settings-sub-tab-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.settings-sub-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

.term-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.term-status-badge.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .term-status-badge.badge-active {
  color: #34d399;
}

.term-status-badge.badge-normal {
  background: var(--border-light);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Academic Roles Organization Grid */
.academic-org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.academic-role-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.academic-role-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
}

.academic-role-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.academic-role-card.role-director::before { background: #8b5cf6; }
.academic-role-card.role-deputy::before { background: #2563eb; }
.academic-role-card.role-academic::before { background: #0284c7; }
.academic-role-card.role-eval::before { background: #10b981; }
.academic-role-card.role-registrar::before { background: #f59e0b; }
.academic-role-card.role-curriculum::before { background: #ec4899; }
.academic-role-card.role-timetable::before { background: #06b6d4; }
.academic-role-card.role-guidance::before { background: #14b8a6; }

.role-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.role-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--primary-light);
  color: var(--primary);
}

.role-director .role-icon-box { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.role-deputy .role-icon-box { background: rgba(37, 99, 235, 0.15); color: #2563eb; }
.role-academic .role-icon-box { background: rgba(2, 132, 199, 0.15); color: #0284c7; }
.role-eval .role-icon-box { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.role-registrar .role-icon-box { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.role-curriculum .role-icon-box { background: rgba(236, 72, 153, 0.15); color: #ec4899; }
.role-timetable .role-icon-box { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
.role-guidance .role-icon-box { background: rgba(20, 184, 166, 0.15); color: #14b8a6; }

.role-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
}

.role-card-body {
  margin-bottom: 14px;
}

.role-user-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.role-user-pos {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.role-user-dept {
  font-size: 0.8rem;
  color: var(--text-light);
}

.role-card-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

/* User & Personnel Management Table auto-fit */
#usersTable {
  width: 100% !important;
  max-width: 100% !important;
  table-layout: auto;
  border-collapse: collapse;
}

#usersTable th {
  padding: 8px 4px !important;
  font-size: 0.8rem !important;
  white-space: nowrap;
  vertical-align: middle;
}

#usersTable td {
  padding: 6px 4px !important;
  font-size: 0.82rem !important;
  vertical-align: middle;
}

#usersTable .role-badge {
  padding: 3px 6px !important;
  font-size: 0.74rem !important;
  line-height: 1.2 !important;
  white-space: normal !important;
  text-align: center;
  display: inline-block !important;
}

/* Term Selector Pills Bar */
.term-pills-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 14px 2px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--border-color);
}

.term-pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.term-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.term-pill-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.term-pill-btn .pill-current-tag {
  background: #10b981;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.term-pill-btn.active .pill-current-tag {
  background: #ffffff;
  color: var(--primary);
}

.term-pill-btn.btn-add-pill {
  background: transparent;
  border-style: dashed;
  color: var(--primary);
}

.term-pill-btn.btn-add-pill:hover {
  background: var(--primary-light);
}

/* ==========================================================================
   ACADEMIC CALENDAR & MILESTONE STYLES
   ========================================================================== */
.academic-calendar-card {
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}

.cal-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
  border-bottom: 1px solid var(--border-color);
}

.cal-category-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.cal-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.cal-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.cal-pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.cal-month-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.cal-month-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  min-width: 140px;
  text-align: center;
}

.cal-body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr);
  gap: 20px;
  padding: 18px 20px;
}

.cal-body-grid > div:first-child {
  min-width: 0;
}

@media (max-width: 992px) {
  .cal-body-grid {
    grid-template-columns: 1fr;
  }
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  gap: 6px;
  background: transparent;
  width: 100%;
  box-sizing: border-box;
}

.cal-grid-header {
  text-align: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 6px 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-grid-header.weekend {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.04);
  border-color: rgba(239, 68, 68, 0.15);
}

.cal-day-cell {
  min-height: 84px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 5px 6px 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.cal-day-cell:hover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.03);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.cal-day-cell.other-month {
  opacity: 0.35;
  background: transparent;
}

.cal-day-cell.weekend .day-number {
  color: #dc2626;
}

.cal-day-cell.today {
  border: 2px solid var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.cal-day-cell.selected {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  min-width: 0;
}

.day-number {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}

.today-tag {
  font-size: 0.58rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.2;
  white-space: nowrap;
}

.cal-event-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  margin-top: 2px;
}

.cal-event-chip {
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.25;
  padding: 2px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: anywhere;
  color: var(--text-main);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  transition: all 0.12s ease;
}

.cal-event-chip:hover {
  background: rgba(37, 99, 235, 0.04);
  border-color: rgba(37, 99, 235, 0.2);
}

.cal-event-more {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  display: inline-block;
  margin-top: 1px;
  white-space: nowrap;
}

.cal-event-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

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

.cal-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.cal-important-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 2px 6px;
  border-radius: 4px;
}

.cal-event-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 4px;
  margin-bottom: 4px;
}

.cal-event-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cal-event-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.45;
}

/* Timeline Layout */
.cal-timeline {
  position: relative;
  padding: 16px 20px 16px 36px;
}

.cal-timeline::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 45px;
  width: 3px;
  background: linear-gradient(180deg, var(--primary) 0%, rgba(37, 99, 235, 0.2) 100%);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.timeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 0 4px var(--bg-card);
  flex-shrink: 0;
}

.timeline-dot.active {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
  animation: pulse 2s infinite;
}

.timeline-content {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

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

/* Timetable Drag & Drop Styles */
.tt-slot-card {
  user-select: none;
  -webkit-user-drag: element;
  cursor: grab !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.tt-slot-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22) !important;
  transform: translateY(-2px);
}
.tt-slot-card:active {
  cursor: grabbing !important;
}
.tt-slot-dragging {
  opacity: 0.35 !important;
  transform: scale(0.96) !important;
  filter: saturate(0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28) !important;
}
.tt-drag-over {
  background: rgba(37, 99, 235, 0.15) !important;
  outline: 2px dashed #2563eb !important;
  outline-offset: -3px !important;
  border-radius: 6px;
  position: relative;
  transition: background 0.15s ease, outline 0.15s ease;
}
.tt-drag-over.empty-tt-cell {
  background: rgba(16, 185, 129, 0.18) !important;
  outline: 2px dashed #059669 !important;
}
.tt-drag-forbidden {
  background: rgba(239, 68, 68, 0.18) !important;
  outline: 2px dashed #dc2626 !important;
  outline-offset: -3px !important;
  cursor: not-allowed !important;
}

/* Grade selection buttons in Batch Lock Activity Modal */
.tt-grade-btn {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tt-grade-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}
.tt-grade-btn.active {
  background: #0284c7 !important;
  color: #ffffff !important;
  border-color: #0284c7 !important;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

/* Parallel Subject Modal Fit & Overflow Prevention */
#modalParallelSubject .modal-dialog {
  max-width: min(1200px, 96vw) !important;
  width: 96% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

#modalParallelSubject .modal-body {
  overflow-x: hidden !important;
  box-sizing: border-box !important;
  padding: 16px 20px !important;
}

#ttParGroupsContainer {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 16px !important;
  width: 100% !important;
  box-sizing: border-box !important;
  align-items: stretch !important;
}

@media (max-width: 860px) {
  #ttParGroupsContainer {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

.parallel-course-card {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  user-select: none;
}

.parallel-card-g1:hover {
  border-color: #60a5fa !important;
  background-color: #f0f7ff !important;
}

.parallel-card-g2:hover {
  border-color: #fcd34d !important;
  background-color: #fffbeb !important;
}

#ttParG1CourseOptionsList::-webkit-scrollbar,
#ttParG2CourseOptionsList::-webkit-scrollbar {
  width: 5px;
}
#ttParG1CourseOptionsList::-webkit-scrollbar-track,
#ttParG2CourseOptionsList::-webkit-scrollbar-track {
  background: transparent;
}
#ttParG1CourseOptionsList::-webkit-scrollbar-thumb,
#ttParG2CourseOptionsList::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
#ttParG1CourseOptionsList::-webkit-scrollbar-thumb:hover,
#ttParG2CourseOptionsList::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Drag and Drop Unscheduled Courses into Timetable */
.unscheduled-drag-chip {
  cursor: grab !important;
  transition: all 0.18s ease-in-out !important;
}

.unscheduled-drag-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25) !important;
  border-color: #d97706 !important;
  background-color: #fffdf5 !important;
}

.unscheduled-drag-chip:active {
  cursor: grabbing !important;
}

.tt-drop-target-highlight {
  background-color: rgba(16, 185, 129, 0.12) !important;
  border: 2px dashed #10b981 !important;
  box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.15);
  animation: pulse-drop-target 1.6s infinite ease-in-out;
}

@keyframes pulse-drop-target {
  0% { background-color: rgba(16, 185, 129, 0.08); }
  50% { background-color: rgba(16, 185, 129, 0.22); }
  100% { background-color: rgba(16, 185, 129, 0.08); }
}

.tt-drag-over {
  background-color: rgba(37, 99, 235, 0.25) !important;
  border: 2px solid #2563eb !important;
  outline: 2px solid #3b82f6 !important;
}

.tt-drag-forbidden {
  background-color: rgba(239, 68, 68, 0.2) !important;
  border: 2px dashed #ef4444 !important;
  cursor: not-allowed !important;
}

/* Modal Timetable Slot Course Dropdown */
#ttSlotCourseSelect {
  font-family: inherit;
  transition: all 0.2s ease-in-out;
}
#ttSlotCourseSelect:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2) !important;
}
#ttSlotCourseSelect optgroup {
  font-weight: 700;
  font-size: 0.82rem;
  color: #1e3a8a;
  background-color: #f1f5f9;
  padding: 6px 4px;
}
#ttSlotCourseSelect option {
  font-weight: 500;
  font-size: 0.88rem;
  color: #1e293b;
  background-color: #ffffff;
  padding: 6px 10px;
}

/* Modal Scout Teachers */
#modalScoutTeachers .modal-dialog {
  max-width: min(1050px, 96vw) !important;
  width: 95% !important;
}
.scout-teacher-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  position: relative;
}
.scout-teacher-card:hover {
  border-color: #10b981;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}
.scout-teacher-card.is-head {
  background: #f0fdf4;
  border: 1.5px solid #059669;
}
.scout-grade-tab.active {
  background: #ffffff !important;
  color: #065f46 !important;
  border-color: var(--border-color) var(--border-color) #059669 !important;
  border-bottom: 3px solid #059669 !important;
}

/* ========================================================================= */
/* LOGIN SYSTEM & AUTHENTICATION OVERLAY                                    */
/* ========================================================================= */
.login-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: radial-gradient(circle at 20% 15%, #1e3a8a 0%, #0f172a 65%, #020617 100%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.login-screen-overlay.active {
  display: flex !important;
  opacity: 1;
  pointer-events: auto !important;
}

/* Background floating glow orbs */
.login-bg-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.login-orb-1 {
  position: absolute;
  top: -10%;
  left: -10%;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.25) 0%, transparent 70%);
  filter: blur(40px);
}

.login-orb-2 {
  position: absolute;
  bottom: -15%;
  right: -10%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
  filter: blur(50px);
}

.login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15);
  padding: 36px 32px;
  margin: auto;
  transition: transform 0.3s ease;
}

[data-theme="dark"] .login-card {
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo-wrap {
  width: 82px;
  height: 82px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #ffffff;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #2563eb;
}

.login-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-system-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #1e3a8a;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

[data-theme="dark"] .login-system-title {
  color: #93c5fd;
}

.login-school-title {
  font-size: 0.92rem;
  color: #64748b;
  margin: 0 0 12px;
  font-weight: 500;
}

[data-theme="dark"] .login-school-title {
  color: #94a3b8;
}

.login-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

[data-theme="dark"] .login-badge-pill {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.4);
  color: #93c5fd;
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  font-size: 1rem;
  pointer-events: none;
  z-index: 2;
}

.login-input-wrap .form-control {
  padding-left: 42px !important;
  height: 44px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.login-input-wrap .form-control:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-citizen-input {
  letter-spacing: 0.12em;
  font-family: var(--font-mono), var(--font-sans);
  font-size: 1.05rem !important;
  font-weight: 600;
}

.btn-toggle-visibility {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  font-size: 0.95rem;
  transition: color 0.2s;
  z-index: 2;
}

.btn-toggle-visibility:hover {
  color: #2563eb;
}

.login-btn-submit {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 20px;
}

.login-btn-submit:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.login-btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Shake Animation for Login Failure */
@keyframes shakeCard {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake-animation {
  animation: shakeCard 0.45s ease-in-out;
}

/* Topbar User Widget */
.topbar-user-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  transition: all 0.2s ease;
}

.topbar-user-widget:hover {
  border-color: #cbd5e1;
}

.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  flex-shrink: 0;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.topbar-user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-user-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout-chip {
  padding: 4px 10px;
  font-size: 0.74rem;
  border-radius: 20px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-logout-chip:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #b91c1c;
}

/* Sidebar User Card */
.sidebar-user-card {
  margin: 10px 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user-card-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user-name {
  color: #f1f5f9;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-dept {
  color: #94a3b8;
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================================================= */
/* P.P.5 Attendance Book Interactive Matrix Cells & Quick Status Picker      */
/* ========================================================================= */
.matrix-cell-interactive {
  cursor: pointer;
  position: relative;
  text-align: center;
  font-size: 0.82rem;
  padding: 4px 2px;
  user-select: none;
  transition: all 0.14s ease-in-out;
  border-radius: 4px;
}

.matrix-cell-interactive:hover {
  background-color: #e2e8f0 !important;
  box-shadow: inset 0 0 0 1.5px #64748b, 0 2px 6px rgba(0,0,0,0.08);
  transform: scale(1.18);
  z-index: 10;
}

.matrix-cell-interactive:active {
  transform: scale(0.92);
}

.matrix-cell-interactive.status-present {
  color: #059669 !important;
  font-weight: 700;
  background-color: rgba(16, 185, 129, 0.08);
}
.matrix-cell-interactive.status-late {
  color: #d97706 !important;
  font-weight: 700;
  background-color: rgba(245, 158, 11, 0.12);
}
.matrix-cell-interactive.status-absent {
  color: #dc2626 !important;
  font-weight: 700;
  background-color: rgba(239, 68, 68, 0.12);
}
.matrix-cell-interactive.status-sick {
  color: #4f46e5 !important;
  font-weight: 700;
  background-color: rgba(79, 70, 229, 0.08);
}
.matrix-cell-interactive.status-leave {
  color: #0284c7 !important;
  font-weight: 700;
  background-color: rgba(2, 132, 199, 0.08);
}
.matrix-cell-interactive.status-activity {
  color: #9333ea !important;
  font-weight: 700;
  background-color: rgba(147, 51, 234, 0.08);
}
.matrix-cell-interactive.status-unrecorded {
  color: #94a3b8 !important;
  background-color: transparent;
}
.matrix-cell-interactive.status-holiday {
  color: #dc2626 !important;
  font-weight: 700;
  background-color: #fff1f2 !important;
  font-size: 0.72rem;
  letter-spacing: -0.5px;
}
.matrix-cell-interactive.status-holiday:hover {
  background-color: #fee2e2 !important;
}

@keyframes cellPopIn {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.matrix-cell-pop {
  animation: cellPopIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Floating Quick Picker for P.P.5 Matrix */
#matrixQuickPicker {
  position: absolute;
  display: none;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  padding: 8px;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 280px;
  animation: fadeIn 0.15s ease-out;
}

#matrixQuickPicker button {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.12s ease;
}

#matrixQuickPicker button:hover {
  transform: translateY(-1px);
  filter: brightness(0.95);
}

/* P.P.5 Matrix Guide Toolbar */
.matrix-guide-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid #e2e8f0;
}

.matrix-legend-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.82rem;
}

.matrix-legend-pill {
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}/* Grade Summary (สรุปผลการเรียน งานวัดและประเมินผล) Styles */
.summary-subtab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.summary-subtab-btn:hover {
  color: var(--primary);
}

.summary-subtab-btn.active {
  color: var(--primary);
  font-weight: 700;
}

.summary-subtab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

.summary-filter-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.summary-filter-btn:hover {
  background: var(--bg-main);
  color: var(--text-main);
  border-color: #cbd5e1;
}

.summary-filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.summary-filter-btn.active i {
  color: #fff !important;
}

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

.summary-view-toggle.active {
  background: var(--primary) !important;
  color: #fff !important;
  box-shadow: var(--shadow-sm);
}

/* Modal Parallel Pool Drop Picker: Perfectly Centered Above All Sidebars */
#modalParallelPoolDropPicker {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(15, 23, 42, 0.65) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
  z-index: 99999 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  box-sizing: border-box !important;
}

#modalParallelPoolDropPicker.active {
  display: flex !important;
}

#modalParallelPoolDropPicker .modal-dialog {
  max-width: 860px !important;
  width: 95% !important;
  max-height: 92vh !important;
  margin: auto !important;
  background: #ffffff !important;
  border-radius: 16px !important;
  overflow: hidden !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4) !important;
  display: flex !important;
  flex-direction: column !important;
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
