:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text: #111827;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-soft: #ede9fe;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --amber-soft: #fffbeb;
  --danger-soft: #fef2f2;
  /* Enhanced shadows for modern depth */
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
  /* Modern gradients */
  --gradient-purple: linear-gradient(135deg, #7c3aed 0%, #6d28d9 50%, #5b21b6 100%);
  --gradient-blue: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
  --gradient-brand: linear-gradient(135deg, #7c3aed 0%, #6366f1 50%, #4f46e5 100%);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { 
  color: var(--primary); 
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover { color: var(--primary-dark); }

.container { 
  max-width: 1240px; 
  margin: 0 auto; 
  padding: 0 24px;
}

.page { 
  max-width: 1240px; 
  margin: 0 auto; 
  padding: 32px 24px 64px;
}

/* === NAVIGATION === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
  gap: 16px;
}

/* === BRAND === */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  color: var(--text);
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--gradient-brand);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}

.brand-title {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 18px;
}

.nav-links { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.nav-links a,
.nav-links button {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-links a:hover,
.nav-links button:hover { 
  background: var(--surface-soft); 
  color: var(--text);
  transform: translateY(-1px);
}

.active-nav { 
  background: var(--primary-soft) !important; 
  color: var(--primary) !important;
  font-weight: 600;
}

/* === PAGE HEADER === */
.page-header { 
  margin-bottom: 28px;
  position: relative;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 36px;
  line-height: 1.15;
  font-weight: 800;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
  display: inline-block;
  position: relative;
}

.page-header h1::after {
  content: '';
  display: block;
  width: 48px;
  height: 4px;
  background: var(--gradient-brand);
  border-radius: 4px;
  margin-top: 10px;
  transition: width 0.3s ease;
}

.page-header:hover h1::after {
  width: 80px;
}

.page-header p { 
  margin: 0; 
  color: var(--muted);
  font-size: 15px;
}

/* === GRIDS === */
.grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; }
.grid-4 { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }

/* === CARDS & PANELS === */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
}

.panel h2, .panel h3 { margin: 0 0 14px; font-weight: 700; }

/* === AUTH PAGES === */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--gradient-purple);
  position: relative;
  overflow: hidden;
}

.auth-wrap::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  animation: pulse 15s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5%, 5%) scale(1.05); }
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: #fff;
  color: var(--text);
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
  padding: 32px;
  position: relative;
  z-index: 1;
}

.auth-card.wide { max-width: 580px; }

.auth-card h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 32px;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.auth-subtitle { 
  text-align: center; 
  color: var(--muted); 
  margin-bottom: 24px;
  font-size: 15px;
}

.form-grid { display: grid; gap: 14px; }
.form-grid.two-col { grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }

/* === FORM INPUTS === */
label { 
  font-size: 14px; 
  color: #334155; 
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

input, textarea, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  background: #fff;
  font-size: 14px;
  transition: all 0.2s ease;
  font-family: inherit;
}

input:hover, textarea:hover, select:hover {
  border-color: #cbd5e1;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #8b5cf6;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
  background: #fefefe;
}

textarea { resize: vertical; min-height: 100px; }

