/* ==========================================================================
   NOVALINGO LMS — DESIGN SYSTEM
   Vibe  : Classic Academic / Oxford Prestige / Modern UX
   Fonts : Cinzel (headings) · Inter (body)
   Palette
     Burgundy  #5B0F1A  — primary brand, authority, tradition
     Gold      #C7A24D  — accent, achievement, warmth
     Stone     #B5B1A6  — muted UI elements
     Parchment #F6F2E6  — page background, editorial warmth
     Ink       #2B2B2D  — primary text
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS (CSS Custom Properties)
   -------------------------------------------------------------------------- */
:root {
  /* Core palette */
  --burgundy:        #5B0F1A;
  --burgundy-soft:   #7A1D2A;
  --burgundy-dim:    rgba(91, 15, 26, 0.08);
  --gold:            #C7A24D;
  --gold-light:      #e8d49e;
  --stone:           #B5B1A6;
  --stone-light:     #E2DDD2;
  --parchment:       #F6F2E6;
  --parchment-warm:  #FFF9EF;
  --ink:             #2B2B2D;
  --ink-muted:       #6E6A63;

  /* Semantic aliases kept for backward compat */
  --bg:              var(--parchment);
  --surface:         var(--parchment-warm);
  --surface-strong:  #FFFDF7;
  --panel-bg:        #FFFFFF;
  --border:          var(--stone-light);
  --muted:           var(--ink-muted);
  --line:            var(--stone-light);
  --brand:           var(--burgundy);
  --brand-soft:      var(--burgundy-soft);

  /* Semantic colours */
  --green:  #1B8A3D;
  --blue:   #2B5C90;
  --red:    #A32020;

  /* Shadows — layered for depth */
  --shadow-xs: 0 1px 3px rgba(43, 35, 24, 0.06);
  --shadow-sm: 0 4px 12px rgba(43, 35, 24, 0.07);
  --shadow:    0 8px 24px rgba(43, 35, 24, 0.09);
  --shadow-lg: 0 16px 40px rgba(43, 35, 24, 0.12);

  /* Typography */
  --font-serif: 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-sans:  'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Motion — intentional, luxury-feel easing */
  --ease-out:   cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in:    cubic-bezier(0.5, 0, 0.75, 0);
  --t-fast:     0.18s var(--ease-out);
  --t-base:     0.30s var(--ease-out);
  --t-slow:     0.50s var(--ease-out);

  /* Layout */
  --sidebar-w: 280px;
  --radius:    10px;
}


/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

/* --------------------------------------------------------------------------
   PRINT STYLES - Credential Panel
   -------------------------------------------------------------------------- */
@media print {
  /* Hide everything except credentials table */
  body * {
    visibility: hidden;
  }
  
  .credential-panel,
  .credential-panel * {
    visibility: visible;
  }
  
  .credential-panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: none !important;
    background: white !important;
    box-shadow: none !important;
  }
  
  /* Hide print button and copy button during print */
  .credential-panel .panel-head button,
  .credential-panel .btn-ghost,
  .credential-panel .um-copy-btn {
    display: none !important;
  }
  
  /* Style the table for printing */
  #credentials-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11pt;
  }
  
  #credentials-table th,
  #credentials-table td {
    border: 1px solid #000;
    padding: 8px;
    text-align: left;
  }
  
  #credentials-table thead {
    background: #7A1020 !important;
    color: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  #credentials-table th {
    font-weight: bold;
    color: white !important;
  }
  
  #credentials-table tbody tr:nth-child(even) {
    background: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  /* Ensure password column is visible and styled */
  #credentials-table td strong {
    font-weight: bold;
    color: #000 !important;
  }
  
  /* Hide the last column (copy button column) */
  #credentials-table th:last-child,
  #credentials-table td:last-child {
    display: none;
  }
  
  /* Page setup */
  @page {
    margin: 2cm;
    size: A4;
  }
  
  .panel-head h2 {
    font-size: 16pt;
    margin-bottom: 12px;
    color: #000 !important;
  }
}


body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* Auth screens get a richer background */
body.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  background: none;
}
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  transition: opacity 1s ease;
}
.auth-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(30,5,10,.72), rgba(30,5,10,.72));
}
#auth-bg-0 {
  background-image: url('https://images.unsplash.com/photo-1504384308090-c894fdcc538d?w=1920&q=80');
  opacity: 1;
}
#auth-bg-1 {
  opacity: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--t-fast);
  cursor: pointer;
}

button, input { font: inherit; }
button, select,
input[type="submit"],
input[type="checkbox"],
input[type="radio"] { cursor: pointer; }

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  pointer-events: none;
  flex-shrink: 0;
}

/* Headings use the serif for that academic gravitas */
h1, h2, h3, .serif { font-family: var(--font-serif); }
h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(28px, 3.5vw, 40px);
  line-height: 1.1;
  color: var(--burgundy);
  letter-spacing: 0.02em;
  margin-bottom: 0;
}
h2 {
  font-size: 20px;
  color: var(--ink);
  letter-spacing: 0.01em;
  margin-bottom: 0;
}
h3 {
  font-size: 16px;
  margin-bottom: 8px;
}


/* --------------------------------------------------------------------------
   3. PAGE ENTRY ANIMATIONS
   Staggered fade-up — gives the UI a "turning a page" feel
   -------------------------------------------------------------------------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes heraldFade {
  0%   { opacity: 0; transform: scale(0.92) translateY(12px); }
  100% { opacity: 1; transform: scale(1)    translateY(0);    }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(199,162,77,0); }
  50%       { box-shadow: 0 0 0 6px rgba(199,162,77,.18); }
}

/* Apply staggered entry to main-panel children */
.main-panel > * {
  animation: fadeUp 0.55s var(--ease-out) both;
}
.main-panel > *:nth-child(1) { animation-delay: 0.05s; }
.main-panel > *:nth-child(2) { animation-delay: 0.12s; }
.main-panel > *:nth-child(3) { animation-delay: 0.19s; }
.main-panel > *:nth-child(4) { animation-delay: 0.26s; }


/* --------------------------------------------------------------------------
   4. APP SHELL & SIDEBAR
   -------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar — deep burgundy, architectural column feel */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 16px;
  background:
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 24px,
      rgba(255,255,255,.018) 24px,
      rgba(255,255,255,.018) 25px
    ),
    radial-gradient(ellipse at top center, rgba(199,162,77,.14) 0%, transparent 55%),
    var(--burgundy);
  color: #fff;
  border-right: 1px solid rgba(199,162,77,.2);
  transition: width var(--t-slow), padding var(--t-slow);
  width: var(--sidebar-w);
}


/* ── Плавные переходы для всех сворачиваемых элементов ──────────────── */
.nav-item span,
.brand span {
  transition: opacity var(--t-slow), width var(--t-slow), margin var(--t-slow);
  white-space: nowrap;
}

/* Gold rule under the brand wordmark */
.sidebar::after {
  content: none; /* decorative rule is done inline via the brand element */
}

/* Brand / Wordmark */
.brand {
  display: block;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  font-style:normal;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: #fff;
  padding: 0 6px 20px;
  border-bottom: 1px solid rgba(199,162,77,.35);
  /* Fade in on load */
  animation: heraldFade 0.9s var(--ease-out) both;
}
/* Gold accent on the second half of the wordmark */
.brand span { color: var(--gold); }

/* Brand subtitle / institution line */
.brand-sub {
  display: block;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(255,255,255,.45);
  margin-top: 4px;
}


/* --------------------------------------------------------------------------
   5. NAVIGATION
   -------------------------------------------------------------------------- */
.nav-list { display: grid; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.75);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  position: relative;
  /* Smooth slide + fade */
  transition: background var(--t-base), color var(--t-fast), transform var(--t-base);
}

/* Gold left-border indicator on hover/active */
.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--gold);
  transform: scaleY(0);
  transition: transform var(--t-base);
}

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

.nav-item.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 700;
  transform: translateX(3px);
}
.nav-item.active::before { transform: scaleY(1); }

/* Section divider inside nav */
.nav-section-label {
  padding: 16px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}


/* --------------------------------------------------------------------------
   6. MAIN PANEL & TOPBAR
   -------------------------------------------------------------------------- */
.main-panel {
  padding: 36px 42px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  position: relative;
  z-index: 2000;
}

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

.topbar-title-box {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.topbar-title-box h1,
.topbar h1 {
  margin: 0;
  min-width: 0;
  font-size: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Eyebrow — small uppercase label above the page title */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold);
  margin-bottom: 6px;
}

.muted { color: var(--muted); }

.intro {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 28px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 1000;
}


/* Search box */
/* Profile chip — cleaner, just hover to reveal */
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 6px 0 14px;
  border-radius: 99px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t-fast);
  text-decoration: none;
}
.profile-chip:hover {
  background: rgba(199,162,77,.08);
}
.profile-chip:visited { color: var(--ink); }

/* Notification bell */
.bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}
.bell-btn:hover {
  background: rgba(199,162,77,.08);
  color: var(--ink);
}
.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: var(--burgundy);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* Bell dropdown */
.bell-wrap { position: relative; }
.bell-dropdown {
  display: none;
  position: absolute;
  top: 44px;
  right: 0;
  width: 340px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  overflow: hidden;
}
.bell-dropdown-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.bell-dropdown-body {
  max-height: 320px;
  overflow-y: auto;
}
.bell-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t-fast);
}
.bell-item:hover { background: var(--surface-subtle); }
.bell-item--unread { background: #fdf8f0; }
.bell-item-title { font-size: 13px; font-weight: 600; }
.bell-item-body { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bell-item-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bell-dropdown-foot {
  display: block;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--burgundy);
  border-top: 1px solid var(--line);
  text-decoration: none;
}

/* Avatar circle */
.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.avatar-img {
  object-fit: cover;
}


/* --------------------------------------------------------------------------
   7. FLASH MESSAGES
   -------------------------------------------------------------------------- */
.flash-list { display: grid; gap: 10px; margin-bottom: 20px; }

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff8e8;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  /* Small slide-in from above */
  animation: fadeUp 0.3s var(--ease-out) both;
}
.flash.error   { background: #F9E3E3; color: #8E1D1D; border-color: #EFC7C7; }
.flash.success { background: #DEF0E7; color: var(--green); border-color: #C3E2D3; }


/* --------------------------------------------------------------------------
   8. PANELS / CARDS
   Each panel gets a classic hairline-top gold accent on hover
   -------------------------------------------------------------------------- */
.panel {
  padding: 28px 30px;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-base), border-color var(--t-base);
  position: relative;
  overflow: hidden;
}

/* Gold top-rule appears on hover — the "Oxford border" */
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent 80%);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-slow);
}
.panel:hover::before { transform: scaleX(1); }
.panel:hover { box-shadow: var(--shadow-sm); }

