/* ==========================================================================
   PRIMARY SCHOOL MANAGEMENT SYSTEM (ប្រព័ន្ធគ្រប់គ្រងសាលាបឋមសិក្សា)
   Modern Glassmorphism & Royal Navy/Gold Theme with Khmer Typography
   ========================================================================== */

@import url('fonts.css');

:root {
  --font-base: 'Khmer OS Battambang', 'Battambang', sans-serif;
  --font-heading: 'Khmer OS Battambang', 'Battambang', sans-serif;
  --font-muol: 'Khmer OS Battambang', 'Battambang', sans-serif;

  /* Color Palette */
  --primary-900: #0f172a;
  --primary-800: #1e293b;
  --primary-700: #1e3a8a; /* Royal Navy */
  --primary-600: #2563eb;
  --primary-500: #3b82f6;
  --primary-100: #dbeafe;
  --primary-50: #eff6ff;

  --accent-gold: #d97706; /* Cambodian Royal Gold */
  --accent-gold-light: #fef3c7;
  
  --emerald-600: #059669;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;

  --danger-600: #dc2626;
  --danger-500: #ef4444;
  --danger-100: #fee2e2;

  --warning-500: #f59e0b;
  --warning-100: #fef3c7;

  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;

  --bg-main: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.96);
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(226, 232, 240, 0.8);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

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

*:not(i):not([class*="fa-"]):not([class^="fa-"]) {
  font-family: 'Khmer OS Battambang', 'Battambang', sans-serif;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-main);
  color: var(--slate-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea, optgroup, option {
  font-family: 'Khmer OS Battambang', 'Battambang', sans-serif !important;
  -webkit-font-smoothing: antialiased;
}

.muol-font {
  font-family: 'Khmer OS Battambang', 'Battambang', sans-serif;
  font-weight: 700;
  letter-spacing: 0.5px;
}

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

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  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 24px rgba(0, 0, 0, 0.15);
}

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

.school-logo-badge {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--accent-gold) 0%, #b45309 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
  flex-shrink: 0;
}

.school-info h2 {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.school-info span {
  font-size: 11px;
  color: var(--accent-gold-light);
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-400);
  padding: 12px 14px 6px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: linear-gradient(90deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nav-item .icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
}

.nav-item .badge-pill {
  margin-left: auto;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

/* Main Content Area */
.main-wrapper {
  margin-left: 280px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  width: calc(100% - 280px);
  max-width: 100%;
  background-color: var(--bg-main);
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Navbar */
.top-navbar {
  height: 70px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.nav-left .page-title-group h1 {
  font-size: clamp(15px, 1.3vw, 19px);
  font-weight: 700;
  color: var(--slate-900);
}

.nav-left .breadcrumb {
  font-size: 12px;
  color: var(--slate-500);
}

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

/* Sidebar Toggle Button (All Devices & Screen Sizes) */
.mobile-nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--slate-200);
  color: var(--slate-700);
  font-size: 17px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.mobile-nav-toggle:hover {
  background: var(--slate-100);
  color: var(--primary-700);
  border-color: var(--primary-500);
}

[data-theme="dark"] .mobile-nav-toggle {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

[data-theme="dark"] .mobile-nav-toggle:hover {
  background: #334155;
  color: #60a5fa;
}

/* Sidebar Backdrop Overlay for Mobile / Tablet */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 48;
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

/* Hero Welcome Banner */
.dashboard-hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #312e81 100%);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 26px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px -10px rgba(30, 58, 138, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.dashboard-hero-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

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

.hero-left h2 {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-left p {
  color: #cbd5e1;
  font-size: 13.5px;
  max-width: 580px;
}

.hero-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-pill {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

/* Quick Action Dock Grid */
.quick-dock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.quick-dock-btn {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  color: var(--slate-800);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.quick-dock-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.08);
  border-color: var(--primary-500);
  color: var(--primary-700);
}

.quick-dock-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.25s ease;
}

.quick-dock-btn:hover .quick-dock-icon {
  transform: scale(1.1);
}
/* Modern Dashboard Grids */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Classes Directory Overview Grid */
.classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.class-overview-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.05);
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.class-overview-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.1);
  border-color: var(--primary-400);
}

.class-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.class-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
}

