/* WebED - Modern 2026 Design */

/* ========== RESET & BASE ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Сброс нативных стилей кнопок (iOS Safari) без переопределения кастомных */
button, input[type="submit"], input[type="button"], input[type="reset"] {
  -webkit-appearance: none;
  appearance: none;
}

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --accent: #06b6d4;
  --accent-hover: #0891b2;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --gray-50: #fafafa;
  --gray-100: #f4f4f5;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;
  --gray-950: #09090b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.03), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.05), 0 4px 10px rgba(0,0,0,0.04);
  --glass-bg: rgba(255,255,255,0.8);
  --glass-border: rgba(0,0,0,0.06);
  --glass-blur: blur(20px);
  --transition: 0.18s cubic-bezier(0.23, 1, 0.32, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

/* Surface & background variables for theme switching */
:root {
  --surface: #ffffff;
  --surface2: #f4f4f5;
  --surface-alt: #fafafa;
  --border-light: #e4e4e7;
}

[data-theme="dark"] {
  --surface: #18181b;
  --surface2: #242f3d;
  --surface-alt: #27272a;
  --border-light: #3f3f46;
}

/* ========== DARK THEME ========== */
[data-theme="dark"] {
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-light: #1e1b4b;
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --danger: #f87171;
  --danger-bg: #451a1a;
  --success: #34d399;
  --success-bg: #064e3b;
  --warning: #fbbf24;
  --warning-bg: #451a03;
  --gray-50: #18181b;
  --gray-100: #27272a;
  --gray-200: #3f3f46;
  --gray-300: #52525b;
  --gray-400: #71717a;
  --gray-500: #a1a1aa;
  --gray-600: #d4d4d8;
  --gray-700: #e4e4e7;
  --gray-800: #f4f4f5;
  --gray-900: #fafafa;
  --gray-950: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5), 0 4px 10px rgba(0,0,0,0.4);
  --glass-bg: rgba(24,24,27,0.85);
  --glass-border: rgba(255,255,255,0.08);
  --glass-blur: blur(20px);
}

[data-theme="dark"] body {
  background: #09090b;
  color: var(--gray-900);
}

[data-theme="dark"] .sidebar {
  background: #0f0f12;
  border-right-color: var(--gray-200);
}

.sidebar-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-400, #94a3b8);
  padding: 10px 14px 4px;
  user-select: none;
}

[data-theme="dark"] .sidebar-category {
  color: #64748b;
}