.panel.compact { padding: 24px; margin-bottom: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.panel-head h2 { font-size: 17px; }
.panel-head a  { color: var(--gold); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; }
.panel-head a:hover { color: var(--burgundy); }


/* --------------------------------------------------------------------------
   9. METRIC CARDS (KPI row)
   -------------------------------------------------------------------------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  min-height: 120px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  display: grid;
  align-content: space-between;
  /* stagger each card's entry */
  animation: fadeUp 0.55s var(--ease-out) both;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
  position: relative;
  overflow: hidden;
}
.metric-card:nth-child(1) { animation-delay: 0.08s; }
.metric-card:nth-child(2) { animation-delay: 0.14s; }
.metric-card:nth-child(3) { animation-delay: 0.20s; }
.metric-card:nth-child(4) { animation-delay: 0.26s; }

/* Subtle shimmer on idle — a nod to gilded paper */
.metric-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 60%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.25) 50%,
    transparent 100%
  );
  background-size: 400px 100%;
  animation: shimmer 3.5s infinite linear;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base);
}
.metric-card:hover::after { opacity: 1; }

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--gold-light);
}

/* Label on top */
.metric-card span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
/* Large number — serif for prestige */
.metric-card strong {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 400;
  color: var(--burgundy);
  line-height: 1;
}


/* --------------------------------------------------------------------------
   10. BUTTONS
   -------------------------------------------------------------------------- */

/* Primary crest button — filled burgundy */
.primary-button,
.review-form button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 20px;
  border: 1px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--burgundy);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--t-base), border-color var(--t-base),
              color var(--t-base), transform var(--t-base), box-shadow var(--t-base);
}

/* Inner shine overlay for luxury feel */
.primary-button::before,
.review-form button::before,
input[type="submit"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.12) 0%, transparent 60%);
  pointer-events: none;
}

.primary-button:hover,
.review-form button:hover,
input[type="submit"]:hover {
  background: var(--burgundy-soft);
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(91,15,26,.22);
}
.primary-button:active,
.review-form button:active,
input[type="submit"]:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Ghost / outline variant */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast),
              background var(--t-fast), transform var(--t-fast);
}
.btn-ghost:hover {
  border-color: var(--burgundy);
  color: var(--burgundy);
  background: var(--burgundy-dim);
  transform: translateY(-1px);
}
.btn-ghost.active {
  border-color: var(--burgundy);
  color: var(--burgundy);
  background: var(--burgundy-dim);
}

/* Row action buttons (table inline) */
.row-actions button, .cell-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment-warm);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast),
              background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.row-actions button:hover, .cell-actions button:hover {
  background: var(--surface-strong);
  border-color: var(--burgundy);
  color: var(--burgundy);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(91,15,26,.08);
}
.row-actions button:active, .cell-actions button:active {
  transform: translateY(0);
  box-shadow: none;
}
.row-actions { white-space: nowrap; }
.row-actions button { margin-right: 6px; }
.cell-actions { display: none; gap: 4px; margin-top: 8px; }
.cell-actions.open { display: flex; }
.cell-actions button { width: 30px; min-height: 30px; padding: 0; font-size: 12px; }
.cell-actions .danger { color: var(--red); }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ebe5d8;
}
.segmented button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented button:hover:not(.active) {
  background: rgba(255,255,255,.5);
  color: var(--burgundy-soft);
}
.segmented button.active {
  background: var(--surface-strong);
  color: var(--burgundy);
  font-weight: 800;
  box-shadow: var(--shadow-xs);
}


/* --------------------------------------------------------------------------
   11. FORMS — Premium Oxford Edition
   Поля с внутренней тенью, золотой фокус, иконки, подсказки.
   -------------------------------------------------------------------------- */

.form-stack { display: grid; gap: 20px; }

.form-stack label {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  position: relative;
}

/* Поле ввода — мягкая внутренняя тень, тёплый фон */
.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #FFFDF7;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  box-shadow: inset 0 2px 4px rgba(43,35,24,.04);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

/* Текстовая область */
.form-stack textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

/* Hover — лёгкое затемнение границы */
.form-stack input:hover,
.form-stack select:hover,
.form-stack textarea:hover {
  border-color: var(--stone);
  background: #FFFDF7;
}

/* Focus — золотой ободок + мягкое свечение */
.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: #fff;
  box-shadow:
    0 0 0 3px rgba(199,162,77,.15),
    inset 0 1px 3px rgba(43,35,24,.06);
}

/* Placeholder */
.form-stack input::placeholder,
.form-stack textarea::placeholder {
  color: var(--stone);
  font-weight: 400;
}

/* Select — кастомная стрелка */
.form-stack select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E6A63' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* Disabled state */
.form-stack select:disabled,
.form-stack input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f5f2ea;
}

/* Форма в 2 колонки */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Inline-форма (создание ДЗ на странице) */
.inline-form {
  margin: 0 0 24px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.4);
  box-shadow: var(--shadow-xs);
  border-left: 3px solid var(--gold);
}

.compact-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

/* ── Form errors ────────────────────────────────────────────────────────── */
.form-errors {
  margin: 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: #FEF2F2;
  color: #991B1B;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #FECACA;
  line-height: 1.5;
}

/* ── Helper text ────────────────────────────────────────────────────────── */
.form-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 2px;
}

/* ── File input ──────────────────────────────────────────────────────────── */
.import-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
}

input[type="file"] {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #FFFDF7;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  font-size: 13px;
  color: var(--muted);
}
input[type="file"]:hover {
  border-color: var(--gold);
  background: #fff;
}

input[type="file"]::file-selector-button {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--burgundy);
  font-weight: 800;
  font-size: 12px;
  padding: 6px 14px;
  margin-right: 10px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
input[type="file"]::file-selector-button:hover {
  background: var(--burgundy);
  color: #fff;
  border-color: var(--burgundy);
}

/* ── Review form (homework inline) ────────────────────────────────────── */
.review-form input,
.review-form select {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #FFFDF7;
  font-size: 13px;
  color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.review-form input:focus,
.review-form select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(199,162,77,.15);
}

/* ── Checkbox / Radio ──────────────────────────────────────────────────── */
.form-stack input[type="checkbox"],
.form-stack input[type="radio"] {
  min-height: unset;
  width: 18px;
  height: 18px;
  accent-color: var(--burgundy);
  cursor: pointer;
  box-shadow: none;
  padding: 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; gap: 14px; }
  .import-row { grid-template-columns: 1fr; }
  .inline-form { padding: 16px; }
}
.auth-card {
  width: min(450px, 100%);
  padding: 32px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 14px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: heraldFade 0.8s var(--ease-out) both;
}

/* The wordmark inside the auth card */
.auth-brand {
  display: block;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.06em;
  color: var(--burgundy);
  text-align: center;
  margin-bottom: 6px;
}
.auth-brand span { color: var(--gold); }

/* Decorative rule under auth wordmark */
.auth-brand::after {
  content: '';
  display: block;
  width: 48px;
  height: 1px;
  background: var(--gold);
  margin: 12px auto 0;
}

.auth-card h1 { font-size: 22px; margin: 18px 0 4px; }

.auth-card--wide {
  width: min(572px, 100%);
  text-align: center;
}



.auth-tagline {
  text-align: center;
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  margin-bottom: 28px;
}

.demo-logins {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.demo-logins-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.demo-logins-head strong { color: var(--ink); font-size: 14px; }
.demo-logins-head span { font-size: 12px; }
.demo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.demo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: all var(--t-fast);
}
.demo-btn:hover {
  border-color: var(--gold);
  background: var(--surface-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xs);
}
.demo-icon { font-size: 22px; }
.demo-name { font-size: 13px; font-weight: 700; color: var(--burgundy); }
.demo-cred { font-size: 11px; color: var(--muted); }

/* Link style used in forms */
.text-link { color: var(--burgundy); font-weight: 700; }
.text-link:hover { color: var(--gold); }


/* --------------------------------------------------------------------------
   13. DASHBOARD LAYOUT
   -------------------------------------------------------------------------- */
.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) 300px;
  gap: 32px;
}
.content-column { min-width: 0; }
.right-rail     { display: grid; align-content: start; gap: 20px; }


/* --------------------------------------------------------------------------
   14. ENGAGEMENT CHART
   -------------------------------------------------------------------------- */
.chart-line svg { width: 100%; height: 180px; display: block; }
.chart-line .area { fill: url(#lineFill); }
.chart-line .line {
  fill: none;
  stroke: var(--burgundy);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.days span:last-child { text-align: right; }


/* --------------------------------------------------------------------------
   15. PROGRESS BARS
   -------------------------------------------------------------------------- */
.progress-list { display: grid; gap: 20px; }
.progress-row  {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: end;
}
.progress-row span,
.course-card p,
.course-card footer,
.homework-card footer,
.lesson-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.progress-track {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 99px;
  background: #E8E5DD;
  overflow: hidden;
}
.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--burgundy), var(--gold));
  /* The width is set inline; animate it for a "filling" effect */
  animation: none;
  transition: width 1.2s var(--ease-out);
}


/* --------------------------------------------------------------------------
   16. DONUT CHART
   -------------------------------------------------------------------------- */
.donut {
  --angle: calc(var(--value) * 3.6deg);
  width: 170px;
  aspect-ratio: 1;
  margin: 20px auto 4px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--angle), #E7DFCF 0);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 4px 16px rgba(199,162,77,.15);
  transition: box-shadow var(--t-base);
}
.donut:hover { box-shadow: 0 6px 22px rgba(199,162,77,.25); animation: goldPulse 2s ease infinite; }
.donut::after {
  content: '';
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--surface);
}
.donut strong,
.donut span { position: relative; z-index: 1; }
.donut strong {
  align-self: end;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--burgundy);
}
.donut span {
  align-self: start;
  font-size: 12px;
  color: var(--muted);
}


/* --------------------------------------------------------------------------
   17. TASK LIST
   -------------------------------------------------------------------------- */
.task-list { display: grid; gap: 12px; }

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--t-fast);
}
.task-item:hover { background: rgba(199,162,77,.06); padding-left: 8px; }
.task-item input {
  width: 18px; height: 18px;
  accent-color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}
.task-item span { transition: color var(--t-fast); font-size: 14px; }
.task-item:hover span { color: var(--burgundy); }
.task-item.done span { color: var(--muted); text-decoration: line-through; }