.class-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--slate-600);
}

/* Modern Card Glow & Progress Bars */
.stat-card-v2 {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 22px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px -3px rgba(15, 23, 42, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.stat-card-v2:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 28px -6px rgba(15, 23, 42, 0.12);
  border-color: #cbd5e1;
}

.stat-card-v2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-600), var(--accent-gold));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card-v2:hover::before {
  opacity: 1;
}

/* Progress bar container */
.ratio-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--slate-100);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  margin-top: 10px;
}

.ratio-progress-segment {
  height: 100%;
  transition: width 0.6s ease;
}

/* Honor Roll List */
.honor-roll-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--slate-200);
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.honor-roll-item:hover {
  background: #fff;
  border-color: var(--primary-300);
  box-shadow: var(--shadow-sm);
  transform: translateX(3px);
}

.honor-rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; box-shadow: 0 2px 6px rgba(217, 119, 6, 0.4); }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.rank-other { background: var(--slate-200); color: var(--slate-700); }


.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.stat-card-title {
  font-size: 13px;
  color: var(--slate-500);
  font-weight: 500;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-card-icon.blue { background: var(--primary-100); color: var(--primary-700); }
.stat-card-icon.gold { background: var(--accent-gold-light); color: var(--accent-gold); }
.stat-card-icon.green { background: var(--emerald-100); color: var(--emerald-600); }
.stat-card-icon.red { background: var(--danger-100); color: var(--danger-600); }
.stat-card-icon.purple { background: #f3e8ff; color: #7e22ce; }

.stat-card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.2;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Dashboard Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--slate-100);
}

.chart-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Data Tables & Panels */
.data-panel {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.panel-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--slate-200);
  flex-wrap: wrap;
  gap: 14px;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Search and Filters Bar */
.filter-bar {
  padding: 14px 24px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-group {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  font-family: var(--font-base);
  font-size: 13.5px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  font-size: 14px;
}

.select-filter {
  padding: 8px 14px;
  font-family: var(--font-base);
  font-size: 13px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--slate-700);
  outline: none;
}

.select-filter:focus {
  border-color: var(--primary-600);
}

/* Custom Styled Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.table-custom th {
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 2px solid var(--slate-200);
  white-space: nowrap;
}

.table-custom th.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.table-custom th.th-sortable:hover {
  background: #e2e8f0;
  color: var(--primary-700);
}

.table-custom th.th-sortable .sort-icon {
  font-size: 11px;
  margin-left: 5px;
  color: var(--slate-400);
  transition: color 0.15s ease;
}

.table-custom th.th-sortable.sorted-asc .sort-icon,
.table-custom th.th-sortable.sorted-desc .sort-icon {
  color: var(--primary-600);
}

.table-custom td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--slate-200);
  color: var(--slate-800);
  vertical-align: middle;
}

.table-custom tbody tr:hover {
  background-color: var(--primary-50);
}

/* Vertical Table Header for Score Sheet */
.th-vertical {
  height: 125px;
  width: 28px;
  min-width: 27px;
  max-width: 32px;
  padding: 4px 1px !important;
  vertical-align: bottom !important;
  text-align: center;
  position: relative;
  background-color: #f8fafc;
  overflow: hidden;
}

.th-v-wrap {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  display: inline-block;
  text-align: left;
  line-height: 1.1;
  margin: 0 auto;
}

.th-v-wrap span {
  font-family: 'Khmer OS Battambang', 'Battambang', sans-serif !important;
  font-size: 10px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
  display: inline-block;
}

.th-vertical-red,
.th-vertical-red .th-v-wrap span {
  color: #dc2626 !important;
  font-weight: 700;
}

/* Master Score Sheet Styling & Horizontal Scrollbar */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  margin-bottom: 1rem;
  position: relative;
}

