/* ==============================================================
   FreDil — Unified Master Design System
   Source of visual truth matching /prototype exactly
   ============================================================== */

@import url('../fonts/montserrat.css');

[x-cloak] {
  display: none !important;
}

:root {
  /* ==============================================================
     BRAND COLOR PALETTE (Blue & White with Restrained Red Accent)
     ============================================================== */
  --color-primary: #1A4FE8;
  --color-primary-dark: #1237A8;
  --color-navy: #0B1739;
  --color-white: #FFFFFF;
  --color-background: #FFFFFF;
  --color-background-soft: #F3F7FF;
  --color-surface: #F8FAFC;
  --color-surface-blue: #E8EFFF;
  --color-surface-dark: #111827;

  /* Neutrals */
  --color-text: #172033;
  --color-text-secondary: #64748B;
  --color-text-muted: #94A3B8;
  --color-border: #CBD5E1;
  --border: #CBD5E1;

  /* Red Accent (Restrained, intentional highlights) */
  --color-accent: #E53945;
  --color-accent-dark: #C62836;
  --color-accent-soft: #FFF1F2;

  /* Functional / Semantic */
  --color-success: #15803D;
  --color-success-soft: #DCFCE7;
  --color-warning: #B45309;
  --color-warning-soft: #FEF3C7;
  --color-error: #C62836;
  --color-info: #1A4FE8;

  /* ==============================================================
     CENTRALIZED TYPOGRAPHY SYSTEM (Montserrat Default)
     ============================================================== */
  --font-primary: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-monospace: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.84rem;    /* 13.5px */
  --font-size-base: 0.94rem;  /* 15px */
  --font-size-md: 1rem;       /* 16px */
  --font-size-lg: 1.15rem;    /* 18.5px */
  --font-size-xl: 1.35rem;    /* 21.5px */
  --font-size-2xl: clamp(1.4rem, 2.2vw, 1.75rem);
  --font-size-3xl: clamp(1.75rem, 3.2vw, 2.25rem);
  --font-size-4xl: clamp(2.1rem, 4.5vw, 3rem);

  --line-height-tight: 1.18;
  --line-height-snug: 1.35;
  --line-height-normal: 1.55;
  --line-height-relaxed: 1.7;

  --letter-spacing-tight: -0.02em;
  --letter-spacing-normal: 0em;
  --letter-spacing-wide: 0.04em;
  --letter-spacing-wider: 0.08em;

  /* UI Tokens */
  --radius: 14px;
  --maxw: 1180px;
  --shadow: 0 12px 32px -18px rgba(11, 23, 57, 0.18);
  --shadow-sm: 0 2px 8px -2px rgba(11, 23, 57, 0.08);
  --shadow-lg: 0 20px 40px -12px rgba(11, 23, 57, 0.22);

  /* Legacy Compatibility Aliases (Seamless zero-regression mapping) */
  --ink: var(--color-text);
  --ink-soft: var(--color-text-secondary);
  --paper: var(--color-background);
  --paper-alt: var(--color-surface);
  --line: var(--color-border);
  --primary: var(--color-primary);
  --primary-hover: var(--color-primary-dark);
  --primary-soft: var(--color-surface-blue);
  --blue: var(--color-primary);
  --blue-deep: var(--color-primary-dark);
  --blue-soft: var(--color-background-soft);
  --teal: var(--color-primary);
  --teal-soft: var(--color-surface-blue);
  --amber: #f59e0b;
  --amber-deep: var(--color-warning);
  --red: var(--color-accent);
  --red-hover: var(--color-accent-dark);
  --red-soft: var(--color-accent-soft);
  --navy: var(--color-navy);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: var(--font-primary);
}

button,
input,
select,
textarea {
  font-family: var(--font-primary);
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font-primary);
  color: var(--color-text);
  background: var(--color-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-primary);
  margin: 0;
  color: var(--color-navy);
}

h1 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
}

h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
}

h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
}

h4 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
}

h5 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
}

h6 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
}

p {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: var(--line-height-normal);
}

a {
  color: inherit;
  text-decoration: none;
}

.mono,
code,
kbd,
samp,
pre {
  font-family: var(--font-monospace);
  font-size: var(--font-size-xs);
  letter-spacing: 0.02em;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  border: 1.5px solid var(--color-primary);
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
  font-family: var(--font-primary);
  text-align: center;
  line-height: 1.2;
}

.btn-primary {
  background: var(--navy, #101C34);
  color: #fff;
  border-color: var(--navy, #101C34);
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: var(--teal, #127A63);
  border-color: var(--teal, #127A63);
  color: #fff;
  box-shadow: 0 4px 14px rgba(18, 122, 99, 0.32);
}

.btn-secondary {
  background: #E3F1EC;
  color: #127A63;
  border: 1.5px solid #127A63;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  background: #127A63;
  color: #FFFFFF;
  border-color: #127A63;
  box-shadow: 0 4px 14px rgba(18, 122, 99, 0.28);
}

.btn-teal {
  background: #127A63;
  color: #fff;
  border-color: #127A63;
}

.btn-teal:hover {
  transform: translateY(-2px);
  background: #169578;
  border-color: #169578;
  color: #fff;
  box-shadow: 0 4px 14px rgba(18, 122, 99, 0.28);
}

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

.btn-accent:hover {
  transform: translateY(-2px);
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  color: #fff;
  box-shadow: 0 4px 14px rgba(229, 57, 69, 0.28);
}

.btn-ghost {
  background: #E3F1EC;
  color: #127A63;
  border-color: #127A63;
}

.btn-ghost:hover {
  background: #127A63;
  border-color: #127A63;
  color: #FFFFFF;
}

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

.btn-danger:hover {
  transform: translateY(-2px);
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
  box-shadow: 0 4px 14px rgba(198, 40, 54, 0.25);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 15px;
  font-size: var(--font-size-xs);
}

/* ==================== BRAND & LOGO ==================== */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-primary);
  font-weight: var(--font-weight-bold);
  font-size: 1.25rem;
  color: var(--color-navy);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex: none;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 68%, var(--color-accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-primary);
  font-size: 0.78rem;
  font-weight: var(--font-weight-extrabold);
  box-shadow: 0 2px 8px rgba(26, 79, 232, 0.3);
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-teal,
.badge-blue {
  background: var(--color-surface-blue);
  color: var(--color-primary);
}

.badge-amber {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.badge-red,
.badge-accent {
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
}

.badge-ink {
  background: var(--color-surface);
  color: var(--color-text-secondary);
}

/* ==================== CARDS ==================== */
.card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 22px;
}

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

/* ==================== APP SHELL & SIDEBAR ==================== */
.app-shell {
  min-height: 100vh;
  position: relative;
  background: var(--color-background);
}

.sidebar {
  background: var(--color-navy);
  color: #c4cfe0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 250px;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.sidebar .brand {
  color: #fff;
  padding: 0 8px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #94a3b8;
  transition: all .15s ease;
  position: relative;
}

.side-nav a .nav-icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
  transition: opacity .15s ease, transform .15s ease;
}

.side-nav a .ic {
  width: 20px;
  height: 20px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-primary);
  font-size: 0.72rem;
  border: 1.5px solid currentColor;
  border-radius: 5px;
}

.side-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.side-nav a:hover .nav-icon {
  opacity: 1;
  transform: translateX(1px);
}

.side-nav a.active {
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(26, 79, 232, 0.35);
}

.side-nav a.active .nav-icon {
  opacity: 1;
}

.side-nav a.side-nav-sub {
  padding: 9px 12px;
  font-size: 0.84rem;
  color: #a8b4c8;
}

.side-nav a.side-nav-sub .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

.side-nav a.side-nav-sub .nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.side-nav a.side-nav-sub:hover,
.side-nav a.side-nav-sub.active {
  color: #ffffff;
}

.side-nav .group-label {
  font-family: var(--font-primary);
  font-size: 11px;
  letter-spacing: var(--letter-spacing-wider);
  color: #6a7c9f;
  text-transform: uppercase;
  padding: 14px 12px 4px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-primary);
  font-weight: var(--font-weight-bold);
  font-size: 0.75rem;
  color: #fff;
  flex: none;
}

.side-user .name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.side-user .role {
  font-size: 0.72rem;
  color: #8fa1c2;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  transition: .15s ease;
  border: 1px solid transparent;
}

.profile-top:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.profile-top .chev {
  margin-left: auto;
  color: #5f7196;
  font-size: 0.95rem;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 4px 10px;
}

/* ==================== MAIN CONTENT & TOPBAR ==================== */
.main {
  margin-left: 250px;
  width: calc(100% - 250px);
  min-width: 0;
  min-height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-background);
  box-sizing: border-box;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
}

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

.topbar h1 {
  font-size: var(--font-size-xl);
  color: var(--color-navy);
  font-weight: var(--font-weight-bold);
}

.topbar .sub {
  font-size: 0.86rem;
  margin-top: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-switch-top {
  display: flex;
  background: var(--color-surface);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-switch-top a,
.lang-switch-top button {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: .15s;
}

.lang-switch-top a.active,
.lang-switch-top button.active {
  background: var(--color-navy);
  color: #fff;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-background);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text);
  transition: .15s ease;
}

.icon-btn:hover {
  background: var(--color-surface);
}

.content {
  padding: 30px 32px 60px;
  min-width: 0;
}

/* Mobile Hamburger & Backdrop */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--color-text);
  font-size: 1.4rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 23, 57, 0.65);
  backdrop-filter: blur(4px);
  z-index: 35;
}