/* === BUTTONS === */
.btn {
  border: none;
  border-radius: 12px;
  background: var(--gradient-purple);
  color: #fff;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(124, 58, 237, 0.15);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover { 
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

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

.btn-outline {
  background: transparent;
  color: #334155;
  border: 1.5px solid var(--border);
  box-shadow: none;
}

.btn-outline:hover { 
  background: var(--surface-soft);
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}

.btn-soft-blue { 
  background: var(--gradient-blue);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
}

.btn-soft-blue:hover {
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-soft-green { 
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.15);
}

.btn-soft-green:hover {
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.muted { color: var(--muted); }

/* === ALERTS & BADGES === */
.alert {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1.5px solid;
  font-weight: 500;
}

.alert-error { 
  background: var(--danger-soft); 
  color: #b91c1c; 
  border-color: #fecaca;
}

.alert-success { 
  background: var(--green-soft); 
  color: #166534; 
  border-color: #86efac;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-green { background: var(--green-soft); color: #166534; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* === STAT CARDS === */
.stat-card p { 
  margin: 10px 0 0; 
  font-weight: 800; 
  font-size: 32px;
  line-height: 1;
}

.attendance-present p { color: #16a34a; }
.attendance-late p { color: #d97706; }
.attendance-missed p { color: #dc2626; }
.homework-pending p { color: #d97706; }
.homework-completed p { color: #16a34a; }

/* === ATTENDANCE & PROGRESS === */
.attendance-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.attendance-percentage {
  margin: 0;
  font-size: 48px;
  font-weight: 800;
  background: var(--gradient-purple);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  letter-spacing: -0.02em;
}

.attendance-progress {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 8px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.attendance-progress-fill { 
  height: 100%;
  transition: width 0.3s ease;
}

.attendance-progress-fill.ok, .mini-progress-fill.ok { 
  background: linear-gradient(90deg, #16a34a, #15803d);
}

.attendance-progress-fill.warn, .mini-progress-fill.warn { 
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.attendance-progress-fill.bad, .mini-progress-fill.bad { 
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.mini-progress {
  margin-top: 8px;
  width: 110px;
  max-width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mini-progress-fill { 
  height: 100%;
  transition: width 0.3s ease;
}

/* === TABS === */
.tab-btn {
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  color: #475569;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
}

.tab-btn:hover { 
  background: #f8fafc;
  border-color: #cbd5e1;
}

.tab-btn.active {
  border-color: #c4b5fd;
  background: #ede9fe;
  color: #7c3aed;
  font-weight: 700;
}

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

.active-tab { 
  background: var(--primary-soft) !important; 
  color: var(--primary) !important; 
  border-color: #c4b5fd !important;
  font-weight: 700;
}

.homework-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 4px;
}

.homework-done { opacity: 0.7; }

/* === UTILITY CLASSES === */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.muted { color: var(--muted); }

/* === EVENT CARDS === */
.events-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-card {
  border: 1.5px solid #fcd34d;
  background: linear-gradient(180deg, #fff 0%, #fffdf5 100%);
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.event-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: #fbbf24;
}

.event-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.event-meta {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  color: #64748b;
  font-size: 13px;
}

.badge-purple { background: #ede9fe; color: #7c3aed; }

/* === TABLES === */
table { 
  width: 100%; 
  border-collapse: collapse; 
  font-size: 14px;
  border-radius: 12px;
  overflow: hidden;
}

th, td { 
  border-bottom: 1px solid var(--border); 
  padding: 14px 12px; 
  text-align: left; 
  vertical-align: top;
}

thead th { 
  color: #64748b; 
  font-size: 12px; 
  text-transform: uppercase; 
  letter-spacing: .05em;
  background: #f8fafc;
  font-weight: 700;
  padding: 16px 12px;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:nth-child(even) {
  background: #fafbfc;
}

tbody tr:hover {
  background: #f1f5f9;
}

.today-row td { 
  background: #eef2ff !important;
  font-weight: 500;
}

.in-progress-row td { 
  background: #ecfdf5 !important;
  font-weight: 500;
}

/* === ANNOUNCEMENTS === */
.announce-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

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

.announce-card h3 { 
  margin: 0 0 8px;
  font-weight: 700;
}

.announce-card p { 
  margin: 0; 
  white-space: pre-wrap; 
  color: #475569;
  line-height: 1.6;
}

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

.active-tab { 
  background: var(--primary-soft) !important; 
  color: var(--primary) !important; 
  border-color: #c4b5fd !important;
  font-weight: 700;
}

.pagination { 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  gap: 10px;
  margin-top: 20px;
}

.disabled { opacity: .4; pointer-events: none; }

/* === AVATAR === */
.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: var(--gradient-brand);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
  font-size: 16px;
}

.avatar img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover;
}

/* === STUDENT CARDS === */
.students-grid { 
  display: grid; 
  gap: 20px; 
  grid-template-columns: repeat(4, minmax(0, 1fr)); 
}

.student-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 20px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.25s ease;
}

.student-card:hover { 
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: #c4b5fd;
}

.student-card h3 { 
  margin: 12px 0 4px; 
  font-size: 16px;
  font-weight: 700;
}

/* === MODALS === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-xl);
}

.modal h3 { 
  margin: 10px 0 4px; 
  font-size: 26px; 
  text-align: center;
  font-weight: 800;
}

.profile-info { 
  display: grid; 
  gap: 10px; 
  margin-top: 18px;
}

.profile-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.profile-item:hover {
  background: #f1f5f9;
}

.profile-item small { 
  color: var(--muted); 
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* === TELEGRAM-STYLE MESSAGES === */
.tg-layout {
  height: calc(100vh - 64px);
  display: flex;
  background: #e8ecf1;
  margin: -24px -24px -40px;
  width: calc(100% + 48px);
  overflow: hidden;
  box-sizing: border-box;
  max-width: 100vw;
}

.tg-sidebar {
  width: 360px;
  min-width: 320px;
  background: #fff;
  border-right: 1px solid #dadfe5;
  display: flex;
  flex-direction: column;
}

.tg-sidebar-head {
  padding: 10px;
  background: #fff;
}

.tg-search {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 22px;
  background: #f0f2f5;
  font-size: 14px;
  outline: none;
  transition: background 0.2s;
}

.tg-search:focus {
  background: #e6e9ed;
}

.tg-chat-list {
  flex: 1;
  overflow-y: auto;
}

.tg-section-divider {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  color: #3390ec;
  background: #f0f2f5;
}

.tg-chat-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  color: var(--text);
  transition: background 0.12s;
  cursor: pointer;
  border-radius: 0;
}

.tg-chat-item:hover { background: #f0f2f5; }

.tg-chat-item.active {
  background: #3390ec;
  color: #fff;
}

.tg-chat-item.active .tg-chat-last,
.tg-chat-item.active .tg-chat-name {
  color: #fff;
}

.tg-chat-avatar {
  width: 50px;
  height: 50px;
  min-width: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ca0f2, #3390ec);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  overflow: hidden;
}

.tg-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.tg-group-avatar {
  background: linear-gradient(135deg, #34d058, #2ea44f);
}

.tg-chat-info { min-width: 0; flex: 1; }
.tg-chat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.tg-chat-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #000;
}

.tg-chat-last {
  font-size: 13px;
  color: #8d969c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tg-reaction-picker {
  display: flex;
  gap: 0;
  flex-wrap: nowrap;
  padding: 2px;
}
.tg-reaction-picker button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  padding: 4px 5px;
  border-radius: 8px;
  transition: background 0.15s, transform 0.15s;
  line-height: 1;
}
.tg-reaction-picker button:hover {
  background: rgba(0,0,0,0.07);
  transform: scale(1.2);
}

/* Back button (only visible on mobile) */
.tg-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  color: #3390ec;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
}
.tg-back-btn:hover { background: #f0f2f5; }

/* Main chat area */
.tg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e8ecf1;
}

.tg-header {
  background: #fff;
  border-bottom: 1px solid #dadfe5;
  padding: 10px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.tg-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tg-header-name { font-weight: 600; font-size: 15px; color: #000; }
.tg-header-status { font-size: 13px; color: #8d969c; }

.tg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: url("data:image/svg+xml,%3Csvg width='80' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23d5dce4' fill-opacity='0.4'%3E%3Ccircle cx='40' cy='40' r='1.5'/%3E%3C/g%3E%3C/svg%3E") repeat;
}

.tg-msg-row {
  display: flex;
  padding: 1px 0;
}

.tg-msg-row.outgoing { justify-content: flex-end; }
.tg-msg-row.incoming { justify-content: flex-start; }

.tg-bubble {
  max-width: 55%;
  padding: 7px 10px 6px;
  border-radius: 12px;
  position: relative;
  word-break: break-word;
  line-height: 1.45;
  font-size: 14px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
}

.tg-bubble.in {
  background: #fff;
  border-bottom-left-radius: 4px;
}

.tg-bubble.out {
  background: #effdde;
  border-bottom-right-radius: 4px;
}

.tg-msg-content {
  white-space: pre-wrap;
  color: #000;
}

.tg-deleted {
  font-style: italic;
  color: #8d969c;
  font-size: 13px;
}

.tg-forwarded {
  font-size: 12px;
  color: #3390ec;
  font-weight: 600;
  margin-bottom: 3px;
}

.tg-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  float: right;
  margin-left: 12px;
  position: relative;
  bottom: -3px;
}

.tg-msg-time {
  font-size: 11px;
  color: #8d969c;
}

.tg-bubble.out .tg-msg-time { color: #6db877; }

.tg-edited {
  font-size: 10px;
  color: #8d969c;
}

.tg-check {
  font-size: 12px;
  color: #4caf50;
  letter-spacing: -3px;
}

.tg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  clear: both;
}

.tg-reaction {
  background: rgba(51,144,236,.1);
  border: 1px solid rgba(51,144,236,.2);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 14px;
  cursor: pointer;
}

/* Hover actions – Telegram-style popup */
.tg-msg-actions {
  display: none;
  position: absolute;
  top: -12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  padding: 0;
  z-index: 10;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.tg-msg-row.outgoing .tg-msg-actions { right: 0; }
.tg-msg-row.incoming .tg-msg-actions { left: 0; }

.tg-bubble:hover .tg-msg-actions {
  display: flex;
}

.tg-action-form { display: contents; }

.tg-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 2px 4px;
  border-top: 1px solid #e8ebee;
}

.tg-actions-row button,
.tg-actions-row .tg-del-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  padding: 7px 10px;
  border-radius: 8px;
  transition: background 0.15s;
  color: #555;
  line-height: 1;
}

.tg-actions-row button:hover {
  background: #f0f2f5;
}

.tg-del-btn:hover {
  background: #fef2f2 !important;
  color: #dc2626 !important;
}

/* Mobile: show actions on tap (toggle via JS) */
.tg-msg-actions.show {
  display: flex;
}

/* Input bar */
.tg-input-bar {
  background: #fff;
  border-top: 1px solid #dadfe5;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.tg-input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: #f0f2f5;
  font-size: 14px;
  outline: none;
}

.tg-input:focus { background: #e6e9ed; }

.tg-send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #3390ec;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.tg-send-btn:hover { background: #2b7dd6; }

/* No chat selected */
.tg-no-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #8d969c;
}

.tg-no-chat-icon { font-size: 64px; opacity: 0.4; margin-bottom: 8px; }
.tg-no-chat h3 { font-size: 18px; color: #555; font-weight: 500; }

.tg-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #8d969c;
  padding: 40px;
}

.tg-empty-icon { font-size: 56px; opacity: 0.4; }

/* Forward modal select */
.tg-fwd-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #dadfe5;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}

.tg-fwd-select:focus { border-color: #3390ec; }

/* Edit textarea */
.tg-edit-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #dadfe5;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.tg-edit-textarea:focus { border-color: #3390ec; }

/* Sidebar top row */
.tg-sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.tg-sidebar-title {
  font-size: 17px;
  font-weight: 700;
  color: #000;
  margin: 0;
}
.tg-compose-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #3390ec;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.tg-compose-btn:hover { background: #2b7dd6; }

/* Pinned developer */
.tg-pinned { border-bottom: 2px solid #3390ec; }
.tg-dev-avatar {
  background: linear-gradient(135deg, #667eea, #764ba2) !important;
  position: relative;
}
.tg-dev-star {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 14px;
  line-height: 1;
}
.tg-dev-tag {
  display: inline-block;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 4px;
}
.tg-chat-item.tg-pinned.active .tg-dev-tag { background: rgba(255,255,255,0.3); }

/* Search results dropdown */
.tg-search-results {
  display: none;
  position: absolute;
  left: 10px;
  right: 10px;
  top: 90px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 30;
  max-height: 300px;
  overflow-y: auto;
}
.tg-sidebar-head { position: relative; }
.tg-sr-label {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  color: #3390ec;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tg-sr-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.12s;
  color: var(--text);
}
.tg-sr-item:hover { background: #f0f2f5; }
.tg-sr-img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.tg-sr-ava {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ca0f2, #3390ec);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.tg-sr-name { font-weight: 600; font-size: 14px; }
.tg-sr-sub { font-size: 12px; color: #8d969c; }

/* Create group link */
.tg-create-group-link {
  padding: 12px 16px;
  font-size: 14px;
  color: #3390ec;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.tg-create-group-link:hover { background: #f0f2f5; }

/* Header actions */
.tg-header-icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.tg-header-icon-btn:hover { background: #f0f2f5; }
.tg-del-chat-btn:hover { background: #fef2f2 !important; }

/* Group chat styles */
.tg-grp-avatar-sm {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5ca0f2, #3390ec);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  margin-right: 6px;
  align-self: flex-end;
  overflow: hidden;
}
.tg-grp-avatar-sm img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.tg-grp-sender {
  font-size: 12px;
  font-weight: 700;
  color: #3390ec;
  margin-bottom: 2px;
}

/* Members list */
.tg-member-list { display: grid; gap: 8px; }
.tg-member-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}

/* === DAY CARDS & TIMETABLE === */
.day-card { 
  border: 1.5px solid var(--border); 
  border-radius: 16px; 
  background: #fff; 
  margin-bottom: 20px; 
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

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

.day-card.today { 
  border-color: #8b5cf6;
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), var(--shadow-md);
}

.day-head { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 16px 18px; 
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  font-weight: 700;
}

.day-lessons { display: grid; }

.lesson-item { 
  padding: 16px 18px; 
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

.lesson-item:hover {
  background: #fafbfc;
}

.lesson-item:last-child { border-bottom: none; }

.lesson-item.active { 
  background: var(--green-soft);
  border-left: 4px solid #16a34a;
  padding-left: 14px;
}

/* === ADMIN SECTIONS === */
.admin-layout { min-height: 100vh; background: var(--bg); }

.admin-nav { 
  background: #fff; 
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.admin-nav-inner { 
  max-width: 1240px; 
  margin: 0 auto; 
  padding: 0 20px; 
  min-height: 68px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center;
}

.admin-content { 
  max-width: 1240px; 
  margin: 0 auto; 
  padding: 28px 20px 56px;
}

.admin-welcome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.admin-feature-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-feature-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.admin-feature-card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.admin-feature-purple { 
  background: linear-gradient(180deg, #fff 0%, #faf5ff 100%); 
  border-color: #ddd6fe;
}

.admin-feature-indigo { 
  background: linear-gradient(180deg, #fff 0%, #eef2ff 100%); 
  border-color: #c7d2fe;
}

.admin-feature-blue { 
  background: linear-gradient(180deg, #fff 0%, #eff6ff 100%); 
  border-color: #bfdbfe;
}

.admin-feature-green { 
  background: linear-gradient(180deg, #fff 0%, #ecfdf5 100%); 
  border-color: #bbf7d0;
}

.admin-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border: 1.5px solid #ddd6fe;
  box-shadow: var(--shadow-md);
}

.admin-hero h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
  color: #6d28d9;
  font-weight: 800;
}

.admin-hero p { 
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.admin-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-stats-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-stat-card {
  background: #fff;
  border: 1px solid var(--border);
  padding: 24px;
}

.admin-stat-label {
  display: block;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-stat-card h3 {
  margin: 8px 0 0;
  font-size: 34px;
  line-height: 1;
  color: #0f172a;
  font-weight: 800;
}

.admin-feature-card {
  text-decoration: none;
  color: inherit;
  transition: transform .2s ease, box-shadow .2s ease;
}

.admin-feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .students-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-feature-grid { grid-template-columns: 1fr 1fr; }
  .admin-stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid.two-col { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .admin-welcome { flex-direction: column; align-items: flex-start; }
  .admin-hero { flex-direction: column; }
}

@media (max-width: 640px) {
  .grid-4 { grid-template-columns: 1fr; }
  .students-grid { grid-template-columns: 1fr; }
  .events-grid { grid-template-columns: 1fr; }
  .attendance-percentage { font-size: 32px; }
  .admin-feature-grid { grid-template-columns: 1fr; }
  .admin-stats-grid { grid-template-columns: 1fr; }
  .page { padding: 20px 16px 40px; }
  .topbar-inner { min-height: 56px; }
}

/* === ENHANCEMENTS FOR ADMIN & DASHBOARD === */
.feature-icon {
  font-size: 24px;
  margin-bottom: 8px;
  display: block;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: block;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  margin-right: 4px;
}

/* Better spacing for admin pages */
.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.admin-section-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Enhanced card hover for clickable items */
a.panel:hover,
a.admin-feature-card:hover {
  border-color: #a78bfa;
  background: linear-gradient(135deg, #fefefe 0%, #faf5ff 100%);
}

/* Better form section styling */
.form-section {
  background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-section h2 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* Improved stat display */
.stat-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
  margin: 12px 0 0;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Better notification badge */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Enhanced empty state */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
}

.empty-state-subtext {
  font-size: 13px;
  opacity: 0.7;
}

/* Card with icon header */
.card-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--gradient-brand);
  color: white;
  font-size: 20px;
  margin-right: 12px;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

/* === ACTION BUTTONS IN HEADER === */
.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* === BREADCRUMB === */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--primary);
  font-weight: 500;
  transition: color 0.15s ease;
}

.breadcrumb a:hover {
  color: var(--primary-dark);
}

.breadcrumb-separator {
  color: var(--muted);
  opacity: 0.5;
}

/* === LOADING STATES === */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(124, 58, 237, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === SUCCESS STATE === */
.success-checkmark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-soft);
  color: var(--green);
  font-size: 28px;
  margin: 0 auto 16px;
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* === DROPDOWN MENU === */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  min-width: 200px;
  padding: 8px;
  display: none;
  z-index: 50;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: var(--surface-soft);
  color: var(--primary);
}

/* === IMPROVED HOVER EFFECTS === */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg) !important;
}

/* === CARD WITH HOVER GLOW === */
.card-glow {
  position: relative;
  overflow: hidden;
}

.card-glow::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-glow:hover::before {
  opacity: 1;
}

/* === ADMIN REFERENCE UI === */
.admin-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.admin-page-head h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.15;
  font-weight: 800;
  color: #1f2937;
}

.admin-section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.section-pill {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}

.section-pill.active {
  border-color: #c4b5fd;
  color: var(--primary);
  background: #f5f3ff;
}

.admin-table-shell {
  padding: 0;
  overflow: hidden;
}

.admin-table-toolbar {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.admin-search-input {
  max-width: 420px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table td,
.admin-table th {
  white-space: nowrap;
}

.student-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ede9fe;
  color: #6d28d9;
  font-weight: 700;
  font-size: 12px;
}

.admin-role-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 10px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  font-weight: 600;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.admin-modal {
  position: relative;
}

.modal-close {
  position: absolute;
  right: 14px;
  top: 10px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: #64748b;
  cursor: pointer;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.timetable-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.timetable-config h2 {
  margin-bottom: 2px;
}

.timetable-grid-wrap {
  overflow: auto;
}

.timetable-grid {
  min-width: 760px;
}

.slot-cell {
  font-weight: 700;
  color: #334155;
  width: 118px;
}

.timetable-cell-course {
  padding: 4px 0;
  font-size: 13px;
  color: #0f172a;
}

.news-form-shell {
  border-color: #c7d2fe;
}

.event-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.pill-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff;
  color: #64748b;
  font-size: 12px;
}

.pill-chip.active {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.event-admin-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.mini-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-head {
  font-size: 11px;
  color: #64748b;
  text-align: center;
  font-weight: 700;
  padding: 2px 0;
}

.cal-cell {
  border: 1px solid #f3f4f6;
  border-radius: 8px;
  min-height: 48px;
  padding: 6px;
  font-size: 12px;
  color: #92400e;
  background: #fffdf5;
}

.lesson-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.lesson-list {
  display: grid;
  gap: 10px;
}

.lesson-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.lesson-card h3 {
  margin: 0 0 4px;
  font-size: 22px;
}

.homework-admin-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.homework-admin-card h3 {
  margin: 0 0 6px;
}

.homework-admin-card p {
  margin: 0 0 8px;
  color: #475569;
}

.homework-admin-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.admin-card-head h3 {
  margin: 0;
}

.avatar-upload-preview {
  margin-bottom: 10px;
}

.avatar-upload-preview img {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.file-upload-area {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px dashed #334155;
  border-radius: 12px;
  background: #0f172a;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.file-upload-area:hover {
  border-color: #7c3aed;
  background: #1a1040;
}
.file-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-upload-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: #fff;
}
.file-upload-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.file-upload-text strong {
  font-size: .9rem;
  color: #e2e8f0;
}
.file-upload-text span {
  font-size: .78rem;
  color: #94a3b8;
}
.file-upload-name {
  margin-top: 6px;
  font-size: .82rem;
  color: #a78bfa;
  word-break: break-all;
}

.mb-16 { margin-bottom: 16px; }

@media (max-width: 1024px) {
  .timetable-layout { grid-template-columns: 1fr; }
  .event-admin-layout { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .lesson-filters { grid-template-columns: 1fr; }
  .admin-page-head { flex-direction: column; align-items: flex-start; }
}

/* ============================================
   NEW UI COMPONENTS (v2)
   ============================================ */

/* === Navigation Dropdown === */
.nav-dropdown {
  position: relative;
  display: inline-flex;
}

.nav-dropdown-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-dropdown-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-dropdown-btn.active-nav {
  background: var(--primary-soft) !important;
  color: var(--primary) !important;
  font-weight: 600;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  margin-top: 4px;
}

.nav-dropdown-menu.show {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.1s;
}

.nav-dropdown-menu a:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-dropdown-menu a.active-nav {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* === Mobile Menu === */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  transition: background 0.15s;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 0;
}
.mobile-menu-btn:hover { background: var(--surface-soft); }

/* === Mobile Sidebar (slide-in overlay, NOT inline scroll) === */
.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.mobile-sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: #fff;
  z-index: 999;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-sidebar.open {
  transform: translateX(0);
}

.mobile-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  flex-shrink: 0;
}
.mobile-sidebar-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
  border-radius: 8px;
  transition: background 0.15s;
}
.mobile-sidebar-close:hover { background: #f1f5f9; }
.mobile-sidebar-section {
  padding: 8px 0;
}
.mobile-sidebar-label {
  padding: 12px 20px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.mobile-sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s ease;
  border-radius: 0;
}
.mobile-sidebar-link:hover { background: #f1f5f9; }
.mobile-sidebar-link.active {
  color: var(--primary);
  background: #eff6ff;
  font-weight: 700;
}
.msb-icon { font-size: 18px; width: 24px; text-align: center; }
.mobile-sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
}
.logout-link { color: #dc2626 !important; }

@media (max-width: 768px) {
  .nav-links { display: none !important; }
  .mobile-menu-btn { display: flex; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr !important; }
  .page-header h1 { font-size: 22px; }
  .page-header p { font-size: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.two-col { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 600px; }
  .tg-layout { flex-direction: column; height: calc(100vh - 52px); min-height: 0; margin: -20px -16px -40px; width: calc(100% + 32px); }
  .tg-sidebar { width: 100%; min-width: 0; flex: 1; border-right: none; max-height: none; overflow-y: auto; }
  .tg-main { display: none; }
  .tg-layout.tg-chat-open .tg-sidebar { display: none; }
  .tg-layout.tg-chat-open .tg-main { display: flex; flex: 1; height: 100%; }
  .tg-back-btn { display: flex; }
  .tg-bubble { max-width: 85%; }
  .tg-chat-avatar { width: 44px; height: 44px; min-width: 44px; font-size: 16px; }
  .panel { padding: 16px; border-radius: 12px; }
  .stat-card { padding: 16px; }
  .admin-section-tabs { flex-wrap: wrap; }
  .event-admin-layout { grid-template-columns: 1fr; }
  .timetable-layout { grid-template-columns: 1fr; }
  .admin-welcome { flex-direction: column; align-items: flex-start; }
  .cal-grid td { padding: 6px 2px; font-size: 13px; }
  .attendance-filters { grid-template-columns: 1fr; }
  .container { padding: 0 16px; }
  .page { padding: 20px 16px 40px; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
  .page { padding: 16px 10px 40px; }
  .topbar-inner { min-height: 52px; gap: 8px; }
  .stat-value { font-size: 20px; }
  .attendance-percentage { font-size: 28px; }
  .brand-title { font-size: 15px; }
  .page-header h1 { font-size: 20px; }
  .tg-layout { height: calc(100vh - 52px); margin: -16px -10px -40px; width: calc(100% + 20px); }
  .tg-sidebar { max-height: none; }
  .tg-chat-item { padding: 8px 10px; }
  .tg-chat-avatar { width: 40px; height: 40px; min-width: 40px; font-size: 14px; }
  .tg-chat-name { font-size: 14px; }
  .tg-input-bar { padding: 6px 8px; }
  .tg-send-btn { width: 38px; height: 38px; }
}

/* === Button sizes === */
.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
}

/* === Auth brand centered === */
.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.auth-footer {
  text-align: center;
  color: var(--muted);
  margin-top: 20px;
  font-size: 14px;
}

.auth-footer a {
  font-weight: 600;
}

/* === Registration Steps === */
.reg-steps {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.reg-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-soft);
  transition: all 0.2s;
}

.reg-step.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.reg-step span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reg-step.active span {
  background: var(--primary);
  color: #fff;
}

.reg-panel {
  animation: fadeIn 0.25s ease;
}

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

.reg-actions {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

/* === Pathway Cards === */
.pathway-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pathway-card {
  cursor: pointer;
}

.pathway-card input[type="radio"] {
  display: none;
}

.pathway-card-inner {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  transition: all 0.2s;
  background: var(--surface);
}

.pathway-card-inner:hover {
  border-color: #a78bfa;
  background: #faf5ff;
}

.pathway-card input:checked + .pathway-card-inner {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.pathway-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.pathway-card-inner strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

@media (max-width: 500px) {
  .pathway-cards { grid-template-columns: 1fr; }
}

/* === Profile Layout === */
.profile-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

.profile-card-panel {
  text-align: center;
}

.profile-card-top {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.avatar-xl {
  width: 80px;
  height: 80px;
  font-size: 28px;
  margin: 0 auto 12px;
}

.profile-bio {
  color: var(--muted);
  font-size: 14px;
  margin-top: 8px;
  line-height: 1.5;
}

.profile-info-grid {
  display: grid;
  gap: 12px;
}

.profile-info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-soft);
}

.profile-info-label {
  color: var(--muted);
  font-size: 13px;
}

.profile-info-value {
  font-weight: 600;
  font-size: 14px;
}

.input-disabled {
  background: #f8fafc !important;
  cursor: not-allowed;
  color: var(--muted);
}

/* === Timetable Week === */
.timetable-week {
  display: grid;
  gap: 16px;
}

.lesson-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* === Event Card v2 === */
.event-card-v2 {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.event-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.event-card-header h3 {
  margin: 0 0 4px;
}

.event-date-badge {
  text-align: center;
  min-width: 50px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--primary-soft);
  flex-shrink: 0;
}

.event-date-day {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.event-date-month {
  display: block;
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
}

.event-card-meta {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.event-card-desc {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.event-card-v2.expanded .event-card-desc {
  display: block;
}

/* === Calendar === */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-header h3 { margin: 0; font-size: 18px; }
.cal-grid { width: 100%; border-collapse: collapse; }
.cal-grid th {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  padding: 6px 4px;
  text-align: center;
}
.cal-grid td {
  text-align: center;
  padding: 8px 4px;
  font-size: 14px;
  color: var(--text);
  cursor: default;
  border-radius: 8px;
}
.cal-day { cursor: pointer; transition: all 0.15s ease; }
.cal-day:hover { background: var(--primary-soft); }
.cal-today { font-weight: 800; color: var(--primary); background: #eff6ff; }
.cal-has-event { position: relative; }
.cal-has-event::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}
.cal-selected {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 700;
}
.cal-selected::after { background: #fff !important; }

/* === Announcements expandable === */
.announce-card.expandable {
  cursor: pointer;
  transition: all 0.2s;
}

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

.announce-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.announce-head h3 { margin: 0; }

.announce-full {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.announce-card.expanded .announce-preview {
  display: none;
}

.announce-card.expanded .announce-full {
  display: block;
}

/* === Timetable Grid Admin === */
.tt-cell-entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: 6px;
  margin: 2px 0;
}

.tt-cell-subj {
  font-weight: 600;
  font-size: 12px;
}

/* Empty cell "+" add button */
.tt-cell-add {
  width: 100%;
  height: 100%;
  min-height: 32px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tt-cell-add:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* === Timetable Filter Bar === */
.tt-filter-bar { padding: 16px 20px; }
.tt-filters {
  display: flex;
  gap: 20px;
  align-items: end;
  flex-wrap: wrap;
}
.tt-filters label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
  color: var(--muted);
}
.tt-filters select {
  min-width: 200px;
}

/* === Attendance Filters === */
.attendance-filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* === Batch attendance table === */
.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.batch-table th,
.batch-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.batch-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}

.batch-student-list {
  max-height: 400px;
  overflow-y: auto;
}

/* === Chat empty msg === */
.chat-empty-msg {
  color: var(--muted);
  text-align: center;
  margin: auto;
  padding: 40px 20px;
}

/* === Chat quick link (dashboard) === */
.chat-quick-link {
  color: var(--text);
}

.chat-quick-link:hover {
  color: var(--text);
  background: var(--surface-soft);
  border-radius: 10px;
}

/* === In progress row === */
.in-progress-row {
  background: #ecfdf5;
}

/* === Stat label/value === */
.stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  margin-top: 6px;
  line-height: 1;
}

/* === Events grid === */
.events-grid {
  display: grid;
  gap: 16px;
}

@media (max-width: 600px) {
  .attendance-filters { grid-template-columns: 1fr; }
  .topbar-inner { min-height: 56px; }
  .page { padding: 20px 16px 40px; }
}