/* --------------------------------------------------------------------------
   18. COURSE GRID & CARDS
   -------------------------------------------------------------------------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 18px;
}

.course-card {
  padding: 22px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  border-top: 3px solid var(--burgundy);  /* monolithic crest accent */
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base), box-shadow var(--t-base), border-top-color var(--t-base);
}
.course-card:hover {
  transform: translateY(-5px);
  border-top-color: var(--gold);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.course-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.course-top span { color: var(--gold); font-weight: 800; font-size: 13px; }
.course-top b    { color: var(--burgundy); }
.course-card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}


/* --------------------------------------------------------------------------
   19. LESSON LIST (in sidebar column)
   -------------------------------------------------------------------------- */
.lesson-list  { display: grid; gap: 0; }
.lesson-item  {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast);
}
.lesson-item:last-child { border-bottom: 0; }
.lesson-item:hover      { background: rgba(199,162,77,.04); }
.lesson-item time       { color: var(--burgundy); font-weight: 800; font-size: 13px; }


/* --------------------------------------------------------------------------
   20. REVIEW FORM (homework inline)
   -------------------------------------------------------------------------- */
.review-form {
  display: grid;
  grid-template-columns: 140px 74px minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 520px;
}


/* --------------------------------------------------------------------------
   21. TABLE & JOURNAL
   -------------------------------------------------------------------------- */
.table-wrap  { overflow-x: auto; }
table        { width: 100%; border-collapse: collapse; min-width: 720px; }

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: rgba(246,242,230,.6);
}
td span { color: var(--muted); font-size: 13px; }

/* Hover highlight on table rows */
tbody tr {
  transition: background var(--t-fast);
}
tbody tr:hover { background: rgba(199,162,77,.05); }

/* Journal-specific sticky first column */
.journal-table th:first-child,
.journal-table td:first-child {
  min-width: 130px;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}
.journal-table th small {
  display: none;
}
.journal-table th[data-date] {
  min-width: 38px;
  padding: 8px 3px;
  text-align: center;
}
.journal-table th[data-date] span {
  display: block;
  font-size: 10px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.journal-cell       { min-width: 34px; padding: 3px 2px; }
.journal-cell form  { display: none; }

.cell-value {
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  border-radius: 6px;
  background: var(--parchment-warm);
  color: var(--burgundy);
  font-weight: 900;
  font-size: 12px;
  border: 1px solid transparent;
  transition: border-color var(--t-fast), background var(--t-fast);
  margin: 0 auto;
}
.cell-value:hover  { border-color: var(--gold); background: #fff; }
.cell-value.absent { background: #F5D9D9; color: var(--red); }
.cell-value.locked { background: #EDE8DD; color: var(--muted); font-weight: 600; }

/* Grade colors inside journal cells — palette from :root variables */
.cell-value.grade-5 { background: var(--green); color: #fff; }
.cell-value.grade-4 { background: var(--blue); color: #fff; }
.cell-value.grade-3 { background: var(--gold); color: #fff; }
.cell-value.grade-2 { background: var(--red); color: #fff; }
.cell-value.grade-1 { background: var(--burgundy); color: #fff; }
.cell-value.grade-nb { background: var(--stone); color: #fff; }

/* Grade picker buttons inside the popup */
.grade-picker {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.grade-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.grade-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.grade-btn.grade-5 { background: var(--green); }
.grade-btn.grade-4 { background: var(--blue); }
.grade-btn.grade-3 { background: var(--gold); }
.grade-btn.grade-2 { background: var(--red); }
.grade-btn.grade-1 { background: var(--burgundy); }
.grade-btn.grade-nb { background: var(--stone); }

/* Journal day column states */
.journal-table th.journal-day-today { background: rgba(199,162,77,.22); }
.journal-table th.journal-day-today span { color: var(--burgundy); }
.journal-table th.journal-day-past,
.journal-table th.journal-day-future { opacity: .55; }


/* --------------------------------------------------------------------------
   22. STATUS BADGES
   -------------------------------------------------------------------------- */
.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #EBE4D6;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.status.published,
.status.graded      { background: #DEF0E7; color: var(--green); }
.status.submitted   { background: #E2EBF5; color: var(--blue); }
.status.needs_revision { background: #F6E5D5; color: #9A4E12; }
.status.draft       { background: #ECE8DF; color: var(--muted); }


/* --------------------------------------------------------------------------
   23. SCHEDULE
   -------------------------------------------------------------------------- */
.schedule-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }

.schedule-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.schedule-item:hover {
  transform: translateY(-4px);
  border-color: var(--gold-light);
  box-shadow: var(--shadow-sm);
}
.schedule-item footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.schedule-item time { color: var(--muted); font-size: 13px; font-weight: 700; }
.schedule-item p    { color: var(--muted); line-height: 1.5; margin-bottom: 0; }


/* --------------------------------------------------------------------------
   24. HOMEWORK CARDS
   -------------------------------------------------------------------------- */
.homework-list { display: grid; gap: 14px; }

.homework-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.homework-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold-light);
  box-shadow: var(--shadow-sm);
}
.homework-card > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.homework-card p    { color: var(--muted); line-height: 1.5; margin: 8px 0 0; }
.homework-card time { color: var(--muted); font-size: 13px; font-weight: 700; }


/* --------------------------------------------------------------------------
   25. MESSAGES
   -------------------------------------------------------------------------- */
.message-list { display: grid; gap: 12px; }

.message-item {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.message-item:hover { border-color: var(--stone); box-shadow: var(--shadow-sm); }
.message-item > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.message-item p    { color: var(--muted); line-height: 1.5; margin-top: 6px; margin-bottom: 0; }
.message-item span { color: var(--muted); font-size: 13px; font-weight: 700; }
.message-item.unread {
  border-color: rgba(91,15,26,.2);
  background: rgba(255,248,233,.7);
}


/* --------------------------------------------------------------------------
   26. SETTINGS & ADMIN
   -------------------------------------------------------------------------- */
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }

.settings-link {
  display: grid;
  gap: 8px;
  min-height: 120px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment-warm);
  font-size: 16px;
  font-weight: 800;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}
.settings-link:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-sm);
  transform: translateY(-3px);
  color: var(--burgundy);
}
.settings-link span { color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1.4; }

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding: 26px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(199,162,77,.08), var(--surface));
  border-left: 3px solid var(--gold);
}
.admin-hero p { margin-bottom: 0; max-width: 720px; line-height: 1.6; }

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

.um-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.um-tab {
  appearance: none; border: 1px solid transparent; border-bottom: none; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 8px 8px 0 0;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: color .15s ease;
}
.um-tab:hover { color: var(--burgundy); background: var(--surface-subtle,#f8f6f2); }
.um-tab.is-active { color: var(--burgundy); background: var(--surface-subtle,#f8f6f2); border-color: var(--line); }
.um-pane { padding: 0; }
.table-wrap { scrollbar-width: thin; }

.uc-chip { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; background: var(--surface-subtle,#f8f6f2); border: 1px solid var(--line); font-size: 12px; }
.uc-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-span { grid-column: 1 / -1; }
.uc-stat { background: var(--surface-subtle,#f8f6f2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.uc-stat-num { font-size: 18px; font-weight: 800; color: var(--burgundy); }
.uc-stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.credential-panel { border-color: rgba(46,125,98,.3); background: #F3FBF6; }


/* --------------------------------------------------------------------------
   27. USER MANAGEMENT (mini tables, teacher chips)
   -------------------------------------------------------------------------- */
.mini-stack { display: grid; gap: 0; }
.mini-stack a {
  display: grid;
  gap: 3px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  transition: color var(--t-fast);
}
.mini-stack a:hover { color: var(--burgundy); }
.mini-stack span { color: var(--muted); font-size: 13px; }

.mini-table         { display: grid; gap: 0; }
.mini-table > div   {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast);
}
.mini-table > div:hover { background: rgba(199,162,77,.04); }
.mini-table > div:last-child { border-bottom: 0; }
.mini-table span    { color: var(--muted); font-size: 14px; }

.teacher-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.teacher-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment-warm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.teacher-chip:hover { border-color: var(--gold-light); box-shadow: var(--shadow-xs); }
.teacher-chip span { color: var(--muted); font-size: 13px; }

.two-column { display: grid; grid-template-columns: 440px minmax(0,1fr); gap: 28px; }


/* --------------------------------------------------------------------------
   28. HTMX LOADING STATE
   -------------------------------------------------------------------------- */
.htmx-request {
  opacity: 0.65;
  pointer-events: none;
  position: relative;
}
.primary-button.htmx-request::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  margin-left: 8px;
}


/* --------------------------------------------------------------------------
   29. DECORATIVE / HERALDIC ELEMENTS
   A subtle watermark crest rendered in CSS — can be placed in headers
   -------------------------------------------------------------------------- */

/* Heraldic divider — gold rule with diamond centrepiece */
.herald-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 24px 0;
}
.herald-divider::before,
.herald-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light), transparent);
}

/* Parchment-texture strip — used in page section separators */
.parchment-strip {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-light) 30%, var(--gold) 50%, var(--gold-light) 70%, transparent);
  margin: 28px 0;
  opacity: 0.6;
}

/* Animated page entrance — use on hero elements */
.hero-crest {
  animation: heraldFade 1.2s var(--ease-out) forwards;
}


/* --------------------------------------------------------------------------
   30. ROLE SELECTION SCREEN
   Full-screen role picker shown before the login form.
   Three cards — Student / Teacher / Admin — with heraldic hover states.
   -------------------------------------------------------------------------- */

/* Page background: parchment with a warm radial glow */
body.role-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(rgba(30,5,10,.70), rgba(30,5,10,.70)),
    url('https://images.unsplash.com/photo-1524178232363-1fb2b075b655?w=1920&q=80') center/cover fixed;
}

/* Outer card — same auth-card shell but wider for three columns */
.role-select-card {
  width: min(680px, 100%);
  padding: 44px 40px 36px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 14px;
  background: rgba(255,255,255,.90);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
  animation: heraldFade 0.8s var(--ease-out) both;
}

/* Wordmark inside the role picker */
.role-select-brand {
  display: block;
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.06em;
  color: var(--burgundy);
  margin-bottom: 0px;
}
.role-select-brand span { color: var(--gold); }

/* Gold rule under wordmark */
.role-select-brand::after {
  content: '';
  display: block;
  width: 44px;
  height: 1px;
  background: var(--gold);
  margin: 10px auto 0;
}

/* Subtitle */
.role-select-sub {
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  margin: 14px 0 32px;
}

/* Row of role cards */
.roles {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Individual role card */
.role-card {
  flex: 1;
  min-width: 160px;
  max-width: 220px;
  padding: 24px 20px 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: fadeUp 0.55s var(--ease-out) both;
  transition:
    transform    var(--t-base),
    border-color var(--t-base),
    box-shadow   var(--t-base),
    background   var(--t-base);
  position: relative;
  overflow: hidden;
}
.role-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,.0)  0%,
    rgba(255,255,255,.12) 50%,
    rgba(255,255,255,.0)  100%
  );
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}

.role-card:nth-child(1) { animation-delay: 0.10s; }
.role-card:nth-child(2) { animation-delay: 0.20s; }
.role-card:nth-child(3) { animation-delay: 0.30s; }

.role-card:hover {
  transform: translateY(-3px);
  border-top-color: var(--gold);
  border-color: var(--gold-light);
  box-shadow: var(--shadow);
  background: var(--surface-strong);
}
.role-card:hover::after { opacity: 1; }

.role-card:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Selected state */
.role-card.selected {
  border-left-color: var(--gold);
  border-color: var(--gold-light);
  background: var(--surface-strong);
  box-shadow: 0 0 0 1px var(--gold-light), var(--shadow-sm);
}
.role-card.selected .role-card-icon svg { color: var(--gold); }
.role-card.selected h2 { color: var(--gold); }
.role-check {
  width: 20px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.role-card.selected .role-check {
  border-color: var(--gold);
  background: var(--gold);
}
.role-card.selected .role-check::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.role-card-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: transform var(--t-base);
}
.role-card-icon svg {
  width: 32px;
  height: 32px;
  color: var(--burgundy);
  transition: transform var(--t-base), color var(--t-base);
}
.role-card-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  transition: transform var(--t-base);
}
.role-card:hover .role-card-icon { transform: scale(1.1); }
.role-card:hover .role-card-icon svg { color: var(--gold); }

.role-card h2 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--burgundy);
  margin-bottom: 2px;
}

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

/* Footer link back to plain login */
.role-select-footer {
  margin-top: 28px;
  font-size: 13px;
  color: var(--muted);
}
.role-select-footer a {
  color: var(--gold);
  font-weight: 700;
  transition: color var(--t-fast);
}
.role-select-footer a:hover { color: var(--burgundy); }


/* --------------------------------------------------------------------------
   32. STUDENT DASHBOARD
   Персональный кабинет студента: KPI-герой, расписание, дедлайны ДЗ,
   лента оценок, посещаемость, прогресс по курсам.
   -------------------------------------------------------------------------- */

/* Layout: wide main col + narrow rail */
.sd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
}
.sd-main { display: grid; align-content: start; gap: 0; }
.sd-rail { display: grid; align-content: start; gap: 20px; }


/* ── Hero KPI row ────────────────────────────────────────────────────────── */
.sd-hero {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.sd-stat {
  padding: 22px 22px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.5s var(--ease-out) both;
  transition: transform var(--t-base), box-shadow var(--t-base), border-top-color var(--t-base);
}
.sd-stat:nth-child(1) { animation-delay: 0.06s; }
.sd-stat:nth-child(2) { animation-delay: 0.12s; }
.sd-stat:nth-child(3) { animation-delay: 0.18s; }
.sd-stat:nth-child(4) { animation-delay: 0.24s; }

.sd-stat:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-top-color: var(--gold);
}

.sd-stat-inner { display: grid; gap: 2px; }

.sd-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.sd-stat-value {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 400;
  line-height: 1;
  color: var(--burgundy);
}
/* Colour variants on the big number */
.sd-stat--gold    .sd-stat-value { color: var(--gold); }
.sd-stat--green,
.sd-stat-value.sd-stat--green { color: var(--green); }
.sd-stat--warn,
.sd-stat-value.sd-stat--warn { color: #C47A1A; }
.sd-stat--danger,
.sd-stat-value.sd-stat--danger { color: var(--red); }
.sd-stat.sd-stat--danger {
  animation: sd-glow-red 1.2s ease-in-out infinite alternate;
}
@keyframes sd-glow-red {
  from { box-shadow: 0 0 4px rgba(163,32,32,.3); }
  to   { box-shadow: 0 0 16px rgba(163,32,32,.6); }
}

.sd-stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Teacher dashboard hero ─────────────────────────────────────────── */
.dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: center;
  padding: 34px 38px;
  margin-bottom: 28px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--burgundy) 0%, #7A1D2A 55%, #A32020 100%);
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.dash-hero::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -50px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(199,162,77,.4), transparent 65%);
}
.dash-hero::after {
  content: "";
  position: absolute;
  bottom: -90px;
  left: 30%;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.08), transparent 65%);
}
.dash-hero-text { position: relative; z-index: 1; }
.dash-hero-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold-light);
}
.dash-hero-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 400;
  margin: 8px 0 4px;
  color: #fff;
}
.dash-hero-date { font-size: 13px; color: rgba(255,255,255,.78); }
.dash-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.dash-hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: var(--gold);
  color: #fff;
}
.dash-hero-cta:hover {
  background: var(--gold);
  color: var(--burgundy);
}
.dash-hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(190px, 1fr));
  gap: 16px;
}
.dash-hero-stats .sd-stat {
  background: rgba(255, 253, 247, .97);
  border-top-color: var(--gold);
}