/* ==================== STAT CARDS (KPI GRID) ==================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1300px) {
  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  }
}

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

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

.stat-card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 142px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -10px rgba(11, 23, 57, 0.12);
  border-color: #cbd5e1;
}

a.stat-card--link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.stat-card--link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

a.stat-card--link-active {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px #bfdbfe, 0 10px 24px -10px rgba(26, 79, 232, 0.15);
}

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

.stat-card-label {
  font-family: var(--font-primary);
  font-size: 0.76rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
  padding-right: 4px;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .18s ease;
}

.stat-card:hover .stat-card-icon {
  transform: scale(1.06);
}

.stat-card-icon.icon-blue {
  background: #eff6ff;
  color: #1a4fe8;
}

.stat-card-icon.icon-teal {
  background: #ecfdf5;
  color: #059669;
}

.stat-card-icon.icon-amber {
  background: #fffbeb;
  color: #d97706;
}

.stat-card-icon.icon-indigo {
  background: #f5f3ff;
  color: #6366f1;
}

.stat-card-icon.icon-rose {
  background: #fff1f2;
  color: #e11d48;
}

.stat-card-value {
  font-family: var(--font-primary);
  font-size: 1.95rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}

.stat-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  margin-top: auto;
  width: 100%;
}

.stat-card-foot--stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

@media (min-width: 420px) {
  .stat-card-foot--stack {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.35;
  max-width: 100%;
  box-sizing: border-box;
}

.stat-badge--month {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.7rem;
  padding: 3px 8px;
}

.stat-badge.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.stat-badge.badge-neutral {
  background: #f1f5f9;
  color: #475569;
}

.stat-badge.badge-accent {
  background: #fee2e2;
  color: #b91c1c;
}

.stat-badge.badge-info {
  background: #dbeafe;
  color: #1d4ed8;
}

.stat-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* Legacy stat-card fallbacks */
.stat-card .lbl {
  font-family: var(--font-primary);
  font-size: 12px;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: var(--font-weight-semibold);
}

.stat-card .num {
  font-family: var(--font-primary);
  font-size: 1.85rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-navy);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-card .delta {
  font-size: 0.8rem;
  margin-top: 6px;
  font-weight: var(--font-weight-bold);
}

.delta.up {
  color: var(--color-success);
}

.delta.down {
  color: var(--color-accent);
}

/* ==================== PROFESSIONAL CHART SYSTEM ==================== */
.chart-card {
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
  margin-bottom: 24px;
  overflow: visible;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.chart-title-area h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-navy);
  margin: 0 0 4px;
}

.chart-subtitle {
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  margin: 0;
}

.chart-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chart-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 3px 10px;
  border-radius: 8px;
}

.chart-chip strong {
  color: var(--color-navy);
  font-weight: 700;
}

.chart-chip.chip-highlight {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.chart-view-toggle {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}

.chart-view-toggle a {
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 7px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all .15s ease;
}

.chart-view-toggle a.active {
  background: #ffffff;
  color: var(--color-navy);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-container-outer {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  /* Room for bar hover tooltips (otherwise clipped by overflow-x auto) */
  padding-top: 46px;
  margin-top: -10px;
}

.chart-body {
  display: flex;
  min-width: 100%;
  height: 240px;
  padding-top: 12px;
  position: relative;
  overflow: visible;
}

.chart-y-axis {
  width: 36px;
  height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  padding-right: 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  user-select: none;
  flex-shrink: 0;
}

.chart-plot-area {
  flex: 1;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
}

.chart-gridlines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-gridline {
  width: 100%;
  border-bottom: 1px dashed #e2e8f0;
  height: 0;
}

.chart-columns {
  position: relative;
  z-index: 2;
  height: 190px;
  display: flex;
  align-items: flex-end;
  width: 100%;
  gap: 8px;
  overflow: visible;
}

.chart-column {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: background .15s ease;
  min-width: 0;
  overflow: visible;
  z-index: 1;
}

.chart-column:hover,
.chart-column:focus-within {
  z-index: 20;
}

.chart-column:hover {
  background: rgba(26, 79, 232, 0.04);
}

.chart-bar-shell {
  width: 100%;
  max-width: 44px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
}

.chart-bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--color-primary), #3b82f6);
  transition: height .3s cubic-bezier(0.4, 0, 0.2, 1), background .2s ease;
  position: relative;
}

.chart-column:hover .chart-bar {
  filter: brightness(1.08);
}

.chart-bar.is-peak {
  background: linear-gradient(180deg, #1237a8, var(--color-primary));
  box-shadow: 0 2px 10px rgba(26, 79, 232, 0.35);
}

.chart-bar.is-zero {
  height: 0 !important;
  background: transparent !important;
}

.chart-zero-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cbd5e1;
  margin-bottom: 2px;
  transition: background .15s ease;
}

.chart-column:hover .chart-zero-dot {
  background: var(--color-primary);
}

/* Tooltip floating card */
.chart-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0b1739;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease, transform .15s ease;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
  z-index: 50;
  text-align: center;
}

.chart-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: #0b1739 transparent transparent transparent;
}

.chart-column:hover .chart-tooltip,
.chart-column:focus-within .chart-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-3px);
}

.chart-tooltip-date {
  font-weight: 500;
  color: #94a3b8;
  margin-bottom: 2px;
}

.chart-tooltip-value {
  font-weight: 700;
  font-size: 13px;
  color: #ffffff;
}

.chart-x-axis {
  height: 34px;
  display: flex;
  width: 100%;
  border-top: 1px solid var(--color-border);
  padding-top: 8px;
  user-select: none;
  gap: 8px;
}

.chart-x-label {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-x-label.is-today {
  color: var(--color-primary);
  font-weight: 700;
}

/* 30-day mode specific bar density */
.chart-columns.dense-30 {
  gap: 3px;
}

.chart-columns.dense-30 .chart-bar-shell {
  max-width: 16px;
}

.chart-columns.dense-30 .chart-x-label {
  font-size: 10px;
}

/* Backward compatibility for .bar-chart */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
  padding-top: 10px;
  width: 100%;
}

.bar-chart .col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.bar-chart .bar-wrapper {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-chart .bar {
  width: 100%;
  max-width: 44px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--color-primary), #3b82f6);
  transition: height .3s ease;
}

.bar-chart .bar.peak {
  background: linear-gradient(180deg, var(--color-primary-dark), var(--color-primary));
}

.bar-chart .lbl {
  font-family: var(--font-primary);
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ==================== TABLES & RESPONSIVE CONTAINERS ==================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

thead th {
  font-family: var(--font-primary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--color-text-secondary);
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  background: var(--color-surface);
  font-weight: var(--font-weight-semibold);
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--color-background-soft);
}

.row-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-avatar .dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  flex: none;
}

/* ==================== FORMS ==================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.field label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-navy);
}

.form-control,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select,
.field textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  display: block;
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-primary);
  font-size: 0.93rem;
  font-weight: 500;
  line-height: 1.5;
  color: #0F172A;
  background-color: #FFFFFF;
  border: 1.5px solid #CBD5E1;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  box-sizing: border-box;
}

.form-control:hover,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
.field select:hover,
.field textarea:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="time"]:hover,
textarea:hover {
  border-color: #94A3B8;
}

.form-control:focus,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.field select:focus,
.field textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
textarea:focus {
  border-color: #1A4FE8 !important;
  outline: none !important;
  box-shadow: 0 0 0 3.5px rgba(26, 79, 232, 0.14) !important;
  background-color: #FFFFFF;
}

.form-control:disabled,
.field input:disabled,
.field select:disabled,
.field textarea:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  background-color: #F8FAFC !important;
  border-color: #E2E8F0 !important;
  color: #64748B !important;
  cursor: not-allowed;
  opacity: 0.85;
}

.form-control::placeholder,
.field input::placeholder,
.field textarea::placeholder,
input::placeholder,
textarea::placeholder {
  color: #94A3B8;
  opacity: 1;
}

select,
.field select,
select.form-control {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-color: #FFFFFF;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
  padding-right: 42px !important;
  cursor: pointer;
}

textarea,
.field textarea,
textarea.form-control {
  min-height: 90px;
  resize: vertical;
  line-height: 1.55;
}

input[type="file"],
.form-control[type="file"] {
  border: 1.5px dashed #CBD5E1;
  border-radius: 10px;
  padding: 8px 12px;
  background: #F8FAFC;
  width: 100%;
  cursor: pointer;
  font-size: 0.85rem;
  color: #475569;
  transition: all 0.15s ease;
}

input[type="file"]:hover,
.form-control[type="file"]:hover {
  border-color: #1A4FE8;
  background: #F0F4FF;
}

input[type="file"]::file-selector-button,
.form-control[type="file"]::file-selector-button {
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #0F172A;
  font-weight: 700;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  margin-right: 12px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

input[type="file"]::file-selector-button:hover,
.form-control[type="file"]::file-selector-button:hover {
  background: #1A4FE8;
  color: #FFFFFF;
  border-color: #1A4FE8;
}

.field-note {
  font-size: 0.76rem;
  color: var(--color-text-secondary);
}

.field-error {
  font-size: 0.78rem;
  color: var(--color-accent);
  font-weight: var(--font-weight-semibold);
}

/* ==================== PROGRESS BAR ==================== */
.pbar {
  height: 8px;
  border-radius: 999px;
  background: var(--color-surface);
  overflow: hidden;
}

.pbar>span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark));
  border-radius: 999px;
}

/* ==================== LESSON STATUS DOTS & CHIPS ==================== */
.log-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
}