/* Custom Visible Scrollbar for Horizontal Table Dragging */
.table-responsive::-webkit-scrollbar,
.top-scrollbar-track::-webkit-scrollbar,
.data-panel::-webkit-scrollbar,
.main-wrapper::-webkit-scrollbar,
body::-webkit-scrollbar {
  height: 14px;
  width: 14px;
}

.table-responsive::-webkit-scrollbar-track,
.top-scrollbar-track::-webkit-scrollbar-track,
.data-panel::-webkit-scrollbar-track,
.main-wrapper::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: #cbd5e1;
  border-radius: 8px;
}

.table-responsive::-webkit-scrollbar-thumb,
.top-scrollbar-track::-webkit-scrollbar-thumb,
.data-panel::-webkit-scrollbar-thumb,
.main-wrapper::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: #2563eb;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  cursor: pointer;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.top-scrollbar-track::-webkit-scrollbar-thumb:hover,
.data-panel::-webkit-scrollbar-thumb:hover,
.main-wrapper::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: #1d4ed8;
}

/* Firefox Scrollbar Support */
.table-responsive,
.top-scrollbar-track,
.data-panel,
.main-wrapper {
  scrollbar-width: auto;
  scrollbar-color: #2563eb #cbd5e1;
}

.score-sheet-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1450px;
  font-size: 11.5px;
  border: 1px solid #94a3b8;
}

.score-sheet-table th, 
.score-sheet-table td {
  border: 1px solid #cbd5e1;
  padding: 4px 3px;
  text-align: center;
  vertical-align: middle;
  background: #ffffff;
}

.score-sheet-table thead th {
  background: #ffffff;
  color: #0f172a;
  font-weight: 700;
}

.score-sheet-table thead tr:first-child th {
  background: #f8fafc;
  font-size: 12px;
}

/* Sticky Left Freeze Columns for Effortless Horizontal Scrolling */
.sticky-col-1 {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #ffffff !important;
  width: 35px;
  min-width: 35px;
}

.sticky-col-2 {
  position: sticky;
  left: 35px;
  z-index: 5;
  background: #ffffff !important;
  width: 75px;
  min-width: 75px;
}

.sticky-col-3 {
  position: sticky;
  left: 110px;
  z-index: 5;
  background: #ffffff !important;
  width: 140px;
  min-width: 140px;
  text-align: left !important;
  padding-left: 8px !important;
}

.sticky-col-4 {
  position: sticky;
  left: 250px;
  z-index: 5;
  background: #ffffff !important;
  width: 45px;
  min-width: 45px;
  box-shadow: 3px 0 6px -2px rgba(0, 0, 0, 0.15);
}

.score-sheet-table thead tr th.sticky-col-1,
.score-sheet-table thead tr th.sticky-col-2,
.score-sheet-table thead tr th.sticky-col-3,
.score-sheet-table thead tr th.sticky-col-4 {
  z-index: 10;
  background: #f1f5f9 !important;
}

/* Quick Scroll Navigation Bar */
.table-scroll-controller {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

.scroll-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid #94a3b8;
  color: #1e3a8a;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.scroll-nav-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
  transform: translateY(-1px);
}

/* Floating Save Action Dock */
.floating-save-dock {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 50px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: slideUp 0.3s ease-out;
}

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

/* Interactive Score Input Cells */
.score-input-cell {
  width: 100%;
  min-width: 42px;
  max-width: 52px;
  height: 26px;
  padding: 1px 3px;
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  outline: none;
  background: #ffffff;
  transition: all 0.15s ease;
}

.score-input-cell:hover {
  border-color: #94a3b8;
}

.score-input-cell:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
  background: #eff6ff;
}

/* Signature Custom Date Inputs */
.signature-date-input {
  border: none;
  border-bottom: 1px dashed #94a3b8;
  text-align: center;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--slate-700);
  background: transparent;
  width: 240px;
  outline: none;
  padding: 3px 6px;
  transition: border-color 0.2s ease;
}

.signature-date-input:focus {
  border-bottom: 2px solid #2563eb;
  background: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.3;
}