/* Teacher dashboard main grid */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (max-width: 1100px) {
  .dash-hero { grid-template-columns: 1fr; }
  .dash-hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}

/* Red card: materials button (placeholder) */
.dash-materials {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding: 18px 20px;
  border: 1px solid rgba(163, 32, 32, .25);
  border-top: 3px solid var(--red);
  border-radius: var(--radius);
  background: linear-gradient(120deg, #A32020 0%, #7A1D2A 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.5s var(--ease-out) both;
}
.dash-materials-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
}
.dash-materials-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.dash-materials-text strong { font-family: var(--font-serif); font-size: 16px; }
.dash-materials-text span { font-size: 12.5px; color: rgba(255,255,255,.82); }
.dash-materials-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 0 18px;
  min-height: 40px;
  border-radius: 10px;
  background: #fff;
  color: var(--red);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.dash-materials-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* Mini progress bar inside each stat card */
.sd-grade-bar {
  height: 6px;
  border-radius: 99px;
  background: var(--stone-light);
  overflow: hidden;
}
.sd-grade-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--burgundy), var(--gold));
  transition: width 1.2s var(--ease-out);
}
.sd-grade-fill--attendance { background: linear-gradient(90deg, var(--green), #74c69d); }
.sd-grade-fill--hw         { background: linear-gradient(90deg, var(--blue), #6fa3d4); }

/* Course count dots */
.sd-course-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.sd-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.75;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.sd-dot:hover { opacity: 1; transform: scale(1.3); }


/* ── Today's schedule ────────────────────────────────────────────────────── */
.sd-schedule {
  display: grid;
  gap: 0;
}

.sd-lesson {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 0 16px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: background var(--t-fast);
}
.sd-lesson:last-child { border-bottom: 0; }
.sd-lesson:hover      { background: rgba(199,162,77,.04); padding-left: 8px; }

/* Highlighted "live" lesson */
.sd-lesson--active {
  background: rgba(91,15,26,.04);
  border-left: 3px solid var(--burgundy);
  padding-left: 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.sd-lesson-time {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}
.sd-lesson-time time {
  font-weight: 800;
  font-size: 14px;
  color: var(--burgundy);
}
.sd-lesson-time span {
  font-size: 12px;
  color: var(--muted);
}
.sd-lesson-time span::before {
  content: '–';
  margin-right: 4px;
}

.sd-lesson-body {
  display: grid;
  gap: 3px;
}
.sd-lesson-body strong { font-size: 15px; }
.sd-lesson-body span   { font-size: 13px; color: var(--muted); }

.sd-lesson-room {
  display: flex !important;
  align-items: center;
  gap: 4px;
  color: var(--muted) !important;
}
.sd-lesson-room svg { width: 12px; height: 12px; opacity: 0.65; }

/* "Сейчас" live badge */
.sd-live-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--burgundy);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  animation: goldPulse 2s ease infinite;
}


/* ── Empty state ─────────────────────────────────────────────────────────── */
.sd-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
}
.sd-empty-icon { font-size: 36px; margin-bottom: 4px; }
.sd-empty p    { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; }
.sd-empty span { font-size: 13px; }


/* ── Homework deadline cards ─────────────────────────────────────────────── */
.sd-hw-list { display: grid; gap: 14px; }

.sd-hw-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--stone-light);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  gap: 8px;
  transition: border-left-color var(--t-base), box-shadow var(--t-base), transform var(--t-base);
}
.sd-hw-card:hover {
  border-left-color: var(--gold);
  box-shadow: var(--shadow-sm);
  transform: translateX(3px);
}
/* Overdue = red left border */
.sd-hw-card--overdue {
  border-left-color: var(--red);
  background: rgba(163,32,32,.03);
}

.sd-hw-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.sd-hw-course {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.sd-hw-due {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.sd-hw-due svg    { width: 12px; height: 12px; }
.sd-hw-due--late  { color: var(--red); }
.sd-hw-due em     { font-style: normal; padding: 1px 6px; background: rgba(163,32,32,.1); border-radius: 4px; }

.sd-hw-title { font-size: 15px; font-weight: 700; margin: 0; }
.sd-hw-desc  { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }

.sd-hw-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
/* Big grade circle on graded HW */
.sd-hw-grade {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
}


/* ── Grade tape (right rail) ─────────────────────────────────────────────── */
.sd-grades-tape { display: grid; gap: 0; }

.sd-grade-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast);
}
.sd-grade-item:last-child { border-bottom: 0; }
.sd-grade-item:hover      { background: rgba(199,162,77,.05); padding-left: 6px; }

/* Grade circle — colour-coded by value */
.sd-grade-badge {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--stone);
}
.sd-grade-badge--5 { background: var(--green); }
.sd-grade-badge--4 { background: var(--blue); }
.sd-grade-badge--3 { background: #C47A1A; }
.sd-grade-badge--2 { background: var(--red); }

.sd-grade-info { display: grid; gap: 2px; min-width: 0; }
.sd-grade-info strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-grade-info span { font-size: 12px; color: var(--muted); }


/* ── Attendance legend ───────────────────────────────────────────────────── */
.sd-attendance-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}
.sd-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.sd-legend-dot--present { background: var(--green); }
.sd-legend-dot--absent  { background: var(--red); }