.log-dot.done {
  background: var(--color-primary);
}

.log-dot.postponed {
  background: var(--color-warning);
}

.log-dot.cancelled {
  background: var(--color-accent);
}

.log-status {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  padding: 4px 10px;
  border-radius: 999px;
  flex: none;
}

.log-status.done {
  background: var(--color-surface-blue);
  color: var(--color-primary);
}

.log-status.postponed {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.log-status.cancelled {
  background: var(--color-accent-soft);
  color: var(--color-accent-dark);
}

/* ==================== STUDENT COURSE HEADER ==================== */
.course-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--ink), #1c2c4d);
  color: #fff;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.course-level-badge {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 14px;
  flex: none;
  background: linear-gradient(135deg, var(--teal), var(--amber));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-primary, 'Montserrat', sans-serif);
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  box-sizing: border-box;
  padding: 4px;
  line-height: 1;
}

.course-level-badge-text {
  display: block;
  max-width: 100%;
  text-align: center;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-level-badge.is-unplaced .course-level-badge-text {
  font-size: 1.35rem;
  opacity: 0.95;
}

.course-head-body {
  flex: 1;
  min-width: 0;
}

.course-head-title {
  color: #fff;
  font-size: 1.35rem;
  margin: 0;
  line-height: 1.25;
  word-break: break-word;
}

.course-head-meta {
  color: #9fb0c9;
  font-size: 0.86rem;
  margin-top: 6px;
  line-height: 1.45;
}

.course-head-meta strong {
  color: #fff;
  font-weight: 700;
}

.course-head-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ==================== SCHEDULE WEEK GRID ==================== */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.day-col .day-lbl {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
  text-align: center;
}

.slot {
  background: var(--color-surface-blue);
  border-left: 3px solid var(--color-primary);
  border-radius: 8px;
  padding: 8px 9px;
  margin-bottom: 8px;
  font-size: 0.76rem;
}

.slot.group {
  background: var(--color-warning-soft);
  border-left-color: var(--color-warning);
}

.slot .t {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-bold);
  color: var(--color-navy);
}

.slot .who {
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.slot.empty {
  background: transparent;
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
  text-align: center;
  padding: 16px 6px;
}

/* ==================== TILES & KPI ROWS ==================== */
.tile-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.tile {
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  background: var(--color-background);
}

.tile .lbl {
  font-family: var(--font-primary);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  font-weight: var(--font-weight-semibold);
}

.tile .num {
  font-family: var(--font-primary);
  font-size: 1.7rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-navy);
  margin-top: 6px;
}

.tile.paid {
  border-left: 4px solid var(--color-primary);
}

.tile.paid .num {
  color: var(--color-primary);
}

.tile.unpaid {
  border-left: 4px solid var(--color-warning);
}

.tile.unpaid .num {
  color: var(--color-warning);
}

.tile.unpaid.critical {
  border-left: 4px solid var(--color-accent);
}

.tile.unpaid.critical .num {
  color: var(--color-accent);
}