.badge-success { background: var(--emerald-100); color: var(--emerald-600); }
.badge-warning { background: var(--warning-100); color: #b45309; }
.badge-danger { background: var(--danger-100); color: var(--danger-600); }
.badge-info { background: var(--primary-100); color: var(--primary-700); }
.badge-secondary { background: var(--slate-200); color: var(--slate-700); }
.badge-gold { background: var(--accent-gold-light); color: var(--accent-gold); }

/* Slow Learner Level Badges */
.badge-slow-1 { background: #fee2e2; color: #b91c1c; border: 1px solid #f87171; } /* 🔴 Level 1 Severe */
.badge-slow-2 { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; } /* 🟡 Level 2 Moderate */
.badge-slow-3 { background: #d1fae5; color: #047857; border: 1px solid #6ee7b7; } /* 🟢 Level 3 Mild */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-base);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-600) 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-800) 0%, var(--primary-700) 100%);
  transform: translateY(-1px);
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #b45309 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.25);
}

.btn-gold:hover {
  background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--emerald-500);
  color: #fff;
}

.btn-success:hover {
  background: var(--emerald-600);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--slate-300);
  color: var(--slate-700);
}

.btn-outline:hover {
  background: var(--slate-100);
  border-color: var(--slate-400);
}

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

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

.btn-copy-pob {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-family: var(--font-base);
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.05);
}

.btn-copy-pob:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.12);
}

.btn-copy-pob:active {
  transform: translateY(0);
}

.btn-copy-pob:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* Modals - Universal Centered & Draggable */
.modal-backdrop,
.sidebar-modal-overlay,
[id*="Modal"][style*="position: fixed"],
[id*="modal"][style*="position: fixed"] {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center !important;
  justify-content: center !important;
  z-index: 99999;
  padding: 16px;
  box-sizing: border-box;
}

.modal-backdrop.show,
.sidebar-modal-overlay.show {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.modal-dialog,
.sidebar-modal-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 650px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  margin: auto;
  box-sizing: border-box;
  position: relative;
  will-change: transform;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header,
.sidebar-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.modal-header:active,
.sidebar-modal-header:active {
  cursor: grabbing;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--slate-400);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: var(--slate-100);
  color: var(--slate-700);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--slate-200);
  background: var(--slate-50);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 14px;
  font-family: var(--font-base);
  font-size: 13.5px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

.toast {
  background: var(--slate-900);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid var(--primary-500);
}

.toast.success { border-left-color: var(--emerald-500); }
.toast.error { border-left-color: var(--danger-500); }
.toast.warning { border-left-color: var(--warning-500); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Styles */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}
/* Toast Notification Styles */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13.5px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  max-width: 420px;
}
.toast:hover {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  transform: translateY(-2px);
}
.toast.success {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #15803d;
}
.toast.error, .toast.danger {
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  color: #b91c1c;
}
.toast.warning {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #b45309;
}
.toast.info {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #1d4ed8;
}
.toast-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  margin-left: auto;
  padding: 0 0 0 10px;
  color: inherit;
  transition: opacity 0.2s ease;
}
.toast-close-btn:hover {
  opacity: 1;
}
@keyframes toastSlideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Student Status Multi-choose Chips */
.status-multi-container {
  background: #f8fafc;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.status-multichoose-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.btn-status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.btn-status-toggle:hover {
  border-color: #93c5fd;
  background: #f0f9ff;
  color: #1e3a8a;
}
.btn-status-toggle.active {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}
.btn-status-toggle.active .check-icon {
  color: #2563eb;
}

/* ==========================================================================
   DARK THEME SYSTEM (ផ្ទាំងងងឹត ឬភ្លឺ)
   ========================================================================== */
[data-theme="dark"] {
  --bg-main: #090d16;
  --card-bg: #111827;
  --glass-bg: rgba(17, 24, 39, 0.88);
  --glass-border: rgba(55, 65, 81, 0.7);
  --slate-900: #f9fafb;
  --slate-800: #f3f4f6;
  --slate-700: #e5e7eb;
  --slate-600: #9ca3af;
  --slate-500: #9ca3af;
  --slate-400: #6b7280;
  --slate-200: #374151;
  --slate-100: #1f2937;
  --slate-50: #111827;
  --primary-50: #1e293b;
  --primary-100: #1e3a8a;
  color-scheme: dark;
}