/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1350px) {
  .sd-layout { grid-template-columns: 1fr; }
  .sd-rail   { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 900px) {
  .sd-hero   { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sd-rail   { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .sd-hero   { grid-template-columns: 1fr; }
  .sd-lesson { grid-template-columns: 60px 1fr; }
  .sd-live-badge { display: none; }
}


/* --------------------------------------------------------------------------
   34. LEVEL BADGES (English CEFR + IELTS)
   Colour-coded by proficiency: light (beginner) → dark (IELTS).
   -------------------------------------------------------------------------- */

.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Each level gets a distinct colour scheme */
.level-beginner          { background: #E8F5E9; color: #2E7D32; }
.level-elementary         { background: #E0F2F1; color: #00695C; }
.level-pre_intermediate   { background: #E3F2FD; color: #0D47A1; }
.level-intermediate       { background: #FFF3E0; color: #E65100; }
.level-upper_intermediate { background: #F3E5F5; color: #6A1B9A; }
.level-advanced           { background: #FCE4EC; color: #880E4F; }
.level-proficiency        { background: #EDE7F6; color: #4527A0; }
.level-ielts              { background: #FFF8E1; color: #8D6E00; }


/* --------------------------------------------------------------------------
   35. HOMEWORK 2.0 — review cards, quick-grade, filters
   Полностью переработанный UX проверки ДЗ с inline HTMX-оценками.
   -------------------------------------------------------------------------- */

/* Layout: two columns for assignments + review */
.hw-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1100px) {
  .hw-layout { grid-template-columns: 1fr; }
}

/* ── Tabs bar ────────────────────────────────────────────────────────── */
.hw-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #EBE5D8;
  flex-wrap: wrap;
  align-items: center;
}
.hw-create-btn {
  margin-left: auto;
  min-height: 34px;
  padding: 0 16px;
  font-size: 12.5px;
}
.hw-tab {
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.hw-tab:hover { background: rgba(255,255,255,.5); color: var(--burgundy-soft); }
.hw-tab.active { background: var(--surface-strong); color: var(--burgundy); font-weight: 800; box-shadow: var(--shadow-xs); }


/* ── Assignment cards ────────────────────────────────────────────────── */
.hw-list { display: grid; gap: 14px; }

.hw-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--stone-light);
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
  transition: border-left-color var(--t-base), box-shadow var(--t-base);
}
.hw-card:hover { border-left-color: var(--gold); box-shadow: var(--shadow-sm); }

.hw-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.hw-due {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.hw-due em { font-style: normal; color: var(--red); }
.hw-due--late { color: var(--red); }
.hw-due svg { width: 12px; height: 12px; }

.hw-card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
}
.hw-card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 10px;
}
.hw-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.hw-card-meta svg { width: 12px; height: 12px; vertical-align: middle; }

/* Status badge on student's submission */
.hw-sub-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.hw-grade-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
}

/* Upload form (hidden until toggled) */
.hw-upload-toggle { margin-top: 12px; }
.hw-upload-form { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }

.hw-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}


/* ── Review cards (teacher) ──────────────────────────────────────────── */
.hw-review-list { display: grid; gap: 14px; }

.hw-review-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  gap: 12px;
  transition: box-shadow var(--t-fast), border-color var(--t-fast);
}
.hw-review-card:hover { box-shadow: var(--shadow-xs); }

/* Animate status change */
.hw-review-card.htmx-swapping { opacity: 0; transition: opacity 0.15s; }

/* Dismiss animation when graded */
.hw-review-card--graded {
  animation: hw-dismiss 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes hw-dismiss {
  0%   { opacity: 1; transform: translateX(0); max-height: 500px; margin-bottom: 16px; padding: 18px; }
  40%  { opacity: 0; transform: translateX(20px); }
  100% { opacity: 0; transform: translateX(40px); max-height: 0; margin-bottom: 0; padding: 0 18px; overflow: hidden; }
}

/* When in "graded" tab, override dismiss to show the card */
.hw-tab[data-filter="graded"].active ~ .hw-review-list .hw-review-card--graded,
.hw-review-list.show-graded .hw-review-card--graded {
  animation: none;
  pointer-events: auto;
  opacity: 1;
  transform: none;
  max-height: none;
  margin-bottom: 16px;
  padding: 18px;
  overflow: visible;
}

.hw-review-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hw-review-meta {
  flex: 1;
  min-width: 0;
}
.hw-review-meta strong { font-size: 14px; display: block; }
.hw-review-meta span  { font-size: 12px; color: var(--muted); display: block; }

/* Answer preview */
.hw-review-answer {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246,242,230,.5);
  font-size: 13px;
  max-height: 120px;
  overflow: hidden;
  position: relative;
}
.hw-review-answer p { margin: 0; color: var(--ink); line-height: 1.5; }
.hw-review-answer .btn-ghost {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 11px;
  min-height: 26px;
  padding: 0 10px;
  background: rgba(255,255,255,.8);
}

/* File link */
.hw-review-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color var(--t-fast);
}
.hw-review-file:hover { border-color: var(--gold); }
.hw-review-file svg { width: 16px; height: 16px; color: var(--burgundy); }
.hw-review-file .text-link { margin-left: auto; }

/* Quick-grade buttons */
.hw-review-actions {
  display: grid;
  gap: 10px;
}
.hw-quick-grade {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.hw-quick-grade span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}
.hw-grade-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.hw-grade-btn:hover {
  border-color: var(--burgundy);
  color: var(--burgundy);
  background: rgba(91,15,26,.06);
  transform: scale(1.1);
}
.hw-grade-btn--active {
  border-color: var(--burgundy);
  background: var(--burgundy);
  color: #fff;
}
.hw-grade-btn--active:hover {
  background: var(--burgundy-soft);
  color: #fff;
}
.hw-grade-btn--revision {
  width: auto;
  border-radius: 99px;
  padding: 0 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  border-color: #C47A1A;
  color: #C47A1A;
}
.hw-grade-btn--revision:hover {
  background: rgba(196,122,26,.1);
  border-color: #C47A1A;
  color: #C47A1A;
}
.hw-grade-btn--revision.hw-grade-btn--active {
  background: #C47A1A;
  color: #fff;
}

/* Comment form */
.hw-review-comment {
  display: flex;
  gap: 8px;
  align-items: center;
}
.hw-review-comment input[type="text"],
.hw-review-comment input:not([type]) {
  flex: 1;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--parchment-warm);
  font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.hw-review-comment input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(199,162,77,.18);
}

/* Footer */
.hw-review-footer {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.hw-review-footer strong { color: var(--burgundy); }


/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .hw-tabs { flex-direction: row; flex-wrap: wrap; }
  .hw-create-btn { margin-left: 0; width: 100%; }
  .hw-review-head { flex-wrap: wrap; }
  .hw-quick-grade { gap: 4px; }
  .hw-grade-btn { width: 28px; height: 28px; font-size: 13px; }
}


/* --------------------------------------------------------------------------
   37. PROFILE PAGE
   -------------------------------------------------------------------------- */

.profile-layout {
  display: grid;
  gap: 24px;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: start;
}
@media (max-width: 640px) {
  .profile-card { grid-template-columns: 1fr; text-align: center; }
  .profile-actions { justify-content: center; }
}

.profile-avatar-wrap {
  display: flex;
  justify-content: center;
  position: relative;
}
.avatar-label {
  position: relative;
  cursor: pointer;
  display: inline-flex;
}
.avatar-edit-icon {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 26px;
  height: 26px;
  background: var(--burgundy);
  border: 2px solid #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .2s;
}
.avatar-label:hover .avatar-edit-icon {
  opacity: 1;
}
.avatar-edit-icon i {
  width: 12px;
  height: 12px;
  color: #fff;
}
.profile-avatar {
  width: 72px !important;
  height: 72px !important;
  font-size: 28px !important;
  background: var(--gold) !important;
  color: var(--burgundy) !important;
}

.profile-info h2 { margin-bottom: 4px; }
.profile-info .status { margin-bottom: 16px; }

.profile-details {
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
.profile-details > div {
  display: flex;
  gap: 20px;
  padding: 14px 4px;
  border-bottom: 1px solid rgba(226,221,210,.4);
  align-items: baseline;
}
.profile-details > div:last-child { border-bottom: 0; }
.profile-details > div > span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-width: 130px;
  flex-shrink: 0;
}
.profile-details > div > strong {
  font-weight: 600;
  font-size: 15px;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.profile-metric {
  text-align: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment-warm);
}
.profile-metric span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 4px; }
.profile-metric strong { font-family: var(--font-serif); font-size: 28px; font-weight: 400; color: var(--burgundy); line-height: 1; }
.profile-metric small { font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }


/* --------------------------------------------------------------------------
   38. SEARCH RESULTS DROPDOWN
   -------------------------------------------------------------------------- */


.htmx-indicator { opacity: 0; transition: opacity var(--t-fast); }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* Clickable stat cards — make the whole <a> behave like a card */
a.sd-stat {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 22px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  animation: fadeUp 0.5s var(--ease-out) both;
  transition: transform var(--t-base), box-shadow var(--t-base), border-top-color var(--t-base);
  cursor: pointer;
}
a.sd-stat:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-top-color: var(--gold);
}
a.sd-stat:visited { color: inherit; }

/* Quick stats grid for admin dashboard */
.admin-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.admin-quick-item,
a.admin-quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
  text-decoration: none;
  color: inherit;
}
.admin-quick-item:hover {
  box-shadow: var(--shadow-xs);
  transform: translateY(-2px);
}
.admin-quick-item svg {
  width: 24px;
  height: 24px;
}
.admin-quick-item strong {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--burgundy);
  line-height: 1;
}
.admin-quick-item span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Ranking badges */
.ranking-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px 10px;
  border-radius: 99px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}
.ranking-grade--5 { background: var(--green); }
.ranking-grade--4 { background: var(--blue); }
.ranking-grade--3 { background: #C47A1A; }
.ranking-grade--2 { background: var(--red); }
.ranking-grade--0 { background: var(--stone); }

.ranking-att {
  font-weight: 700;
  font-size: 14px;
}
.ranking-att--good { color: var(--green); }
.ranking-att--ok  { color: #C47A1A; }
.ranking-att--bad { color: var(--red); }

.ranking-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}


/* --------------------------------------------------------------------------
   99. RESPONSIVE BREAKPOINTS (global)
   -------------------------------------------------------------------------- */

/* Wider screens only — sidebar collapse */
@media (min-width: 761px) {
  .sidebar--collapsed {
    width: 68px;
    padding: 24px 10px;
    align-items: center;
  }
  .sidebar--collapsed .brand {
    font-size: 0;
    width: auto;
    padding: 0 0 14px;
    border-bottom: 1px solid rgba(199,162,77,.35);
    text-align: center;
  }
  .sidebar--collapsed .brand::after {
    content: "N";
    font-family: var(--font-serif);
    font-size: 22px;
    color: var(--gold);
    font-weight: 700;
  }
  .sidebar--collapsed .brand-sub { display: none; }
  .sidebar--collapsed .brand span { opacity: 0; }
  .sidebar--collapsed .nav-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  .sidebar--collapsed .nav-item {
    justify-content: center;
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  .sidebar--collapsed .nav-item::before { display: none; }
  .sidebar--collapsed .nav-item span {
    opacity: 0;
    width: 0;
    margin: 0;
    overflow: hidden;
  }
  .sidebar--collapsed .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  .sidebar--collapsed .sidebar-footer .nav-item span { display: none; }
  .sidebar--collapsed .nav-section-label { display: none; }
}

/* Плавные переходы для текста в навигации */
.nav-item span,
.brand span {
  transition: opacity var(--t-slow), width var(--t-slow), margin var(--t-slow);
  white-space: nowrap;
}

/* Button — sidebar toggle, visible only on mobile */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.hamburger:hover { background: rgba(91,15,26,.08); }

/* Three bars */
.hamburger span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--burgundy);
  transition: transform var(--t-base), opacity var(--t-fast);
}