/* ==================== NET PROFIT HIGHLIGHT CARD ==================== */
.net-card {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.net-card h3 {
  color: #fff;
}

.net-card .formula {
  font-family: var(--font-monospace);
  font-size: 12px;
  color: #9fb0c9;
  margin-top: 10px;
  word-break: break-all;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 23, 57, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  background: var(--color-background);
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 28px;
}

/* ==================== MESSAGING & CHAT SYSTEM ==================== */
.msg-shell {
  display: grid;
  grid-template-columns: 330px 1fr;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  height: calc(100vh - 180px);
  min-height: 580px;
  max-height: 840px;
  box-shadow: 0 4px 24px -2px rgba(15, 23, 42, 0.08);
}

.msg-list {
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  background: #FAFBFD;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.conv {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
  background: transparent;
}

.conv:hover {
  background: #F4F7FB;
}

.conv.active {
  background: #F0F5FF;
  border-left: 3px solid var(--color-primary, #1A4FE8);
}

.conv .av {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.conv .info {
  flex: 1;
  min-width: 0;
}

.conv .name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv .snippet {
  font-size: 0.78rem;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.conv .time {
  font-size: 0.7rem;
  color: #94A3B8;
  flex: none;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #F8FAFC;
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  background: #FFFFFF;
  flex-shrink: 0;
}

.chat-head .av {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
}

.chat-back-mobile {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #F1F5F9;
  color: #1E293B;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #E2E8F0;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.chat-back-mobile:active {
  background: #E2E8F0;
}

.chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F8FAFC;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.bubble {
  max-width: 75%;
  padding: 10px 16px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.bubble.them {
  background: #FFFFFF;
  border: 1px solid var(--color-border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: #0F172A;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.bubble.me {
  background: var(--color-primary, #1A4FE8);
  color: #FFFFFF;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(26, 79, 232, 0.2);
}

/* Typing Indicator Animation */
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFFFFF;
  border: 1px solid var(--color-border, #E2E8F0);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94A3B8;
  display: inline-block;
  animation: typingWave 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingWave {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
    background: var(--color-primary, #1A4FE8);
  }
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--color-border);
  background: #FFFFFF;
  flex-shrink: 0;
}

.chat-input input {
  flex: 1;
  border: 1.5px solid var(--color-border);
  border-radius: 24px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  background: #FAFBFD;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.chat-input input:focus {
  border-color: var(--color-primary, #1A4FE8);
  box-shadow: 0 0 0 3px rgba(26, 79, 232, 0.12);
  background: #FFFFFF;
}

/* ==================== MULTI-COLUMN CONTENT & FORM GRIDS ==================== */
.two-col,
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.grid-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

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

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 56px;
  align-items: center;
}

.demo-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
}

.slot-repeater-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

/* Smooth custom scrollbars for horizontal tables and grids */
.table-responsive::-webkit-scrollbar,
.week-grid::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track,
.week-grid::-webkit-scrollbar-track {
  background: var(--paper-alt);
  border-radius: 999px;
}

.table-responsive::-webkit-scrollbar-thumb,
.week-grid::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.week-grid::-webkit-scrollbar-thumb:hover {
  background: var(--ink-soft);
}

/* Base prevention of accidental horizontal viewport overflow */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.app-shell,
.content {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */

/* Base responsive table container */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  border-radius: var(--radius-sm, 8px);
}

.table-responsive table {
  min-width: 600px;
  width: 100%;
}

.table-responsive thead th {
  white-space: nowrap;
}

.table-responsive tbody td .badge,
.table-responsive tbody td .mono,
.table-responsive tbody td .btn {
  white-space: nowrap;
}

/* Laptop screens (1025px - 1400px): optimized content and card padding to prevent table clipping */
@media (min-width: 1025px) and (max-width: 1400px) {
  .content {
    padding: 24px 20px 48px;
  }
  .card {
    padding: 18px 16px;
  }
}

/* Universal Sticky Actions in Responsive Tables */
@media (min-width: 641px) {
  .table-responsive .th-actions,
  .table-responsive .td-actions {
    position: sticky;
    right: 0;
    z-index: 3;
    text-align: right;
    box-shadow: -4px 0 10px -3px rgba(15, 23, 42, 0.08);
  }

  .table-responsive thead .th-actions {
    z-index: 4;
  }
}

/* Tablet Landscape & iPads (<= 1024px) */
@media (max-width: 1024px) {
  .app-shell {
    display: block;
    width: 100%;
  }

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

  .msg-shell {
    grid-template-columns: 290px 1fr;
    height: calc(100vh - 160px);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    transition: left .28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000 !important;
    box-shadow: none;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 23, 57, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999 !important;
    touch-action: none !important;
    overscroll-behavior: none !important;
  }

  .sidebar-overlay.active {
    display: block !important;
    touch-action: none !important;
  }

  /* Prevent main page scrolling when sidebar is open on mobile */
  html.sidebar-lock,
  body.sidebar-lock,
  body.sidebar-open {
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none !important;
    overscroll-behavior: none !important;
  }

  body.sidebar-lock main.main,
  body.sidebar-open main.main {
    pointer-events: none !important;
    touch-action: none !important;
    user-select: none !important;
  }

  .mobile-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--color-surface, #F8FAFC);
    border: 1.5px solid var(--color-border, #E2E8F0);
    color: var(--color-navy, #0B1739);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.15s ease;
  }

  .mobile-nav-toggle:hover {
    background: var(--color-surface-blue, #E8EFFF);
    border-color: var(--color-primary, #1A4FE8);
    color: var(--color-primary, #1A4FE8);
  }

  .sidebar .sidebar-close-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 1.5rem;
    line-height: 1;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    cursor: pointer;
    padding: 0;
  }

  .two-col,
  .grid-2col,
  .settings-grid,
  .hero-grid,
  .footer-grid,
  .demo-grid,
  .two-col[style],
  .grid-2col[style],
  .settings-grid[style],
  .hero-grid[style],
  .footer-grid[style],
  .demo-grid[style] {
    grid-template-columns: 1fr !important;
    gap: 22px !important;
  }

  .stat-grid,
  .stat-grid[style],
  div.stat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }

  .tile-row,
  .tile-row[style] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }

  .week-grid {
    grid-template-columns: repeat(7, minmax(110px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  .topbar {
    padding: 15px 22px;
  }

  .content {
    padding: 22px 20px 48px;
  }
}

/* Tablet Portrait & Large Phones (<= 820px) */
@media (max-width: 820px) {
  .public-nav {
    display: none !important;
  }

  .public-header-inner {
    padding: 14px 18px !important;
  }

  .form-grid-2,
  .form-grid-3,
  .grid-3col,
  .form-grid-2[style],
  .form-grid-3[style],
  .grid-3col[style] {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .panel-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .panel-head form {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .panel-head .search-box,
  .search-box {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .search-box input {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .panel-head select {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .panel-head .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Messaging full mobile toggle */
  .msg-shell {
    grid-template-columns: 1fr !important;
    height: calc(100dvh - 135px) !important;
    min-height: 480px !important;
    margin: -10px -10px 0 !important;
    border-radius: 12px !important;
  }

  .msg-shell.has-active .msg-list {
    display: none !important;
  }

  .msg-shell.has-active .chat-pane {
    display: flex !important;
    width: 100% !important;
  }

  .msg-shell:not(.has-active) .msg-list {
    display: flex !important;
    width: 100% !important;
    border-right: none !important;
  }

  .msg-shell:not(.has-active) .chat-pane {
    display: none !important;
  }

  .chat-back-mobile {
    display: inline-flex !important;
  }

  .bubble {
    max-width: 86% !important;
  }

  .modal-dialog,
  div.modal-dialog {
    width: calc(100% - 24px) !important;
    max-width: 100% !important;
    margin: 12px auto !important;
    padding: 22px 18px !important;
    max-height: calc(100vh - 40px) !important;
    overflow-y: auto !important;
    border-radius: 18px !important;
  }
}

/* Mobile Screens (<= 640px) */
@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 1.18rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar .sub {
    display: none !important;
  }

  .topbar-right {
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .lang-switch-top a,
  .lang-switch-top button {
    padding: 4px 8px;
    font-size: 11px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }

  .content {
    padding: 16px 14px 40px;
  }

  .card {
    padding: 18px 16px;
    border-radius: 12px;
  }

  .stat-card {
    padding: 16px;
    border-radius: 12px;
  }

  .stat-card .num {
    font-size: 1.55rem;
  }

  .stat-grid,
  .stat-grid[style],
  div.stat-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .tile-row,
  .tile-row[style] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .tile {
    padding: 16px;
  }

  .tile .num {
    font-size: 1.5rem;
  }

  .slot-repeater-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  .slot-repeater-row button {
    grid-column: span 2;
    justify-self: end;
  }

  .btn {
    padding: 10px 18px;
    font-size: 0.88rem;
  }

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

  /* Prevent iOS Safari auto-zoom on input focus */
  .field input,
  .field select,
  .field textarea,
  input,
  select,
  textarea {
    font-size: 16px !important;
    padding: 11px 12px;
  }

  table {
    font-size: 0.82rem;
  }

  thead th {
    padding: 10px 10px;
    font-size: 11px;
  }

  tbody td {
    padding: 11px 10px;
    font-size: 0.82rem;
  }

  .bar-chart {
    height: 130px;
    gap: 6px;
    overflow-x: auto;
  }

  .bar-chart .bar-wrapper {
    height: 90px;
  }

  .bar-chart .lbl {
    font-size: 10px;
  }

  .week-grid {
    grid-template-columns: repeat(7, minmax(100px, 1fr));
  }

  .slot {
    padding: 6px 7px;
    font-size: 0.72rem;
  }

  .hero {
    padding: 44px 0 28px !important;
  }

  .hero h1 {
    font-size: clamp(1.85rem, 6.8vw, 2.5rem) !important;
  }

  .badge {
    font-size: 11px;
    padding: 3px 9px;
  }

  .net-card {
    padding: 20px 16px !important;
    border-radius: 16px !important;
  }

  .net-card h2 {
    font-size: 1.65rem !important;
  }

  .net-card .formula {
    font-size: 0.78rem !important;
    white-space: normal !important;
    word-break: break-all !important;
  }
}

/* Compact Smartphones & 390px iPhone Standard (<= 480px) */
@media (max-width: 480px) {
  .topbar {
    padding: 10px 12px;
  }

  .topbar h1 {
    font-size: 1.12rem;
  }

  .content {
    padding: 14px 10px 32px;
  }

  .card {
    padding: 15px 12px;
  }

  .brand {
    font-size: 1.15rem;
    gap: 8px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .auth-form-side {
    padding: 24px 16px !important;
  }

  .demo-creds {
    padding: 12px !important;
  }

  .bubble {
    max-width: 88%;
    font-size: 0.84rem;
    padding: 10px 14px;
  }

  .chat-input {
    padding: 10px 12px;
  }

  .chat-input input {
    font-size: 16px !important;
    padding: 9px 14px;
  }
}

/* ==============================================================
   FLUID ENTRANCE ANIMATIONS & MICRO-INTERACTIONS
   Transforms the UI from static/abrupt into a smooth, premium experience
   ============================================================== */

@keyframes fdFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fdSlideUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fdSlideDown {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fdScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fdPulseGlow {

  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(26, 79, 232, 0.4);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 6px rgba(26, 79, 232, 0);
  }
}

/* Smooth page and topbar entrances */
.topbar {
  animation: fdSlideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.content {
  animation: fdFadeIn 0.35s ease-out both;
}

/* Entrance animation on cards and containers */
.card,
.stat-card,
.hero,
.section-panel {
  animation: fdSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.24s ease, border-color 0.2s ease;
}

/* Subtle interactive hover lift on cards */
.card:hover,
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px -14px rgba(11, 23, 57, 0.12);
  border-color: #cdd8e4;
}

/* Staggered entrance delays for organic cascade */
.stat-grid> :nth-child(1),
.tile-row> :nth-child(1) {
  animation-delay: 0.04s;
}

.stat-grid> :nth-child(2),
.tile-row> :nth-child(2) {
  animation-delay: 0.09s;
}

.stat-grid> :nth-child(3),
.tile-row> :nth-child(3) {
  animation-delay: 0.14s;
}

.stat-grid> :nth-child(4),
.tile-row> :nth-child(4) {
  animation-delay: 0.19s;
}

.stat-grid> :nth-child(5) {
  animation-delay: 0.24s;
}

.content> :nth-child(1) {
  animation-delay: 0.02s;
}

.content> :nth-child(2) {
  animation-delay: 0.08s;
}

.content> :nth-child(3) {
  animation-delay: 0.14s;
}

.content> :nth-child(4) {
  animation-delay: 0.20s;
}

/* Enhanced micro-interactions for buttons */
.btn {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.24s ease;
}

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

.btn-primary:hover {
  box-shadow: 0 8px 22px -6px rgba(26, 79, 232, 0.35);
}

.btn-teal:hover {
  box-shadow: 0 8px 22px -6px rgba(26, 79, 232, 0.35);
}

/* Sidebar navigation item sliding micro-transition */
.side-nav a {
  transition: background 0.18s ease, color 0.18s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.side-nav a:hover {
  transform: translateX(4px);
}

/* Modals & Overlays */
.modal {
  animation: fdScaleIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-overlay {
  animation: fdFadeIn 0.2s ease-out both;
}

/* Table row interactive feedback */
tbody tr {
  transition: background 0.15s ease, transform 0.15s ease;
}

tbody tr:hover {
  background: var(--paper-alt);
}

/* Badges micro-hover */
.badge {
  transition: transform 0.15s ease, background 0.2s ease;
}

.badge:hover {
  transform: translateY(-1px);
}

/* Live indicators and progress bars */
.pbar>span {
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.live-dot,
.conv .unread {
  animation: fdPulseGlow 2.2s infinite ease-in-out;
}

/* Scroll Reveal Helper Classes */
.reveal-in {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1), transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal-in.revealed {
  opacity: 1;
  transform: translateY(0);
}

.reveal-stagger>* {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1), transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-stagger.revealed>* {
  opacity: 1;
  transform: translateY(0);
}

.reveal-stagger.revealed> :nth-child(1) {
  transition-delay: 0.05s;
}

.reveal-stagger.revealed> :nth-child(2) {
  transition-delay: 0.12s;
}

.reveal-stagger.revealed> :nth-child(3) {
  transition-delay: 0.19s;
}

.reveal-stagger.revealed> :nth-child(4) {
  transition-delay: 0.26s;
}

.reveal-stagger.revealed> :nth-child(5) {
  transition-delay: 0.33s;
}

.reveal-stagger.revealed> :nth-child(6) {
  transition-delay: 0.40s;
}

/* ==================== GLOBAL MODALS ==================== */
html.fre-modal-open,
html.fre-modal-open body {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 23, 57, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: fdModalFadeIn 0.2s ease;
}

/* Portaled modals (Alpine x-teleport="body") — always full viewport */
.modal-backdrop--portal {
  z-index: 10050;
  align-items: flex-start;
  padding: max(20px, env(safe-area-inset-top)) 20px 24px;
}

.modal-dialog--teacher-report {
  max-width: 640px;
  width: min(640px, calc(100vw - 32px));
  margin: auto;
  flex-shrink: 0;
}

.modal-dialog--teacher-report .modal-dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-background);
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

/* Teacher schedule editor — aligned day / time / duration controls */
.teacher-schedule-slot-row,
.teacher-schedule-manual-row {
  display: grid;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.teacher-schedule-slot-row {
  grid-template-columns: minmax(0, 1.35fr) minmax(88px, 1fr) minmax(64px, 72px) 36px;
}

.teacher-schedule-manual-row {
  grid-template-columns: minmax(0, 1fr) minmax(88px, 1fr) 36px;
}

.teacher-schedule-manual-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.teacher-schedule-manual-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-navy, #0f172a);
  line-height: 1.2;
}

.teacher-schedule-slot-control {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  color: #0f172a;
  background-color: #fff;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.teacher-schedule-slot-control:hover {
  border-color: #94a3b8;
}

.teacher-schedule-slot-control:focus {
  border-color: #1a4fe8;
  outline: none;
  box-shadow: 0 0 0 3.5px rgba(26, 79, 232, 0.14);
}

select.teacher-schedule-slot-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}

.teacher-schedule-slot-duration {
  text-align: center;
  padding-left: 10px;
  padding-right: 10px;
}

.teacher-schedule-slot-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--color-danger, #e11d48);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.teacher-schedule-slot-remove:hover {
  background: rgba(225, 29, 72, 0.08);
}

@media (max-width: 520px) {
  .teacher-schedule-slot-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "day day"
      "time duration"
      "remove remove";
  }

  .teacher-schedule-slot-row select.teacher-schedule-slot-control {
    grid-area: day;
  }

  .teacher-schedule-slot-row input.time-24h {
    grid-area: time;
  }

  .teacher-schedule-slot-row .teacher-schedule-slot-duration {
    grid-area: duration;
  }

  .teacher-schedule-slot-row .teacher-schedule-slot-remove {
    grid-area: remove;
    justify-self: end;
  }

  .teacher-schedule-manual-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "date date"
      "time remove";
  }

  .teacher-schedule-manual-row .teacher-schedule-manual-field:first-child {
    grid-area: date;
  }

  .teacher-schedule-manual-row .teacher-schedule-manual-field:nth-child(2) {
    grid-area: time;
  }

  .teacher-schedule-manual-row .teacher-schedule-slot-remove {
    grid-area: remove;
    align-self: end;
  }
}

@keyframes fdModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background: var(--color-background);
  border-radius: 18px;
  max-width: 580px;
  width: 100%;
  padding: 30px;
  box-shadow: 0 25px 50px -12px rgba(11, 23, 57, 0.35);
  border: 1px solid var(--color-border);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: fdModalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ==================== PROGRESS BARS ==================== */
.pbar {
  width: 100%;
  height: 8px;
  background: var(--color-surface-blue);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.pbar > span,
.pbar > .pbar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, #38BDF8 100%);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ==================== AVATARS & ICONS ==================== */
.side-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-surface-blue);
  color: var(--color-primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--color-border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-text);
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--color-surface-blue);
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

/* ==================== HEADER & NAVIGATION ==================== */
.lang-switch-top {
  display: inline-flex;
  align-items: center;
  background: #F1F5F9;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid #E2E8F0;
  gap: 2px;
}

.lang-switch-top a {
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 7px;
  color: #64748B;
  transition: all 0.15s ease;
  line-height: 1;
}

.lang-switch-top a:hover {
  color: var(--color-text);
}

.lang-switch-top a.active {
  background: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(26, 79, 232, 0.3);
}

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-navy);
  line-height: 1;
}

@media (max-width: 860px) {
  .public-nav {
    display: none !important;
  }
  .mobile-nav-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
}

/* ==================== RESPONSIVE GRIDS ==================== */
.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 56px;
  align-items: center;
}

@media (max-width: 991px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

.reg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.demo-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}

@media (max-width: 900px) {
  .demo-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
}

@media (max-width: 800px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ==================== REALTIME CHAT NOTIFICATIONS & ANIMATIONS ==================== */
.fre-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 32px);
  pointer-events: none;
}

.fre-toast {
  pointer-events: auto;
  background: #FFFFFF;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  box-shadow: 0 12px 35px -4px rgba(15, 23, 42, 0.16), 0 4px 10px -2px rgba(15, 23, 42, 0.06);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: all 0.2s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.fre-toast:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px -4px rgba(15, 23, 42, 0.22);
  border-color: var(--color-primary, #1A4FE8);
}

.fre-toast-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.fre-toast-content {
  flex: 1;
  min-width: 0;
}

.fre-toast-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #0F172A;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.fre-toast-time {
  font-size: 0.7rem;
  color: #94A3B8;
  font-weight: 500;
}

.fre-toast-body {
  font-size: 0.82rem;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.fre-toast-close {
  background: none;
  border: none;
  color: #94A3B8;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s;
}

.fre-toast-close:hover {
  color: #0F172A;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes badgePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(26, 79, 232, 0.7);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 0 8px rgba(26, 79, 232, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(26, 79, 232, 0);
  }
}

.badge-pulse {
  animation: badgePulse 1.2s infinite ease-in-out;
}

/* Chat message entrance animation */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-item-animated {
  animation: messageSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Typing animation indicator */
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  width: fit-content;
  margin-top: 4px;
  animation: messageSlideIn 0.2s ease-out;
}

.typing-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary, #1A4FE8);
  opacity: 0.6;
  animation: typingWave 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingWave {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.typing-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 4px;
  animation: messageSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.typing-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #64748B;
  font-family: var(--font-primary, sans-serif);
}

/* ==========================================================================
   IN-APP REAL-TIME NOTIFICATION PANEL STYLES
   ========================================================================== */

.fre-notif-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.fre-notif-backdrop {
  display: none;
}

.fre-notif-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-surface, #FFFFFF);
  border: 1.5px solid var(--border, #E2E8F0);
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  outline: none;
}

.fre-notif-btn:hover,
.fre-notif-btn.active {
  background: #F8FAFC;
  border-color: #CBD5E1;
  color: var(--color-primary, #1A4FE8);
  box-shadow: 0 2px 8px rgba(26, 79, 232, 0.12);
  transform: translateY(-1px);
}

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

.fre-notif-icon {
  width: 19px;
  height: 19px;
  transition: transform 0.2s ease;
}

.fre-notif-btn:hover .fre-notif-icon {
  transform: rotate(12deg);
}

.fre-notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #EF4444;
  color: #FFFFFF;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
  line-height: 1;
}

@keyframes frePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.12); box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.fre-pulse-badge {
  animation: frePulse 1.6s infinite;
}

/* Dropdown Card */
.fre-notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 415px;
  max-width: calc(100vw - 20px);
  background: #FFFFFF;
  border-radius: 16px;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(15, 23, 42, 0.08);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: notifDropIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.fre-notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #F1F5F9;
  background: #FFFFFF;
  gap: 8px;
}

.fre-notif-header-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.fre-notif-header-title .title-text {
  font-size: 15px;
  font-weight: 800;
  color: #0F172A;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.fre-notif-header-title .count-pill {
  background: #EEF2FF;
  color: #1A4FE8;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid #E0E7FF;
}

.fre-notif-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Sound Icon-only Square Button */
.fre-notif-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.fre-notif-icon-btn:hover {
  background: #EEF2FF;
  color: #1A4FE8;
  border-color: #C7D2FE;
}

.fre-notif-icon-btn.muted {
  color: #94A3B8;
  background: #F8FAFC;
  border-color: #E2E8F0;
}

/* Modern Pill Action Buttons */
.fre-notif-action-btn {
  height: 30px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap !important;
  flex-shrink: 0;
  transition: all 0.15s ease;
  line-height: 1;
}

.fre-notif-action-btn.primary {
  background: #EEF2FF;
  color: #1A4FE8;
  border: 1px solid #C7D2FE;
}

.fre-notif-action-btn.primary:hover {
  background: #1A4FE8;
  color: #FFFFFF;
  border-color: #1A4FE8;
  box-shadow: 0 2px 8px rgba(26, 79, 232, 0.25);
}

.fre-notif-action-btn.danger {
  color: #E11D48;
  background: #FFF1F2;
  border: 1px solid #FECDD3;
}

.fre-notif-action-btn.danger:hover {
  background: #E11D48;
  color: #FFFFFF;
  border-color: #E11D48;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.25);
}

.fre-notif-tool-btn {
  height: 30px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap !important;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.fre-notif-tool-btn:hover {
  background: #EEF2FF;
  color: #1A4FE8;
  border-color: #C7D2FE;
}

.fre-notif-tool-btn.muted {
  color: #94A3B8;
  background: #F1F5F9;
}

.fre-notif-tool-btn.danger {
  color: #E11D48;
  background: #FFF1F2;
  border-color: #FECDD3;
}

.fre-notif-tool-btn.danger:hover {
  background: #E11D48;
  color: #FFFFFF;
  border-color: #E11D48;
}

.fre-notif-tabs {
  display: flex;
  padding: 6px 14px;
  background: #F8FAFC;
  border-bottom: 1px solid #F1F5F9;
  gap: 6px;
}

.fre-notif-tabs button {
  font-size: 12px;
  font-weight: 600;
  color: #64748B;
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fre-notif-tabs button.active {
  background: #FFFFFF;
  color: #1A4FE8;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fre-notif-list {
  max-height: 380px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.fre-notif-empty {
  padding: 40px 20px;
  text-align: center;
}

.fre-notif-empty .empty-icon {
  font-size: 34px;
  margin-bottom: 10px;
  opacity: 0.7;
}

.fre-notif-empty .empty-title {
  font-size: 14px;
  font-weight: 700;
  color: #1E293B;
  margin-bottom: 4px;
}

.fre-notif-empty .empty-desc {
  font-size: 12px;
  color: #94A3B8;
  max-width: 250px;
  margin: 0 auto;
}

.fre-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  background: #FFFFFF;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.fre-notif-item:hover {
  background: #F8FAFC;
}

.fre-notif-item.unread {
  background: #F0F6FF;
  border-left: 3.5px solid #1A4FE8;
}

.fre-notif-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.fre-notif-item-body {
  flex: 1;
  min-width: 0;
}

.fre-notif-item-body .item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.fre-notif-item-body .item-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fre-notif-item-body .item-time {
  font-size: 11px;
  color: #94A3B8;
  font-weight: 500;
}

.fre-notif-item-body .item-title {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
  margin-bottom: 2px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fre-notif-item.unread .item-title {
  color: #1A4FE8;
}

.fre-notif-item-body .item-message {
  font-size: 12px;
  color: #475569;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fre-notif-item-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-self: center;
  opacity: 0.85;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.fre-notif-item:hover .fre-notif-item-actions {
  opacity: 1;
}

.fre-notif-item-actions .btn-action {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #64748B;
  transition: all 0.15s ease;
  padding: 0;
}

.fre-notif-item-actions .btn-action.mark-read:hover {
  background: #EEF2FF;
  border-color: #BFDBFE;
  color: #1A4FE8;
}

.fre-notif-item-actions .btn-action.delete-notif:hover {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #DC2626;
}

.fre-notif-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #F8FAFC;
  border-top: 1px solid #F1F5F9;
  font-size: 11px;
}

.fre-notif-footer .live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #64748B;
  font-weight: 600;
}

.fre-notif-footer .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.fre-notif-footer .footer-link {
  color: #1A4FE8;
  font-weight: 700;
  text-decoration: none;
  font-size: 11px;
}

.fre-notif-footer .footer-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Mobile Responsive Adjustments for Topbar & Notification Center
   ========================================================================== */
@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }

  .topbar-left {
    gap: 8px !important;
    min-width: 0;
    flex: 1;
  }

  .topbar-left h1 {
    font-size: 1.08rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-right {
    gap: 6px !important;
    flex-shrink: 0;
  }

  .fre-notif-btn {
    width: 36px;
    height: 36px;
  }

  .fre-notif-icon {
    width: 18px;
    height: 18px;
  }

  .fre-notif-badge {
    top: -3px;
    right: -3px;
    min-width: 17px;
    height: 17px;
    line-height: 17px;
    font-size: 10px;
    padding: 0 4px;
  }

  .lang-switch-top {
    padding: 2px;
    gap: 1px;
  }

  .lang-switch-top a,
  .lang-switch-top button {
    padding: 4px 6px;
    font-size: 10.5px;
  }

  /* Mobile backdrop for notification modal */
  .fre-notif-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 2400;
  }

  /* Notification dropdown on mobile: bound within viewport, zero horizontal overflow */
  .fre-notif-dropdown {
    position: fixed !important;
    top: 58px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100vh - 72px) !important;
    max-height: calc(100dvh - 72px) !important;
    border-radius: 16px !important;
    z-index: 2500 !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.12) !important;
    animation: none !important;
  }

  .fre-notif-header {
    padding: 10px 12px;
    gap: 6px;
  }

  .fre-notif-header-title {
    gap: 6px;
    min-width: 0;
  }

  .fre-notif-header-title .title-text {
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
  }

  .fre-notif-header-title .count-pill {
    font-size: 10.5px;
    padding: 2px 6px;
    white-space: nowrap;
  }

  .fre-notif-header-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .fre-notif-action-btn {
    height: 28px;
    padding: 0 7px;
    font-size: 10.5px;
    gap: 3px;
  }

  .fre-notif-icon-btn {
    width: 28px;
    height: 28px;
  }

  .fre-notif-tool-btn {
    padding: 4px 7px;
    font-size: 11px;
    gap: 3px;
  }

  .fre-notif-tabs {
    padding: 6px 10px;
    gap: 4px;
  }

  .fre-notif-tabs button {
    font-size: 11.5px;
    padding: 4px 8px;
  }

  .fre-notif-list {
    max-height: calc(100vh - 210px);
    max-height: calc(100dvh - 210px);
    -webkit-overflow-scrolling: touch;
  }

  .fre-notif-item {
    padding: 10px 12px;
    gap: 10px;
  }

  .fre-notif-item-icon {
    width: 34px;
    height: 34px;
    font-size: 16px;
    border-radius: 8px;
  }

  .fre-notif-item-body .item-title {
    font-size: 12.5px;
  }

  .fre-notif-item-body .item-message {
    font-size: 11.5px;
    line-height: 1.4;
  }

  .fre-notif-footer {
    padding: 8px 12px;
    font-size: 10.5px;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 8px 10px;
    gap: 6px;
  }

  .topbar-left {
    gap: 6px !important;
  }

  .topbar-left h1 {
    font-size: 1.02rem;
  }

  .mobile-nav-toggle {
    width: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
  }

  .fre-notif-btn {
    width: 34px;
    height: 34px;
  }

  .fre-notif-icon {
    width: 17px;
    height: 17px;
  }

  .lang-switch-top a,
  .lang-switch-top button {
    padding: 3px 5px;
    font-size: 10px;
  }

  .fre-notif-dropdown {
    top: 54px !important;
    left: 8px !important;
    right: 8px !important;
    max-height: calc(100vh - 64px) !important;
    max-height: calc(100dvh - 64px) !important;
  }

  .fre-notif-list {
    max-height: calc(100vh - 195px);
    max-height: calc(100dvh - 195px);
  }
}

/* Admin: teacher weekly schedule color picker */
.schedule-palette-field .schedule-palette-preview {
  margin-bottom: 14px;
}

.schedule-palette-field .schedule-palette-preview-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 0 2px 8px rgba(11, 23, 57, 0.06);
}

.schedule-palette-field .schedule-palette-preview-chip--auto {
  background: var(--paper-alt);
}

.schedule-palette-field .schedule-palette-preview-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 2px;
}

.schedule-palette-field .schedule-palette-preview-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--navy);
}

.schedule-palette-field .schedule-palette-preview-swatch {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 3px solid var(--line);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.schedule-palette-field .schedule-palette-preview-swatch--auto {
  background: linear-gradient(135deg, #e2e8f0 25%, #f8fafc 25%, #f8fafc 50%, #e2e8f0 50%, #e2e8f0 75%, #f8fafc 75%);
  background-size: 12px 12px;
  border-color: #94a3b8;
}

.schedule-palette-field .schedule-palette-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.schedule-palette-field .schedule-palette-auto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.schedule-palette-field .schedule-palette-auto input {
  width: auto;
  margin: 0;
}

.schedule-palette-field .schedule-palette-auto.is-selected,
.schedule-palette-field .schedule-palette-auto:has(input[type="radio"]:checked) {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26, 79, 232, 0.25);
  background: #f0f4ff;
}

.schedule-palette-field .schedule-palette-swatch-btn {
  position: relative;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.schedule-palette-field .schedule-palette-swatch-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.schedule-palette-field .schedule-palette-swatch {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 3px solid;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.schedule-palette-field .schedule-palette-swatch-num {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--ink-soft);
  font-family: 'Montserrat', sans-serif;
}

.schedule-palette-field .schedule-palette-swatch-btn.is-selected,
.schedule-palette-field .schedule-palette-swatch-btn:has(input[type="radio"]:checked) {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26, 79, 232, 0.35);
  transform: scale(1.08);
  z-index: 1;
}

.schedule-palette-field .schedule-palette-swatch-btn.is-selected .schedule-palette-swatch-num,
.schedule-palette-field .schedule-palette-swatch-btn:has(input[type="radio"]:checked) .schedule-palette-swatch-num {
  color: var(--navy);
  font-size: 0.78rem;
}

.schedule-palette-field .schedule-palette-swatch-btn:has(input[type="radio"]:checked) .schedule-palette-swatch {
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.06),
    0 0 0 2px #fff,
    0 0 0 4px var(--navy);
}

.schedule-palette-field .schedule-palette-swatch-btn.is-selected::after,
.schedule-palette-field .schedule-palette-swatch-btn:has(input[type="radio"]:checked)::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(11, 23, 57, 0.25);
}