[data-theme="dark"] body {
  background-color: #090d16;
  color: #e5e7eb;
}

[data-theme="dark"] .main-wrapper,
[data-theme="dark"] .content-body {
  background-color: #090d16;
}

[data-theme="dark"] .sidebar {
  background: #0f172a;
  border-right-color: #1e293b;
}

[data-theme="dark"] .sidebar-header {
  border-bottom-color: #1e293b;
}

[data-theme="dark"] .top-navbar {
  background: #111827;
  border-bottom-color: #1f2937;
  color: #f9fafb;
}

[data-theme="dark"] .data-panel,
[data-theme="dark"] .class-overview-card,
[data-theme="dark"] .stat-card-clean,
[data-theme="dark"] .stat-card {
  background-color: #111827 !important;
  color: #f9fafb !important;
  border-color: #374151 !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
  border-color: #374151 !important;
}

[data-theme="dark"] td, [data-theme="dark"] th {
  border-color: #374151 !important;
  color: #e5e7eb !important;
}

[data-theme="dark"] .nav-item {
  color: #9ca3af;
}

[data-theme="dark"] .nav-item:hover {
  background: #1f2937;
  color: #60a5fa;
}

[data-theme="dark"] .nav-item.active {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #ffffff;
}

/* Sidebar Modals (Subscription & Feedback) */
.sidebar-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sidebar-modal-card {
  background: #ffffff;
  color: #0f172a;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
[data-theme="dark"] .sidebar-modal-card {
  background: #1e293b;
  color: #f8fafc;
  border-color: #334155;
}
[data-theme="dark"] .sidebar-modal-card .plan-box-inner {
  background: rgba(22, 163, 74, 0.15) !important;
  border-color: rgba(34, 197, 94, 0.4) !important;
}
[data-theme="dark"] .sidebar-modal-card .plan-box-title {
  color: #86efac !important;
}
[data-theme="dark"] .sidebar-modal-card .spec-row {
  border-bottom-color: #334155 !important;
  color: #cbd5e1 !important;
}
[data-theme="dark"] .sidebar-modal-card .spec-val {
  color: #f1f5f9 !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM (Desktop, Laptop, Tablet, Phone)
   ========================================================================== */

/* 1. Desktop & Laptop Collapsed Mini-Sidebar Mode (Width >= 1025px) */
@media (min-width: 1025px) {
  .sidebar-collapsed .sidebar {
    width: 72px !important;
  }
  .sidebar-collapsed .sidebar .sidebar-header {
    display: none !important;
  }
  .sidebar-collapsed .sidebar .nav-section-title {
    display: none !important;
  }
  .sidebar-collapsed .sidebar .nav-item {
    justify-content: center !important;
    padding: 12px 0 !important;
    position: relative;
    border-radius: 10px;
    margin: 4px 6px;
  }
  .sidebar-collapsed .sidebar .nav-item span:not(.icon),
  .sidebar-collapsed .sidebar .nav-item i:not(.icon i):not(.fa-solid):not(.fa-regular),
  .sidebar-collapsed .sidebar .nav-item #theme_toggle_switch,
  .sidebar-collapsed .sidebar .nav-item span[style*="border-radius: 9999px"] {
    display: none !important;
  }
  .sidebar-collapsed .sidebar .nav-item .icon {
    font-size: 20px !important;
    width: auto !important;
    margin: 0 !important;
  }
  .sidebar-collapsed .sidebar .sidebar-footer {
    display: none !important;
  }
  .sidebar-collapsed .main-wrapper {
    margin-left: 72px !important;
    width: calc(100% - 72px) !important;
  }
  /* Floating Tooltip on Hover in Mini Mode */
  .sidebar-collapsed .sidebar .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 78px;
    background: #0f172a;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: none;
    animation: miniNavTooltip 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

@keyframes miniNavTooltip {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

/* 2. Standard Laptops (1025px - 1440px / 1366x768 screens) */
@media (min-width: 1025px) and (max-width: 1440px) {
  .top-navbar {
    padding: 0 16px;
  }
  .nav-left {
    gap: 12px;
  }
  .nav-left .page-title-group h1 {
    font-size: 16px;
  }
  .nav-right {
    gap: 10px;
  }
  .user-profile-menu div > div:first-child {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .content-body {
    padding: 18px !important;
  }
}

/* 3. Universal Responsive Table Container across ALL Screen Sizes */
table {
  max-width: 100%;
}
.table-responsive,
.data-panel .table-wrapper,
.data-panel > div:has(table),
div:has(> table),
.data-panel table {
  max-width: 100%;
}

.table-responsive,
.data-panel > div:has(table),
div:has(> table) {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* 4. Short Screens / Laptop Height (<= 800px viewport height) */
@media (max-height: 800px) {
  .modal-dialog,
  .sidebar-modal-card {
    max-height: calc(100vh - 24px) !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .modal-header,
  .sidebar-modal-header {
    flex-shrink: 0 !important;
    padding: 12px 18px !important;
  }
  .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 16px 18px !important;
    max-height: calc(100vh - 130px) !important;
  }
  .modal-footer {
    flex-shrink: 0 !important;
    padding: 10px 18px !important;
  }
}

/* 5. Tablet & Large Mobile (<= 1024px) */
@media (max-width: 1024px) {
  .mobile-nav-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    z-index: 50;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.35);
  }

  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
  }

  .top-navbar {
    padding: 0 16px;
    height: 64px;
  }

  .content-body {
    padding: 16px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }

  .charts-grid,
  .dashboard-columns {
    grid-template-columns: 1fr !important;
  }

  .action-grid-container,
  .action-grid-secondary,
  .action-grid-tertiary {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  }
}

/* 6. Mobile Devices & Phones (<= 768px) */
@media (max-width: 768px) {
  .app-container {
    overflow-x: hidden;
  }

  .top-navbar {
    height: auto;
    min-height: 58px;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-left {
    gap: 10px;
    flex: 1;
    min-width: 0;
  }

  .nav-left .page-title-group h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
  }

  .nav-left .breadcrumb {
    display: none !important;
  }

  .nav-right {
    gap: 8px;
    flex-shrink: 0;
  }

  .user-profile-menu {
    padding: 4px 8px;
    gap: 6px;
  }

  .user-profile-menu div > div:first-child {
    font-size: 12px !important;
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-profile-menu div > div:last-child {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .stat-card-v2 {
    padding: 14px !important;
  }

  .stat-card-value {
    font-size: 24px !important;
  }

  .action-grid-container,
  .action-grid-secondary,
  .action-grid-tertiary {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .feature-action-card {
    padding: 12px 10px !important;
  }

  .content-body {
    padding: 12px !important;
  }

  .data-panel table {
    min-width: 540px;
  }

  /* Responsive Modals */
  .modal-dialog,
  .sidebar-modal-card {
    width: 95% !important;
    max-width: 95% !important;
    margin: 12px auto !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    padding: 0 !important;
  }

  /* Stack multi-column forms into 1 column on phone */
  form div[style*="grid-template-columns: 1fr 1fr"],
  form div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .panel-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .panel-header .btn,
  .panel-header a {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* Touch Friendly Targets (min 42px) */
  .btn, button, .nav-item {
    min-height: 42px;
  }
}

/* 7. Small Phones (<= 420px) */
@media (max-width: 420px) {
  .action-grid-container,
  .action-grid-secondary,
  .action-grid-tertiary {
    grid-template-columns: 1fr !important;
  }

  .nav-left .page-title-group h1 {
    font-size: 14px;
    max-width: 50vw;
  }
}

/* 8. Modern Native Desktop App UI Feel */
.sidebar,
.top-navbar,
.modal-header,
.modal-footer,
.panel-header,
button,
.btn {
  user-select: none;
  -webkit-user-select: none;
}

td,
.data-panel table td,
input,
textarea,
select {
  user-select: text;
  -webkit-user-select: text;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
}

.top-navbar {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .top-navbar {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
}