/* Overlay backdrop — hidden by default */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 98;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}
.sidebar-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Responsive: mobile (<760px) ─────────────────────────────────────── */
@media (max-width: 760px) {
  .hamburger { display: flex; }

  /* Topbar sits below the drawer so the hamburger never overlaps the logo */
  .topbar { z-index: 50; }

  /* Sidebar becomes a fixed drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 290px;
    max-width: 85vw;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--t-slow);
    border-right: 1px solid rgba(199,162,77,.2);
  }
  .sidebar--open { transform: translateX(0); }

  .sidebar-overlay { display: block; }

  /* Show sidebar footer on mobile too */
  .sidebar-footer { display: grid; }
}

/* Wide laptop — collapse right-rail */
@media (max-width: 1350px) {
  :root { --sidebar-w: 240px; }
  .dashboard-layout, .two-column { grid-template-columns: 1fr; }
  .right-rail { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

/* Tablet landscape — 2-column grids */
@media (max-width: 1180px) {
  .metric-grid, .course-grid, .schedule-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .settings-grid, .admin-grid               { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .main-panel { padding: 28px 28px; }
}

/* Tablet portrait / large phone */
@media (max-width: 900px) {
  .review-form {
    grid-template-columns: 1fr 1fr;
    min-width: unset;
  }
}

/* Mobile — layout + sidebar handled by hamburger drawer above */
@media (max-width: 760px) {
  .app-shell { display: block; }
  .main-panel { padding: 20px 16px; }
  .topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .topbar-left {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    gap: 8px;
  }
  .topbar-title-box {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }
  .topbar h1,
  .topbar-title-box h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar .eyebrow { display: none; }
  .topbar-actions {
    width: auto;
    flex-shrink: 0;
    gap: 6px;
  }
  .profile-chip .profile-chip-text { display: none !important; }
  .profile-chip span:last-child { display: none; }
  .profile-chip { padding: 0 4px !important; height: 36px; }
  .panel-head          { align-items: flex-start; flex-direction: column; }
  .admin-hero          { align-items: flex-start; flex-direction: column; }

  .metric-grid, .course-grid, .schedule-grid,
  .right-rail, .admin-grid, .teacher-list,
  .import-row, .form-grid, .settings-grid { grid-template-columns: 1fr; }

  .panel { padding: 18px; }
  .brand { font-size: 22px; }
  .dashboard-layout { grid-template-columns: 1fr; }
}

/* ── Calendar grid ────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 700px;
}
.cal-col {
  background: #fff;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}
.cal-col--today .cal-header {
  background: var(--burgundy);
  color: #fff;
}
.cal-header {
  text-align: center;
  padding: 10px 6px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
}
.cal-day-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.cal-day-num {
  display: block;
  font-size: 20px;
  font-weight: 800;
  font-family: var(--font-serif);
  margin-top: 2px;
}
.cal-body {
  flex: 1;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-lesson {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  position: relative;
  background: #f9f6f0;
  border-left: 3px solid var(--line);
}
.cal-lesson.level-beginner,
.cal-lesson.level-elementary { border-left-color: var(--green); }
.cal-lesson.level-pre_intermediate,
.cal-lesson.level-intermediate { border-left-color: var(--blue); }
.cal-lesson.level-upper_intermediate,
.cal-lesson.level-advanced { border-left-color: #C47A1A; }
.cal-lesson.level-ielts,
.cal-lesson.level-proficiency { border-left-color: var(--burgundy); }
.cal-lesson--live { background: #fdf8f0; box-shadow: 0 0 0 1px var(--gold); }
.cal-lesson-time {
  font-weight: 700;
  font-size: 11px;
  color: var(--burgundy);
}
.cal-lesson-title {
  font-weight: 700;
  margin-top: 2px;
}
.cal-lesson-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
}
.cal-lesson-edit {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  transition: opacity .15s;
  color: var(--muted);
}
.cal-lesson:hover .cal-lesson-edit { opacity: 1; }
.cal-empty {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 12px 0;
}

/* ── Login enhancements (UI/UX Pro Max) ──────────────────────── */
.auth-overlay-pattern {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .06  ;
  background-image:
    radial-gradient(circle at 25% 25%, #fff 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, #fff 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
.auth-brand-wrap {
  text-align: center;
  margin-bottom: 8px;
}
.auth-brand-icon {
  display: flex;
  justify-content: center;
  margin-bottom: -30px;
}
.auth-brand-icon svg {
  width: 40px;
  height: 40px;
}
.role-card-text {
  text-align: center;
}
.role-card-sub {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 1px;
}
.form-back-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.form-back-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--t-fast);
}
.form-back-btn:hover {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--gold-light);
}
.form-back-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--burgundy);
  font-family: var(--font-serif);
}
.input-group {
  margin-bottom: 16px;
}
.input-group label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
  display: block;
}
.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.input-icon-wrap input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input-icon-wrap input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(199,162,77,.15);
}
.input-icon-wrap input::placeholder {
  color: var(--muted);
  opacity: .6;
}

/* ── Group cards (teacher dashboard) ───────────────────────── */
.group-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.group-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.group-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.group-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.group-card-head strong {
  font-family: var(--font-serif);
  color: var(--burgundy);
}
.group-card-students {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.group-card-foot {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
}

/* ── Modals ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 12, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2500;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-card {
  background: #FFFFFF !important;
  color: var(--ink) !important;
  border-radius: 14px;
  border: 1px solid var(--stone-light);
  padding: 24px;
  width: min(520px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: fadeUp .25s ease-out;
  position: relative;
  z-index: 2501;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}

/* ── Star selector ─────────────────────────────────────────── */
.star-select {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.star-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--t-fast);
}
.star-btn:hover,
.star-btn.hovered {
  border-color: var(--gold);
  color: var(--gold);
  transform: scale(1.08);
}
.star-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
  transform: scale(1.15);
}

/* Teacher block inside the rating popup */
.rating-teacher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.rating-teacher strong {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--burgundy);
}

/* ── Messenger layout ─────────────────────────────────────── */
.messenger-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  min-height: 500px;
}
.messenger-layout--single {
  grid-template-columns: 1fr;
}
.messenger-sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface-subtle);
}
.messenger-sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
}
.messenger-sidebar-head h3 { font-size: 15px; }
.messenger-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 12px 14px 6px;
}
.messenger-channel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast);
}
.messenger-channel:hover { background: rgba(199,162,77,.08); }
.messenger-channel-info {}
.messenger-channel-info strong { display: block; font-size: 13px; }
.messenger-channel-info span { font-size: 11px; }
.messenger-main {
  display: flex;
  flex-direction: column;
  height: 500px;
}
.messenger-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.messenger-header strong { font-size: 15px; }
.messenger-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.msg--sent {
  align-self: flex-end;
  background: var(--burgundy);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(122,16,32,.18);
}
.msg--received {
  align-self: flex-start;
  background: var(--gold);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(199,162,77,.25);
}
.msg--received .msg-name { color: var(--burgundy); }
.msg--received .msg-meta { color: rgba(42,30,20,.7); }
.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.msg-avatar {
  width: 22px;
  height: 22px;
  font-size: 9px;
}
.msg-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--burgundy);
}
.msg-body { margin-bottom: 4px; }
.msg-meta {
  font-size: 11px;
  opacity: .7;
  display: flex;
  gap: 8px;
}
.messenger-channel.active {
  background: rgba(199,162,77,.15);
  border-left: 3px solid var(--gold);
}
.msg-input {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}


/* ==========================================================================
   41. MOBILE ADAPTATION (phones & small screens)
   --------------------------------------------------------------------------
   Финальные правки под телефоны: топбар, KPI-карточки, журнал,
   модалки, уведомления, авторизация и мессенджер.
   ========================================================================== */

/* ── Phones / narrow screens ─────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Topbar — не даём длинному заголовку сжать кнопки справа */
  .topbar > div:first-child,
  .topbar-left { min-width: 0; flex: 1 1 auto; overflow: hidden; }
  .topbar-title-box { min-width: 0; flex: 1 1 auto; overflow: hidden; }
  .topbar h1,
  .topbar-title-box h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions { flex-shrink: 0; }
  .topbar { margin-bottom: 20px; }
  .main-panel { padding: 14px 12px 32px; }
  .panel { padding: 16px; }
  .intro { margin-bottom: 18px; }

  /* KPI-карточки — компактнее */
  .sd-hero { gap: 12px; margin-bottom: 20px; }
  .sd-stat { padding: 16px 14px 12px; gap: 10px; }
  .sd-stat-value { font-size: 30px; }
  .sd-stat-sub { font-size: 11px; }
  .dash-hero { padding: 24px 20px; border-radius: 14px; }
  .dash-hero-title {
    font-size: 21px;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .dash-hero-kicker {
    font-size: 10px;
    letter-spacing: .14em;
    white-space: normal;
  }
  .dash-hero-cta { margin-top: 14px; }

  /* Red materials card — stacks on phones */
  .dash-materials { flex-wrap: wrap; gap: 12px; padding: 16px; }
  .dash-materials-btn { width: 100%; justify-content: center; }

  /* Журнал — компактные колонки, весь месяц помещается на экране */
  .journal-table th:first-child,
  .journal-table td:first-child { min-width: 110px; }
  .journal-table th[data-date] { min-width: 32px; }
  .journal-cell { min-width: 28px; }
  .cell-value { width: 22px; height: 20px; font-size: 11px; }
  th, td { padding: 6px 2px; }

  /* Модалки — во всю ширину, скролл при низком экране */
  .modal-overlay { padding: 12px; }
  .modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 18px 16px;
  }
  .modal-card form > div[style*="display:flex"] { flex-wrap: wrap; }
  .modal-card form > div[style*="display:flex"] > * { flex: 1 1 140px; }

  /* Уведомления — выпадашка на всю ширину */
  .bell-dropdown {
    position: fixed;
    top: 52px;
    left: 8px;
    right: 8px;
    width: auto;
  }

  /* Авторизация и выбор роли */
  body.auth-body { padding: 16px; }
  .auth-card { padding: 24px 18px; }
  .auth-brand { font-size: 24px; }
  .auth-tagline { white-space: normal; }
  .role-select-card { padding: 26px 14px 22px; }
  .role-select-sub { white-space: normal; margin-bottom: 20px; }
  .roles { flex-direction: column; align-items: stretch; }
  .role-card { max-width: none; min-width: 0; min-height: 0; padding: 16px 16px 14px; }

  /* Мессенджер — список каналов над перепиской */
  .messenger-layout { grid-template-columns: 1fr; min-height: 0; }
  .messenger-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 38vh;
    overflow-y: auto;
  }
  .messenger-main { height: 60vh; }
  .msg { max-width: 88%; }
}