/* Student / teacher lesson reports list — mobile-friendly */
.student-lesson-reports__student-head-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.student-lesson-reports__filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.student-lesson-reports-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lesson-report-card {
  padding: 24px;
}

.lesson-report-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.lesson-report-card__title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.lesson-report-card__title {
  font-size: 1.15rem;
  margin: 0;
  line-height: 1.3;
  word-break: break-word;
}

.lesson-report-card__meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 6px;
  line-height: 1.45;
  word-break: break-word;
}

.lesson-report-card__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  max-width: 100%;
}

.lesson-report-card__datetime {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.lesson-report-card__action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.lesson-report-card__action-form {
  margin: 0;
  width: 100%;
}

.lesson-report-card__revert-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--teal, #0d9488);
  background: #fff;
  color: var(--teal, #0d9488);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 10px;
  cursor: pointer;
}

.lesson-report-card__revert-btn:hover:not(:disabled) {
  background: var(--teal-soft, #ecfdf5);
}

.lesson-report-card__remove-form {
  margin: 0;
  width: 100%;
}

.lesson-report-card__remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(220, 38, 38, 0.35);
  background: #fff;
  color: var(--red, #dc2626);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lesson-report-card__remove-btn:hover:not(:disabled) {
  background: var(--red-soft, #fef2f2);
  border-color: var(--red, #dc2626);
}

.lesson-report-card__remove-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.lesson-report-card__remove-icon {
  font-size: 1rem;
  line-height: 1;
}

.lesson-report-card__body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: var(--paper-alt);
  border-radius: 12px;
  padding: 18px;
}

.lesson-report-card__text {
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
}

@media (max-width: 768px) {
  .student-lesson-reports__student-head-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .student-lesson-reports__back {
    width: 100%;
    justify-content: center;
  }

  .student-lesson-reports__filter-form .field {
    min-width: 0 !important;
    flex: 1 1 100%;
  }

  .student-lesson-reports__filter-form .btn {
    flex: 1 1 auto;
  }

  .lesson-report-card {
    padding: 16px;
  }

  .lesson-report-card__head {
    flex-direction: column;
    align-items: stretch;
  }

  .lesson-report-card__actions {
    align-items: stretch;
    width: 100%;
  }

  .lesson-report-card__datetime {
    white-space: normal;
  }

  .lesson-report-card__action-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .lesson-report-card__action-form {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
  }

  .lesson-report-card__revert-btn,
  .lesson-report-card__remove-btn {
    width: 100%;
  }

  .lesson-report-card__body {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 14px;
  }
}

/* ==========================================================================
   COMPREHENSIVE MOBILE & TABLET RESPONSIVE SYSTEM (FREDIL 2.0)
   Full-screen fluid adaptation across iPhones, iPads, Androids & Tablets
   ========================================================================== */

/* --- Base Global Safety for Touch & Small Screens --- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Touch targets: momentum scrolling everywhere */
.table-responsive,
.chart-container-outer,
.week-grid,
.ws-calendar-scroll-box,
.modal-dialog,
.sidebar,
.fre-notif-list {
  -webkit-overflow-scrolling: touch;
}

/* --- TABLET ADAPTATIONS (max-width: 1024px) --- */
@media (max-width: 1024px) {
  .app-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }

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

  /* Topbar touch sizing */
  .topbar {
    padding: 12px 20px !important;
    min-height: 58px !important;
  }

  .mobile-nav-toggle {
    display: inline-flex !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    border-radius: 10px !important;
  }

  /* Off-canvas sidebar */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -320px !important;
    width: 290px !important;
    max-width: 86vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 2000 !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), left 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow-y: auto !important;
  }

  .sidebar.open {
    left: 0 !important;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.55) !important;
  }

  .sidebar-overlay {
    z-index: 1999 !important;
  }

  /* Content padding for tablets */
  .content {
    padding: 20px 20px 48px !important;
  }

  /* Stat Grids on tablets: 2 columns */
  .stat-grid,
  .stat-grid[style],
  div.stat-grid,
  .tile-row,
  .tile-row[style] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  /* 2-column content grids */
  .two-col,
  .two-col[style],
  .grid-2col,
  .grid-2col[style],
  .settings-grid,
  .settings-grid[style] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Course catalog and card grids */
  div[style*="grid-template-columns:repeat(auto-fill"] {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)) !important;
    gap: 20px !important;
  }

  /* Messaging layout on tablet */
  .msg-shell {
    grid-template-columns: 280px 1fr !important;
    height: calc(100dvh - 160px) !important;
  }
}