[data-theme="dark"] .topbar {
  background: rgba(15,15,18,0.9);
  border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .card {
  background: #18181b;
  border-color: var(--gray-200);
}

[data-theme="dark"] .student-card {
  background: #18181b;
  border-color: var(--gray-200);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"] {
  background: #27272a;
  border-color: var(--gray-300);
  color: var(--gray-900);
}

[data-theme="dark"] .tag-input {
  background: #27272a;
  border-color: var(--gray-300);
}

[data-theme="dark"] .tag-input-field {
  color: var(--gray-900);
}

[data-theme="dark"] .modal-content {
  background: #18181b;
  border: 1px solid var(--gray-200);
}

[data-theme="dark"] .toast-confirm-box {
  background: #27272a;
}

[data-theme="dark"] .cal-today-bg {
  background: rgba(129,140,248,0.08);
}

[data-theme="dark"] .cal-slot-free:hover {
  background: rgba(129,140,248,0.1);
}

[data-theme="dark"] .cal-slot-selected, [data-theme="dark"] .cal-cell.cal-slot-selected {
  background: rgba(99, 102, 241, 0.35) !important;
  box-shadow: inset 0 0 0 2px #818cf8 !important;
}

[data-theme="dark"] .cal-context-menu {
  background: #27272a;
  border-color: var(--gray-300);
}

[data-theme="dark"] .table tr:hover td {
  background: var(--gray-100);
}

[data-theme="dark"] .hw-file-tag {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* Dark theme overrides for hardcoded-colored elements */
[data-theme="dark"] .student-card-top { border-color: var(--gray-200); }
[data-theme="dark"] .cal-slot-occupied { background: #1e1b4b; border-color: #3730a3; }
[data-theme="dark"] .cal-slot-unpaid { background: #451a03; border-color: #92400e; }
[data-theme="dark"] .cal-slot-paid { background: #064e3b; border-color: #065f46; }
[data-theme="dark"] .cal-slot-cancelled { background: #451a1a; border-color: #7f1d1d; }
[data-theme="dark"] .cal-slot-rescheduled { background: #1e1b4b; border-color: #6d28d9; }
[data-theme="dark"] .cal-slot-my { background: #064e3b; border-color: #065f46; }
[data-theme="dark"] .cal-slot-other { background: var(--gray-100); border-color: var(--gray-300); }
[data-theme="dark"] .cal-time-slot { border-color: var(--gray-300); }
[data-theme="dark"] .cal-day-col { border-left-color: var(--gray-300); }
[data-theme="dark"] .cal-header { border-bottom-color: var(--gray-300); background: var(--surface, #1e1e2e); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
[data-theme="dark"] .cal-cell { border-bottom-color: var(--gray-300); }
[data-theme="dark"] .cal-lesson-title { color: var(--gray-800); }
[data-theme="dark"] .cal-lesson-student { color: var(--gray-500); }
[data-theme="dark"] .cal-lesson-time { color: var(--gray-600); }
[data-theme="dark"] .cal-lesson-status-badge.status-unpaid { background: #78350f; color: #fbbf24; }
[data-theme="dark"] .cal-lesson-status-badge.status-paid { background: #065f46; color: #34d399; }
[data-theme="dark"] .cal-lesson-status-badge.status-cancelled { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .cal-lesson-status-badge.status-rescheduled { background: #4c1d95; color: #c4b5fd; }
[data-theme="dark"] .cal-lesson-status-badge.status-open-window { background: #1e293b; color: #94a3b8; border: 1px dashed #475569; }
[data-theme="dark"] .cal-legend { border-top-color: var(--gray-200); }
[data-theme="dark"] .legend-free { background: var(--surface); border-color: var(--gray-300); }
[data-theme="dark"] .legend-unpaid { background: #451a03; border-color: #92400e; }
[data-theme="dark"] .legend-paid { background: #064e3b; border-color: #065f46; }
[data-theme="dark"] .legend-cancelled { background: #451a1a; border-color: #7f1d1d; }
[data-theme="dark"] .legend-rescheduled { background: #1e1b4b; border-color: #6d28d9; }
[data-theme="dark"] .lesson-item { border-bottom-color: var(--gray-200); }
[data-theme="dark"] .lesson-status-unpaid { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .lesson-status-paid { background: #064e3b; color: #34d399; }
[data-theme="dark"] .lesson-status-cancelled { background: #451a1a; color: #fca5a5; }
[data-theme="dark"] .lesson-status-rescheduled { background: #1e1b4b; color: #c4b5fd; }
[data-theme="dark"] .hw-item { border-bottom-color: var(--gray-200); }
[data-theme="dark"] .btn-edit { border-color: var(--gray-300); color: var(--gray-600); }
[data-theme="dark"] .badge-active { background: #064e3b; color: #34d399; }
[data-theme="dark"] .grade-badge { background: #1e1b4b; color: var(--primary); }
[data-theme="dark"] .grade-badge.grade-overall { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .achievement-badge { background: var(--surface); border-color: var(--gray-200); }
[data-theme="dark"] .modal-header { border-bottom-color: var(--gray-200); }
[data-theme="dark"] .card-header { border-bottom-color: var(--gray-200); }
[data-theme="dark"] .student-card-avatar { background: var(--primary-light); }
[data-theme="dark"] .student-card-login { color: var(--gray-500); }
[data-theme="dark"] .tb-tree > li > details > summary { background: var(--gray-100); border-color: var(--gray-200); }
[data-theme="dark"] .tb-tree > li > details > summary:hover { background: var(--primary-light); border-color: var(--primary); }
[data-theme="dark"] .tb-tree summary:hover { background: var(--gray-200); }
[data-theme="dark"] .success-message { background: #064e3b; color: #34d399; border-color: #065f46; }
[data-theme="dark"] .error-message { background: #451a1a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .drop-zone { background: var(--gray-100); border-color: var(--gray-300); }
[data-theme="dark"] .stat-bar-wrap { background: var(--gray-200); }
[data-theme="dark"] .toast-success { background: #064e3b; border-color: #065f46; color: #34d399; }
[data-theme="dark"] .toast-success .toast-icon { background: #059669; }
[data-theme="dark"] .toast-error { background: #451a1a; border-color: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .toast-error .toast-icon { background: #dc2626; }
[data-theme="dark"] .toast-info { background: #172554; border-color: #1e40af; color: #bfdbfe; }
[data-theme="dark"] .toast-info .toast-icon { background: #2563eb; }
[data-theme="dark"] .toast-warning { background: #451a03; border-color: #92400e; color: #fde68a; }
[data-theme="dark"] .toast-warning .toast-icon { background: #d97706; }
[data-theme="dark"] .login-card { background: var(--surface); border-color: var(--gray-200); }
[data-theme="dark"] .login-page { background: #09090b; }
[data-theme="dark"] .dashboard-page { background: #09090b; }
[data-theme="dark"] .welcome-card h2 { color: var(--gray-800); }
[data-theme="dark"] .topbar-left h2 { color: var(--gray-900); }
[data-theme="dark"] .cal-week-label { color: var(--gray-700); }
[data-theme="dark"] .cal-day-header { color: var(--gray-700); }
[data-theme="dark"] .tag-badge { background: var(--primary-light); color: var(--primary); }
[data-theme="dark"] .table th { background: var(--gray-100); border-bottom-color: var(--gray-200); }
[data-theme="dark"] .table td { border-bottom-color: var(--gray-200); color: var(--gray-700); }
[data-theme="dark"] .hw-file-tag.by-teacher { background: #172554; color: #bfdbfe; }
[data-theme="dark"] .hw-file-tag.by-student { background: #064e3b; color: #34d399; }
[data-theme="dark"] .modal-body .hw-send-block { background: var(--gray-100); }
[data-theme="dark"] .cal-lesson-actions .btn,
[data-theme="dark"] .cal-lesson-actions a { background: rgba(24,24,27,0.9); border-color: var(--gray-300); color: var(--gray-600); }
[data-theme="dark"] .cal-lesson-actions .btn-danger { background: #451a1a; border-color: #7f1d1d; color: #f87171; }
[data-theme="dark"] .cal-grade-btn { background: rgba(24,24,27,0.8); border-color: var(--gray-300); }
[data-theme="dark"] .form-group-check label { color: var(--gray-700); }
[data-theme="dark"] .legend-item { color: var(--gray-600); }
[data-theme="dark"] .info-label { color: var(--gray-500); }
[data-theme="dark"] .info-value { color: var(--gray-800); }
[data-theme="dark"] .info-value code { background: var(--gray-200); color: var(--gray-800); }
[data-theme="dark"] .btn-outline { color: var(--gray-600); border-color: var(--gray-300); }
[data-theme="dark"] .btn-outline:hover { background: var(--gray-200); }
[data-theme="dark"] .topbar-role { background: var(--gray-200); color: var(--gray-500); }
[data-theme="dark"] .btn-primary { background: var(--primary); }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-hover); }
[data-theme="dark"] .btn-edit:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== LOGIN PAGE ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--gray-50);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0,102,255,0.05) 0%, transparent 70%);
  border-radius: 50%;
}

.login-page::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(5,150,105,0.04) 0%, transparent 70%);
  border-radius: 50%;
}

.login-container {
  width: 100%;
  max-width: 440px;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.login-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--gray-500);
  font-size: 15px;
  font-weight: 400;
}

/* ========== FORM ========== */
.login-form {
  display: flex;
  flex-direction: column;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-group input {
  width: 100%;
  padding: 11px 16px;
  font-size: 15px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--gray-900);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.1);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

/* ========== PASSWORD WRAPPER & TOGGLE (LEFT-ALIGNED) ========== */
.password-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.password-wrapper input,
.form-group .password-wrapper input {
  width: 100%;
  padding-left: 44px !important;
  padding-right: 16px !important;
  box-sizing: border-box;
}

button.password-toggle-btn,
.password-toggle-btn {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 6px !important;
  color: #94a3b8 !important;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease !important;
  z-index: 5;
  -webkit-appearance: none !important;
  appearance: none !important;
  line-height: 1 !important;
}

button.password-toggle-btn:hover,
.password-toggle-btn:hover {
  color: var(--primary, #4f46e5) !important;
  background-color: rgba(79, 70, 229, 0.08) !important;
}

button.password-toggle-btn:active,
.password-toggle-btn:active {
  transform: translateY(-50%) scale(0.92) !important;
}

button.password-toggle-btn:focus-visible,
.password-toggle-btn:focus-visible {
  outline: 2px solid var(--primary, #4f46e5) !important;
  outline-offset: 1px;
}

.password-toggle-btn .eye-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.password-toggle-btn .eye-closed {
  display: none;
}

.password-toggle-btn.is-visible .eye-open {
  display: none !important;
}

.password-toggle-btn.is-visible .eye-closed {
  display: block !important;
}

[data-theme="dark"] button.password-toggle-btn,
[data-theme="dark"] .password-toggle-btn {
  color: #94a3b8 !important;
}

[data-theme="dark"] button.password-toggle-btn:hover,
[data-theme="dark"] .password-toggle-btn:hover {
  color: #818cf8 !important;
  background-color: rgba(255, 255, 255, 0.1) !important;
}

/* ========== BUTTONS ========== */
.btn, .btn-sm, .btn-xs, .btn-primary, .btn-danger, .btn-outline, .btn-edit, .btn-warning,
button[class*="btn"], .cal-context-item, .hw-file-tag {
  white-space: nowrap;
  overflow: visible !important;
  width: auto !important;
  max-width: none !important;
  flex-shrink: 0;
  box-sizing: border-box;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--dur-press, 140ms) var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)), background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: visible !important;
  width: fit-content;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gray-900);
  color: #fff;
}

.btn-primary:hover {
  background: var(--gray-800);
}

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
  transform: none;
}

.btn-full {
  width: 100%;
}

/* ========== ERROR MESSAGE ========== */
.error-message {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid #fecaca;
  text-align: center;
}

.hidden {
  display: none;
}

/* ========== FOOTER ========== */
.login-footer {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  margin-top: 24px;
}

/* ========== DASHBOARD LAYOUT ========== */
.dashboard-page {
  background: var(--gray-50);
  min-height: 100vh;
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 64px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-left h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.3px;
}

.topbar-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  font-size: 14px;
  color: var(--gray-700);
  font-weight: 500;
}

.btn-outline {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.btn-outline:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ========== DASHBOARD MAIN ========== */
.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ========== STATS ROW ========== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--gray-100);
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -1px;
}

.stat-label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

/* ========== CARDS ========== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: visible;
  border: 1px solid var(--gray-100);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}

.card-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-900);
}

.card-placeholder {
  padding: 24px;
  color: var(--gray-400);
  font-size: 14px;
  text-align: center;
}

/* ========== INLINE FORM (create student) ========== */
.inline-form {
  padding: 16px 20px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row .form-group {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

.form-group-btn {
  flex: 0 0 auto !important;
  min-width: auto !important;
}

/* ========== TABLE ========== */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.table td {
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background: var(--gray-50);
}

.td-empty {
  text-align: center !important;
  color: var(--gray-400) !important;
  padding: 32px 20px !important;
}

.td-name {
  font-weight: 500;
}

.td-date {
  color: var(--gray-500);
  font-size: 13px;
}

/* ========== BADGES ========== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-active {
  background: #f0fdf4;
  color: #16a34a;
}

.badge-inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ========== BUTTON VARIANTS ========== */
.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-danger:active {
  transform: scale(0.97);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
  transition: transform 140ms var(--ease-out, ease-out), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

/* Micro-animations for all interactive elements */
.btn, .btn-edit, .btn-outline, .btn-danger, .btn-xs, .btn-sm,
.cal-context-item, .nav-item, .hw-file-tag, .achievement-badge {
  transition: transform 140ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.btn:active, .btn-edit:active, .btn-outline:active {
  transform: scale(0.97);
}

.btn-edit {
  background: transparent;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  padding: 4px 10px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  vertical-align: middle;
}

.btn-edit:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-warning {
  background: #f59e0b;
  color: #fff;
  border: none;
}

.btn-warning:hover {
  background: #d97706;
}

/* ========== WELCOME CARD ========== */
.welcome-card {
  text-align: center;
  padding: 32px 20px;
}

.welcome-card h2 {
  font-size: 24px;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.teacher-info {
  color: var(--primary);
  font-weight: 500;
  font-size: 16px;
}

/* ========== INFO GRID ========== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
}

.info-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-800);
}

.info-value code {
  background: var(--gray-100);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
}

/* ========== LOGIN HINTS ========== */
.login-hints {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--gray-500);
}

.hint-item code {
  background: var(--gray-100);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--gray-700);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.hint-role {
  display: inline-block;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 56px;
  text-align: center;
}

.hint-role {
  background: var(--primary-light);
  color: var(--primary);
}

/* ========== ADMIN BADGE ========== */
.badge-admin {
  background: var(--primary-light);
  color: var(--primary);
}

/* ========== SUCCESS MESSAGE ========== */
.success-message {
  background: #f0fdf4;
  color: #16a34a;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-top: 12px;
  border: 1px solid #bbf7d0;
  text-align: center;
}

/* ========== CALENDAR ========== */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: nowrap;
}

.cal-week-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-700);
  white-space: nowrap;
  min-width: 110px;
  text-align: center;
}

.calendar-grid {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 78vh;
  margin-top: 16px;
  position: relative;
  border-radius: var(--radius-md, 8px);
}

.cal-placeholder {
  text-align: center;
  color: var(--gray-400);
  padding: 40px 0;
  font-size: 15px;
}

.cal-header {
  display: flex;
  min-width: 980px;
  width: 100%;
  border-bottom: 2px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--surface, #ffffff);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.cal-time-col {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  flex: 0 0 58px;
}

.cal-day-header {
  flex: 1 1 0px;
  width: 0;
  min-width: 130px;
  text-align: center;
  padding: 8px 4px;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-700);
  text-transform: capitalize;
  box-sizing: border-box;
}

.cal-day-num {
  font-size: 16px;
  font-weight: 700;
}

.cal-today {
  color: var(--primary);
}

.cal-body {
  display: flex;
  min-width: 980px;
  width: 100%;
  position: relative;
}

.cal-time-slot {
  height: 66px !important;
  min-height: 66px !important;
  max-height: 66px !important;
  box-sizing: border-box !important;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 4px 8px 0 0;
  font-size: 11px;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-300);
  overflow: hidden;
}

.cal-day-col {
  flex: 1 1 0px;
  width: 0;
  min-width: 130px;
  border-left: 1px solid var(--gray-300);
  box-sizing: border-box;
  position: relative;
}

.cal-today-bg {
  background: rgba(79, 70, 229, 0.03);
}

.cal-grid-cells {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.cal-cell {
  height: 66px !important;
  min-height: 66px !important;
  max-height: 66px !important;
  box-sizing: border-box !important;
  border-bottom: 1px solid var(--gray-300);
  padding: 0 !important;
  margin: 0 !important;
  cursor: default;
  position: relative;
  overflow: hidden !important;
  transition: background 0.15s ease;
  width: 100%;
}

.cal-slot-free {
  cursor: pointer;
}

.cal-slot-free:hover {
  background: rgba(79, 70, 229, 0.06);
}

.cal-slot-selected, .cal-cell.cal-slot-selected {
  background: rgba(51, 144, 236, 0.28) !important;
  box-shadow: inset 0 0 0 2px #3390ec, 0 2px 8px rgba(51, 144, 236, 0.2) !important;
  position: relative !important;
  z-index: 5 !important;
}

.cal-slot-free::after {
  content: '+';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-400);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.cal-slot-free:hover::after {
  opacity: 0.6;
  transform: translateY(-50%) scale(1.15);
}

.cal-slot-selected::after {
  content: '✓';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 800;
  color: #3390ec;
  opacity: 1 !important;
  pointer-events: none;
}

[data-theme="dark"] .cal-slot-selected::after {
  color: #818cf8;
}

.cal-slot-busy {
  cursor: default;
  background: transparent;
}

.cal-events-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.cal-event-card {
  position: absolute;
  left: 2px;
  right: 2px;
  box-sizing: border-box !important;
  border-radius: 6px;
  padding: 4px 6px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  gap: 2px;
  overflow: hidden !important;
  cursor: pointer;
  pointer-events: auto;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.cal-event-card:hover {
  z-index: 15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.cal-event-card.status-unpaid, .cal-slot-unpaid {
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.cal-event-card.status-paid, .cal-slot-paid {
  background: #dcfce7;
  border: 1px solid #86efac;
}

.cal-event-card.status-cancelled, .cal-slot-cancelled {
  background: #fef2f2;
  border: 1px solid #fecaca;
  opacity: 0.7;
  text-decoration: line-through;
}

.cal-event-card.status-rescheduled, .cal-slot-rescheduled {
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
}

.cal-event-card.status-open-window, .cal-slot-open-window {
  background: #f8fafc;
  border: 1px dashed #94a3b8;
}

[data-theme="dark"] .cal-event-card.status-open-window, [data-theme="dark"] .cal-slot-open-window {
  background: rgba(30, 41, 59, 0.6);
  border: 1px dashed #64748b;
}

.cal-event-card.cal-slot-my, .cal-slot-my {
  background: #dcfce7;
  border: 1px solid #86efac;
}

.cal-event-card.cal-slot-other, .cal-slot-other {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
}

.cal-slot-cancelled.cal-slot-single { border: 1px solid #fecaca !important; border-radius: 6px !important; background: #fef2f2 !important; text-decoration: line-through; opacity: 0.7; }
.cal-slot-cancelled.cal-slot-first { border-top: 1px solid #fecaca !important; border-left: 1px solid #fecaca !important; border-right: 1px solid #fecaca !important; border-bottom: none !important; border-radius: 6px 6px 0 0 !important; background: #fef2f2 !important; text-decoration: line-through; opacity: 0.7; }
.cal-slot-cancelled.cal-slot-mid { border-top: none !important; border-bottom: none !important; border-left: 1px solid #fecaca !important; border-right: 1px solid #fecaca !important; border-radius: 0 !important; background: #fef2f2 !important; text-decoration: line-through; opacity: 0.7; }
.cal-slot-cancelled.cal-slot-last { border-top: none !important; border-bottom: 1px solid #fecaca !important; border-left: 1px solid #fecaca !important; border-right: 1px solid #fecaca !important; border-radius: 0 0 6px 6px !important; background: #fef2f2 !important; text-decoration: line-through; opacity: 0.7; }

.cal-slot-rescheduled.cal-slot-single { border: 1px solid #c4b5fd !important; border-radius: 6px !important; background: #f5f3ff !important; }
.cal-slot-rescheduled.cal-slot-first { border-top: 1px solid #c4b5fd !important; border-left: 1px solid #c4b5fd !important; border-right: 1px solid #c4b5fd !important; border-bottom: none !important; border-radius: 6px 6px 0 0 !important; background: #f5f3ff !important; }
.cal-slot-rescheduled.cal-slot-mid { border-top: none !important; border-bottom: none !important; border-left: 1px solid #c4b5fd !important; border-right: 1px solid #c4b5fd !important; border-radius: 0 !important; background: #f5f3ff !important; }
.cal-slot-rescheduled.cal-slot-last { border-top: none !important; border-bottom: 1px solid #c4b5fd !important; border-left: 1px solid #c4b5fd !important; border-right: 1px solid #c4b5fd !important; border-radius: 0 0 6px 6px !important; background: #f5f3ff !important; }

.cal-slot-my.cal-slot-single { border: 1px solid #86efac !important; border-radius: 6px !important; background: #dcfce7 !important; }
.cal-slot-my.cal-slot-first { border-top: 1px solid #86efac !important; border-left: 1px solid #86efac !important; border-right: 1px solid #86efac !important; border-bottom: none !important; border-radius: 6px 6px 0 0 !important; background: #dcfce7 !important; }
.cal-slot-my.cal-slot-mid { border-top: none !important; border-bottom: none !important; border-left: 1px solid #86efac !important; border-right: 1px solid #86efac !important; border-radius: 0 !important; background: #dcfce7 !important; }
.cal-slot-my.cal-slot-last { border-top: none !important; border-bottom: 1px solid #86efac !important; border-left: 1px solid #86efac !important; border-right: 1px solid #86efac !important; border-radius: 0 0 6px 6px !important; background: #dcfce7 !important; }

.cal-slot-other.cal-slot-single { border: 1px solid var(--gray-300) !important; border-radius: 6px !important; background: var(--gray-100) !important; }
.cal-slot-other.cal-slot-first { border-top: 1px solid var(--gray-300) !important; border-left: 1px solid var(--gray-300) !important; border-right: 1px solid var(--gray-300) !important; border-bottom: none !important; border-radius: 6px 6px 0 0 !important; background: var(--gray-100) !important; }
.cal-slot-other.cal-slot-mid { border-top: none !important; border-bottom: none !important; border-left: 1px solid var(--gray-300) !important; border-right: 1px solid var(--gray-300) !important; border-radius: 0 !important; background: var(--gray-100) !important; }
.cal-slot-other.cal-slot-last { border-top: none !important; border-bottom: 1px solid var(--gray-300) !important; border-left: 1px solid var(--gray-300) !important; border-right: 1px solid var(--gray-300) !important; border-radius: 0 0 6px 6px !important; background: var(--gray-100) !important; }

.cal-lesson-title {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.15;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-lesson-student {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-600);
  line-height: 1.15;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-lesson-time {
  display: block;
  font-size: 9px;
  color: var(--gray-500);
  line-height: 1.1;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-lesson-status-badge {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  margin: 0;
  line-height: 1.1;
  width: fit-content;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-lesson-status-badge.status-unpaid { background: #fef3c7; color: #b45309; }
.cal-lesson-status-badge.status-paid { background: #bbf7d0; color: #15803d; }
.cal-lesson-status-badge.status-cancelled { background: #fecaca; color: #b91c1c; }
.cal-lesson-status-badge.status-rescheduled { background: #ddd6fe; color: #6d28d9; }
.cal-lesson-status-badge.status-open-window { background: #f1f5f9; color: #475569; border: 1px dashed #cbd5e1; }

.cal-lesson-desc {
  display: block;
  font-size: 9px;
  color: #475569;
  line-height: 1.15;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  opacity: 0.9;
}

[data-theme="dark"] .cal-lesson-desc {
  color: #94a3b8;
}

.cal-context-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--bg-alt, #f8fafc);
  border-radius: 8px 8px 0 0;
}

[data-theme="dark"] .cal-context-header {
  background: #1e293b;
  border-color: #334155;
}

.cal-context-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #0f172a);
  margin-bottom: 2px;
}

.cal-context-meta {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-context-desc {
  font-size: 11px;
  color: var(--primary, #6366f1);
  font-style: italic;
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 4px;
  border-left: 2px solid var(--primary, #6366f1);
  word-break: break-word;
  white-space: normal;
}

/* Calendar lesson block - clickable area for context menu */
.cal-lesson-block {
  cursor: pointer;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  padding: 2px 4px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  overflow: hidden !important;
}

.cal-lesson-block:hover {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.cal-lesson-cont-block {
  display: none !important;
}

/* Floating Calendar Selection Action Bar */
.cal-selection-bar {
  position: sticky;
  bottom: 12px;
  left: 0;
  right: 0;
  margin: 14px auto 6px;
  max-width: 580px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(51, 144, 236, 0.4);
  box-shadow: 0 8px 32px rgba(51, 144, 236, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 100;
  animation: slideUpFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.cal-selection-bar.hidden {
  display: none !important;
}

.cal-selection-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.cal-selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="dark"] .cal-selection-bar {
  background: rgba(30, 27, 75, 0.85);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.36);
}

[data-theme="dark"] .cal-selection-info {
  color: #fff;
}

/* ========== CONTEXT MENU ========== */
.cal-context-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  padding: 6px;
  min-width: 240px;
  animation: calMenuFadeIn 0.12s ease;
}

@keyframes calMenuFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.cal-context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease;
  text-align: left;
  font-family: inherit;
}

.cal-context-item:hover:not(:disabled) {
  background: var(--gray-100);
}

.cal-context-item:disabled {
  opacity: 0.35;
  cursor: default;
}

.cal-context-item.cal-context-danger {
  color: var(--danger);
}

.cal-context-item.cal-context-danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.cal-context-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.cal-context-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 4px 8px;
}

/* ========== CALENDAR LEGEND ========== */
.cal-legend {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-600);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-my {
  background: #dcfce7;
  border: 1px solid #86efac;
}

.legend-occupied {
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.legend-other {
  background: var(--gray-200);
  border: 1px solid var(--gray-300);
}

.legend-free {
  background: #fff;
  border: 1px solid var(--gray-300);
}

.legend-unpaid {
  background: #fffbeb;
  border: 1px solid #fcd34d;
}

.legend-paid {
  background: #dcfce7;
  border: 1px solid #86efac;
}

.legend-cancelled {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.legend-rescheduled {
  background: #f5f3ff;
  border: 1px solid #c4b5fd;
}

/* ========== LESSONS LIST ========== */
.lessons-list {
  padding: 16px 20px;
}

.lesson-item {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding: 16px !important;
  background: var(--surface, #ffffff) !important;
  border: 1px solid var(--tg-border, var(--gray-200, #e2e8f0)) !important;
  border-radius: 14px !important;
  margin-bottom: 12px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
  transition: transform 140ms var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1)) !important, background-color 160ms ease !important, border-color 160ms ease !important, box-shadow 160ms ease !important;
}

.lesson-item:hover {
  border-color: var(--tg-button, #3390ec) !important;
  box-shadow: 0 4px 14px rgba(51, 144, 236, 0.1) !important;
}

.lesson-item-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  width: 100% !important;
  flex-wrap: nowrap !important;
}

.lesson-item-title {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  color: var(--tg-text, var(--gray-900, #0f172a)) !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin: 0 !important;
}

.lesson-item-badge,
.lesson-item-status {
  display: inline-flex !important;
  align-items: center !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.lesson-item-meta {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-top: 4px !important;
  padding-top: 10px !important;
  border-top: 1px solid var(--gray-100, #f1f5f9) !important;
}

.lesson-item-meta > span {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--tg-hint, var(--gray-700, #334155)) !important;
  background: var(--tg-bg-secondary, var(--gray-100, #f8fafc)) !important;
  padding: 5px 11px !important;
  border-radius: 8px !important;
  border: 1px solid var(--gray-200, #e2e8f0) !important;
  line-height: 1.2 !important;
}

.status-paid,
.lesson-status-paid {
  background: #dcfce7 !important;
  color: #15803d !important;
  border: 1px solid #bbf7d0 !important;
}

.status-unpaid,
.lesson-status-unpaid {
  background: #fef3c7 !important;
  color: #b45309 !important;
  border: 1px solid #fde68a !important;
}

.status-cancelled,
.lesson-status-cancelled {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border: 1px solid #fecaca !important;
}

.status-rescheduled,
.lesson-status-rescheduled {
  background: #f3e8ff !important;
  color: #7e22ce !important;
  border: 1px solid #e9d5ff !important;
}

.status-open-window,
.lesson-status-open-window {
  background: #f1f5f9 !important;
  color: #64748b !important;
  border: 1px dashed #cbd5e1 !important;
}

[data-theme="dark"] .status-open-window,
[data-theme="dark"] .lesson-status-open-window {
  background: #1e293b !important;
  color: #94a3b8 !important;
  border: 1px dashed #475569 !important;
}

.lesson-item-desc {
  margin-top: 4px !important;
  padding: 10px 14px !important;
  background: rgba(51, 144, 236, 0.04) !important;
  border-left: 3px solid var(--tg-button, #3390ec) !important;
  border-radius: 6px !important;
  font-size: 13px !important;
  color: var(--tg-text, var(--gray-700, #334155)) !important;
  line-height: 1.5 !important;
}

/* ========== TELEGRAM-STYLE CARDS & CHIPS ========== */
.tg-lesson-card,
.next-lesson-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--tg-border, var(--gray-200, #e2e8f0));
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tg-lesson-card:hover,
.next-lesson-card:hover {
  border-color: var(--tg-button, #3390ec);
  box-shadow: 0 4px 14px rgba(51, 144, 236, 0.1);
}

.tg-lesson-top,
.next-lesson-top {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  margin-bottom: 10px !important;
  flex-wrap: nowrap !important;
}

.tg-lesson-title,
.next-lesson-title {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: var(--tg-text, var(--gray-900, #0f172a)) !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  line-height: 1.3 !important;
}

.tg-lesson-chips,
.next-lesson-meta {
  display: flex !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  margin-top: 10px !important;
  padding-top: 10px !important;
  border-top: 1px solid var(--gray-100, #f1f5f9) !important;
}

.tg-chip {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--tg-hint, var(--gray-700, #334155)) !important;
  background: var(--tg-bg-secondary, var(--gray-100, #f8fafc)) !important;
  padding: 5px 11px !important;
  border-radius: 8px !important;
  border: 1px solid var(--gray-200, #e2e8f0) !important;
  line-height: 1.2 !important;
}

.tg-chip svg {
  flex-shrink: 0 !important;
  color: var(--tg-link, #3390ec) !important;
}

.tg-chip-subtle {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #3390ec !important;
  background: rgba(51, 144, 236, 0.1) !important;
  border-color: rgba(51, 144, 236, 0.2) !important;
  padding: 3px 8px !important;
}

.tg-lesson-desc,
.next-lesson-desc {
  margin-top: 12px !important;
  padding: 10px 14px !important;
  background: rgba(51, 144, 236, 0.04) !important;
  border-left: 3px solid var(--tg-button, #3390ec) !important;
  border-radius: 6px !important;
  font-size: 13px !important;
  color: var(--tg-text, var(--gray-700, #334155)) !important;
  line-height: 1.5 !important;
}

/* Telegram Badges */
.tg-badge {
  display: inline-flex !important;
  align-items: center !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

.tg-badge-paid {
  background: #dcfce7 !important;
  color: #15803d !important;
  border: 1px solid #bbf7d0 !important;
}

.tg-badge-unpaid {
  background: #fef3c7 !important;
  color: #b45309 !important;
  border: 1px solid #fde68a !important;
}

.tg-badge-cancelled {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border: 1px solid #fecaca !important;
}

.tg-badge-rescheduled {
  background: #f3e8ff !important;
  color: #7e22ce !important;
  border: 1px solid #e9d5ff !important;
}

[data-theme="dark"] .tg-lesson-card,
[data-theme="dark"] .next-lesson-card {
  background: #18181b !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

[data-theme="dark"] .tg-lesson-chips,
[data-theme="dark"] .next-lesson-meta {
  border-top-color: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .tg-chip {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #e4e4e7 !important;
}

[data-theme="dark"] .tg-lesson-desc,
[data-theme="dark"] .next-lesson-desc {
  background: rgba(51, 144, 236, 0.08) !important;
  color: #cbd5e1 !important;
}

[data-theme="dark"] .tg-badge-paid {
  background: rgba(34, 197, 94, 0.16) !important;
  color: #4ade80 !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

[data-theme="dark"] .tg-badge-unpaid {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #fbbf24 !important;
  border-color: rgba(245, 158, 11, 0.3) !important;
}

[data-theme="dark"] .tg-badge-cancelled {
  background: rgba(239, 68, 68, 0.16) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

[data-theme="dark"] .tg-badge-rescheduled {
  background: rgba(168, 85, 247, 0.16) !important;
  color: #c084fc !important;
  border-color: rgba(168, 85, 247, 0.3) !important;
}

/* ========== CARD PLACEHOLDER ========== */
.card-placeholder {
  color: var(--gray-400);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

/* ========== FORM ADJUSTMENTS ========== */
select {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--gray-800);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: auto;
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

input[type="date"],
input[type="time"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--gray-800);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

input[type="date"]:focus,
input[type="time"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-xs {
  padding: 8px 14px;
  font-size: 13px;
}

.cal-board-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 14px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.cal-board-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ========== FORM CHECKBOX ========== */
.form-group-check {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.form-group-check label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-700);
  cursor: pointer;
  white-space: nowrap;
}

.form-group-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  margin: 0;
}

/* ========== HOMEWORK ========== */
.homework-list {
  padding: 0;
}

.hw-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}

.hw-item:last-child {
  border-bottom: none;
}

.hw-item-main {
  flex: 1;
  min-width: 220px;
}

.hw-item-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.hw-item-meta {
  font-size: 12px;
  color: var(--gray-500);
}

.hw-item-meta span {
  margin-right: 10px;
}

.hw-item-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.hw-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  background: var(--gray-100);
  border-radius: 4px;
  color: var(--gray-700);
  text-decoration: none;
  transition: background var(--transition);
}

.hw-file-tag:hover {
  background: var(--gray-200);
}

.hw-file-tag.by-teacher {
  background: #dbeafe;
  color: #1e40af;
}

.hw-file-tag.by-student {
  background: #dcfce7;
  color: #166534;
}

.hw-item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.hw-upload-btn {
  position: relative;
  overflow: hidden;
}

.hw-upload-btn input[type="file"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.hw-upload-status {
  font-size: 11px;
  color: var(--success);
  margin-top: 2px;
}

/* ========== MODAL ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-body {
  padding: 16px 20px 20px 20px;
}

.modal-body .hw-detail-desc {
  margin: 8px 0 16px 0;
  color: var(--gray-600);
  font-size: 14px;
  white-space: pre-wrap;
}

.modal-body .hw-detail-section {
  margin-top: 12px;
}

.modal-body .hw-detail-section h4 {
  font-size: 13px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.modal-body .hw-send-block {
  margin-top: 16px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
}

.modal-body .hw-send-block p {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

/* ========== TEXTAREA ========== */
textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--gray-900);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
  resize: vertical;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ========== GRADE STYLES ========== */
.cal-grade-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--gray-300);
  cursor: pointer;
  color: var(--gray-800);
}

.cal-grade-btn:hover {
  background: #fef3c7;
  border-color: #f59e0b;
}

.grade-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.grade-badge.grade-overall {
  background: #fef3c7;
  color: #b45309;
}

input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--gray-900);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.toast-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.toast-success .toast-icon {
  background: #10b981;
  color: #fff;
}

.toast-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.toast-error .toast-icon {
  background: #ef4444;
  color: #fff;
}

.toast-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.toast-info .toast-icon {
  background: #3b82f6;
  color: #fff;
}

.toast-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}
.toast-warning .toast-icon {
  background: #f59e0b;
  color: #fff;
}

/* Toast Confirm Dialog */
.toast-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0);
  transition: background 0.25s ease;
}
.toast-confirm-visible {
  background: rgba(0,0,0,0.45);
}

.toast-confirm-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: scale(0.9) translateY(10px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast-confirm-visible .toast-confirm-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.toast-confirm-msg {
  font-size: 15px;
  color: var(--gray-800);
  margin-bottom: 20px;
  line-height: 1.5;
}

.toast-confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ========== SKELETON LOADERS ========== */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}
.skeleton-text:last-child { width: 60%; }

.skeleton-title {
  height: 20px;
  width: 40%;
  margin-bottom: 12px;
}

.skeleton-card {
  height: 80px;
  border-radius: var(--radius);
}

.skeleton-row {
  display: flex;
  gap: 8px;
  padding: 10px 0;
}
.skeleton-cell {
  height: 28px;
  border-radius: 6px;
}
.skeleton-cell:nth-child(1) { width: 6%; }
.skeleton-cell:nth-child(2) { width: 22%; }
.skeleton-cell:nth-child(3) { width: 18%; }
.skeleton-cell:nth-child(4) { width: 16%; }
.skeleton-cell:nth-child(5) { width: 14%; }
.skeleton-cell:nth-child(6) { width: 10%; }

/* ========== RIPPLE EFFECT ========== */
.btn, .cal-lesson-block, .nav-item, .cal-slot-free {
  position: relative;
  overflow: hidden;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0.15);
  animation: ripple-effect 0.35s cubic-bezier(0.23, 1, 0.32, 1);
  pointer-events: none;
}

@keyframes ripple-effect {
  to {
    transform: scale(3.5);
    opacity: 0;
  }
}

.btn-primary .ripple { background: rgba(255,255,255,0.35); }
.btn-danger .ripple { background: rgba(255,255,255,0.3); }
.cal-slot-free .ripple { background: rgba(79, 70, 229, 0.15); }

/* ========== AVATAR ========== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* ========== SECTION TRANSITIONS ========== */
.section {
  display: none;
  animation: sectionFadeOut 0.2s ease forwards;
}
.section.active {
  display: block;
  animation: sectionFadeIn 0.22s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sectionFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ========== DRAG & DROP FILE ZONE ========== */
.drop-zone {
  position: relative;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  background: var(--gray-50);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone-icon {
  font-size: 36px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.drop-zone-text {
  font-size: 14px;
  color: var(--gray-600);
  font-weight: 500;
}

.drop-zone-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-files {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.drop-zone-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 6px;
  font-weight: 500;
}

.drop-zone-file-tag .remove-file {
  cursor: pointer;
  font-weight: 700;
  margin-left: 2px;
  opacity: 0.6;
}
.drop-zone-file-tag .remove-file:hover { opacity: 1; }

/* ========== THEME TOGGLE ========== */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--gray-200);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms var(--ease-out, ease-out), background-color 160ms ease, color 160ms ease;
  color: var(--gray-600);
  padding: 0;
}

.theme-toggle-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
  transform: rotate(15deg);
}

/* Кнопка темы на страницах входа (фиксированная, правый верхний угол) */
.theme-toggle-btn.theme-toggle-fixed {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 1100;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-color: var(--glass-border);
}

[data-theme="dark"] .theme-toggle-btn.theme-toggle-fixed {
  background: rgba(24, 24, 27, 0.85);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e4e4e7;
}

/* Toast progress bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  background: currentColor;
  opacity: 0.3;
  transition: width linear;
}

/* ========== CURRENT TIME LINE ========== */
.cal-now-line {
  position: absolute;
  left: 60px;
  right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 30 !important;
  pointer-events: none;
  transition: top 0.25s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.cal-now-dot {
  position: absolute;
  left: 56px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  transform: translateY(-4px);
  z-index: 31 !important;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

/* ========== TAG INPUT ========== */
.tag-input {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 44px;
  gap: 6px;
}

.tag-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.tag-input-field {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-800);
  flex: 1;
  min-width: 120px;
  background: transparent;
  padding: 2px 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  user-select: none;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 6px;
  white-space: nowrap;
}

.tag-remove {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  opacity: 0.5;
  line-height: 1;
  transition: opacity 0.15s;
}
.tag-remove:hover { opacity: 1; }

/* ========== STAT BAR ========== */
.stat-bar-wrap {
  margin-top: 8px;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ========== ACHIEVEMENTS ========== */
.achievement-level-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.achievement-level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

.achievement-level-num {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.achievement-level-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.85;
  margin-top: 2px;
}

.achievement-xp-wrap {
  flex: 1;
  min-width: 150px;
}

.achievement-xp-info {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.achievement-xp-bar {
  height: 10px;
  background: var(--gray-100);
  border-radius: 5px;
  overflow: hidden;
}

.achievement-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: 5px;
  transition: width 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.achievement-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  transition: transform 0.15s ease;
}

.achievement-badge:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.achievement-badge-icon {
  font-size: 20px;
}

.achievement-badge-name {
  white-space: nowrap;
}

/* ========== TEXTBOOK CSS TREE ========== */
.tb-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tb-tree li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tb-tree details {
  margin: 0;
  padding-left: 24px;
}

.tb-tree details > ul {
  padding-left: 0;
}

.tb-tree summary {
  cursor: pointer;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  list-style: none;
  user-select: none;
}

.tb-tree summary::-webkit-details-marker {
  display: none;
}

.tb-tree summary::before {
  content: '▸';
  display: inline-block;
  width: 16px;
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--gray-400);
  flex-shrink: 0;
  text-align: center;
}

.tb-tree details[open] > summary::before {
  transform: rotate(90deg);
}

.tb-tree summary:hover {
  background: var(--gray-100);
}

.tb-tree .tb-node-folder {
  font-weight: 600;
  color: var(--gray-800);
}

.tb-tree .tb-node-leaf {
  font-weight: 400;
  color: var(--gray-600);
}

.tb-tree .tb-node-leaf::before {
  content: '';
  width: 16px;
  flex-shrink: 0;
}

/* Root chapters */
.tb-tree > li > details {
  padding-left: 0;
}

.tb-tree > li > details > summary {
  font-size: 15px;
  font-weight: 700;
  padding: 10px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  margin-bottom: 4px;
  border-radius: 8px;
}

.tb-tree > li > details > summary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 1024px) {
  /* Сайдбар скрывается, появляется бургер */
  .sidebar {
    transform: translateX(-105%) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1000 !important;
    height: 100vh !important;
    width: 300px !important;
    max-width: 85vw;
    transition: transform 0.3s ease !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }
  .sidebar-overlay.show {
    display: block;
  }

  /* Бургер-кнопка */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--gray-800, #1e293b);
    margin-right: 10px;
    padding: 0;
    line-height: 1;
    user-select: none;
  }

  [data-theme="dark"] .mobile-menu-btn {
    color: #ffffff !important;
  }

  .dashboard-wrapper,
  [class*="dashboard-wrapper"] {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* Показать topbar-left — там бургер кнопка */
  .topbar-left {
    display: flex !important;
  }

  /* Текст в сайдбаре — принудительно показать и увеличить */
  .sidebar .nav-label {
    display: inline !important;
    font-size: 15px !important;
    white-space: normal !important;
    overflow: visible !important;
  }
  .sidebar .sidebar-logo {
    font-size: 22px !important;
    margin-bottom: 8px !important;
  }
  .sidebar .sidebar-role {
    display: block !important;
    font-size: 12px !important;
  }
  .sidebar .sidebar-nav .nav-item {
    justify-content: flex-start !important;
    gap: 12px !important;
    padding: 12px 16px !important;
    text-align: left !important;
  }
  .sidebar .sidebar-header {
    padding: 24px 20px !important;
    text-align: left !important;
  }
  .sidebar .sidebar-footer {
    padding: 16px 12px !important;
  }
  .btn-logout {
    font-size: 13px !important;
    padding: 10px 12px !important;
    width: 100% !important;
  }
  .btn-logout::before {
    content: none !important;
  }

  .topbar {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-left h2 {
    font-size: 16px;
  }

  /* Карточки в 1 колонку */
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Календарь — минимальная ширина, скролл */
  .calendar-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 11px;
  }
  .cal-header {
    white-space: nowrap;
    min-width: 490px; /* 7 дней × 70px */
  }
  .cal-body {
    white-space: nowrap;
    min-width: 490px;
  }
  .cal-day-header {
    display: inline-block;
    font-size: 10px;
    padding: 4px 2px;
    min-width: 70px;
    width: 70px;
  }
  .cal-day-col {
    display: inline-block;
    min-width: 70px;
    width: 70px;
  }
  .cal-day-num {
    font-size: 12px;
  }
  .cal-time-slot {
    height: 66px !important;
    min-height: 66px !important;
    max-height: 66px !important;
    box-sizing: border-box !important;
    font-size: 10px;
    padding: 2px 4px;
    min-width: 35px;
  }
  .cal-time-col {
    width: 50px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: top;
  }
  .cal-cell {
    height: 66px !important;
    min-height: 66px !important;
    max-height: 66px !important;
    box-sizing: border-box !important;
    display: block;
    overflow: hidden !important;
  }
  .cal-lesson-title {
    font-size: 10px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cal-lesson-student {
    font-size: 9px;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cal-lesson-time {
    font-size: 8.5px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cal-lesson-status-badge {
    font-size: 8px;
    padding: 1px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Календарь легенда */
  .cal-legend {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
  }

  /* Кнопки навигации календаря */
  .calendar-nav {
    flex-wrap: wrap;
    gap: 4px;
  }
  .calendar-nav .btn-sm {
    font-size: 11px;
    padding: 4px 8px;
  }

  /* Формы — в колонку */
  .form-row {
    flex-direction: column;
    gap: 8px;
  }
  .form-group {
    width: 100%;
    min-width: 0 !important;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    font-size: 16px; /* не даёт iOS зуму при фокусе */
  }
  .form-group-btn {
    align-self: stretch;
  }
  .form-group-btn button {
    width: 100%;
  }

  /* Карточки учеников */
  .student-cards {
    grid-template-columns: 1fr !important;
  }
  .student-card {
    padding: 12px;
  }
  .student-card-actions {
    flex-direction: column;
  }

  /* Таблицы — горизонтальный скролл */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table {
    font-size: 12px;
    min-width: 500px;
  }
  .table th,
  .table td {
    padding: 6px 8px;
  }

  /* ДЗ список */
  .hw-item {
    flex-direction: column;
    padding: 10px;
    gap: 8px;
  }
  .hw-item-actions {
    flex-direction: row;
    width: 100%;
  }
  .hw-item-actions button {
    flex: 1;
    font-size: 12px;
  }
  .hw-file-tag {
    font-size: 11px;
  }

  /* Модалки */
  .modal-content {
    width: 95vw;
    max-width: 95vw;
    margin: 10px;
    border-radius: 12px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-wide {
    max-width: 95vw;
  }
  .modal-body {
    padding: 12px;
  }

  /* Достижения */
  .achievement-level-row {
    flex-direction: column;
    align-items: center;
  }
  .achievement-level-card {
    margin-bottom: 10px;
  }

  /* Хлебные крошки/информация */
  .info-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .student-info-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  /* Teлемост/доска кнопки */
  .welcome-card .btn {
    font-size: 13px;
    padding: 8px 14px;
  }

  /* Контекстное меню */
  .cal-context-menu {
    left: 5px !important;
    right: 5px;
    width: auto;
    max-width: calc(100vw - 10px);
  }
}

@media (max-width: 600px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
  .stat-card {
    padding: 12px;
  }
  .stat-value {
    font-size: 22px;
  }
  .stat-label {
    font-size: 11px;
  }

  .calendar-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cal-day-header {
    min-width: 90px;
    width: 90px;
    font-size: 11px;
    padding: 6px 2px;
  }
  .cal-day-col {
    min-width: 90px;
    width: 90px;
  }
  .cal-day-num {
    font-size: 13px;
  }
  .cal-time-slot {
    min-width: 44px;
    font-size: 10px;
    padding: 4px 6px 0 0;
  }
  .cal-header { min-width: 680px; }
  .cal-body { min-width: 680px; }
  .cal-event-card {
    padding: 3px 5px !important;
    border-radius: 5px;
  }
  .cal-lesson-title {
    font-size: 10.5px;
  }
  .cal-lesson-student {
    font-size: 9.5px;
  }
  .cal-lesson-time {
    font-size: 8.5px;
  }
  .cal-lesson-status-badge {
    font-size: 7.5px;
  }

  .topbar-role {
    display: none;
  }
  .topbar-user {
    font-size: 12px;
  }
}

/* ========== CHARTS (Chart.js) ========== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  padding: 16px 20px;
}
.charts-grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.chart-box {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
}
[data-theme="dark"] .chart-box { border-color: var(--gray-700); }
.chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, var(--gray-600));
  margin-bottom: 8px;
}
.chart-canvas-wrap {
  position: relative;
  height: 180px;
  width: 100%;
}

/* ========== COMPREHENSIVE MOBILE ADAPTATION SYSTEM (iOS & Android) ========== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  border-radius: 8px;
}

.table-responsive table {
  min-width: 580px;
}

@media (max-width: 768px) {
  :root {
    --safe-bottom: env(safe-area-inset-bottom, 12px);
    --safe-top: env(safe-area-inset-top, 0px);
  }

  /* Dynamic viewport height */
  html, body {
    min-height: 100dvh;
    -webkit-text-size-adjust: 100%;
  }

  /* Touch Targets */
  .btn, .btn-sm, button, .tab-btn, .nav-btn, .modal-input, select, input[type="text"], input[type="password"], input[type="number"] {
    min-height: 40px;
    touch-action: manipulation;
  }

  /* Horizontal Pill Scroller */
  .filter-bar, .topic-filter-bar, .pill-row, .tabs-header {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 6px;
    flex-wrap: nowrap;
  }
  .filter-bar::-webkit-scrollbar, .topic-filter-bar::-webkit-scrollbar, .pill-row::-webkit-scrollbar {
    display: none;
  }
  .topic-filter-pill, .tab-pill, .filter-pill {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Responsive Grid layouts */
  .grid-2, .grid-3, .grid-4, .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* Telegram-style Bottom Sheet Modals on Mobile */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal-overlay .modal-card,
  .modal-overlay .modal-content,
  .student-modal .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 88dvh !important;
    margin: 0 !important;
    padding: 18px 16px max(18px, env(safe-area-inset-bottom)) 16px !important;
    box-sizing: border-box !important;
    animation: webed-slide-up 220ms cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  /* Cards & Sections */
  .card, .content-section, .section {
    padding: 14px 12px;
    border-radius: 12px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .dashboard-container, .main-content {
    padding: 10px 8px max(16px, env(safe-area-inset-bottom)) 8px !important;
  }

  .stats-grid, .stats-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  .topbar {
    padding: 8px 12px !important;
    gap: 8px;
  }

  .btn-group {
    flex-wrap: wrap;
    width: 100%;
  }
  .btn-group .btn {
    flex: 1;
    min-width: 120px;
  }
}


/* Мобильные экраны: предотвращение pull-to-refresh и масштабирования */
#canvasWrap, .canvas-container, .canvas-container canvas {
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

/* ========== MATH FRACTION RENDERING ========== */
.math-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  padding: 0 0.22em;
  font-size: 1.12em;
  line-height: 1;
  position: relative;
  top: -0.1em;
  font-family: inherit;
}
.math-num {
  display: block;
  font-size: 0.9em;
  line-height: 1.15;
  padding: 0 0.12em 0.08em 0.12em;
  border-bottom: 1.4px solid currentColor;
}
.math-den {
  display: block;
  font-size: 0.9em;
  line-height: 1.15;
  padding: 0.08em 0.12em 0 0.12em;
}
.math-mixed {
  display: inline-flex;
  align-items: center;
  gap: 0.18em;
  vertical-align: middle;
}

/* ============================================================
   FAMILY HIERARCHY — APPLE / EMIL KOWALSKI DESIGN
   ============================================================ */
.hierarchy-card-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  padding-bottom: 16px !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}
.hierarchy-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hierarchy-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hierarchy-title-group h3 {
  margin: 0 !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  color: var(--gray-900, #18181b);
}
.hierarchy-title-group p {
  margin: 2px 0 0 0 !important;
  font-size: 13px !important;
  color: var(--gray-500, #71717a);
}

/* Apple Segmented Control */
.hierarchy-view-segmented {
  display: inline-flex !important;
  align-items: center !important;
  background: #ebebed !important;
  padding: 3px !important;
  border-radius: 9px !important;
  gap: 2px !important;
  border: none !important;
}
.hierarchy-view-btn {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: none !important;
  background: transparent !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  font-family: inherit !important;
  color: #636366 !important;
  border-radius: 7px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  line-height: 1 !important;
  transition: background-color 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.15s ease, box-shadow 0.15s ease !important;
}
.hierarchy-view-btn:hover:not(.active) {
  color: #1c1c1e !important;
  background: rgba(255, 255, 255, 0.4) !important;
}
.hierarchy-view-btn.active {
  background: #ffffff !important;
  color: #1c1c1e !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0.5px 1px rgba(0, 0, 0, 0.06) !important;
}

/* Search bar & Filter toolbar */
.hierarchy-toolbar {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  margin: 16px 0 !important;
}
.hierarchy-search-box {
  position: relative !important;
  width: 100% !important;
}
.hierarchy-search-box input {
  width: 100% !important;
  height: 40px !important;
  padding: 0 14px 0 38px !important;
  border-radius: 10px !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  background: #f4f4f6 !important;
  font-size: 13px !important;
  font-family: inherit !important;
  color: var(--gray-900, #18181b) !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease !important;
}
.hierarchy-search-box input:focus {
  background: #ffffff !important;
  border-color: #7c3aed !important;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14) !important;
}
.hierarchy-search-icon {
  position: absolute !important;
  left: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  color: var(--gray-400, #a1a1aa) !important;
  pointer-events: none !important;
  display: flex !important;
  align-items: center !important;
}

/* Filter Chips (Apple Pills) */
.hierarchy-filter-chips {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  align-items: center !important;
}
.hierarchy-chip {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  background: #ffffff !important;
  padding: 6px 13px !important;
  border-radius: 9999px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  font-family: inherit !important;
  color: #3f3f46 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
  transition: background-color 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.15s ease, transform 0.1s ease, color 0.15s ease !important;
}
.hierarchy-chip:hover {
  background: #f4f4f6 !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}
.hierarchy-chip:active {
  transform: scale(0.97) !important;
}
.hierarchy-chip .chip-count {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(0, 0, 0, 0.06) !important;
  padding: 1px 7px !important;
  border-radius: 10px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #52525b !important;
}
.hierarchy-chip.active {
  background: #18181b !important;
  border-color: #18181b !important;
  color: #ffffff !important;
}
.hierarchy-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.22) !important;
  color: #ffffff !important;
}

/* Highlighted "2 ребёнка" chip */
.hierarchy-chip-two {
  background: rgba(124, 58, 237, 0.05) !important;
  border-color: rgba(124, 58, 237, 0.25) !important;
  color: #6d28d9 !important;
  font-weight: 600 !important;
}
.hierarchy-chip-two .chip-count {
  background: rgba(124, 58, 237, 0.12) !important;
  color: #6d28d9 !important;
}
.hierarchy-chip-two.active {
  background: #7c3aed !important;
  border-color: #7c3aed !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25) !important;
}
.hierarchy-chip-two.active .chip-count {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #ffffff !important;
}

/* Badges for child counts */
.badge-two-kids {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: rgba(124, 58, 237, 0.09) !important;
  color: #7c3aed !important;
  border: 1px solid rgba(124, 58, 237, 0.22) !important;
  padding: 3px 9px !important;
  border-radius: 6px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
}
.badge-multi-kids {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: rgba(245, 158, 11, 0.1) !important;
  color: #b45309 !important;
  border: 1px solid rgba(245, 158, 11, 0.2) !important;
  padding: 3px 9px !important;
  border-radius: 6px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
}
.badge-single-kid {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: rgba(59, 130, 246, 0.08) !important;
  color: #1d4ed8 !important;
  border: 1px solid rgba(59, 130, 246, 0.18) !important;
  padding: 3px 9px !important;
  border-radius: 6px !important;
  font-size: 11.5px !important;
  font-weight: 500 !important;
}
.badge-no-kids {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  background: rgba(142, 142, 147, 0.08) !important;
  color: #71717a !important;
  border: 1px solid rgba(142, 142, 147, 0.16) !important;
  padding: 3px 9px !important;
  border-radius: 6px !important;
  font-size: 11.5px !important;
  font-weight: 500 !important;
}

/* Family cards grid */
.family-tree-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)) !important;
  gap: 16px !important;
  margin-top: 16px !important;
}
@media (max-width: 640px) {
  .family-tree-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Family card */
.family-tree-card {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  border-radius: 14px !important;
  padding: 18px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease, border-color 0.18s ease !important;
}
.family-tree-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06) !important;
}
.family-tree-card.has-two-children {
  border-color: rgba(124, 58, 237, 0.35) !important;
  background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%) !important;
  box-shadow: 0 3px 12px rgba(124, 58, 237, 0.06) !important;
}
.family-tree-card.has-two-children:hover {
  border-color: rgba(124, 58, 237, 0.55) !important;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.12) !important;
}

.family-tree-card-header {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}
.family-parent-info {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  min-width: 0 !important;
}
.family-avatar {
  width: 40px !important;
  height: 40px !important;
  border-radius: 10px !important;
  background: #f4f4f6 !important;
  color: var(--gray-700, #3f3f46) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  font-size: 15px !important;
  flex-shrink: 0 !important;
}
.family-avatar-two {
  background: #ede9fe !important;
  color: #7c3aed !important;
  border: 1px solid rgba(124, 58, 237, 0.2) !important;
}
.family-avatar-multi {
  background: #fef3c7 !important;
  color: #b45309 !important;
}
.family-parent-text {
  min-width: 0 !important;
}
.family-parent-name {
  font-size: 14.5px !important;
  font-weight: 700 !important;
  color: var(--gray-900, #18181b) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.family-parent-meta {
  font-size: 12px !important;
  color: var(--gray-500, #71717a) !important;
  margin-top: 2px !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.family-parent-meta code {
  font-size: 11px !important;
  background: rgba(0, 0, 0, 0.04) !important;
  padding: 1px 5px !important;
  border-radius: 4px !important;
}
.family-parent-badges {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
}

/* Children list */
.family-children-container {
  padding-top: 14px !important;
  flex-grow: 1 !important;
}
.family-children-title {
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  color: var(--gray-400, #a1a1aa) !important;
  margin-bottom: 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}
.family-children-tree {
  position: relative !important;
  padding-left: 16px !important;
  margin-left: 8px !important;
  border-left: 2px solid rgba(0, 0, 0, 0.07) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}
.family-tree-card.has-two-children .family-children-tree {
  border-left-color: rgba(124, 58, 237, 0.28) !important;
}
.family-child-node {
  position: relative !important;
  background: #f9f9fb !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  border-radius: 8px !important;
  padding: 9px 12px !important;
  transition: background-color 0.15s ease, border-color 0.15s ease !important;
}
.family-child-node::before {
  content: '' !important;
  position: absolute !important;
  left: -16px !important;
  top: 50% !important;
  width: 14px !important;
  height: 2px !important;
  background: rgba(0, 0, 0, 0.07) !important;
}
.family-tree-card.has-two-children .family-child-node::before {
  background: rgba(124, 58, 237, 0.28) !important;
}
.family-tree-card.has-two-children .family-child-node {
  background: #ffffff !important;
  border-color: rgba(124, 58, 237, 0.15) !important;
}
.family-child-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
}
.family-child-main {
  min-width: 0 !important;
}
.family-child-name {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--gray-900, #18181b) !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: wrap !important;
}
.family-child-details {
  font-size: 11.5px !important;
  color: var(--gray-500, #71717a) !important;
  margin-top: 3px !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-wrap: wrap !important;
}
.family-child-tag {
  background: rgba(0, 0, 0, 0.04) !important;
  padding: 1px 6px !important;
  border-radius: 4px !important;
}
.family-child-sibling-tag {
  background: rgba(124, 58, 237, 0.08) !important;
  color: #7c3aed !important;
  font-weight: 500 !important;
}
.family-card-footer {
  margin-top: 14px !important;
  padding-top: 12px !important;
  border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
}