/* ── Очень маленькие телефоны (<420px) ──────────────────────────────── */
@media (max-width: 420px) {
  .sd-hero { grid-template-columns: 1fr; }
  .dash-hero-stats { grid-template-columns: 1fr; }
  .sd-stat-value { font-size: 28px; }
  .topbar h1 { font-size: 15px; }
  .grade-btn { width: 46px; height: 46px; }
  .star-btn { width: 42px; height: 42px; }
  .flash { font-size: 13px; }
}

/* ── Admin KPI row (3 cards after revenue was removed) ──────────────── */
.sd-hero--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .sd-hero--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .sd-hero--3 { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   34. KPI PAGES — light academic theme helpers
   Badges, primary/small buttons and form controls used by the KPI templates.
   Uses the site palette (parchment, white panels, burgundy, gold, ink).
   -------------------------------------------------------------------------- */

/* Generic badge / status pill */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #EBE4D6;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--open,
.badge--approved,
.badge--live,
.badge--included        { background: #DEF0E7; color: var(--green); }
.badge--submitted,
.badge--frozen,
.badge--n_a_low_sample  { background: #E2EBF5; color: var(--blue); }
.badge--review,
.badge--under_review,
.badge--provisional,
.badge--pending,
.badge--warn            { background: #F6E5D5; color: #9A4E12; }
.badge--blocked,
.badge--rejected,
.badge--excluded,
.badge--danger          { background: #F9E3E3; color: var(--red); }
.badge--shadow          { background: #EDE8DD; color: var(--muted); }

/* Filled primary button (burgundy) — pairs with .btn-ghost */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--burgundy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn-primary:hover {
  background: var(--burgundy-soft);
  border-color: var(--gold);
  transform: translateY(-1px);
}
/* Small button sizing — use with .btn-ghost / .btn-primary */
.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}
/* Danger outline variant for reject actions */
.btn-danger {
  border-color: var(--red);
  color: var(--red);
}
.btn-danger:hover {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

/* Form controls used on KPI modals */
.form-group { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
}
.form-input:focus { outline: none; border-color: var(--gold); }
.form-input[readonly] { background: var(--parchment); color: var(--muted); }

/* ==========================================================================
   35. MOBILE RESPONSIVENESS & ADAPTIVE LAYOUTS (R1–R4)
   Mobile viewport: 375px - 414px | Tablets: 768px - 1024px | Desktop: >1024px
   ========================================================================== */

/* Global container & table scrolling safety */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}
/* overflow-x: clip does not turn overflow-y into 'auto', so the sticky
   sidebar keeps working (hidden would break position: sticky on some browsers) */
@supports (overflow-x: clip) {
  html, body { overflow-x: clip; }
}

.app-shell,
.main-panel {
  max-width: 100%;
  box-sizing: border-box;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Modals global elevation above sticky navigation, drawer and topbar */
.modal-overlay,
.kpi-modal-overlay,
[id*="modal"].modal-overlay,
div[class*="modal-overlay"] {
  z-index: 2500 !important;
}
.modal-card,
.kpi-modal-dialog,
[id*="modal"] .modal-card,
div[class*="modal-card"] {
  z-index: 2501 !important;
}

/* ── Schedule Generator: Base Layout & Mobile Tabs ── */
.schedule-gen-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}
.schedule-mobile-tabs {
  display: none;
}
.mobile-only-back,
.mobile-only-save {
  display: none;
}

@media (max-width: 960px) {
  .schedule-mobile-tabs {
    display: flex !important;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--surface-hover, #f1f5f9);
    padding: 5px;
    border-radius: 10px;
    border: 1px solid var(--line);
  }
  .sched-tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
  }
  .sched-tab-btn.active {
    background: var(--surface, #ffffff);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .sched-tab-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(99,102,241,0.12);
    color: #6366f1;
  }
  .sched-tab-badge.badge-danger {
    background: rgba(239,68,68,0.15);
    color: #dc2626;
  }
  .sched-tab-badge.badge-success {
    background: rgba(16,185,129,0.15);
    color: #059669;
  }
  .schedule-gen-grid {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .schedule-gen-grid > .panel {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .mobile-only-back,
  .mobile-only-save {
    display: block !important;
  }
  .schedule-gen-topbar {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .schedule-gen-topbar .topbar-sep {
    display: none !important;
  }
  .schedule-gen-topbar > div {
    width: 100% !important;
    flex-wrap: wrap !important;
  }
}

/* ── Mobile & Tablet Adaptive Rules (<768px) ── */
@media (max-width: 768px) {
  /* Prevent iOS Safari accidental auto-zoom on input focus */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  input[type="text"],
  input[type="search"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="tel"],
  input[type="file"],
  select,
  textarea,
  .form-input {
    font-size: 16px !important;
    touch-action: manipulation;
  }

  /* Universal minimum touch targets and hit areas (minimum 44x44px area) */
  .primary-button,
  .btn-primary,
  .btn-ghost,
  .tab-btn,
  .segmented a,
  .segmented button,
  .modal-close,
  .kpi-modal-close,
  .hamburger,
  .bell-btn,
  .profile-chip {
    min-height: 44px;
    box-sizing: border-box;
    touch-action: manipulation;
  }

  .hamburger,
  .bell-btn,
  .profile-chip {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  /* Modal overlay padding on mobile: maximize usable card width on 375px-414px screens */
  .modal-overlay {
    padding: 10px !important;
  }

  /* Modal close buttons: 44x44px minimum touch target */
  .modal-close,
  .modal-card button.modal-close,
  .modal-head button,
  .modal-card > div:first-child button.btn-ghost,
  .kpi-modal-close {
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 20px !important;
    padding: 0 !important;
    touch-action: manipulation;
  }

  /* Generic modal-card responsiveness: fit within viewport with internal scrolling */
  .modal-card {
    max-height: calc(100vh - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
  }

  /* ── R1: User Management (/settings/users/) ── */
  .admin-hero-actions {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .admin-hero-actions .primary-button {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    padding: 0 10px !important;
    font-size: 12.5px !important;
    min-height: 44px !important;
  }
  .group-create-form {
    padding: 12px 10px !important;
  }
  .group-create-form .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .group-create-form label input,
  .group-create-form label select {
    width: 100% !important;
    display: block !important;
    margin-top: 4px !important;
    min-height: 44px !important;
  }
  .group-create-form .group-create-submit {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
  }

  /* Group list items adapted to responsive card tiles */
  .group-row-card {
    flex-direction: column !important;
    align-items: flex-start !important;
    padding: 12px 10px !important;
    background: var(--surface-strong) !important;
    border-radius: 8px !important;
    margin-bottom: 8px !important;
    border: 1px solid var(--line-soft, #f0ede6) !important;
  }
  .group-row-info {
    width: 100% !important;
    min-width: 0 !important;
  }
  .group-row-actions {
    width: 100% !important;
    margin-left: 0 !important;
    margin-top: 8px !important;
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  .group-row-actions .btn-ghost {
    min-height: 44px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    flex: 1 1 auto !important;
    justify-content: center !important;
    display: inline-flex !important;
    align-items: center !important;
  }
  .group-row-actions form {
    flex: 0 0 auto !important;
    margin: 0 !important;
  }
  .group-row-actions form .btn-ghost {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Admin Creation Form & 3-Tier Admin Table */
  .admin-create-submit {
    width: 100% !important;
  }
  .admin-create-submit button {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
  }
  .recent-student-row {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .recent-student-row form {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }
  .recent-student-row form input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    min-height: 44px !important;
  }
  .recent-student-row form button {
    min-height: 44px !important;
    padding: 0 14px !important;
    flex: 0 0 auto !important;
  }
  .admin-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain;
    width: 100% !important;
  }
  .admin-table-wrap table {
    min-width: 720px !important;
  }
  .admin-table-wrap table select {
    min-height: 44px !important;
    font-size: 16px !important;
  }
  .admin-table-wrap table .btn-ghost {
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* "Add Students to Group" Modal (full-width, high-height, sticky footer) */
  .modal-card--students {
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100vh - 20px) !important;
    height: calc(100dvh - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 16px 14px !important;
  }
  .modal-card--students form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
    min-height: 0 !important;
  }
  .modal-students-search-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .modal-students-search-box {
    width: 100% !important;
    min-width: 0 !important;
  }
  .modal-students-quick-btns {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
  }
  .modal-students-quick-btns button {
    flex: 1 1 50% !important;
    min-height: 44px !important;
    justify-content: center !important;
  }
  #modal-student-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
  }
  .modal-student-item {
    min-height: 48px !important;
    padding: 10px !important;
  }
  .modal-student-checkbox {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
  }
  .modal-card--students .modal-footer {
    position: sticky !important;
    bottom: 0 !important;
    background: #FFFFFF !important;
    margin-top: auto !important;
    padding-top: 12px !important;
    padding-bottom: max(6px, env(safe-area-inset-bottom)) !important;
    border-top: 1px solid var(--line) !important;
    display: flex !important;
    gap: 10px !important;
    z-index: 10 !important;
  }
  .modal-card--students .modal-footer button {
    flex: 1 1 50% !important;
    min-height: 44px !important;
    justify-content: center !important;
  }

  /* "Assign Teacher" Modal */
  .modal-card--assign-teacher {
    width: 100% !important;
    max-height: calc(100vh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
    padding: 18px 16px !important;
  }
  .modal-card--assign-teacher select {
    min-height: 44px !important;
  }
  .modal-card--assign-teacher button {
    min-height: 44px !important;
  }
  .modal-card--assign-teacher form > div:last-child {
    display: flex !important;
    gap: 10px !important;
  }
  .modal-card--assign-teacher form > div:last-child button {
    flex: 1 1 50% !important;
    justify-content: center !important;
  }

  /* ── R2: Students & Search (/students/) ── */
  .students-actions-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .student-search-form {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  .student-search-form > div {
    flex: 1 1 180px !important;
    min-width: 0 !important;
  }
  .student-search-form input[type="search"] {
    width: 100% !important;
    min-height: 44px !important;
  }
  .student-search-form button,
  .student-search-form a {
    min-height: 44px !important;
    padding: 0 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 auto !important;
  }
  .students-admin-buttons {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)) !important;
    gap: 8px !important;
  }
  .students-admin-buttons .primary-button {
    min-height: 44px !important;
    justify-content: center !important;
    width: 100% !important;
  }
  .segmented-scrollable {
    max-width: 100% !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain;
  }
  .segmented-scrollable a {
    white-space: nowrap !important;
    min-height: 44px !important;
    min-width: 44px !important;
    justify-content: center !important;
    display: inline-flex !important;
    align-items: center !important;
  }
  .table-wrap table {
    min-width: 720px;
  }
  .table-wrap table .btn-ghost {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 8px 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  /* ── R3: Trial Students Funnel, Filters & Modals (/trial-students/) ── */
  .trial-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .trial-stat-grid .stat-card {
    padding: 14px 12px !important;
  }
  .trial-stat-grid .stat-card > div:last-child {
    font-size: 24px !important;
  }
  .trial-stat-grid .stat-card:last-child {
    grid-column: 1 / -1 !important;
  }
  .trial-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    overflow-x: visible !important;
    flex-wrap: wrap !important;
  }
  #trial-search-form {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  #trial-search-form > div {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  #trial-search-input {
    width: 100% !important;
    min-height: 44px !important;
  }
  #trial-search-form button,
  #trial-search-form a {
    min-height: 44px !important;
    padding: 0 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 auto !important;
  }
  .trial-filter-bar .segmented {
    max-width: 100% !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain;
  }
  .trial-filter-bar .segmented a {
    min-height: 44px !important;
    min-width: 44px !important;
    justify-content: center !important;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
  }
  .trial-filter-bar > button.primary-button {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
    margin-left: 0 !important;
  }

  /* Trial table: ensure 9 columns have comfortable breathing room without clipping */
  .panel .table-wrap table {
    min-width: 820px;
  }
  .table-wrap table td > div[style*="inline-flex"] button.btn-ghost {
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Trial Modals */
  .trial-form-row {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  #trial-modal .modal-card,
  #status-modal .modal-card {
    width: 100% !important;
    max-height: calc(100vh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain;
    padding: 18px 14px !important;
  }
  #trial-modal input,
  #trial-modal select,
  #trial-modal textarea,
  #status-modal select {
    min-height: 44px !important;
  }
  #trial-modal button,
  #status-modal button {
    min-height: 44px !important;
    padding: 0 16px !important;
  }
  #trial-modal form > div > div:last-child,
  #status-modal form > div:last-child {
    display: flex !important;
    gap: 10px !important;
  }
  #trial-modal form > div > div:last-child button,
  #status-modal form > div:last-child button {
    flex: 1 1 50% !important;
    justify-content: center !important;
  }

  /* ── R4: Schedule Generator (/schedule/generator/) ── */
  .schedule-gen-grid > .panel {
    min-height: auto !important;
  }
  #preview-placeholder {
    padding: 40px 16px !important;
  }
  #preview-header > div > div:last-child {
    width: 100% !important;
    text-align: left !important;
  }
  .schedule-preview-wrap {
    max-height: 70vh !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain;
  }
  .schedule-preview-table {
    min-width: 650px !important;
  }
  .schedule-preview-table th,
  .schedule-preview-table td {
    padding: 8px 10px !important;
    font-size: 12px !important;
  }
  #schedule-gen-form input,
  #schedule-gen-form select {
    min-height: 44px !important;
  }
  #schedule-gen-form button {
    min-height: 44px !important;
  }
  #schedule-gen-form label[id*="label-pattern"] {
    min-height: 44px !important;
  }

  /* ── R4: KPI Control Room & Teacher KPI (/kpi/) ── */
  .manager-kpi-header-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .manager-kpi-header-bar > div {
    width: 100% !important;
    flex-wrap: wrap !important;
  }
  .manager-kpi-header-bar select {
    width: 100% !important;
    min-height: 44px !important;
  }
  .manager-kpi-header-bar .btn-sm {
    min-height: 44px !important;
    flex: 1 1 auto !important;
    justify-content: center !important;
  }
  .manager-kpi-header-bar form {
    flex: 1 1 auto !important;
  }
  .manager-kpi-header-bar form button {
    width: 100% !important;
    min-height: 44px !important;
    justify-content: center !important;
  }
  .kpi-tabs-nav {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    padding-bottom: 6px !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain;
  }
  .kpi-tabs-nav .tab-btn {
    white-space: nowrap !important;
    min-height: 44px !important;
    padding: 0 14px !important;
    font-size: 13px !important;
  }
  .manager-kpi-wrapper .table {
    min-width: 680px !important;
  }
  .manager-kpi-wrapper .table button,
  .manager-kpi-wrapper .table a,
  .manager-kpi-wrapper .table .btn-sm,
  .manager-kpi-wrapper .table input[type="text"] {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
  }
  .manager-kpi-wrapper .table form {
    align-items: center !important;
  }
  .drilldown-view .table {
    min-width: 560px !important;
  }
}

/* Narrow phones (max-width: 400px) */
@media (max-width: 400px) {
  .trial-stat-grid {
    grid-template-columns: 1fr !important;
  }
  .trial-stat-grid .stat-card:last-child {
    grid-column: auto !important;
  }
  .students-admin-buttons {
    grid-template-columns: 1fr !important;
  }
  .admin-hero-actions {
    grid-template-columns: 1fr !important;
  }
}

/* Outer displays of foldables / ultra-narrow viewports (max-width: 340px) */
@media (max-width: 340px) {
  .group-row-actions form {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  .group-row-actions form .btn-ghost {
    width: 100% !important;
  }
  .group-row-actions .btn-ghost {
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  .modal-card--students .modal-footer {
    flex-direction: column !important;
  }
  .modal-card--students .modal-footer button {
    width: 100% !important;
  }
  .modal-students-quick-btns {
    flex-direction: column !important;
  }
  .student-search-form {
    flex-direction: column !important;
  }
  .student-search-form button,
  .student-search-form a {
    width: 100% !important;
  }
  #trial-search-form {
    flex-direction: column !important;
  }
  #trial-search-form button,
  #trial-search-form a {
    width: 100% !important;
  }
  #schedule-gen-form div:has(> label[id*="label-pattern"]) {
    grid-template-columns: 1fr !important;
  }
  #schedule-gen-form label[id*="label-pattern"] {
    width: 100% !important;
  }
}

/* ── Password visibility toggle (eye icon) ────────────────────── */
.password-input-wrap {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color var(--t-fast);
}

.password-toggle:hover {
  color: var(--ink);
}

.password-field {
  padding-right: 44px; /* space for eye icon */
}




/* ===================================================================
   UNIFIED DESIGN SYSTEM - All Pages
   =================================================================== */

/* --- Page Header ----------------------------------------------- */
.page-header {
  margin-bottom: 28px;
}

.page-header-title {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.page-header-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* --- Section Navigation Tabs ----------------------------------- */
.section-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--line);
  flex-wrap: wrap;
}