/* --- TABLET PORTRAIT & COMPACT DEVICES (max-width: 820px) --- */
@media (max-width: 820px) {
  .form-grid-2,
  .form-grid-3,
  .grid-3col,
  .form-grid-2[style],
  .form-grid-3[style],
  .grid-3col[style] {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  /* Panel heads stack nicely */
  .panel-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .panel-head form {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .panel-head .search-box,
  .search-box,
  .panel-head select,
  .search-box-wrap {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .search-box input,
  .search-box-wrap input,
  #paymentsStudentSearch,
  #billingStudentSearch {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .panel-head > .btn,
  .panel-head > a.btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* Modal Dialogues: take full comfortable width */
  .modal-dialog,
  div.modal-dialog {
    width: calc(100% - 24px) !important;
    max-width: 600px !important;
    margin: 12px auto !important;
    padding: 22px 18px !important;
    max-height: calc(100dvh - 36px) !important;
    border-radius: 18px !important;
    box-sizing: border-box !important;
  }

  /* Student lesson balance tiles */
  .stat-grid[style*="repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* --- MOBILE PHONES (max-width: 640px) --- */
@media (max-width: 640px) {
  /* Container paddings */
  .topbar {
    padding: 10px 14px !important;
    min-height: 54px !important;
    gap: 8px !important;
  }

  .topbar h1 {
    font-size: 1.12rem !important;
    max-width: calc(100vw - 120px) !important;
  }

  .content {
    padding: 14px 12px 36px !important;
  }

  .card {
    padding: 16px 14px !important;
    border-radius: 12px !important;
  }

  /* Stat cards */
  .stat-grid,
  .stat-grid[style],
  div.stat-grid,
  .tile-row,
  .tile-row[style] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .stat-card {
    padding: 14px 16px !important;
    min-height: auto !important;
  }

  .stat-card .num,
  .tile .num {
    font-size: 1.45rem !important;
  }

  .stat-card .lbl,
  .tile .lbl {
    font-size: 0.78rem !important;
  }

  /* Automatically stack any inline grids that were not captured by class */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1.2fr 0.8fr"],
  [style*="grid-template-columns:1.2fr 0.8fr"],
  [style*="grid-template-columns: 1.15fr 0.85fr"],
  [style*="grid-template-columns:1.15fr 0.85fr"],
  [style*="grid-template-columns:repeat(3, 1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Form actions bars (Payments top bar, Billing top bar, etc.) */
  div[style*="justify-content:space-between"][style*="flex-wrap:wrap"],
  div[style*="justify-content: space-between"][style*="flex-wrap: wrap"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  div[style*="justify-content:space-between"][style*="flex-wrap:wrap"] > div[style*="display:flex"],
  div[style*="justify-content: space-between"][style*="flex-wrap: wrap"] > div[style*="display: flex"] {
    width: 100% !important;
  }

  div[style*="justify-content:space-between"][style*="flex-wrap:wrap"] form,
  div[style*="justify-content: space-between"][style*="flex-wrap: wrap"] form {
    width: 100% !important;
  }

  div[style*="justify-content:space-between"][style*="flex-wrap:wrap"] .btn,
  div[style*="justify-content: space-between"][style*="flex-wrap: wrap"] .btn {
    flex: 1 1 auto !important;
    justify-content: center !important;
    text-align: center !important;
  }

  /* Prevent table inputs from blowing up */
  td input,
  td select {
    padding: 5px 8px !important;
    font-size: 13px !important;
    height: auto !important;
    box-sizing: border-box !important;
  }

  /* Form field inputs (outside tables) get 16px to prevent iOS auto-zoom */
  .field input:not([type=checkbox]):not([type=radio]),
  .field select,
  .field textarea,
  form:not(td form) input:not([type=checkbox]):not([type=radio]),
  form:not(td form) select,
  form:not(td form) textarea {
    font-size: 16px !important;
    padding: 10px 12px !important;
    min-height: 42px !important;
    box-sizing: border-box !important;
  }

  /* Keep room for icons inside fields (select chevron, leading/trailing input icons) */
  .field select,
  form:not(td form) select {
    padding-right: 38px !important;
  }

  td select {
    padding-right: 28px !important;
    background-position: right 8px center;
  }

  form .input-control-box input.auth-input.auth-input {
    padding-left: 48px !important;
  }

  form .input-password-wrap input.auth-input.auth-input {
    padding-right: 46px !important;
  }

  form input[style*="padding-right"]:not([type=checkbox]):not([type=radio]),
  input[style*="8px 36px"]:not([type=checkbox]):not([type=radio]) {
    padding-right: 36px !important;
  }

  /* Buttons on mobile */
  .btn {
    min-height: 40px !important;
    padding: 9px 16px !important;
  }

  .btn-sm {
    min-height: 34px !important;
    padding: 6px 12px !important;
  }

  /* Modal action buttons */
  .modal-dialog div[style*="justify-content:flex-end"],
  .modal-dialog div[style*="justify-content: flex-end"] {
    flex-direction: column-reverse !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .modal-dialog div[style*="justify-content:flex-end"] .btn,
  .modal-dialog div[style*="justify-content: flex-end"] .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
  }

  /* Notification dropdown on mobile */
  .fre-notif-dropdown {
    position: fixed !important;
    top: 54px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - 66px) !important;
    border-radius: 16px !important;
    z-index: 2500 !important;
  }

  /* 7-Day Streak on mobile */
  div[style*="justify-content:space-between"][style*="gap:8px"] > div[style*="text-align:center"] {
    min-width: 0 !important;
  }

  div[style*="justify-content:space-between"][style*="gap:8px"] div[style*="width:40px;height:40px"] {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.8rem !important;
    margin-bottom: 4px !important;
  }

  /* Student & Teacher Dashboards: list items stacking */
  div[style*="justify-content:space-between"][style*="border-radius:10px"][style*="background:var(--paper-alt)"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  div[style*="justify-content:space-between"][style*="border-radius:10px"][style*="background:var(--paper-alt)"] > div:last-child {
    justify-content: flex-end !important;
    width: 100% !important;
  }
}

/* --- COMPACT PHONES (max-width: 420px) --- */
@media (max-width: 420px) {
  .topbar {
    padding: 8px 10px !important;
    min-height: 50px !important;
    gap: 6px !important;
  }

  .topbar h1 {
    font-size: 1.02rem !important;
  }

  .content {
    padding: 10px 8px 30px !important;
  }

  .card {
    padding: 14px 10px !important;
  }

  .modal-dialog,
  div.modal-dialog {
    width: calc(100% - 16px) !important;
    padding: 18px 14px !important;
    margin: 8px auto !important;
    border-radius: 14px !important;
  }

  .stat-card .num,
  .tile .num {
    font-size: 1.35rem !important;
  }
}

/* ==================== Teacher → Students breakdown modal (billing / teachers) ==================== */
.modal-dialog.ts-modal {
  overscroll-behavior: contain;
  max-width: 1120px;
  width: min(1120px, calc(100vw - 32px));
  box-sizing: border-box;
}
.table-responsive table.ts-table {
  min-width: 0;
}
.ts-table td.ts-student {
  min-width: 200px;
}
.ts-table td.ts-actions .btn {
  white-space: nowrap;
}
/* Desktop table: stack "Edit" + "Reports" so the actions column stays narrow */
.ts-table td.ts-actions .ts-actions-group {
  flex-direction: column;
  align-items: stretch;
}
.ts-table td.ts-actions .ts-actions-group .btn {
  justify-content: center;
}

@media (max-width: 1080px) {
  .modal-dialog.ts-modal,
  div.modal-dialog.ts-modal {
    width: calc(100% - 24px) !important;
    max-width: 100% !important;
  }
  .table-responsive table.ts-table,
  .ts-table tbody {
    display: block;
    min-width: 0 !important;
    width: 100%;
  }
  .ts-table thead {
    display: none;
  }
  .ts-table tbody tr {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px 14px;
    border: 1px solid var(--line, #e2e8f0) !important;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fff;
  }
  .ts-table tbody td {
    display: block;
    padding: 0 !important;
    text-align: left !important;
    white-space: normal !important;
    min-width: 0;
    border-bottom: 0 !important;
  }
  .ts-table tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft, #64748b);
    margin-bottom: 4px;
  }
  .ts-table td.ts-student,
  .ts-table td.ts-actions {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .ts-table td.ts-actions .ts-actions-group {
    display: flex !important;
    flex-direction: row;
    width: 100%;
  }
  .ts-table td.ts-actions .btn {
    width: 100%;
    flex: 1 1 0;
    justify-content: center;
  }
  .ts-table tbody td .badge {
    max-width: 100% !important;
  }
}

/* Salary settings panel: keep the small close (✕) button compact on phones */
.ts-salary-edit .ts-salary-edit-close {
  width: auto !important;
  flex: 0 0 auto !important;
}

/* ==================== STUDENT PANEL MOBILE ==================== */
@media (max-width: 640px) {
  .stu-pkg-card { padding: 20px 16px !important; border-radius: 16px !important; }
  .stu-pkg-head { flex-wrap: wrap; gap: 12px; }
  .stu-pkg-head > div:last-child { text-align: left !important; }
  .stu-next-card, .stu-hw-form, .stu-report-card { padding: 18px 14px !important; }
  .stu-streak { gap: 4px !important; flex-wrap: nowrap; }
  .stu-streak > div > div { width: 32px !important; height: 32px !important; font-size: 0.8rem !important; }
  .stu-enr-row { flex-wrap: wrap; gap: 10px; }
  .stu-enr-row > div { min-width: 0; }
  .stu-week.week-grid { grid-template-columns: 1fr !important; overflow: visible !important; gap: 8px !important; }
  .stu-week .day-col { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .stu-week .day-col .day-lbl { min-width: 44px; text-align: left; margin: 6px 0 0; }
  .stu-week .slot { flex: 1 1 120px; margin-bottom: 0; }
  .legend-row { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 0.78rem; }
  .stu-log-list .log-item { flex-wrap: wrap; gap: 8px 12px !important; }
  .stu-log-list .log-info { min-width: 0; flex: 1 1 60%; }
  .stu-log-list .log-arrow { display: none; }
  .stu-hw-head { flex-wrap: wrap; gap: 6px; }
  .stu-profile-grid strong { word-break: break-word; }
  .stu-report-title h2 { font-size: 1.15rem !important; }
}

/* ==================== TABLET FIT (iPad / Safari landscape) ====================
   Grid children default to min-width:auto, so a wide table (min-width 600px)
   pushes its column past the viewport. Let grid items shrink so tables scroll
   inside their own card, and stack two-column panels on tablet widths. */
.content .two-col > *,
.content .grid-2col > *,
.content .grid-3col > *,
.content .stat-grid > *,
.content [style*="grid-template-columns"] > * {
  min-width: 0;
}

.content .card {
  max-width: 100%;
}

@media (max-width: 1400px) {
  .content .two-col,
  .content .two-col[style] {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (min-width: 901px) and (max-width: 1400px) {
  .content .stat-grid[style*="repeat(4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* ==================== DEMO REQUESTS: delete + level test review ==================== */
.demo-req-actions .demo-del-btn { display: inline-flex; align-items: center; gap: 4px; }
.demo-test-top { margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.demo-test-top .btn { display: inline-flex; align-items: center; gap: 6px; }
.demo-test-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.demo-test-btns .btn { display: inline-flex; align-items: center; gap: 4px; }
.demo-test-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; padding: 20px 22px; }
.demo-test-person { min-width: 0; }
.demo-test-name { font-weight: 800; font-size: 1.15rem; }
.demo-test-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 0.84rem; color: var(--ink-soft); word-break: break-word; }
.demo-test-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.demo-test-stat { min-width: 96px; padding: 10px 14px; border: 1px solid var(--line, var(--color-border)); border-radius: 12px; text-align: center; }
.demo-test-stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.demo-test-stat-value { font-size: 1.25rem; font-weight: 800; margin-top: 2px; }
.demo-test-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.demo-test-list > * { min-width: 0; }
.demo-q { padding: 16px 18px; border-left: 4px solid var(--line, var(--color-border)); margin: 0; }
.demo-q--right { border-left-color: #16A34A; }
.demo-q--wrong { border-left-color: #DC2626; }
.demo-q--skipped { border-left-color: #D97706; }
.demo-q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.demo-q-num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(26, 79, 232, .1); color: var(--color-primary); font-weight: 700; font-size: .82rem; }
.demo-q-result { margin-left: auto; }
.demo-q-text { font-weight: 600; margin-bottom: 10px; line-height: 1.45; }
.demo-q-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.demo-q-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line, var(--color-border)); border-radius: 10px; font-size: .9rem; flex-wrap: wrap; }
.demo-q-letter { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; background: rgba(100, 116, 139, .12); }
.demo-q-opt-text { flex: 1 1 auto; min-width: 0; }
.demo-q-opt.is-correct { border-color: #16A34A; background: rgba(22, 163, 74, .10); }
.demo-q-opt.is-correct .demo-q-letter { background: #16A34A; color: #fff; }
.demo-q-opt.is-wrong { border-color: #DC2626; background: rgba(220, 38, 38, .10); }
.demo-q-opt.is-wrong .demo-q-letter { background: #DC2626; color: #fff; }
.demo-q-tag { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(26, 79, 232, .12); color: var(--color-primary); white-space: nowrap; }
.demo-q-tag--ok { background: rgba(22, 163, 74, .14); color: #15803D; }
html[data-theme="dark"] .demo-q-tag { color: #93B4FF; }
html[data-theme="dark"] .demo-q-tag--ok { color: #4ADE80; }
html[data-theme="dark"] .demo-q-num { color: #93B4FF; }

@media (max-width: 1100px) {
  .demo-test-list { grid-template-columns: minmax(0, 1fr); }
}

/* Desktop table: keep every column (incl. actions) visible without clipping */
@media (min-width: 1321px) {
  .demo-req-table { min-width: 0 !important; width: 100%; }
  .demo-req-table td.demo-req-email { overflow-wrap: anywhere; word-break: normal; max-width: 220px; }
  .demo-req-table td.demo-req-actions { min-width: 150px; }
  .demo-req-table th, .demo-req-table td { padding-left: 10px; padding-right: 10px; white-space: normal; }
  .demo-req-table th { white-space: normal !important; vertical-align: bottom; }
  .demo-req-table td.demo-req-email { min-width: 170px; }
  .demo-req-table td.demo-req-actions > div { display: flex !important; flex-direction: column; align-items: stretch !important; }
  .demo-req-table td.demo-req-actions select { width: 100%; }
  .demo-req-table td.demo-req-actions .demo-del-btn { justify-content: center; }
}

/* Demo requests table becomes stacked cards on phones / tablets / small laptops */
@media (max-width: 1320px) {
  .demo-req-table td.demo-req-email { overflow-wrap: anywhere; word-break: normal; }
  .demo-req-wrap { overflow: visible; }
  .demo-req-table { min-width: 0 !important; width: 100%; }
  .demo-req-table thead { display: none; }
  .demo-req-table, .demo-req-table tbody, .demo-req-table tr, .demo-req-table td { display: block; width: 100%; }
  .demo-req-table tr { border: 1px solid var(--line, var(--color-border)); border-radius: 12px; padding: 6px 12px; margin-bottom: 12px; }
  .demo-req-table td { display: grid !important; grid-template-columns: 38% minmax(0, 1fr); justify-items: end; align-items: start; column-gap: 12px; row-gap: 2px; padding: 8px 0 !important; border: 0 !important; border-bottom: 1px dashed var(--line, var(--color-border)) !important; text-align: right !important; }
  .demo-req-table td:last-child { border-bottom: 0 !important; }
  .demo-req-table td::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 6; justify-self: start; text-align: left; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
  .demo-req-table td > * { grid-column: 2; min-width: 0; max-width: 100%; }
  .demo-req-table td.demo-req-empty { display: block; text-align: center !important; }
  .demo-req-table td.demo-req-empty::before { content: none; }
  .demo-test-summary { padding: 16px; }
  .demo-test-stats { width: 100%; }
  .demo-test-stat { flex: 1 1 0; min-width: 0; }
}