.section-nav-btn {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
  margin-bottom: -2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.section-nav-btn:hover {
  color: var(--text);
}

.section-nav-btn.is-active {
  color: var(--burgundy);
  border-bottom-color: var(--burgundy);
}

.section-content {
  display: none;
}

.section-content.is-active {
  display: block;
  animation: fadeInSection 0.2s ease;
}

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

/* --- Cards & Panels -------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header p {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--muted);
}

.card-body {
  padding: 0;
}

.card-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Form Cards ------------------------------------------------ */
.form-card {
  background: var(--surface-subtle, #f8f6f2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.form-card-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.form-card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.form-card-header p {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* --- Tables ---------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead tr {
  background: var(--surface-subtle, #faf8f5);
  border-bottom: 1px solid var(--line);
}

.data-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--line-soft, #f0ede6);
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--surface-subtle, #faf8f5);
}

.data-table tbody td {
  padding: 10px 12px;
}

/* --- Status Badges --------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: rgba(40, 167, 69, 0.12);
  color: var(--green);
}

.badge-warning {
  background: rgba(255, 193, 7, 0.12);
  color: var(--gold);
}

.badge-danger {
  background: rgba(220, 53, 69, 0.12);
  color: var(--red);
}

.badge-info {
  background: rgba(13, 110, 253, 0.12);
  color: #0d6efd;
}

.badge-primary {
  background: rgba(122, 16, 32, 0.12);
  color: var(--burgundy);
}

.badge-secondary {
  background: rgba(108, 117, 125, 0.12);
  color: #6c757d;
}

/* --- Action Buttons Group -------------------------------------- */
.action-group {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.action-group-vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* --- Empty States ---------------------------------------------- */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  opacity: 0.3;
  color: var(--muted);
}

.empty-state-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.empty-state-text {
  margin: 0 0 20px 0;
  font-size: 13px;
}

/* --- Alert Boxes ----------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-success {
  background: rgba(40, 167, 69, 0.1);
  border: 1px solid rgba(40, 167, 69, 0.3);
  color: var(--green);
}

.alert-warning {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  color: var(--gold);
}

.alert-danger {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: var(--red);
}

.alert-info {
  background: rgba(13, 110, 253, 0.1);
  border: 1px solid rgba(13, 110, 253, 0.3);
  color: #0d6efd;
}

/* --- Loading States -------------------------------------------- */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--burgundy);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* --- Utility Classes ------------------------------------------- */
.text-muted {
  color: var(--muted);
}

.text-success {
  color: var(--green);
}

.text-warning {
  color: var(--gold);
}

.text-danger {
  color: var(--red);
}

.text-center {
  text-align: center;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 8px;
}

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

.mb-3 {
  margin-bottom: 24px;
}

.mt-0 {
  margin-top: 0;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.d-flex {
  display: flex;
}

.d-none {
  display: none;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.gap-3 {
  gap: 24px;
}

/* --- Responsive Utilities -------------------------------------- */
@media (max-width: 768px) {
  .page-header-title {
    font-size: 20px;
  }

  .page-header-actions {
    flex-direction: column;
  }

  .section-nav-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .card {
    padding: 16px;
  }

  .form-card {
    padding: 16px;
  }
}

